Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
644eb700
Commit
644eb700
authored
Oct 23, 2014
by
Clayton Coleman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor tests to split ObjectMeta from TypeMeta
parent
7550c146
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
55 changed files
with
453 additions
and
372 deletions
+453
-372
integration.go
cmd/integration/integration.go
+15
-8
examples_test.go
examples/examples_test.go
+2
-2
context_test.go
pkg/api/context_test.go
+4
-4
latest_test.go
pkg/api/latest/latest_test.go
+19
-1
ref_test.go
pkg/api/ref_test.go
+3
-8
serialization_test.go
pkg/api/serialization_test.go
+23
-0
conversion_test.go
pkg/api/v1beta1/conversion_test.go
+2
-2
validation_test.go
pkg/api/validation/validation_test.go
+0
-0
apiserver_test.go
pkg/apiserver/apiserver_test.go
+5
-1
operation_test.go
pkg/apiserver/operation_test.go
+3
-3
reflector_test.go
pkg/client/cache/reflector_test.go
+10
-10
client_test.go
pkg/client/client_test.go
+57
-33
event_test.go
pkg/client/record/event_test.go
+1
-1
request_test.go
pkg/client/request_test.go
+6
-6
minioncontroller_test.go
pkg/cloudprovider/controller/minioncontroller_test.go
+5
-5
replication_controller_test.go
pkg/controller/replication_controller_test.go
+10
-12
kubecfg_test.go
pkg/kubecfg/kubecfg_test.go
+4
-4
parse_test.go
pkg/kubecfg/parse_test.go
+12
-5
resource_printer_test.go
pkg/kubecfg/resource_printer_test.go
+2
-2
resource_printer_test.go
pkg/kubectl/resource_printer_test.go
+1
-1
config_test.go
pkg/kubelet/config/config_test.go
+3
-3
etcd_test.go
pkg/kubelet/config/etcd_test.go
+8
-8
file_test.go
pkg/kubelet/config/file_test.go
+2
-2
http_test.go
pkg/kubelet/config/http_test.go
+3
-3
kubelet_test.go
pkg/kubelet/kubelet_test.go
+14
-14
runonce_test.go
pkg/kubelet/runonce_test.go
+1
-1
server_test.go
pkg/kubelet/server_test.go
+3
-3
pod_cache_test.go
pkg/master/pod_cache_test.go
+1
-1
api_test.go
pkg/proxy/config/api_test.go
+6
-6
config_test.go
pkg/proxy/config/config_test.go
+16
-16
proxier_test.go
pkg/proxy/proxier_test.go
+14
-14
roundrobin_test.go
pkg/proxy/roundrobin_test.go
+7
-7
rest_test.go
pkg/registry/controller/rest_test.go
+20
-18
rest_test.go
pkg/registry/endpoint/rest_test.go
+5
-5
etcd_test.go
pkg/registry/etcd/etcd_test.go
+0
-0
registry_test.go
pkg/registry/event/registry_test.go
+2
-2
rest_test.go
pkg/registry/event/rest_test.go
+4
-4
etcd_test.go
pkg/registry/generic/etcd/etcd_test.go
+9
-9
healthy_registry_test.go
pkg/registry/minion/healthy_registry_test.go
+1
-1
rest_test.go
pkg/registry/minion/rest_test.go
+3
-3
bound_pod_factory_test.go
pkg/registry/pod/bound_pod_factory_test.go
+3
-3
rest_test.go
pkg/registry/pod/rest_test.go
+18
-16
rest_test.go
pkg/registry/service/rest_test.go
+30
-30
helper_test.go
pkg/runtime/helper_test.go
+6
-6
generic_scheduler_test.go
pkg/scheduler/generic_scheduler_test.go
+2
-2
priorities_test.go
pkg/scheduler/priorities_test.go
+5
-5
spreading_test.go
pkg/scheduler/spreading_test.go
+15
-15
endpoints_controller_test.go
pkg/service/endpoints_controller_test.go
+9
-11
etcd_tools_test.go
pkg/tools/etcd_tools_test.go
+30
-29
etcd_tools_watch_test.go
pkg/tools/etcd_tools_watch_test.go
+12
-12
decoder_test.go
pkg/watch/json/decoder_test.go
+1
-1
encoder_test.go
pkg/watch/json/encoder_test.go
+3
-3
factory_test.go
plugin/pkg/scheduler/factory/factory_test.go
+10
-8
scheduler_test.go
plugin/pkg/scheduler/scheduler_test.go
+2
-2
etcd_tools_test.go
test/integration/etcd_tools_test.go
+1
-1
No files found.
cmd/integration/integration.go
View file @
644eb700
...
@@ -256,11 +256,16 @@ func runAtomicPutTest(c *client.Client) {
...
@@ -256,11 +256,16 @@ func runAtomicPutTest(c *client.Client) {
var
svc
api
.
Service
var
svc
api
.
Service
err
:=
c
.
Post
()
.
Path
(
"services"
)
.
Body
(
err
:=
c
.
Post
()
.
Path
(
"services"
)
.
Body
(
&
api
.
Service
{
&
api
.
Service
{
TypeMeta
:
api
.
TypeMeta
{
Name
:
"atomicservice"
,
APIVersion
:
latest
.
Version
},
TypeMeta
:
api
.
TypeMeta
{
Port
:
12345
,
APIVersion
:
latest
.
Version
,
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"atomicservice"
,
Labels
:
map
[
string
]
string
{
Labels
:
map
[
string
]
string
{
"name"
:
"atomicService"
,
"name"
:
"atomicService"
,
},
},
},
Port
:
12345
,
// This is here because validation requires it.
// This is here because validation requires it.
Selector
:
map
[
string
]
string
{
Selector
:
map
[
string
]
string
{
"foo"
:
"bar"
,
"foo"
:
"bar"
,
...
@@ -330,7 +335,12 @@ func runAtomicPutTest(c *client.Client) {
...
@@ -330,7 +335,12 @@ func runAtomicPutTest(c *client.Client) {
func
runServiceTest
(
client
*
client
.
Client
)
{
func
runServiceTest
(
client
*
client
.
Client
)
{
ctx
:=
api
.
NewDefaultContext
()
ctx
:=
api
.
NewDefaultContext
()
pod
:=
api
.
Pod
{
pod
:=
api
.
Pod
{
TypeMeta
:
api
.
TypeMeta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
,
Labels
:
map
[
string
]
string
{
"name"
:
"thisisalonglabel"
,
},
},
DesiredState
:
api
.
PodState
{
DesiredState
:
api
.
PodState
{
Manifest
:
api
.
ContainerManifest
{
Manifest
:
api
.
ContainerManifest
{
Version
:
"v1beta1"
,
Version
:
"v1beta1"
,
...
@@ -348,9 +358,6 @@ func runServiceTest(client *client.Client) {
...
@@ -348,9 +358,6 @@ func runServiceTest(client *client.Client) {
CurrentState
:
api
.
PodState
{
CurrentState
:
api
.
PodState
{
PodIP
:
"1.2.3.4"
,
PodIP
:
"1.2.3.4"
,
},
},
Labels
:
map
[
string
]
string
{
"name"
:
"thisisalonglabel"
,
},
}
}
_
,
err
:=
client
.
CreatePod
(
ctx
,
&
pod
)
_
,
err
:=
client
.
CreatePod
(
ctx
,
&
pod
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -360,7 +367,7 @@ func runServiceTest(client *client.Client) {
...
@@ -360,7 +367,7 @@ func runServiceTest(client *client.Client) {
glog
.
Fatalf
(
"FAILED: pod never started running %v"
,
err
)
glog
.
Fatalf
(
"FAILED: pod never started running %v"
,
err
)
}
}
svc1
:=
api
.
Service
{
svc1
:=
api
.
Service
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"service1"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"service1"
},
Selector
:
map
[
string
]
string
{
Selector
:
map
[
string
]
string
{
"name"
:
"thisisalonglabel"
,
"name"
:
"thisisalonglabel"
,
},
},
...
@@ -375,7 +382,7 @@ func runServiceTest(client *client.Client) {
...
@@ -375,7 +382,7 @@ func runServiceTest(client *client.Client) {
}
}
// A second service with the same port.
// A second service with the same port.
svc2
:=
api
.
Service
{
svc2
:=
api
.
Service
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"service2"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"service2"
},
Selector
:
map
[
string
]
string
{
Selector
:
map
[
string
]
string
{
"name"
:
"thisisalonglabel"
,
"name"
:
"thisisalonglabel"
,
},
},
...
...
examples/examples_test.go
View file @
644eb700
...
@@ -41,14 +41,14 @@ func validateObject(obj runtime.Object) (errors []error) {
...
@@ -41,14 +41,14 @@ func validateObject(obj runtime.Object) (errors []error) {
errors
=
append
(
errors
,
validateObject
(
&
t
.
Items
[
i
])
...
)
errors
=
append
(
errors
,
validateObject
(
&
t
.
Items
[
i
])
...
)
}
}
case
*
api
.
Service
:
case
*
api
.
Service
:
api
.
ValidNamespace
(
ctx
,
&
t
.
Type
Meta
)
api
.
ValidNamespace
(
ctx
,
&
t
.
Object
Meta
)
errors
=
validation
.
ValidateService
(
t
)
errors
=
validation
.
ValidateService
(
t
)
case
*
api
.
ServiceList
:
case
*
api
.
ServiceList
:
for
i
:=
range
t
.
Items
{
for
i
:=
range
t
.
Items
{
errors
=
append
(
errors
,
validateObject
(
&
t
.
Items
[
i
])
...
)
errors
=
append
(
errors
,
validateObject
(
&
t
.
Items
[
i
])
...
)
}
}
case
*
api
.
Pod
:
case
*
api
.
Pod
:
api
.
ValidNamespace
(
ctx
,
&
t
.
Type
Meta
)
api
.
ValidNamespace
(
ctx
,
&
t
.
Object
Meta
)
errors
=
validation
.
ValidateManifest
(
&
t
.
DesiredState
.
Manifest
)
errors
=
validation
.
ValidateManifest
(
&
t
.
DesiredState
.
Manifest
)
case
*
api
.
PodList
:
case
*
api
.
PodList
:
for
i
:=
range
t
.
Items
{
for
i
:=
range
t
.
Items
{
...
...
pkg/api/context_test.go
View file @
644eb700
...
@@ -45,18 +45,18 @@ func TestValidNamespace(t *testing.T) {
...
@@ -45,18 +45,18 @@ func TestValidNamespace(t *testing.T) {
ctx
:=
api
.
NewDefaultContext
()
ctx
:=
api
.
NewDefaultContext
()
namespace
,
_
:=
api
.
NamespaceFrom
(
ctx
)
namespace
,
_
:=
api
.
NamespaceFrom
(
ctx
)
resource
:=
api
.
ReplicationController
{}
resource
:=
api
.
ReplicationController
{}
if
!
api
.
ValidNamespace
(
ctx
,
&
resource
.
Type
Meta
)
{
if
!
api
.
ValidNamespace
(
ctx
,
&
resource
.
Object
Meta
)
{
t
.
Errorf
(
"expected success"
)
t
.
Errorf
(
"expected success"
)
}
}
if
namespace
!=
resource
.
Namespace
{
if
namespace
!=
resource
.
Namespace
{
t
.
Errorf
(
"expected resource to have the default namespace assigned during validation"
)
t
.
Errorf
(
"expected resource to have the default namespace assigned during validation"
)
}
}
resource
=
api
.
ReplicationController
{
TypeMeta
:
api
.
Type
Meta
{
Namespace
:
"other"
}}
resource
=
api
.
ReplicationController
{
ObjectMeta
:
api
.
Object
Meta
{
Namespace
:
"other"
}}
if
api
.
ValidNamespace
(
ctx
,
&
resource
.
Type
Meta
)
{
if
api
.
ValidNamespace
(
ctx
,
&
resource
.
Object
Meta
)
{
t
.
Errorf
(
"Expected error that resource and context errors do not match because resource has different namespace"
)
t
.
Errorf
(
"Expected error that resource and context errors do not match because resource has different namespace"
)
}
}
ctx
=
api
.
NewContext
()
ctx
=
api
.
NewContext
()
if
api
.
ValidNamespace
(
ctx
,
&
resource
.
Type
Meta
)
{
if
api
.
ValidNamespace
(
ctx
,
&
resource
.
Object
Meta
)
{
t
.
Errorf
(
"Expected error that resource and context errors do not match since context has no namespace"
)
t
.
Errorf
(
"Expected error that resource and context errors do not match since context has no namespace"
)
}
}
...
...
pkg/api/latest/latest_test.go
View file @
644eb700
...
@@ -37,6 +37,8 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
...
@@ -37,6 +37,8 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
// APIVersion and Kind must remain blank in memory.
// APIVersion and Kind must remain blank in memory.
j
.
APIVersion
=
""
j
.
APIVersion
=
""
j
.
Kind
=
""
j
.
Kind
=
""
},
func
(
j
*
internal
.
ObjectMeta
,
c
fuzz
.
Continue
)
{
j
.
Name
=
c
.
RandString
()
j
.
Name
=
c
.
RandString
()
// TODO: Fix JSON/YAML packages and/or write custom encoding
// TODO: Fix JSON/YAML packages and/or write custom encoding
// for uint64's. Somehow the LS *byte* of this is lost, but
// for uint64's. Somehow the LS *byte* of this is lost, but
...
@@ -49,6 +51,13 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
...
@@ -49,6 +51,13 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
c
.
Fuzz
(
&
nsec
)
c
.
Fuzz
(
&
nsec
)
j
.
CreationTimestamp
=
util
.
Unix
(
sec
,
nsec
)
.
Rfc3339Copy
()
j
.
CreationTimestamp
=
util
.
Unix
(
sec
,
nsec
)
.
Rfc3339Copy
()
},
},
func
(
j
*
internal
.
ListMeta
,
c
fuzz
.
Continue
)
{
// TODO: Fix JSON/YAML packages and/or write custom encoding
// for uint64's. Somehow the LS *byte* of this is lost, but
// only when all 8 bytes are set.
j
.
ResourceVersion
=
strconv
.
FormatUint
(
c
.
RandUint64
()
>>
8
,
10
)
j
.
SelfLink
=
c
.
RandString
()
},
func
(
j
*
internal
.
ObjectReference
,
c
fuzz
.
Continue
)
{
func
(
j
*
internal
.
ObjectReference
,
c
fuzz
.
Continue
)
{
// We have to customize the randomization of TypeMetas because their
// We have to customize the randomization of TypeMetas because their
// APIVersion and Kind must remain blank in memory.
// APIVersion and Kind must remain blank in memory.
...
@@ -133,7 +142,7 @@ func TestInternalRoundTrip(t *testing.T) {
...
@@ -133,7 +142,7 @@ func TestInternalRoundTrip(t *testing.T) {
}
}
func
TestResourceVersioner
(
t
*
testing
.
T
)
{
func
TestResourceVersioner
(
t
*
testing
.
T
)
{
pod
:=
internal
.
Pod
{
TypeMeta
:
internal
.
Type
Meta
{
ResourceVersion
:
"10"
}}
pod
:=
internal
.
Pod
{
ObjectMeta
:
internal
.
Object
Meta
{
ResourceVersion
:
"10"
}}
version
,
err
:=
ResourceVersioner
.
ResourceVersion
(
&
pod
)
version
,
err
:=
ResourceVersioner
.
ResourceVersion
(
&
pod
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
...
@@ -141,6 +150,15 @@ func TestResourceVersioner(t *testing.T) {
...
@@ -141,6 +150,15 @@ func TestResourceVersioner(t *testing.T) {
if
version
!=
"10"
{
if
version
!=
"10"
{
t
.
Errorf
(
"unexpected version %v"
,
version
)
t
.
Errorf
(
"unexpected version %v"
,
version
)
}
}
podList
:=
internal
.
PodList
{
ListMeta
:
internal
.
ListMeta
{
ResourceVersion
:
"10"
}}
version
,
err
=
ResourceVersioner
.
ResourceVersion
(
&
podList
)
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
if
version
!=
"10"
{
t
.
Errorf
(
"unexpected version %v"
,
version
)
}
}
}
func
TestCodec
(
t
*
testing
.
T
)
{
func
TestCodec
(
t
*
testing
.
T
)
{
...
...
pkg/api/ref_test.go
View file @
644eb700
...
@@ -35,7 +35,7 @@ func TestGetReference(t *testing.T) {
...
@@ -35,7 +35,7 @@ func TestGetReference(t *testing.T) {
}{
}{
"pod"
:
{
"pod"
:
{
obj
:
&
Pod
{
obj
:
&
Pod
{
TypeMeta
:
Type
Meta
{
ObjectMeta
:
Object
Meta
{
Name
:
"foo"
,
Name
:
"foo"
,
UID
:
"bar"
,
UID
:
"bar"
,
ResourceVersion
:
"42"
,
ResourceVersion
:
"42"
,
...
@@ -52,9 +52,7 @@ func TestGetReference(t *testing.T) {
...
@@ -52,9 +52,7 @@ func TestGetReference(t *testing.T) {
},
},
"serviceList"
:
{
"serviceList"
:
{
obj
:
&
ServiceList
{
obj
:
&
ServiceList
{
TypeMeta
:
TypeMeta
{
ListMeta
:
ListMeta
{
Name
:
"foo"
,
UID
:
"bar"
,
ResourceVersion
:
"42"
,
ResourceVersion
:
"42"
,
SelfLink
:
"/api/v1beta2/services"
,
SelfLink
:
"/api/v1beta2/services"
,
},
},
...
@@ -62,15 +60,12 @@ func TestGetReference(t *testing.T) {
...
@@ -62,15 +60,12 @@ func TestGetReference(t *testing.T) {
ref
:
&
ObjectReference
{
ref
:
&
ObjectReference
{
Kind
:
"ServiceList"
,
Kind
:
"ServiceList"
,
APIVersion
:
"v1beta2"
,
APIVersion
:
"v1beta2"
,
Name
:
"foo"
,
UID
:
"bar"
,
ResourceVersion
:
"42"
,
ResourceVersion
:
"42"
,
},
},
},
},
"badSelfLink"
:
{
"badSelfLink"
:
{
obj
:
&
ServiceList
{
obj
:
&
ServiceList
{
TypeMeta
:
TypeMeta
{
ListMeta
:
ListMeta
{
Name
:
"foo"
,
ResourceVersion
:
"42"
,
ResourceVersion
:
"42"
,
SelfLink
:
"v1beta2/services"
,
SelfLink
:
"v1beta2/services"
,
},
},
...
...
pkg/api/serialization_test.go
View file @
644eb700
...
@@ -47,12 +47,26 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
...
@@ -47,12 +47,26 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
// APIVersion and Kind must remain blank in memory.
// APIVersion and Kind must remain blank in memory.
j
.
APIVersion
=
""
j
.
APIVersion
=
""
j
.
Kind
=
""
j
.
Kind
=
""
j
.
Name
=
c
.
RandString
()
// TODO: Fix JSON/YAML packages and/or write custom encoding
// for uint64's. Somehow the LS *byte* of this is lost, but
// only when all 8 bytes are set.
j
.
ResourceVersion
=
strconv
.
FormatUint
(
c
.
RandUint64
()
>>
8
,
10
)
j
.
SelfLink
=
c
.
RandString
()
var
sec
,
nsec
int64
c
.
Fuzz
(
&
sec
)
c
.
Fuzz
(
&
nsec
)
j
.
CreationTimestamp
=
util
.
Unix
(
sec
,
nsec
)
.
Rfc3339Copy
()
},
},
func
(
j
*
api
.
TypeMeta
,
c
fuzz
.
Continue
)
{
func
(
j
*
api
.
TypeMeta
,
c
fuzz
.
Continue
)
{
// We have to customize the randomization of TypeMetas because their
// We have to customize the randomization of TypeMetas because their
// APIVersion and Kind must remain blank in memory.
// APIVersion and Kind must remain blank in memory.
j
.
APIVersion
=
""
j
.
APIVersion
=
""
j
.
Kind
=
""
j
.
Kind
=
""
},
func
(
j
*
api
.
ObjectMeta
,
c
fuzz
.
Continue
)
{
j
.
Name
=
c
.
RandString
()
j
.
Name
=
c
.
RandString
()
// TODO: Fix JSON/YAML packages and/or write custom encoding
// TODO: Fix JSON/YAML packages and/or write custom encoding
// for uint64's. Somehow the LS *byte* of this is lost, but
// for uint64's. Somehow the LS *byte* of this is lost, but
...
@@ -65,6 +79,13 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
...
@@ -65,6 +79,13 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
c
.
Fuzz
(
&
nsec
)
c
.
Fuzz
(
&
nsec
)
j
.
CreationTimestamp
=
util
.
Unix
(
sec
,
nsec
)
.
Rfc3339Copy
()
j
.
CreationTimestamp
=
util
.
Unix
(
sec
,
nsec
)
.
Rfc3339Copy
()
},
},
func
(
j
*
api
.
ListMeta
,
c
fuzz
.
Continue
)
{
// TODO: Fix JSON/YAML packages and/or write custom encoding
// for uint64's. Somehow the LS *byte* of this is lost, but
// only when all 8 bytes are set.
j
.
ResourceVersion
=
strconv
.
FormatUint
(
c
.
RandUint64
()
>>
8
,
10
)
j
.
SelfLink
=
c
.
RandString
()
},
func
(
intstr
*
util
.
IntOrString
,
c
fuzz
.
Continue
)
{
func
(
intstr
*
util
.
IntOrString
,
c
fuzz
.
Continue
)
{
// util.IntOrString will panic if its kind is set wrong.
// util.IntOrString will panic if its kind is set wrong.
if
c
.
RandBool
()
{
if
c
.
RandBool
()
{
...
@@ -173,7 +194,9 @@ func TestTypes(t *testing.T) {
...
@@ -173,7 +194,9 @@ func TestTypes(t *testing.T) {
func
TestEncode_Ptr
(
t
*
testing
.
T
)
{
func
TestEncode_Ptr
(
t
*
testing
.
T
)
{
pod
:=
&
api
.
Pod
{
pod
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
Labels
:
map
[
string
]
string
{
"name"
:
"foo"
},
Labels
:
map
[
string
]
string
{
"name"
:
"foo"
},
},
}
}
obj
:=
runtime
.
Object
(
pod
)
obj
:=
runtime
.
Object
(
pod
)
data
,
err
:=
latest
.
Codec
.
Encode
(
obj
)
data
,
err
:=
latest
.
Codec
.
Encode
(
obj
)
...
...
pkg/api/v1beta1/conversion_test.go
View file @
644eb700
...
@@ -119,7 +119,7 @@ func TestMinionListConversionToNew(t *testing.T) {
...
@@ -119,7 +119,7 @@ func TestMinionListConversionToNew(t *testing.T) {
return
v1beta1
.
Minion
{
TypeMeta
:
v1beta1
.
TypeMeta
{
ID
:
id
}}
return
v1beta1
.
Minion
{
TypeMeta
:
v1beta1
.
TypeMeta
{
ID
:
id
}}
}
}
newMinion
:=
func
(
id
string
)
newer
.
Minion
{
newMinion
:=
func
(
id
string
)
newer
.
Minion
{
return
newer
.
Minion
{
TypeMeta
:
newer
.
Type
Meta
{
Name
:
id
}}
return
newer
.
Minion
{
ObjectMeta
:
newer
.
Object
Meta
{
Name
:
id
}}
}
}
oldMinions
:=
[]
v1beta1
.
Minion
{
oldMinions
:=
[]
v1beta1
.
Minion
{
oldMinion
(
"foo"
),
oldMinion
(
"foo"
),
...
@@ -166,7 +166,7 @@ func TestMinionListConversionToOld(t *testing.T) {
...
@@ -166,7 +166,7 @@ func TestMinionListConversionToOld(t *testing.T) {
return
v1beta1
.
Minion
{
TypeMeta
:
v1beta1
.
TypeMeta
{
ID
:
id
}}
return
v1beta1
.
Minion
{
TypeMeta
:
v1beta1
.
TypeMeta
{
ID
:
id
}}
}
}
newMinion
:=
func
(
id
string
)
newer
.
Minion
{
newMinion
:=
func
(
id
string
)
newer
.
Minion
{
return
newer
.
Minion
{
TypeMeta
:
newer
.
Type
Meta
{
Name
:
id
}}
return
newer
.
Minion
{
ObjectMeta
:
newer
.
Object
Meta
{
Name
:
id
}}
}
}
oldMinions
:=
[]
v1beta1
.
Minion
{
oldMinions
:=
[]
v1beta1
.
Minion
{
oldMinion
(
"foo"
),
oldMinion
(
"foo"
),
...
...
pkg/api/validation/validation_test.go
View file @
644eb700
This diff is collapsed.
Click to expand it.
pkg/apiserver/apiserver_test.go
View file @
644eb700
...
@@ -54,6 +54,7 @@ func init() {
...
@@ -54,6 +54,7 @@ func init() {
type
Simple
struct
{
type
Simple
struct
{
api
.
TypeMeta
`yaml:",inline" json:",inline"`
api
.
TypeMeta
`yaml:",inline" json:",inline"`
api
.
ObjectMeta
`yaml:"metadata,inline" json:"metadata,inline"`
Other
string
`yaml:"other,omitempty" json:"other,omitempty"`
Other
string
`yaml:"other,omitempty" json:"other,omitempty"`
}
}
...
@@ -61,6 +62,7 @@ func (*Simple) IsAnAPIObject() {}
...
@@ -61,6 +62,7 @@ func (*Simple) IsAnAPIObject() {}
type
SimpleList
struct
{
type
SimpleList
struct
{
api
.
TypeMeta
`yaml:",inline" json:",inline"`
api
.
TypeMeta
`yaml:",inline" json:",inline"`
api
.
ListMeta
`yaml:"metadata,inline" json:"metadata,inline"`
Items
[]
Simple
`yaml:"items,omitempty" json:"items,omitempty"`
Items
[]
Simple
`yaml:"items,omitempty" json:"items,omitempty"`
}
}
...
@@ -108,7 +110,7 @@ func (storage *SimpleRESTStorage) Delete(ctx api.Context, id string) (<-chan run
...
@@ -108,7 +110,7 @@ func (storage *SimpleRESTStorage) Delete(ctx api.Context, id string) (<-chan run
}
}
return
MakeAsync
(
func
()
(
runtime
.
Object
,
error
)
{
return
MakeAsync
(
func
()
(
runtime
.
Object
,
error
)
{
if
storage
.
injectedFunction
!=
nil
{
if
storage
.
injectedFunction
!=
nil
{
return
storage
.
injectedFunction
(
&
Simple
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
id
}})
return
storage
.
injectedFunction
(
&
Simple
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
id
}})
}
}
return
&
api
.
Status
{
Status
:
api
.
StatusSuccess
},
nil
return
&
api
.
Status
{
Status
:
api
.
StatusSuccess
},
nil
}),
nil
}),
nil
...
@@ -310,6 +312,8 @@ func TestNonEmptyList(t *testing.T) {
...
@@ -310,6 +312,8 @@ func TestNonEmptyList(t *testing.T) {
if
resp
.
StatusCode
!=
http
.
StatusOK
{
if
resp
.
StatusCode
!=
http
.
StatusOK
{
t
.
Errorf
(
"Unexpected status: %d, Expected: %d, %#v"
,
resp
.
StatusCode
,
http
.
StatusOK
,
resp
)
t
.
Errorf
(
"Unexpected status: %d, Expected: %d, %#v"
,
resp
.
StatusCode
,
http
.
StatusOK
,
resp
)
body
,
_
:=
ioutil
.
ReadAll
(
resp
.
Body
)
t
.
Logf
(
"Data: %s"
,
string
(
body
))
}
}
var
listOut
SimpleList
var
listOut
SimpleList
...
...
pkg/apiserver/operation_test.go
View file @
644eb700
...
@@ -43,7 +43,7 @@ func TestOperation(t *testing.T) {
...
@@ -43,7 +43,7 @@ func TestOperation(t *testing.T) {
time
.
Sleep
(
time
.
Millisecond
)
time
.
Sleep
(
time
.
Millisecond
)
go
func
()
{
go
func
()
{
time
.
Sleep
(
500
*
time
.
Millisecond
)
time
.
Sleep
(
500
*
time
.
Millisecond
)
c
<-
&
Simple
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"All done"
}}
c
<-
&
Simple
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"All done"
}}
}()
}()
if
op
.
expired
(
time
.
Now
()
.
Add
(
-
time
.
Minute
))
{
if
op
.
expired
(
time
.
Now
()
.
Add
(
-
time
.
Minute
))
{
...
@@ -119,7 +119,7 @@ func TestOperationsList(t *testing.T) {
...
@@ -119,7 +119,7 @@ func TestOperationsList(t *testing.T) {
client
:=
http
.
Client
{}
client
:=
http
.
Client
{}
simple
:=
&
Simple
{
simple
:=
&
Simple
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
}
}
data
,
err
:=
codec
.
Encode
(
simple
)
data
,
err
:=
codec
.
Encode
(
simple
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -175,7 +175,7 @@ func TestOpGet(t *testing.T) {
...
@@ -175,7 +175,7 @@ func TestOpGet(t *testing.T) {
client
:=
http
.
Client
{}
client
:=
http
.
Client
{}
simple
:=
&
Simple
{
simple
:=
&
Simple
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
}
}
data
,
err
:=
codec
.
Encode
(
simple
)
data
,
err
:=
codec
.
Encode
(
simple
)
t
.
Log
(
string
(
data
))
t
.
Log
(
string
(
data
))
...
...
pkg/client/cache/reflector_test.go
View file @
644eb700
...
@@ -54,13 +54,13 @@ func TestReflector_watchHandler(t *testing.T) {
...
@@ -54,13 +54,13 @@ func TestReflector_watchHandler(t *testing.T) {
s
:=
NewStore
()
s
:=
NewStore
()
g
:=
NewReflector
(
&
testLW
{},
&
api
.
Pod
{},
s
)
g
:=
NewReflector
(
&
testLW
{},
&
api
.
Pod
{},
s
)
fw
:=
watch
.
NewFake
()
fw
:=
watch
.
NewFake
()
s
.
Add
(
"foo"
,
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
}})
s
.
Add
(
"foo"
,
&
api
.
Pod
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
}})
s
.
Add
(
"bar"
,
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"bar"
}})
s
.
Add
(
"bar"
,
&
api
.
Pod
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"bar"
}})
go
func
()
{
go
func
()
{
fw
.
Add
(
&
api
.
Service
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"rejected"
}})
fw
.
Add
(
&
api
.
Service
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"rejected"
}})
fw
.
Delete
(
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
}})
fw
.
Delete
(
&
api
.
Pod
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
}})
fw
.
Modify
(
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"bar"
,
ResourceVersion
:
"55"
}})
fw
.
Modify
(
&
api
.
Pod
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"bar"
,
ResourceVersion
:
"55"
}})
fw
.
Add
(
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"baz"
,
ResourceVersion
:
"32"
}})
fw
.
Add
(
&
api
.
Pod
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"baz"
,
ResourceVersion
:
"32"
}})
fw
.
Stop
()
fw
.
Stop
()
}()
}()
var
resumeRV
string
var
resumeRV
string
...
@@ -118,7 +118,7 @@ func TestReflector_listAndWatch(t *testing.T) {
...
@@ -118,7 +118,7 @@ func TestReflector_listAndWatch(t *testing.T) {
return
fw
,
nil
return
fw
,
nil
},
},
ListFunc
:
func
()
(
runtime
.
Object
,
error
)
{
ListFunc
:
func
()
(
runtime
.
Object
,
error
)
{
return
&
api
.
PodList
{
TypeMeta
:
api
.
Type
Meta
{
ResourceVersion
:
"1"
}},
nil
return
&
api
.
PodList
{
ListMeta
:
api
.
List
Meta
{
ResourceVersion
:
"1"
}},
nil
},
},
}
}
s
:=
NewFIFO
()
s
:=
NewFIFO
()
...
@@ -132,7 +132,7 @@ func TestReflector_listAndWatch(t *testing.T) {
...
@@ -132,7 +132,7 @@ func TestReflector_listAndWatch(t *testing.T) {
fw
=
<-
createdFakes
fw
=
<-
createdFakes
}
}
sendingRV
:=
strconv
.
FormatUint
(
uint64
(
i
+
2
),
10
)
sendingRV
:=
strconv
.
FormatUint
(
uint64
(
i
+
2
),
10
)
fw
.
Add
(
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
id
,
ResourceVersion
:
sendingRV
}})
fw
.
Add
(
&
api
.
Pod
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
id
,
ResourceVersion
:
sendingRV
}})
if
sendingRV
==
"3"
{
if
sendingRV
==
"3"
{
// Inject a failure.
// Inject a failure.
fw
.
Stop
()
fw
.
Stop
()
...
@@ -158,10 +158,10 @@ func TestReflector_listAndWatch(t *testing.T) {
...
@@ -158,10 +158,10 @@ func TestReflector_listAndWatch(t *testing.T) {
func
TestReflector_listAndWatchWithErrors
(
t
*
testing
.
T
)
{
func
TestReflector_listAndWatchWithErrors
(
t
*
testing
.
T
)
{
mkPod
:=
func
(
id
string
,
rv
string
)
*
api
.
Pod
{
mkPod
:=
func
(
id
string
,
rv
string
)
*
api
.
Pod
{
return
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
id
,
ResourceVersion
:
rv
}}
return
&
api
.
Pod
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
id
,
ResourceVersion
:
rv
}}
}
}
mkList
:=
func
(
rv
string
,
pods
...*
api
.
Pod
)
*
api
.
PodList
{
mkList
:=
func
(
rv
string
,
pods
...*
api
.
Pod
)
*
api
.
PodList
{
list
:=
&
api
.
PodList
{
TypeMeta
:
api
.
Type
Meta
{
ResourceVersion
:
rv
}}
list
:=
&
api
.
PodList
{
ListMeta
:
api
.
List
Meta
{
ResourceVersion
:
rv
}}
for
_
,
pod
:=
range
pods
{
for
_
,
pod
:=
range
pods
{
list
.
Items
=
append
(
list
.
Items
,
*
pod
)
list
.
Items
=
append
(
list
.
Items
,
*
pod
)
}
}
...
...
pkg/client/client_test.go
View file @
644eb700
...
@@ -166,6 +166,7 @@ func TestListPods(t *testing.T) {
...
@@ -166,6 +166,7 @@ func TestListPods(t *testing.T) {
CurrentState
:
api
.
PodState
{
CurrentState
:
api
.
PodState
{
Status
:
"Foobar"
,
Status
:
"Foobar"
,
},
},
ObjectMeta
:
api
.
ObjectMeta
{
Labels
:
map
[
string
]
string
{
Labels
:
map
[
string
]
string
{
"foo"
:
"bar"
,
"foo"
:
"bar"
,
"name"
:
"baz"
,
"name"
:
"baz"
,
...
@@ -174,6 +175,7 @@ func TestListPods(t *testing.T) {
...
@@ -174,6 +175,7 @@ func TestListPods(t *testing.T) {
},
},
},
},
},
},
},
}
}
receivedPodList
,
err
:=
c
.
Setup
()
.
ListPods
(
ctx
,
labels
.
Everything
())
receivedPodList
,
err
:=
c
.
Setup
()
.
ListPods
(
ctx
,
labels
.
Everything
())
c
.
Validate
(
t
,
receivedPodList
,
err
)
c
.
Validate
(
t
,
receivedPodList
,
err
)
...
@@ -197,6 +199,7 @@ func TestListPodsLabels(t *testing.T) {
...
@@ -197,6 +199,7 @@ func TestListPodsLabels(t *testing.T) {
CurrentState
:
api
.
PodState
{
CurrentState
:
api
.
PodState
{
Status
:
"Foobar"
,
Status
:
"Foobar"
,
},
},
ObjectMeta
:
api
.
ObjectMeta
{
Labels
:
map
[
string
]
string
{
Labels
:
map
[
string
]
string
{
"foo"
:
"bar"
,
"foo"
:
"bar"
,
"name"
:
"baz"
,
"name"
:
"baz"
,
...
@@ -205,6 +208,7 @@ func TestListPodsLabels(t *testing.T) {
...
@@ -205,6 +208,7 @@ func TestListPodsLabels(t *testing.T) {
},
},
},
},
},
},
},
}
}
c
.
Setup
()
c
.
Setup
()
c
.
QueryValidator
[
"labels"
]
=
validateLabels
c
.
QueryValidator
[
"labels"
]
=
validateLabels
...
@@ -223,12 +227,14 @@ func TestGetPod(t *testing.T) {
...
@@ -223,12 +227,14 @@ func TestGetPod(t *testing.T) {
CurrentState
:
api
.
PodState
{
CurrentState
:
api
.
PodState
{
Status
:
"Foobar"
,
Status
:
"Foobar"
,
},
},
ObjectMeta
:
api
.
ObjectMeta
{
Labels
:
map
[
string
]
string
{
Labels
:
map
[
string
]
string
{
"foo"
:
"bar"
,
"foo"
:
"bar"
,
"name"
:
"baz"
,
"name"
:
"baz"
,
},
},
},
},
},
},
},
}
}
receivedPod
,
err
:=
c
.
Setup
()
.
GetPod
(
ctx
,
"foo"
)
receivedPod
,
err
:=
c
.
Setup
()
.
GetPod
(
ctx
,
"foo"
)
c
.
Validate
(
t
,
receivedPod
,
err
)
c
.
Validate
(
t
,
receivedPod
,
err
)
...
@@ -248,10 +254,12 @@ func TestCreatePod(t *testing.T) {
...
@@ -248,10 +254,12 @@ func TestCreatePod(t *testing.T) {
CurrentState
:
api
.
PodState
{
CurrentState
:
api
.
PodState
{
Status
:
"Foobar"
,
Status
:
"Foobar"
,
},
},
ObjectMeta
:
api
.
ObjectMeta
{
Labels
:
map
[
string
]
string
{
Labels
:
map
[
string
]
string
{
"foo"
:
"bar"
,
"foo"
:
"bar"
,
"name"
:
"baz"
,
"name"
:
"baz"
,
},
},
},
}
}
c
:=
&
testClient
{
c
:=
&
testClient
{
Request
:
testRequest
{
Method
:
"POST"
,
Path
:
"/pods"
,
Body
:
requestPod
},
Request
:
testRequest
{
Method
:
"POST"
,
Path
:
"/pods"
,
Body
:
requestPod
},
...
@@ -266,14 +274,17 @@ func TestCreatePod(t *testing.T) {
...
@@ -266,14 +274,17 @@ func TestCreatePod(t *testing.T) {
func
TestUpdatePod
(
t
*
testing
.
T
)
{
func
TestUpdatePod
(
t
*
testing
.
T
)
{
requestPod
:=
&
api
.
Pod
{
requestPod
:=
&
api
.
Pod
{
TypeMeta
:
api
.
TypeMeta
{
Name
:
"foo"
,
ResourceVersion
:
"1"
},
ObjectMeta
:
api
.
ObjectMeta
{
CurrentState
:
api
.
PodState
{
Name
:
"foo"
,
Status
:
"Foobar"
,
ResourceVersion
:
"1"
,
},
Labels
:
map
[
string
]
string
{
Labels
:
map
[
string
]
string
{
"foo"
:
"bar"
,
"foo"
:
"bar"
,
"name"
:
"baz"
,
"name"
:
"baz"
,
},
},
},
CurrentState
:
api
.
PodState
{
Status
:
"Foobar"
,
},
}
}
c
:=
&
testClient
{
c
:=
&
testClient
{
Request
:
testRequest
{
Method
:
"PUT"
,
Path
:
"/pods/foo"
},
Request
:
testRequest
{
Method
:
"PUT"
,
Path
:
"/pods/foo"
},
...
@@ -290,15 +301,17 @@ func TestListControllers(t *testing.T) {
...
@@ -290,15 +301,17 @@ func TestListControllers(t *testing.T) {
Body
:
&
api
.
ReplicationControllerList
{
Body
:
&
api
.
ReplicationControllerList
{
Items
:
[]
api
.
ReplicationController
{
Items
:
[]
api
.
ReplicationController
{
{
{
TypeMeta
:
api
.
TypeMeta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
ObjectMeta
{
DesiredState
:
api
.
ReplicationControllerState
{
Name
:
"foo"
,
Replicas
:
2
,
},
Labels
:
map
[
string
]
string
{
Labels
:
map
[
string
]
string
{
"foo"
:
"bar"
,
"foo"
:
"bar"
,
"name"
:
"baz"
,
"name"
:
"baz"
,
},
},
},
},
DesiredState
:
api
.
ReplicationControllerState
{
Replicas
:
2
,
},
},
},
},
},
},
},
},
...
@@ -314,15 +327,17 @@ func TestGetController(t *testing.T) {
...
@@ -314,15 +327,17 @@ func TestGetController(t *testing.T) {
Response
:
Response
{
Response
:
Response
{
StatusCode
:
200
,
StatusCode
:
200
,
Body
:
&
api
.
ReplicationController
{
Body
:
&
api
.
ReplicationController
{
TypeMeta
:
api
.
TypeMeta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
ObjectMeta
{
DesiredState
:
api
.
ReplicationControllerState
{
Name
:
"foo"
,
Replicas
:
2
,
},
Labels
:
map
[
string
]
string
{
Labels
:
map
[
string
]
string
{
"foo"
:
"bar"
,
"foo"
:
"bar"
,
"name"
:
"baz"
,
"name"
:
"baz"
,
},
},
},
},
DesiredState
:
api
.
ReplicationControllerState
{
Replicas
:
2
,
},
},
},
},
}
}
receivedController
,
err
:=
c
.
Setup
()
.
GetReplicationController
(
api
.
NewDefaultContext
(),
"foo"
)
receivedController
,
err
:=
c
.
Setup
()
.
GetReplicationController
(
api
.
NewDefaultContext
(),
"foo"
)
...
@@ -331,22 +346,24 @@ func TestGetController(t *testing.T) {
...
@@ -331,22 +346,24 @@ func TestGetController(t *testing.T) {
func
TestUpdateController
(
t
*
testing
.
T
)
{
func
TestUpdateController
(
t
*
testing
.
T
)
{
requestController
:=
&
api
.
ReplicationController
{
requestController
:=
&
api
.
ReplicationController
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
,
ResourceVersion
:
"1"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
,
ResourceVersion
:
"1"
},
}
}
c
:=
&
testClient
{
c
:=
&
testClient
{
Request
:
testRequest
{
Method
:
"PUT"
,
Path
:
"/replicationControllers/foo"
},
Request
:
testRequest
{
Method
:
"PUT"
,
Path
:
"/replicationControllers/foo"
},
Response
:
Response
{
Response
:
Response
{
StatusCode
:
200
,
StatusCode
:
200
,
Body
:
&
api
.
ReplicationController
{
Body
:
&
api
.
ReplicationController
{
TypeMeta
:
api
.
TypeMeta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
ObjectMeta
{
DesiredState
:
api
.
ReplicationControllerState
{
Name
:
"foo"
,
Replicas
:
2
,
},
Labels
:
map
[
string
]
string
{
Labels
:
map
[
string
]
string
{
"foo"
:
"bar"
,
"foo"
:
"bar"
,
"name"
:
"baz"
,
"name"
:
"baz"
,
},
},
},
},
DesiredState
:
api
.
ReplicationControllerState
{
Replicas
:
2
,
},
},
},
},
}
}
receivedController
,
err
:=
c
.
Setup
()
.
UpdateReplicationController
(
api
.
NewDefaultContext
(),
requestController
)
receivedController
,
err
:=
c
.
Setup
()
.
UpdateReplicationController
(
api
.
NewDefaultContext
(),
requestController
)
...
@@ -364,22 +381,24 @@ func TestDeleteController(t *testing.T) {
...
@@ -364,22 +381,24 @@ func TestDeleteController(t *testing.T) {
func
TestCreateController
(
t
*
testing
.
T
)
{
func
TestCreateController
(
t
*
testing
.
T
)
{
requestController
:=
&
api
.
ReplicationController
{
requestController
:=
&
api
.
ReplicationController
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
}
}
c
:=
&
testClient
{
c
:=
&
testClient
{
Request
:
testRequest
{
Method
:
"POST"
,
Path
:
"/replicationControllers"
,
Body
:
requestController
},
Request
:
testRequest
{
Method
:
"POST"
,
Path
:
"/replicationControllers"
,
Body
:
requestController
},
Response
:
Response
{
Response
:
Response
{
StatusCode
:
200
,
StatusCode
:
200
,
Body
:
&
api
.
ReplicationController
{
Body
:
&
api
.
ReplicationController
{
TypeMeta
:
api
.
TypeMeta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
ObjectMeta
{
DesiredState
:
api
.
ReplicationControllerState
{
Name
:
"foo"
,
Replicas
:
2
,
},
Labels
:
map
[
string
]
string
{
Labels
:
map
[
string
]
string
{
"foo"
:
"bar"
,
"foo"
:
"bar"
,
"name"
:
"baz"
,
"name"
:
"baz"
,
},
},
},
},
DesiredState
:
api
.
ReplicationControllerState
{
Replicas
:
2
,
},
},
},
},
}
}
receivedController
,
err
:=
c
.
Setup
()
.
CreateReplicationController
(
api
.
NewDefaultContext
(),
requestController
)
receivedController
,
err
:=
c
.
Setup
()
.
CreateReplicationController
(
api
.
NewDefaultContext
(),
requestController
)
...
@@ -402,11 +421,13 @@ func TestListServices(t *testing.T) {
...
@@ -402,11 +421,13 @@ func TestListServices(t *testing.T) {
Body
:
&
api
.
ServiceList
{
Body
:
&
api
.
ServiceList
{
Items
:
[]
api
.
Service
{
Items
:
[]
api
.
Service
{
{
{
TypeMeta
:
api
.
TypeMeta
{
Name
:
"name"
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"name"
,
Labels
:
map
[
string
]
string
{
Labels
:
map
[
string
]
string
{
"foo"
:
"bar"
,
"foo"
:
"bar"
,
"name"
:
"baz"
,
"name"
:
"baz"
,
},
},
},
Selector
:
map
[
string
]
string
{
Selector
:
map
[
string
]
string
{
"one"
:
"two"
,
"one"
:
"two"
,
},
},
...
@@ -416,6 +437,7 @@ func TestListServices(t *testing.T) {
...
@@ -416,6 +437,7 @@ func TestListServices(t *testing.T) {
},
},
}
}
receivedServiceList
,
err
:=
c
.
Setup
()
.
ListServices
(
api
.
NewDefaultContext
(),
labels
.
Everything
())
receivedServiceList
,
err
:=
c
.
Setup
()
.
ListServices
(
api
.
NewDefaultContext
(),
labels
.
Everything
())
t
.
Logf
(
"received services: %v %#v"
,
err
,
receivedServiceList
)
c
.
Validate
(
t
,
receivedServiceList
,
err
)
c
.
Validate
(
t
,
receivedServiceList
,
err
)
}
}
...
@@ -426,11 +448,13 @@ func TestListServicesLabels(t *testing.T) {
...
@@ -426,11 +448,13 @@ func TestListServicesLabels(t *testing.T) {
Body
:
&
api
.
ServiceList
{
Body
:
&
api
.
ServiceList
{
Items
:
[]
api
.
Service
{
Items
:
[]
api
.
Service
{
{
{
TypeMeta
:
api
.
TypeMeta
{
Name
:
"name"
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"name"
,
Labels
:
map
[
string
]
string
{
Labels
:
map
[
string
]
string
{
"foo"
:
"bar"
,
"foo"
:
"bar"
,
"name"
:
"baz"
,
"name"
:
"baz"
,
},
},
},
Selector
:
map
[
string
]
string
{
Selector
:
map
[
string
]
string
{
"one"
:
"two"
,
"one"
:
"two"
,
},
},
...
@@ -449,7 +473,7 @@ func TestListServicesLabels(t *testing.T) {
...
@@ -449,7 +473,7 @@ func TestListServicesLabels(t *testing.T) {
func
TestGetService
(
t
*
testing
.
T
)
{
func
TestGetService
(
t
*
testing
.
T
)
{
c
:=
&
testClient
{
c
:=
&
testClient
{
Request
:
testRequest
{
Method
:
"GET"
,
Path
:
"/services/1"
},
Request
:
testRequest
{
Method
:
"GET"
,
Path
:
"/services/1"
},
Response
:
Response
{
StatusCode
:
200
,
Body
:
&
api
.
Service
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"service-1"
}}},
Response
:
Response
{
StatusCode
:
200
,
Body
:
&
api
.
Service
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"service-1"
}}},
}
}
response
,
err
:=
c
.
Setup
()
.
GetService
(
api
.
NewDefaultContext
(),
"1"
)
response
,
err
:=
c
.
Setup
()
.
GetService
(
api
.
NewDefaultContext
(),
"1"
)
c
.
Validate
(
t
,
response
,
err
)
c
.
Validate
(
t
,
response
,
err
)
...
@@ -457,15 +481,15 @@ func TestGetService(t *testing.T) {
...
@@ -457,15 +481,15 @@ func TestGetService(t *testing.T) {
func
TestCreateService
(
t
*
testing
.
T
)
{
func
TestCreateService
(
t
*
testing
.
T
)
{
c
:=
&
testClient
{
c
:=
&
testClient
{
Request
:
testRequest
{
Method
:
"POST"
,
Path
:
"/services"
,
Body
:
&
api
.
Service
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"service-1"
}}},
Request
:
testRequest
{
Method
:
"POST"
,
Path
:
"/services"
,
Body
:
&
api
.
Service
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"service-1"
}}},
Response
:
Response
{
StatusCode
:
200
,
Body
:
&
api
.
Service
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"service-1"
}}},
Response
:
Response
{
StatusCode
:
200
,
Body
:
&
api
.
Service
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"service-1"
}}},
}
}
response
,
err
:=
c
.
Setup
()
.
CreateService
(
api
.
NewDefaultContext
(),
&
api
.
Service
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"service-1"
}})
response
,
err
:=
c
.
Setup
()
.
CreateService
(
api
.
NewDefaultContext
(),
&
api
.
Service
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"service-1"
}})
c
.
Validate
(
t
,
response
,
err
)
c
.
Validate
(
t
,
response
,
err
)
}
}
func
TestUpdateService
(
t
*
testing
.
T
)
{
func
TestUpdateService
(
t
*
testing
.
T
)
{
svc
:=
&
api
.
Service
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"service-1"
,
ResourceVersion
:
"1"
}}
svc
:=
&
api
.
Service
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"service-1"
,
ResourceVersion
:
"1"
}}
c
:=
&
testClient
{
c
:=
&
testClient
{
Request
:
testRequest
{
Method
:
"PUT"
,
Path
:
"/services/service-1"
,
Body
:
svc
},
Request
:
testRequest
{
Method
:
"PUT"
,
Path
:
"/services/service-1"
,
Body
:
svc
},
Response
:
Response
{
StatusCode
:
200
,
Body
:
svc
},
Response
:
Response
{
StatusCode
:
200
,
Body
:
svc
},
...
@@ -490,7 +514,7 @@ func TestListEndpooints(t *testing.T) {
...
@@ -490,7 +514,7 @@ func TestListEndpooints(t *testing.T) {
Body
:
&
api
.
EndpointsList
{
Body
:
&
api
.
EndpointsList
{
Items
:
[]
api
.
Endpoints
{
Items
:
[]
api
.
Endpoints
{
{
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"endpoint-1"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"endpoint-1"
},
Endpoints
:
[]
string
{
"10.245.1.2:8080"
,
"10.245.1.3:8080"
},
Endpoints
:
[]
string
{
"10.245.1.2:8080"
,
"10.245.1.3:8080"
},
},
},
},
},
...
@@ -504,7 +528,7 @@ func TestListEndpooints(t *testing.T) {
...
@@ -504,7 +528,7 @@ func TestListEndpooints(t *testing.T) {
func
TestGetEndpoints
(
t
*
testing
.
T
)
{
func
TestGetEndpoints
(
t
*
testing
.
T
)
{
c
:=
&
testClient
{
c
:=
&
testClient
{
Request
:
testRequest
{
Method
:
"GET"
,
Path
:
"/endpoints/endpoint-1"
},
Request
:
testRequest
{
Method
:
"GET"
,
Path
:
"/endpoints/endpoint-1"
},
Response
:
Response
{
StatusCode
:
200
,
Body
:
&
api
.
Endpoints
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"endpoint-1"
}}},
Response
:
Response
{
StatusCode
:
200
,
Body
:
&
api
.
Endpoints
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"endpoint-1"
}}},
}
}
response
,
err
:=
c
.
Setup
()
.
GetEndpoints
(
api
.
NewDefaultContext
(),
"endpoint-1"
)
response
,
err
:=
c
.
Setup
()
.
GetEndpoints
(
api
.
NewDefaultContext
(),
"endpoint-1"
)
c
.
Validate
(
t
,
response
,
err
)
c
.
Validate
(
t
,
response
,
err
)
...
@@ -540,7 +564,7 @@ func TestGetServerVersion(t *testing.T) {
...
@@ -540,7 +564,7 @@ func TestGetServerVersion(t *testing.T) {
func
TestListMinions
(
t
*
testing
.
T
)
{
func
TestListMinions
(
t
*
testing
.
T
)
{
c
:=
&
testClient
{
c
:=
&
testClient
{
Request
:
testRequest
{
Method
:
"GET"
,
Path
:
"/minions"
},
Request
:
testRequest
{
Method
:
"GET"
,
Path
:
"/minions"
},
Response
:
Response
{
StatusCode
:
200
,
Body
:
&
api
.
MinionList
{
TypeMeta
:
api
.
TypeMeta
{
Name
:
"minion-
1"
}}},
Response
:
Response
{
StatusCode
:
200
,
Body
:
&
api
.
MinionList
{
ListMeta
:
api
.
ListMeta
{
ResourceVersion
:
"
1"
}}},
}
}
response
,
err
:=
c
.
Setup
()
.
ListMinions
()
response
,
err
:=
c
.
Setup
()
.
ListMinions
()
c
.
Validate
(
t
,
response
,
err
)
c
.
Validate
(
t
,
response
,
err
)
...
@@ -548,7 +572,7 @@ func TestListMinions(t *testing.T) {
...
@@ -548,7 +572,7 @@ func TestListMinions(t *testing.T) {
func
TestCreateMinion
(
t
*
testing
.
T
)
{
func
TestCreateMinion
(
t
*
testing
.
T
)
{
requestMinion
:=
&
api
.
Minion
{
requestMinion
:=
&
api
.
Minion
{
TypeMeta
:
api
.
Type
Meta
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"minion-1"
,
Name
:
"minion-1"
,
},
},
HostIP
:
"123.321.456.654"
,
HostIP
:
"123.321.456.654"
,
...
...
pkg/client/record/event_test.go
View file @
644eb700
...
@@ -54,7 +54,7 @@ func TestEventf(t *testing.T) {
...
@@ -54,7 +54,7 @@ func TestEventf(t *testing.T) {
}{
}{
{
{
obj
:
&
api
.
Pod
{
obj
:
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
ObjectMeta
:
api
.
Object
Meta
{
SelfLink
:
"/api/v1beta1/pods/foo"
,
SelfLink
:
"/api/v1beta1/pods/foo"
,
Name
:
"foo"
,
Name
:
"foo"
,
UID
:
"bar"
,
UID
:
"bar"
,
...
...
pkg/client/request_test.go
View file @
644eb700
...
@@ -72,7 +72,7 @@ func TestDoRequestNewWay(t *testing.T) {
...
@@ -72,7 +72,7 @@ func TestDoRequestNewWay(t *testing.T) {
}
}
func
TestDoRequestNewWayReader
(
t
*
testing
.
T
)
{
func
TestDoRequestNewWayReader
(
t
*
testing
.
T
)
{
reqObj
:=
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
}}
reqObj
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
}}
reqBodyExpected
,
_
:=
v1beta1
.
Codec
.
Encode
(
reqObj
)
reqBodyExpected
,
_
:=
v1beta1
.
Codec
.
Encode
(
reqObj
)
expectedObj
:=
&
api
.
Service
{
Port
:
12345
}
expectedObj
:=
&
api
.
Service
{
Port
:
12345
}
expectedBody
,
_
:=
v1beta1
.
Codec
.
Encode
(
expectedObj
)
expectedBody
,
_
:=
v1beta1
.
Codec
.
Encode
(
expectedObj
)
...
@@ -108,7 +108,7 @@ func TestDoRequestNewWayReader(t *testing.T) {
...
@@ -108,7 +108,7 @@ func TestDoRequestNewWayReader(t *testing.T) {
}
}
func
TestDoRequestNewWayObj
(
t
*
testing
.
T
)
{
func
TestDoRequestNewWayObj
(
t
*
testing
.
T
)
{
reqObj
:=
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
}}
reqObj
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
}}
reqBodyExpected
,
_
:=
v1beta2
.
Codec
.
Encode
(
reqObj
)
reqBodyExpected
,
_
:=
v1beta2
.
Codec
.
Encode
(
reqObj
)
expectedObj
:=
&
api
.
Service
{
Port
:
12345
}
expectedObj
:=
&
api
.
Service
{
Port
:
12345
}
expectedBody
,
_
:=
v1beta2
.
Codec
.
Encode
(
expectedObj
)
expectedBody
,
_
:=
v1beta2
.
Codec
.
Encode
(
expectedObj
)
...
@@ -143,7 +143,7 @@ func TestDoRequestNewWayObj(t *testing.T) {
...
@@ -143,7 +143,7 @@ func TestDoRequestNewWayObj(t *testing.T) {
}
}
func
TestDoRequestNewWayFile
(
t
*
testing
.
T
)
{
func
TestDoRequestNewWayFile
(
t
*
testing
.
T
)
{
reqObj
:=
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
}}
reqObj
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
}}
reqBodyExpected
,
err
:=
v1beta1
.
Codec
.
Encode
(
reqObj
)
reqBodyExpected
,
err
:=
v1beta1
.
Codec
.
Encode
(
reqObj
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %v"
,
err
)
t
.
Errorf
(
"unexpected error: %v"
,
err
)
...
@@ -412,9 +412,9 @@ func TestWatch(t *testing.T) {
...
@@ -412,9 +412,9 @@ func TestWatch(t *testing.T) {
t
watch
.
EventType
t
watch
.
EventType
obj
runtime
.
Object
obj
runtime
.
Object
}{
}{
{
watch
.
Added
,
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"first"
}}},
{
watch
.
Added
,
&
api
.
Pod
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"first"
}}},
{
watch
.
Modified
,
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"second"
}}},
{
watch
.
Modified
,
&
api
.
Pod
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"second"
}}},
{
watch
.
Deleted
,
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"last"
}}},
{
watch
.
Deleted
,
&
api
.
Pod
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"last"
}}},
}
}
auth
:=
&
Config
{
Username
:
"user"
,
Password
:
"pass"
}
auth
:=
&
Config
{
Username
:
"user"
,
Password
:
"pass"
}
...
...
pkg/cloudprovider/controller/minioncontroller_test.go
View file @
644eb700
...
@@ -45,8 +45,8 @@ func NewTestEtcdRegistry(client tools.EtcdClient) *etcdregistry.Registry {
...
@@ -45,8 +45,8 @@ func NewTestEtcdRegistry(client tools.EtcdClient) *etcdregistry.Registry {
func
TestSyncCreateMinion
(
t
*
testing
.
T
)
{
func
TestSyncCreateMinion
(
t
*
testing
.
T
)
{
ctx
:=
api
.
NewContext
()
ctx
:=
api
.
NewContext
()
fakeClient
:=
tools
.
NewFakeEtcdClient
(
t
)
fakeClient
:=
tools
.
NewFakeEtcdClient
(
t
)
m1
:=
runtime
.
EncodeOrDie
(
latest
.
Codec
,
&
api
.
Minion
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"m1"
}})
m1
:=
runtime
.
EncodeOrDie
(
latest
.
Codec
,
&
api
.
Minion
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"m1"
}})
m2
:=
runtime
.
EncodeOrDie
(
latest
.
Codec
,
&
api
.
Minion
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"m2"
}})
m2
:=
runtime
.
EncodeOrDie
(
latest
.
Codec
,
&
api
.
Minion
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"m2"
}})
fakeClient
.
Set
(
"/registry/minions/m1"
,
m1
,
0
)
fakeClient
.
Set
(
"/registry/minions/m1"
,
m1
,
0
)
fakeClient
.
Set
(
"/registry/minions/m2"
,
m2
,
0
)
fakeClient
.
Set
(
"/registry/minions/m2"
,
m2
,
0
)
fakeClient
.
ExpectNotFoundGet
(
"/registry/minions/m3"
)
fakeClient
.
ExpectNotFoundGet
(
"/registry/minions/m3"
)
...
@@ -88,9 +88,9 @@ func TestSyncCreateMinion(t *testing.T) {
...
@@ -88,9 +88,9 @@ func TestSyncCreateMinion(t *testing.T) {
func
TestSyncDeleteMinion
(
t
*
testing
.
T
)
{
func
TestSyncDeleteMinion
(
t
*
testing
.
T
)
{
ctx
:=
api
.
NewContext
()
ctx
:=
api
.
NewContext
()
fakeClient
:=
tools
.
NewFakeEtcdClient
(
t
)
fakeClient
:=
tools
.
NewFakeEtcdClient
(
t
)
m1
:=
runtime
.
EncodeOrDie
(
latest
.
Codec
,
&
api
.
Minion
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"m1"
}})
m1
:=
runtime
.
EncodeOrDie
(
latest
.
Codec
,
&
api
.
Minion
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"m1"
}})
m2
:=
runtime
.
EncodeOrDie
(
latest
.
Codec
,
&
api
.
Minion
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"m2"
}})
m2
:=
runtime
.
EncodeOrDie
(
latest
.
Codec
,
&
api
.
Minion
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"m2"
}})
m3
:=
runtime
.
EncodeOrDie
(
latest
.
Codec
,
&
api
.
Minion
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"m3"
}})
m3
:=
runtime
.
EncodeOrDie
(
latest
.
Codec
,
&
api
.
Minion
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"m3"
}})
fakeClient
.
Set
(
"/registry/minions/m1"
,
m1
,
0
)
fakeClient
.
Set
(
"/registry/minions/m1"
,
m1
,
0
)
fakeClient
.
Set
(
"/registry/minions/m2"
,
m2
,
0
)
fakeClient
.
Set
(
"/registry/minions/m2"
,
m2
,
0
)
fakeClient
.
Set
(
"/registry/minions/m3"
,
m3
,
0
)
fakeClient
.
Set
(
"/registry/minions/m3"
,
m3
,
0
)
...
...
pkg/controller/replication_controller_test.go
View file @
644eb700
...
@@ -17,7 +17,6 @@ limitations under the License.
...
@@ -17,7 +17,6 @@ limitations under the License.
package
controller
package
controller
import
(
import
(
"encoding/json"
"fmt"
"fmt"
"net/http"
"net/http"
"net/http/httptest"
"net/http/httptest"
...
@@ -89,7 +88,7 @@ func newPodList(count int) *api.PodList {
...
@@ -89,7 +88,7 @@ func newPodList(count int) *api.PodList {
pods
:=
[]
api
.
Pod
{}
pods
:=
[]
api
.
Pod
{}
for
i
:=
0
;
i
<
count
;
i
++
{
for
i
:=
0
;
i
<
count
;
i
++
{
pods
=
append
(
pods
,
api
.
Pod
{
pods
=
append
(
pods
,
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
fmt
.
Sprintf
(
"pod%d"
,
i
),
Name
:
fmt
.
Sprintf
(
"pod%d"
,
i
),
},
},
})
})
...
@@ -183,8 +182,8 @@ func TestCreateReplica(t *testing.T) {
...
@@ -183,8 +182,8 @@ func TestCreateReplica(t *testing.T) {
}
}
controllerSpec
:=
api
.
ReplicationController
{
controllerSpec
:=
api
.
ReplicationController
{
TypeMeta
:
api
.
Type
Meta
{
ObjectMeta
:
api
.
Object
Meta
{
Kind
:
"ReplicationController
"
,
Name
:
"test
"
,
},
},
DesiredState
:
api
.
ReplicationControllerState
{
DesiredState
:
api
.
ReplicationControllerState
{
PodTemplate
:
api
.
PodTemplate
{
PodTemplate
:
api
.
PodTemplate
{
...
@@ -200,6 +199,7 @@ func TestCreateReplica(t *testing.T) {
...
@@ -200,6 +199,7 @@ func TestCreateReplica(t *testing.T) {
Labels
:
map
[
string
]
string
{
Labels
:
map
[
string
]
string
{
"name"
:
"foo"
,
"name"
:
"foo"
,
"type"
:
"production"
,
"type"
:
"production"
,
"replicationController"
:
"test"
,
},
},
},
},
},
},
...
@@ -208,21 +208,19 @@ func TestCreateReplica(t *testing.T) {
...
@@ -208,21 +208,19 @@ func TestCreateReplica(t *testing.T) {
podControl
.
createReplica
(
ctx
,
controllerSpec
)
podControl
.
createReplica
(
ctx
,
controllerSpec
)
expectedPod
:=
api
.
Pod
{
expectedPod
:=
api
.
Pod
{
TypeMeta
:
api
.
TypeMeta
{
ObjectMeta
:
api
.
ObjectMeta
{
Kind
:
"Pod"
,
APIVersion
:
testapi
.
Version
(),
},
Labels
:
controllerSpec
.
DesiredState
.
PodTemplate
.
Labels
,
Labels
:
controllerSpec
.
DesiredState
.
PodTemplate
.
Labels
,
},
DesiredState
:
controllerSpec
.
DesiredState
.
PodTemplate
.
DesiredState
,
DesiredState
:
controllerSpec
.
DesiredState
.
PodTemplate
.
DesiredState
,
}
}
fakeHandler
.
ValidateRequest
(
t
,
makeURL
(
"/pods?namespace=default"
),
"POST"
,
nil
)
fakeHandler
.
ValidateRequest
(
t
,
makeURL
(
"/pods?namespace=default"
),
"POST"
,
nil
)
actualPod
:=
api
.
Pod
{}
actualPod
,
err
:=
client
.
Codec
.
Decode
([]
byte
(
fakeHandler
.
RequestBody
))
if
err
:=
json
.
Unmarshal
([]
byte
(
fakeHandler
.
RequestBody
),
&
actualPod
);
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Unexpected error: %#v"
,
err
)
t
.
Errorf
(
"Unexpected error: %#v"
,
err
)
}
}
if
!
reflect
.
DeepEqual
(
expectedPod
,
actualPod
)
{
if
!
reflect
.
DeepEqual
(
&
expectedPod
,
actualPod
)
{
t
.
Logf
(
"Body: %s"
,
fakeHandler
.
RequestBody
)
t
.
Logf
(
"Body: %s"
,
fakeHandler
.
RequestBody
)
t
.
Errorf
(
"Unexpected mismatch. Expected
\n
%#v,
\n
Got:
\n
%#v"
,
expectedPod
,
actualPod
)
t
.
Errorf
(
"Unexpected mismatch. Expected
\n
%#v,
\n
Got:
\n
%#v"
,
&
expectedPod
,
actualPod
)
}
}
}
}
...
...
pkg/kubecfg/kubecfg_test.go
View file @
644eb700
...
@@ -38,8 +38,8 @@ func TestUpdateWithPods(t *testing.T) {
...
@@ -38,8 +38,8 @@ func TestUpdateWithPods(t *testing.T) {
fakeClient
:=
client
.
Fake
{
fakeClient
:=
client
.
Fake
{
Pods
:
api
.
PodList
{
Pods
:
api
.
PodList
{
Items
:
[]
api
.
Pod
{
Items
:
[]
api
.
Pod
{
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"pod-1"
}},
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"pod-1"
}},
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"pod-2"
}},
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"pod-2"
}},
},
},
},
},
}
}
...
@@ -69,8 +69,8 @@ func TestUpdateWithNewImage(t *testing.T) {
...
@@ -69,8 +69,8 @@ func TestUpdateWithNewImage(t *testing.T) {
fakeClient
:=
client
.
Fake
{
fakeClient
:=
client
.
Fake
{
Pods
:
api
.
PodList
{
Pods
:
api
.
PodList
{
Items
:
[]
api
.
Pod
{
Items
:
[]
api
.
Pod
{
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"pod-1"
}},
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"pod-1"
}},
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"pod-2"
}},
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"pod-2"
}},
},
},
},
},
Ctrl
:
api
.
ReplicationController
{
Ctrl
:
api
.
ReplicationController
{
...
...
pkg/kubecfg/parse_test.go
View file @
644eb700
...
@@ -69,7 +69,8 @@ var testParser = NewParser(map[string]runtime.Object{
...
@@ -69,7 +69,8 @@ var testParser = NewParser(map[string]runtime.Object{
func
TestParsePod
(
t
*
testing
.
T
)
{
func
TestParsePod
(
t
*
testing
.
T
)
{
DoParseTest
(
t
,
"pods"
,
&
api
.
Pod
{
DoParseTest
(
t
,
"pods"
,
&
api
.
Pod
{
TypeMeta
:
api
.
TypeMeta
{
APIVersion
:
"v1beta1"
,
Name
:
"test pod"
,
Kind
:
"Pod"
},
TypeMeta
:
api
.
TypeMeta
{
APIVersion
:
"v1beta1"
,
Kind
:
"Pod"
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"test pod"
},
DesiredState
:
api
.
PodState
{
DesiredState
:
api
.
PodState
{
Manifest
:
api
.
ContainerManifest
{
Manifest
:
api
.
ContainerManifest
{
ID
:
"My manifest"
,
ID
:
"My manifest"
,
...
@@ -86,11 +87,14 @@ func TestParsePod(t *testing.T) {
...
@@ -86,11 +87,14 @@ func TestParsePod(t *testing.T) {
func
TestParseService
(
t
*
testing
.
T
)
{
func
TestParseService
(
t
*
testing
.
T
)
{
DoParseTest
(
t
,
"services"
,
&
api
.
Service
{
DoParseTest
(
t
,
"services"
,
&
api
.
Service
{
TypeMeta
:
api
.
TypeMeta
{
APIVersion
:
"v1beta1"
,
Name
:
"my service"
,
Kind
:
"Service"
},
TypeMeta
:
api
.
TypeMeta
{
APIVersion
:
"v1beta1"
,
Kind
:
"Service"
},
Port
:
8080
,
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"my service"
,
Labels
:
map
[
string
]
string
{
Labels
:
map
[
string
]
string
{
"area"
:
"staging"
,
"area"
:
"staging"
,
},
},
},
Port
:
8080
,
Selector
:
map
[
string
]
string
{
Selector
:
map
[
string
]
string
{
"area"
:
"staging"
,
"area"
:
"staging"
,
},
},
...
@@ -99,7 +103,8 @@ func TestParseService(t *testing.T) {
...
@@ -99,7 +103,8 @@ func TestParseService(t *testing.T) {
func
TestParseController
(
t
*
testing
.
T
)
{
func
TestParseController
(
t
*
testing
.
T
)
{
DoParseTest
(
t
,
"replicationControllers"
,
&
api
.
ReplicationController
{
DoParseTest
(
t
,
"replicationControllers"
,
&
api
.
ReplicationController
{
TypeMeta
:
api
.
TypeMeta
{
APIVersion
:
"v1beta1"
,
Name
:
"my controller"
,
Kind
:
"ReplicationController"
},
TypeMeta
:
api
.
TypeMeta
{
APIVersion
:
"v1beta1"
,
Kind
:
"ReplicationController"
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"my controller"
},
DesiredState
:
api
.
ReplicationControllerState
{
DesiredState
:
api
.
ReplicationControllerState
{
Replicas
:
9001
,
Replicas
:
9001
,
PodTemplate
:
api
.
PodTemplate
{
PodTemplate
:
api
.
PodTemplate
{
...
@@ -121,6 +126,7 @@ func TestParseController(t *testing.T) {
...
@@ -121,6 +126,7 @@ func TestParseController(t *testing.T) {
type
TestParseType
struct
{
type
TestParseType
struct
{
api
.
TypeMeta
`json:",inline" yaml:",inline"`
api
.
TypeMeta
`json:",inline" yaml:",inline"`
api
.
ObjectMeta
`json:"metadata" yaml:"metadata"`
Data
string
`json:"data" yaml:"data"`
Data
string
`json:"data" yaml:"data"`
}
}
...
@@ -134,7 +140,8 @@ func TestParseCustomType(t *testing.T) {
...
@@ -134,7 +140,8 @@ func TestParseCustomType(t *testing.T) {
"custom"
:
&
TestParseType
{},
"custom"
:
&
TestParseType
{},
})
})
DoParseTest
(
t
,
"custom"
,
&
TestParseType
{
DoParseTest
(
t
,
"custom"
,
&
TestParseType
{
TypeMeta
:
api
.
TypeMeta
{
APIVersion
:
""
,
Name
:
"my custom object"
,
Kind
:
"TestParseType"
},
TypeMeta
:
api
.
TypeMeta
{
APIVersion
:
""
,
Kind
:
"TestParseType"
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"my custom object"
},
Data
:
"test data"
,
Data
:
"test data"
,
},
v1beta1
.
Codec
,
parser
)
},
v1beta1
.
Codec
,
parser
)
}
}
pkg/kubecfg/resource_printer_test.go
View file @
644eb700
...
@@ -68,7 +68,7 @@ func TestYAMLPrinterPrint(t *testing.T) {
...
@@ -68,7 +68,7 @@ func TestYAMLPrinterPrint(t *testing.T) {
}
}
obj
:=
&
api
.
Pod
{
obj
:=
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
}
}
buf
.
Reset
()
buf
.
Reset
()
printer
.
PrintObj
(
obj
,
buf
)
printer
.
PrintObj
(
obj
,
buf
)
...
@@ -92,7 +92,7 @@ func TestIdentityPrinter(t *testing.T) {
...
@@ -92,7 +92,7 @@ func TestIdentityPrinter(t *testing.T) {
}
}
obj
:=
&
api
.
Pod
{
obj
:=
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
}
}
buff
.
Reset
()
buff
.
Reset
()
printer
.
PrintObj
(
obj
,
buff
)
printer
.
PrintObj
(
obj
,
buff
)
...
...
pkg/kubectl/resource_printer_test.go
View file @
644eb700
...
@@ -69,7 +69,7 @@ func testPrinter(t *testing.T, printer ResourcePrinter, unmarshalFunc func(data
...
@@ -69,7 +69,7 @@ func testPrinter(t *testing.T, printer ResourcePrinter, unmarshalFunc func(data
}
}
obj
:=
&
api
.
Pod
{
obj
:=
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
}
}
buf
.
Reset
()
buf
.
Reset
()
printer
.
PrintObj
(
obj
,
buf
)
printer
.
PrintObj
(
obj
,
buf
)
...
...
pkg/kubelet/config/config_test.go
View file @
644eb700
...
@@ -50,7 +50,7 @@ func (s sortedPods) Less(i, j int) bool {
...
@@ -50,7 +50,7 @@ func (s sortedPods) Less(i, j int) bool {
func
CreateValidPod
(
name
,
namespace
,
source
string
)
api
.
BoundPod
{
func
CreateValidPod
(
name
,
namespace
,
source
string
)
api
.
BoundPod
{
return
api
.
BoundPod
{
return
api
.
BoundPod
{
TypeMeta
:
api
.
Type
Meta
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
name
,
Name
:
name
,
Namespace
:
namespace
,
Namespace
:
namespace
,
Annotations
:
map
[
string
]
string
{
kubelet
.
ConfigSourceAnnotationKey
:
source
},
Annotations
:
map
[
string
]
string
{
kubelet
.
ConfigSourceAnnotationKey
:
source
},
...
@@ -158,7 +158,7 @@ func TestInvalidPodFiltered(t *testing.T) {
...
@@ -158,7 +158,7 @@ func TestInvalidPodFiltered(t *testing.T) {
expectPodUpdate
(
t
,
ch
,
CreatePodUpdate
(
kubelet
.
ADD
,
CreateValidPod
(
"foo"
,
"new"
,
"test"
)))
expectPodUpdate
(
t
,
ch
,
CreatePodUpdate
(
kubelet
.
ADD
,
CreateValidPod
(
"foo"
,
"new"
,
"test"
)))
// add an invalid update
// add an invalid update
podUpdate
=
CreatePodUpdate
(
kubelet
.
UPDATE
,
api
.
BoundPod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
}})
podUpdate
=
CreatePodUpdate
(
kubelet
.
UPDATE
,
api
.
BoundPod
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
}})
channel
<-
podUpdate
channel
<-
podUpdate
expectNoPodUpdate
(
t
,
ch
)
expectNoPodUpdate
(
t
,
ch
)
}
}
...
@@ -217,7 +217,7 @@ func TestNewPodAddedUpdatedRemoved(t *testing.T) {
...
@@ -217,7 +217,7 @@ func TestNewPodAddedUpdatedRemoved(t *testing.T) {
channel
<-
podUpdate
channel
<-
podUpdate
expectPodUpdate
(
t
,
ch
,
CreatePodUpdate
(
kubelet
.
UPDATE
,
pod
))
expectPodUpdate
(
t
,
ch
,
CreatePodUpdate
(
kubelet
.
UPDATE
,
pod
))
podUpdate
=
CreatePodUpdate
(
kubelet
.
REMOVE
,
api
.
BoundPod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
,
Namespace
:
"new"
}})
podUpdate
=
CreatePodUpdate
(
kubelet
.
REMOVE
,
api
.
BoundPod
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
,
Namespace
:
"new"
}})
channel
<-
podUpdate
channel
<-
podUpdate
expectPodUpdate
(
t
,
ch
,
CreatePodUpdate
(
kubelet
.
REMOVE
,
pod
))
expectPodUpdate
(
t
,
ch
,
CreatePodUpdate
(
kubelet
.
REMOVE
,
pod
))
}
}
...
...
pkg/kubelet/config/etcd_test.go
View file @
644eb700
...
@@ -44,14 +44,14 @@ func TestEventToPods(t *testing.T) {
...
@@ -44,14 +44,14 @@ func TestEventToPods(t *testing.T) {
input
:
watch
.
Event
{
input
:
watch
.
Event
{
Object
:
&
api
.
BoundPods
{
Object
:
&
api
.
BoundPods
{
Items
:
[]
api
.
BoundPod
{
Items
:
[]
api
.
BoundPod
{
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
}},
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
}},
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"bar"
}},
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"bar"
}},
},
},
},
},
},
},
pods
:
[]
api
.
BoundPod
{
pods
:
[]
api
.
BoundPod
{
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
,
Namespace
:
"default"
},
Spec
:
api
.
PodSpec
{}},
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
,
Namespace
:
"default"
},
Spec
:
api
.
PodSpec
{}},
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"bar"
,
Namespace
:
"default"
},
Spec
:
api
.
PodSpec
{}},
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"bar"
,
Namespace
:
"default"
},
Spec
:
api
.
PodSpec
{}},
},
},
fail
:
false
,
fail
:
false
,
},
},
...
@@ -59,14 +59,14 @@ func TestEventToPods(t *testing.T) {
...
@@ -59,14 +59,14 @@ func TestEventToPods(t *testing.T) {
input
:
watch
.
Event
{
input
:
watch
.
Event
{
Object
:
&
api
.
BoundPods
{
Object
:
&
api
.
BoundPods
{
Items
:
[]
api
.
BoundPod
{
Items
:
[]
api
.
BoundPod
{
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"1"
}},
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"1"
}},
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"2"
,
Namespace
:
"foo"
}},
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"2"
,
Namespace
:
"foo"
}},
},
},
},
},
},
},
pods
:
[]
api
.
BoundPod
{
pods
:
[]
api
.
BoundPod
{
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"1"
,
Namespace
:
"default"
},
Spec
:
api
.
PodSpec
{}},
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"1"
,
Namespace
:
"default"
},
Spec
:
api
.
PodSpec
{}},
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"2"
,
Namespace
:
"foo"
},
Spec
:
api
.
PodSpec
{}},
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"2"
,
Namespace
:
"foo"
},
Spec
:
api
.
PodSpec
{}},
},
},
fail
:
false
,
fail
:
false
,
},
},
...
...
pkg/kubelet/config/file_test.go
View file @
644eb700
...
@@ -52,7 +52,7 @@ func ExampleManifestAndPod(id string) (api.ContainerManifest, api.BoundPod) {
...
@@ -52,7 +52,7 @@ func ExampleManifestAndPod(id string) (api.ContainerManifest, api.BoundPod) {
},
},
}
}
expectedPod
:=
api
.
BoundPod
{
expectedPod
:=
api
.
BoundPod
{
TypeMeta
:
api
.
Type
Meta
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
id
,
Name
:
id
,
UID
:
"uid"
,
UID
:
"uid"
,
Namespace
:
"default"
,
Namespace
:
"default"
,
...
@@ -118,7 +118,7 @@ func TestReadFromFile(t *testing.T) {
...
@@ -118,7 +118,7 @@ func TestReadFromFile(t *testing.T) {
case
got
:=
<-
ch
:
case
got
:=
<-
ch
:
update
:=
got
.
(
kubelet
.
PodUpdate
)
update
:=
got
.
(
kubelet
.
PodUpdate
)
expected
:=
CreatePodUpdate
(
kubelet
.
SET
,
api
.
BoundPod
{
expected
:=
CreatePodUpdate
(
kubelet
.
SET
,
api
.
BoundPod
{
TypeMeta
:
api
.
Type
Meta
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
simpleSubdomainSafeHash
(
file
.
Name
()),
Name
:
simpleSubdomainSafeHash
(
file
.
Name
()),
UID
:
simpleSubdomainSafeHash
(
file
.
Name
()),
UID
:
simpleSubdomainSafeHash
(
file
.
Name
()),
Namespace
:
"default"
,
Namespace
:
"default"
,
...
...
pkg/kubelet/config/http_test.go
View file @
644eb700
...
@@ -124,7 +124,7 @@ func TestExtractFromHTTP(t *testing.T) {
...
@@ -124,7 +124,7 @@ func TestExtractFromHTTP(t *testing.T) {
manifests
:
api
.
ContainerManifest
{
Version
:
"v1beta1"
,
ID
:
"foo"
},
manifests
:
api
.
ContainerManifest
{
Version
:
"v1beta1"
,
ID
:
"foo"
},
expected
:
CreatePodUpdate
(
kubelet
.
SET
,
expected
:
CreatePodUpdate
(
kubelet
.
SET
,
api
.
BoundPod
{
api
.
BoundPod
{
TypeMeta
:
api
.
Type
Meta
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
,
Name
:
"foo"
,
Namespace
:
"default"
,
Namespace
:
"default"
,
},
},
...
@@ -141,14 +141,14 @@ func TestExtractFromHTTP(t *testing.T) {
...
@@ -141,14 +141,14 @@ func TestExtractFromHTTP(t *testing.T) {
},
},
expected
:
CreatePodUpdate
(
kubelet
.
SET
,
expected
:
CreatePodUpdate
(
kubelet
.
SET
,
api
.
BoundPod
{
api
.
BoundPod
{
TypeMeta
:
api
.
Type
Meta
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"1"
,
Name
:
"1"
,
Namespace
:
"default"
,
Namespace
:
"default"
,
},
},
Spec
:
api
.
PodSpec
{
Containers
:
[]
api
.
Container
{{
Name
:
"1"
,
Image
:
"foo"
}}},
Spec
:
api
.
PodSpec
{
Containers
:
[]
api
.
Container
{{
Name
:
"1"
,
Image
:
"foo"
}}},
},
},
api
.
BoundPod
{
api
.
BoundPod
{
TypeMeta
:
api
.
Type
Meta
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"bar"
,
Name
:
"bar"
,
Namespace
:
"default"
,
Namespace
:
"default"
,
},
},
...
...
pkg/kubelet/kubelet_test.go
View file @
644eb700
...
@@ -167,7 +167,7 @@ func TestSyncPodsDoesNothing(t *testing.T) {
...
@@ -167,7 +167,7 @@ func TestSyncPodsDoesNothing(t *testing.T) {
}
}
err
:=
kubelet
.
SyncPods
([]
api
.
BoundPod
{
err
:=
kubelet
.
SyncPods
([]
api
.
BoundPod
{
{
{
TypeMeta
:
api
.
Type
Meta
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
,
Name
:
"foo"
,
Namespace
:
"new"
,
Namespace
:
"new"
,
Annotations
:
map
[
string
]
string
{
ConfigSourceAnnotationKey
:
"test"
},
Annotations
:
map
[
string
]
string
{
ConfigSourceAnnotationKey
:
"test"
},
...
@@ -213,7 +213,7 @@ func TestSyncPodsCreatesNetAndContainer(t *testing.T) {
...
@@ -213,7 +213,7 @@ func TestSyncPodsCreatesNetAndContainer(t *testing.T) {
fakeDocker
.
ContainerList
=
[]
docker
.
APIContainers
{}
fakeDocker
.
ContainerList
=
[]
docker
.
APIContainers
{}
err
:=
kubelet
.
SyncPods
([]
api
.
BoundPod
{
err
:=
kubelet
.
SyncPods
([]
api
.
BoundPod
{
{
{
TypeMeta
:
api
.
Type
Meta
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
,
Name
:
"foo"
,
Namespace
:
"new"
,
Namespace
:
"new"
,
Annotations
:
map
[
string
]
string
{
ConfigSourceAnnotationKey
:
"test"
},
Annotations
:
map
[
string
]
string
{
ConfigSourceAnnotationKey
:
"test"
},
...
@@ -261,7 +261,7 @@ func TestSyncPodsCreatesNetAndContainerPullsImage(t *testing.T) {
...
@@ -261,7 +261,7 @@ func TestSyncPodsCreatesNetAndContainerPullsImage(t *testing.T) {
fakeDocker
.
ContainerList
=
[]
docker
.
APIContainers
{}
fakeDocker
.
ContainerList
=
[]
docker
.
APIContainers
{}
err
:=
kubelet
.
SyncPods
([]
api
.
BoundPod
{
err
:=
kubelet
.
SyncPods
([]
api
.
BoundPod
{
{
{
TypeMeta
:
api
.
Type
Meta
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
,
Name
:
"foo"
,
Namespace
:
"new"
,
Namespace
:
"new"
,
Annotations
:
map
[
string
]
string
{
ConfigSourceAnnotationKey
:
"test"
},
Annotations
:
map
[
string
]
string
{
ConfigSourceAnnotationKey
:
"test"
},
...
@@ -306,7 +306,7 @@ func TestSyncPodsWithNetCreatesContainer(t *testing.T) {
...
@@ -306,7 +306,7 @@ func TestSyncPodsWithNetCreatesContainer(t *testing.T) {
}
}
err
:=
kubelet
.
SyncPods
([]
api
.
BoundPod
{
err
:=
kubelet
.
SyncPods
([]
api
.
BoundPod
{
{
{
TypeMeta
:
api
.
Type
Meta
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
,
Name
:
"foo"
,
Namespace
:
"new"
,
Namespace
:
"new"
,
Annotations
:
map
[
string
]
string
{
ConfigSourceAnnotationKey
:
"test"
},
Annotations
:
map
[
string
]
string
{
ConfigSourceAnnotationKey
:
"test"
},
...
@@ -347,7 +347,7 @@ func TestSyncPodsWithNetCreatesContainerCallsHandler(t *testing.T) {
...
@@ -347,7 +347,7 @@ func TestSyncPodsWithNetCreatesContainerCallsHandler(t *testing.T) {
}
}
err
:=
kubelet
.
SyncPods
([]
api
.
BoundPod
{
err
:=
kubelet
.
SyncPods
([]
api
.
BoundPod
{
{
{
TypeMeta
:
api
.
Type
Meta
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
,
Name
:
"foo"
,
Namespace
:
"new"
,
Namespace
:
"new"
,
Annotations
:
map
[
string
]
string
{
ConfigSourceAnnotationKey
:
"test"
},
Annotations
:
map
[
string
]
string
{
ConfigSourceAnnotationKey
:
"test"
},
...
@@ -400,7 +400,7 @@ func TestSyncPodsDeletesWithNoNetContainer(t *testing.T) {
...
@@ -400,7 +400,7 @@ func TestSyncPodsDeletesWithNoNetContainer(t *testing.T) {
}
}
err
:=
kubelet
.
SyncPods
([]
api
.
BoundPod
{
err
:=
kubelet
.
SyncPods
([]
api
.
BoundPod
{
{
{
TypeMeta
:
api
.
Type
Meta
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
,
Name
:
"foo"
,
Namespace
:
"new"
,
Namespace
:
"new"
,
Annotations
:
map
[
string
]
string
{
ConfigSourceAnnotationKey
:
"test"
},
Annotations
:
map
[
string
]
string
{
ConfigSourceAnnotationKey
:
"test"
},
...
@@ -495,7 +495,7 @@ func TestSyncPodDeletesDuplicate(t *testing.T) {
...
@@ -495,7 +495,7 @@ func TestSyncPodDeletesDuplicate(t *testing.T) {
},
},
}
}
err
:=
kubelet
.
syncPod
(
&
api
.
BoundPod
{
err
:=
kubelet
.
syncPod
(
&
api
.
BoundPod
{
TypeMeta
:
api
.
Type
Meta
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"bar"
,
Name
:
"bar"
,
Namespace
:
"new"
,
Namespace
:
"new"
,
Annotations
:
map
[
string
]
string
{
ConfigSourceAnnotationKey
:
"test"
},
Annotations
:
map
[
string
]
string
{
ConfigSourceAnnotationKey
:
"test"
},
...
@@ -544,7 +544,7 @@ func TestSyncPodBadHash(t *testing.T) {
...
@@ -544,7 +544,7 @@ func TestSyncPodBadHash(t *testing.T) {
},
},
}
}
err
:=
kubelet
.
syncPod
(
&
api
.
BoundPod
{
err
:=
kubelet
.
syncPod
(
&
api
.
BoundPod
{
TypeMeta
:
api
.
Type
Meta
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
,
Name
:
"foo"
,
Namespace
:
"new"
,
Namespace
:
"new"
,
Annotations
:
map
[
string
]
string
{
ConfigSourceAnnotationKey
:
"test"
},
Annotations
:
map
[
string
]
string
{
ConfigSourceAnnotationKey
:
"test"
},
...
@@ -588,7 +588,7 @@ func TestSyncPodUnhealthy(t *testing.T) {
...
@@ -588,7 +588,7 @@ func TestSyncPodUnhealthy(t *testing.T) {
},
},
}
}
err
:=
kubelet
.
syncPod
(
&
api
.
BoundPod
{
err
:=
kubelet
.
syncPod
(
&
api
.
BoundPod
{
TypeMeta
:
api
.
Type
Meta
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
,
Name
:
"foo"
,
Namespace
:
"new"
,
Namespace
:
"new"
,
Annotations
:
map
[
string
]
string
{
ConfigSourceAnnotationKey
:
"test"
},
Annotations
:
map
[
string
]
string
{
ConfigSourceAnnotationKey
:
"test"
},
...
@@ -648,7 +648,7 @@ func TestMakeEnvVariables(t *testing.T) {
...
@@ -648,7 +648,7 @@ func TestMakeEnvVariables(t *testing.T) {
func
TestMountExternalVolumes
(
t
*
testing
.
T
)
{
func
TestMountExternalVolumes
(
t
*
testing
.
T
)
{
kubelet
,
_
,
_
:=
newTestKubelet
(
t
)
kubelet
,
_
,
_
:=
newTestKubelet
(
t
)
pod
:=
api
.
BoundPod
{
pod
:=
api
.
BoundPod
{
TypeMeta
:
api
.
Type
Meta
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
,
Name
:
"foo"
,
Namespace
:
"test"
,
Namespace
:
"test"
,
},
},
...
@@ -703,7 +703,7 @@ func TestMakeVolumesAndBinds(t *testing.T) {
...
@@ -703,7 +703,7 @@ func TestMakeVolumesAndBinds(t *testing.T) {
}
}
pod
:=
api
.
BoundPod
{
pod
:=
api
.
BoundPod
{
TypeMeta
:
api
.
Type
Meta
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"pod"
,
Name
:
"pod"
,
Namespace
:
"test"
,
Namespace
:
"test"
,
},
},
...
@@ -991,7 +991,7 @@ func TestRunInContainerNoSuchPod(t *testing.T) {
...
@@ -991,7 +991,7 @@ func TestRunInContainerNoSuchPod(t *testing.T) {
podNamespace
:=
"etcd"
podNamespace
:=
"etcd"
containerName
:=
"containerFoo"
containerName
:=
"containerFoo"
output
,
err
:=
kubelet
.
RunInContainer
(
output
,
err
:=
kubelet
.
RunInContainer
(
GetPodFullName
(
&
api
.
BoundPod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
podName
,
Namespace
:
podNamespace
}}),
GetPodFullName
(
&
api
.
BoundPod
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
podName
,
Namespace
:
podNamespace
}}),
""
,
""
,
containerName
,
containerName
,
[]
string
{
"ls"
})
[]
string
{
"ls"
})
...
@@ -1023,7 +1023,7 @@ func TestRunInContainer(t *testing.T) {
...
@@ -1023,7 +1023,7 @@ func TestRunInContainer(t *testing.T) {
cmd
:=
[]
string
{
"ls"
}
cmd
:=
[]
string
{
"ls"
}
_
,
err
:=
kubelet
.
RunInContainer
(
_
,
err
:=
kubelet
.
RunInContainer
(
GetPodFullName
(
&
api
.
BoundPod
{
GetPodFullName
(
&
api
.
BoundPod
{
TypeMeta
:
api
.
Type
Meta
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
podName
,
Name
:
podName
,
Namespace
:
podNamespace
,
Namespace
:
podNamespace
,
Annotations
:
map
[
string
]
string
{
ConfigSourceAnnotationKey
:
"test"
},
Annotations
:
map
[
string
]
string
{
ConfigSourceAnnotationKey
:
"test"
},
...
@@ -1165,7 +1165,7 @@ func TestSyncPodEventHandlerFails(t *testing.T) {
...
@@ -1165,7 +1165,7 @@ func TestSyncPodEventHandlerFails(t *testing.T) {
},
},
}
}
err
:=
kubelet
.
syncPod
(
&
api
.
BoundPod
{
err
:=
kubelet
.
syncPod
(
&
api
.
BoundPod
{
TypeMeta
:
api
.
Type
Meta
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
,
Name
:
"foo"
,
Namespace
:
"new"
,
Namespace
:
"new"
,
Annotations
:
map
[
string
]
string
{
ConfigSourceAnnotationKey
:
"test"
},
Annotations
:
map
[
string
]
string
{
ConfigSourceAnnotationKey
:
"test"
},
...
...
pkg/kubelet/runonce_test.go
View file @
644eb700
...
@@ -108,7 +108,7 @@ func TestRunOnce(t *testing.T) {
...
@@ -108,7 +108,7 @@ func TestRunOnce(t *testing.T) {
kb
.
dockerPuller
=
&
dockertools
.
FakeDockerPuller
{}
kb
.
dockerPuller
=
&
dockertools
.
FakeDockerPuller
{}
results
,
err
:=
kb
.
runOnce
([]
api
.
BoundPod
{
results
,
err
:=
kb
.
runOnce
([]
api
.
BoundPod
{
{
{
TypeMeta
:
api
.
Type
Meta
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
,
Name
:
"foo"
,
Namespace
:
"new"
,
Namespace
:
"new"
,
Annotations
:
map
[
string
]
string
{
ConfigSourceAnnotationKey
:
"test"
},
Annotations
:
map
[
string
]
string
{
ConfigSourceAnnotationKey
:
"test"
},
...
...
pkg/kubelet/server_test.go
View file @
644eb700
...
@@ -132,7 +132,7 @@ func TestContainer(t *testing.T) {
...
@@ -132,7 +132,7 @@ func TestContainer(t *testing.T) {
}
}
expectedPods
:=
[]
api
.
BoundPod
{
expectedPods
:=
[]
api
.
BoundPod
{
{
{
TypeMeta
:
api
.
Type
Meta
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"test_manifest"
,
Name
:
"test_manifest"
,
UID
:
"value"
,
UID
:
"value"
,
},
},
...
@@ -207,7 +207,7 @@ func TestContainers(t *testing.T) {
...
@@ -207,7 +207,7 @@ func TestContainers(t *testing.T) {
}
}
expectedPods
:=
[]
api
.
BoundPod
{
expectedPods
:=
[]
api
.
BoundPod
{
{
{
TypeMeta
:
api
.
Type
Meta
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"1"
,
Name
:
"1"
,
},
},
Spec
:
api
.
PodSpec
{
Spec
:
api
.
PodSpec
{
...
@@ -227,7 +227,7 @@ func TestContainers(t *testing.T) {
...
@@ -227,7 +227,7 @@ func TestContainers(t *testing.T) {
},
},
},
},
{
{
TypeMeta
:
api
.
Type
Meta
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"2"
,
Name
:
"2"
,
},
},
Spec
:
api
.
PodSpec
{
Spec
:
api
.
PodSpec
{
...
...
pkg/master/pod_cache_test.go
View file @
644eb700
...
@@ -124,7 +124,7 @@ func TestPodGetPodInfoGetter(t *testing.T) {
...
@@ -124,7 +124,7 @@ func TestPodGetPodInfoGetter(t *testing.T) {
func
TestPodUpdateAllContainers
(
t
*
testing
.
T
)
{
func
TestPodUpdateAllContainers
(
t
*
testing
.
T
)
{
pod
:=
api
.
Pod
{
pod
:=
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
,
Namespace
:
api
.
NamespaceDefault
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
,
Namespace
:
api
.
NamespaceDefault
},
CurrentState
:
api
.
PodState
{
CurrentState
:
api
.
PodState
{
Host
:
"machine"
,
Host
:
"machine"
,
},
},
...
...
pkg/proxy/config/api_test.go
View file @
644eb700
...
@@ -27,7 +27,7 @@ import (
...
@@ -27,7 +27,7 @@ import (
)
)
func
TestServices
(
t
*
testing
.
T
)
{
func
TestServices
(
t
*
testing
.
T
)
{
service
:=
api
.
Service
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"bar"
,
ResourceVersion
:
"2"
}}
service
:=
api
.
Service
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"bar"
,
ResourceVersion
:
"2"
}}
fakeWatch
:=
watch
.
NewFake
()
fakeWatch
:=
watch
.
NewFake
()
fakeClient
:=
&
client
.
Fake
{
Watch
:
fakeWatch
}
fakeClient
:=
&
client
.
Fake
{
Watch
:
fakeWatch
}
...
@@ -72,13 +72,13 @@ func TestServices(t *testing.T) {
...
@@ -72,13 +72,13 @@ func TestServices(t *testing.T) {
}
}
func
TestServicesFromZero
(
t
*
testing
.
T
)
{
func
TestServicesFromZero
(
t
*
testing
.
T
)
{
service
:=
api
.
Service
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"bar"
,
ResourceVersion
:
"2"
}}
service
:=
api
.
Service
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"bar"
,
ResourceVersion
:
"2"
}}
fakeWatch
:=
watch
.
NewFake
()
fakeWatch
:=
watch
.
NewFake
()
fakeWatch
.
Stop
()
fakeWatch
.
Stop
()
fakeClient
:=
&
client
.
Fake
{
Watch
:
fakeWatch
}
fakeClient
:=
&
client
.
Fake
{
Watch
:
fakeWatch
}
fakeClient
.
ServiceList
=
api
.
ServiceList
{
fakeClient
.
ServiceList
=
api
.
ServiceList
{
TypeMeta
:
api
.
Type
Meta
{
ResourceVersion
:
"2"
},
ListMeta
:
api
.
List
Meta
{
ResourceVersion
:
"2"
},
Items
:
[]
api
.
Service
{
Items
:
[]
api
.
Service
{
service
,
service
,
},
},
...
@@ -152,7 +152,7 @@ func TestServicesFromZeroError(t *testing.T) {
...
@@ -152,7 +152,7 @@ func TestServicesFromZeroError(t *testing.T) {
}
}
func
TestEndpoints
(
t
*
testing
.
T
)
{
func
TestEndpoints
(
t
*
testing
.
T
)
{
endpoint
:=
api
.
Endpoints
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"bar"
,
ResourceVersion
:
"2"
},
Endpoints
:
[]
string
{
"127.0.0.1:9000"
}}
endpoint
:=
api
.
Endpoints
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"bar"
,
ResourceVersion
:
"2"
},
Endpoints
:
[]
string
{
"127.0.0.1:9000"
}}
fakeWatch
:=
watch
.
NewFake
()
fakeWatch
:=
watch
.
NewFake
()
fakeClient
:=
&
client
.
Fake
{
Watch
:
fakeWatch
}
fakeClient
:=
&
client
.
Fake
{
Watch
:
fakeWatch
}
...
@@ -197,13 +197,13 @@ func TestEndpoints(t *testing.T) {
...
@@ -197,13 +197,13 @@ func TestEndpoints(t *testing.T) {
}
}
func
TestEndpointsFromZero
(
t
*
testing
.
T
)
{
func
TestEndpointsFromZero
(
t
*
testing
.
T
)
{
endpoint
:=
api
.
Endpoints
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"bar"
,
ResourceVersion
:
"2"
},
Endpoints
:
[]
string
{
"127.0.0.1:9000"
}}
endpoint
:=
api
.
Endpoints
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"bar"
,
ResourceVersion
:
"2"
},
Endpoints
:
[]
string
{
"127.0.0.1:9000"
}}
fakeWatch
:=
watch
.
NewFake
()
fakeWatch
:=
watch
.
NewFake
()
fakeWatch
.
Stop
()
fakeWatch
.
Stop
()
fakeClient
:=
&
client
.
Fake
{
Watch
:
fakeWatch
}
fakeClient
:=
&
client
.
Fake
{
Watch
:
fakeWatch
}
fakeClient
.
EndpointsList
=
api
.
EndpointsList
{
fakeClient
.
EndpointsList
=
api
.
EndpointsList
{
TypeMeta
:
api
.
Type
Meta
{
ResourceVersion
:
"2"
},
ListMeta
:
api
.
List
Meta
{
ResourceVersion
:
"2"
},
Items
:
[]
api
.
Endpoints
{
Items
:
[]
api
.
Endpoints
{
endpoint
,
endpoint
,
},
},
...
...
pkg/proxy/config/config_test.go
View file @
644eb700
...
@@ -136,7 +136,7 @@ func TestNewServiceAddedAndNotified(t *testing.T) {
...
@@ -136,7 +136,7 @@ func TestNewServiceAddedAndNotified(t *testing.T) {
handler
:=
NewServiceHandlerMock
()
handler
:=
NewServiceHandlerMock
()
handler
.
Wait
(
1
)
handler
.
Wait
(
1
)
config
.
RegisterHandler
(
handler
)
config
.
RegisterHandler
(
handler
)
serviceUpdate
:=
CreateServiceUpdate
(
ADD
,
api
.
Service
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
Port
:
10
})
serviceUpdate
:=
CreateServiceUpdate
(
ADD
,
api
.
Service
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Port
:
10
})
channel
<-
serviceUpdate
channel
<-
serviceUpdate
handler
.
ValidateServices
(
t
,
serviceUpdate
.
Services
)
handler
.
ValidateServices
(
t
,
serviceUpdate
.
Services
)
...
@@ -147,24 +147,24 @@ func TestServiceAddedRemovedSetAndNotified(t *testing.T) {
...
@@ -147,24 +147,24 @@ func TestServiceAddedRemovedSetAndNotified(t *testing.T) {
channel
:=
config
.
Channel
(
"one"
)
channel
:=
config
.
Channel
(
"one"
)
handler
:=
NewServiceHandlerMock
()
handler
:=
NewServiceHandlerMock
()
config
.
RegisterHandler
(
handler
)
config
.
RegisterHandler
(
handler
)
serviceUpdate
:=
CreateServiceUpdate
(
ADD
,
api
.
Service
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
Port
:
10
})
serviceUpdate
:=
CreateServiceUpdate
(
ADD
,
api
.
Service
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Port
:
10
})
handler
.
Wait
(
1
)
handler
.
Wait
(
1
)
channel
<-
serviceUpdate
channel
<-
serviceUpdate
handler
.
ValidateServices
(
t
,
serviceUpdate
.
Services
)
handler
.
ValidateServices
(
t
,
serviceUpdate
.
Services
)
serviceUpdate2
:=
CreateServiceUpdate
(
ADD
,
api
.
Service
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"bar"
},
Port
:
20
})
serviceUpdate2
:=
CreateServiceUpdate
(
ADD
,
api
.
Service
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"bar"
},
Port
:
20
})
handler
.
Wait
(
1
)
handler
.
Wait
(
1
)
channel
<-
serviceUpdate2
channel
<-
serviceUpdate2
services
:=
[]
api
.
Service
{
serviceUpdate2
.
Services
[
0
],
serviceUpdate
.
Services
[
0
]}
services
:=
[]
api
.
Service
{
serviceUpdate2
.
Services
[
0
],
serviceUpdate
.
Services
[
0
]}
handler
.
ValidateServices
(
t
,
services
)
handler
.
ValidateServices
(
t
,
services
)
serviceUpdate3
:=
CreateServiceUpdate
(
REMOVE
,
api
.
Service
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
}})
serviceUpdate3
:=
CreateServiceUpdate
(
REMOVE
,
api
.
Service
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
}})
handler
.
Wait
(
1
)
handler
.
Wait
(
1
)
channel
<-
serviceUpdate3
channel
<-
serviceUpdate3
services
=
[]
api
.
Service
{
serviceUpdate2
.
Services
[
0
]}
services
=
[]
api
.
Service
{
serviceUpdate2
.
Services
[
0
]}
handler
.
ValidateServices
(
t
,
services
)
handler
.
ValidateServices
(
t
,
services
)
serviceUpdate4
:=
CreateServiceUpdate
(
SET
,
api
.
Service
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foobar"
},
Port
:
99
})
serviceUpdate4
:=
CreateServiceUpdate
(
SET
,
api
.
Service
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foobar"
},
Port
:
99
})
handler
.
Wait
(
1
)
handler
.
Wait
(
1
)
channel
<-
serviceUpdate4
channel
<-
serviceUpdate4
services
=
[]
api
.
Service
{
serviceUpdate4
.
Services
[
0
]}
services
=
[]
api
.
Service
{
serviceUpdate4
.
Services
[
0
]}
...
@@ -180,8 +180,8 @@ func TestNewMultipleSourcesServicesAddedAndNotified(t *testing.T) {
...
@@ -180,8 +180,8 @@ func TestNewMultipleSourcesServicesAddedAndNotified(t *testing.T) {
}
}
handler
:=
NewServiceHandlerMock
()
handler
:=
NewServiceHandlerMock
()
config
.
RegisterHandler
(
handler
)
config
.
RegisterHandler
(
handler
)
serviceUpdate1
:=
CreateServiceUpdate
(
ADD
,
api
.
Service
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
Port
:
10
})
serviceUpdate1
:=
CreateServiceUpdate
(
ADD
,
api
.
Service
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Port
:
10
})
serviceUpdate2
:=
CreateServiceUpdate
(
ADD
,
api
.
Service
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"bar"
},
Port
:
20
})
serviceUpdate2
:=
CreateServiceUpdate
(
ADD
,
api
.
Service
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"bar"
},
Port
:
20
})
handler
.
Wait
(
2
)
handler
.
Wait
(
2
)
channelOne
<-
serviceUpdate1
channelOne
<-
serviceUpdate1
channelTwo
<-
serviceUpdate2
channelTwo
<-
serviceUpdate2
...
@@ -197,8 +197,8 @@ func TestNewMultipleSourcesServicesMultipleHandlersAddedAndNotified(t *testing.T
...
@@ -197,8 +197,8 @@ func TestNewMultipleSourcesServicesMultipleHandlersAddedAndNotified(t *testing.T
handler2
:=
NewServiceHandlerMock
()
handler2
:=
NewServiceHandlerMock
()
config
.
RegisterHandler
(
handler
)
config
.
RegisterHandler
(
handler
)
config
.
RegisterHandler
(
handler2
)
config
.
RegisterHandler
(
handler2
)
serviceUpdate1
:=
CreateServiceUpdate
(
ADD
,
api
.
Service
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
Port
:
10
})
serviceUpdate1
:=
CreateServiceUpdate
(
ADD
,
api
.
Service
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Port
:
10
})
serviceUpdate2
:=
CreateServiceUpdate
(
ADD
,
api
.
Service
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"bar"
},
Port
:
20
})
serviceUpdate2
:=
CreateServiceUpdate
(
ADD
,
api
.
Service
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"bar"
},
Port
:
20
})
handler
.
Wait
(
2
)
handler
.
Wait
(
2
)
handler2
.
Wait
(
2
)
handler2
.
Wait
(
2
)
channelOne
<-
serviceUpdate1
channelOne
<-
serviceUpdate1
...
@@ -217,11 +217,11 @@ func TestNewMultipleSourcesEndpointsMultipleHandlersAddedAndNotified(t *testing.
...
@@ -217,11 +217,11 @@ func TestNewMultipleSourcesEndpointsMultipleHandlersAddedAndNotified(t *testing.
config
.
RegisterHandler
(
handler
)
config
.
RegisterHandler
(
handler
)
config
.
RegisterHandler
(
handler2
)
config
.
RegisterHandler
(
handler2
)
endpointsUpdate1
:=
CreateEndpointsUpdate
(
ADD
,
api
.
Endpoints
{
endpointsUpdate1
:=
CreateEndpointsUpdate
(
ADD
,
api
.
Endpoints
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Endpoints
:
[]
string
{
"endpoint1"
,
"endpoint2"
},
Endpoints
:
[]
string
{
"endpoint1"
,
"endpoint2"
},
})
})
endpointsUpdate2
:=
CreateEndpointsUpdate
(
ADD
,
api
.
Endpoints
{
endpointsUpdate2
:=
CreateEndpointsUpdate
(
ADD
,
api
.
Endpoints
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"bar"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"bar"
},
Endpoints
:
[]
string
{
"endpoint3"
,
"endpoint4"
},
Endpoints
:
[]
string
{
"endpoint3"
,
"endpoint4"
},
})
})
handler
.
Wait
(
2
)
handler
.
Wait
(
2
)
...
@@ -243,11 +243,11 @@ func TestNewMultipleSourcesEndpointsMultipleHandlersAddRemoveSetAndNotified(t *t
...
@@ -243,11 +243,11 @@ func TestNewMultipleSourcesEndpointsMultipleHandlersAddRemoveSetAndNotified(t *t
config
.
RegisterHandler
(
handler
)
config
.
RegisterHandler
(
handler
)
config
.
RegisterHandler
(
handler2
)
config
.
RegisterHandler
(
handler2
)
endpointsUpdate1
:=
CreateEndpointsUpdate
(
ADD
,
api
.
Endpoints
{
endpointsUpdate1
:=
CreateEndpointsUpdate
(
ADD
,
api
.
Endpoints
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Endpoints
:
[]
string
{
"endpoint1"
,
"endpoint2"
},
Endpoints
:
[]
string
{
"endpoint1"
,
"endpoint2"
},
})
})
endpointsUpdate2
:=
CreateEndpointsUpdate
(
ADD
,
api
.
Endpoints
{
endpointsUpdate2
:=
CreateEndpointsUpdate
(
ADD
,
api
.
Endpoints
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"bar"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"bar"
},
Endpoints
:
[]
string
{
"endpoint3"
,
"endpoint4"
},
Endpoints
:
[]
string
{
"endpoint3"
,
"endpoint4"
},
})
})
handler
.
Wait
(
2
)
handler
.
Wait
(
2
)
...
@@ -261,7 +261,7 @@ func TestNewMultipleSourcesEndpointsMultipleHandlersAddRemoveSetAndNotified(t *t
...
@@ -261,7 +261,7 @@ func TestNewMultipleSourcesEndpointsMultipleHandlersAddRemoveSetAndNotified(t *t
// Add one more
// Add one more
endpointsUpdate3
:=
CreateEndpointsUpdate
(
ADD
,
api
.
Endpoints
{
endpointsUpdate3
:=
CreateEndpointsUpdate
(
ADD
,
api
.
Endpoints
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foobar"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foobar"
},
Endpoints
:
[]
string
{
"endpoint5"
,
"endpoint6"
},
Endpoints
:
[]
string
{
"endpoint5"
,
"endpoint6"
},
})
})
handler
.
Wait
(
1
)
handler
.
Wait
(
1
)
...
@@ -273,7 +273,7 @@ func TestNewMultipleSourcesEndpointsMultipleHandlersAddRemoveSetAndNotified(t *t
...
@@ -273,7 +273,7 @@ func TestNewMultipleSourcesEndpointsMultipleHandlersAddRemoveSetAndNotified(t *t
// Update the "foo" service with new endpoints
// Update the "foo" service with new endpoints
endpointsUpdate1
=
CreateEndpointsUpdate
(
ADD
,
api
.
Endpoints
{
endpointsUpdate1
=
CreateEndpointsUpdate
(
ADD
,
api
.
Endpoints
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Endpoints
:
[]
string
{
"endpoint77"
},
Endpoints
:
[]
string
{
"endpoint77"
},
})
})
handler
.
Wait
(
1
)
handler
.
Wait
(
1
)
...
@@ -284,7 +284,7 @@ func TestNewMultipleSourcesEndpointsMultipleHandlersAddRemoveSetAndNotified(t *t
...
@@ -284,7 +284,7 @@ func TestNewMultipleSourcesEndpointsMultipleHandlersAddRemoveSetAndNotified(t *t
handler2
.
ValidateEndpoints
(
t
,
endpoints
)
handler2
.
ValidateEndpoints
(
t
,
endpoints
)
// Remove "bar" service
// Remove "bar" service
endpointsUpdate2
=
CreateEndpointsUpdate
(
REMOVE
,
api
.
Endpoints
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"bar"
}})
endpointsUpdate2
=
CreateEndpointsUpdate
(
REMOVE
,
api
.
Endpoints
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"bar"
}})
handler
.
Wait
(
1
)
handler
.
Wait
(
1
)
handler2
.
Wait
(
1
)
handler2
.
Wait
(
1
)
channelTwo
<-
endpointsUpdate2
channelTwo
<-
endpointsUpdate2
...
...
pkg/proxy/proxier_test.go
View file @
644eb700
...
@@ -163,7 +163,7 @@ func TestTCPProxy(t *testing.T) {
...
@@ -163,7 +163,7 @@ func TestTCPProxy(t *testing.T) {
lb
:=
NewLoadBalancerRR
()
lb
:=
NewLoadBalancerRR
()
lb
.
OnUpdate
([]
api
.
Endpoints
{
lb
.
OnUpdate
([]
api
.
Endpoints
{
{
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"echo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"echo"
},
Endpoints
:
[]
string
{
net
.
JoinHostPort
(
"127.0.0.1"
,
tcpServerPort
)},
Endpoints
:
[]
string
{
net
.
JoinHostPort
(
"127.0.0.1"
,
tcpServerPort
)},
},
},
})
})
...
@@ -181,7 +181,7 @@ func TestUDPProxy(t *testing.T) {
...
@@ -181,7 +181,7 @@ func TestUDPProxy(t *testing.T) {
lb
:=
NewLoadBalancerRR
()
lb
:=
NewLoadBalancerRR
()
lb
.
OnUpdate
([]
api
.
Endpoints
{
lb
.
OnUpdate
([]
api
.
Endpoints
{
{
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"echo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"echo"
},
Endpoints
:
[]
string
{
net
.
JoinHostPort
(
"127.0.0.1"
,
udpServerPort
)},
Endpoints
:
[]
string
{
net
.
JoinHostPort
(
"127.0.0.1"
,
udpServerPort
)},
},
},
})
})
...
@@ -208,7 +208,7 @@ func TestTCPProxyStop(t *testing.T) {
...
@@ -208,7 +208,7 @@ func TestTCPProxyStop(t *testing.T) {
lb
:=
NewLoadBalancerRR
()
lb
:=
NewLoadBalancerRR
()
lb
.
OnUpdate
([]
api
.
Endpoints
{
lb
.
OnUpdate
([]
api
.
Endpoints
{
{
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"echo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"echo"
},
Endpoints
:
[]
string
{
net
.
JoinHostPort
(
"127.0.0.1"
,
tcpServerPort
)},
Endpoints
:
[]
string
{
net
.
JoinHostPort
(
"127.0.0.1"
,
tcpServerPort
)},
},
},
})
})
...
@@ -236,7 +236,7 @@ func TestUDPProxyStop(t *testing.T) {
...
@@ -236,7 +236,7 @@ func TestUDPProxyStop(t *testing.T) {
lb
:=
NewLoadBalancerRR
()
lb
:=
NewLoadBalancerRR
()
lb
.
OnUpdate
([]
api
.
Endpoints
{
lb
.
OnUpdate
([]
api
.
Endpoints
{
{
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"echo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"echo"
},
Endpoints
:
[]
string
{
net
.
JoinHostPort
(
"127.0.0.1"
,
udpServerPort
)},
Endpoints
:
[]
string
{
net
.
JoinHostPort
(
"127.0.0.1"
,
udpServerPort
)},
},
},
})
})
...
@@ -264,7 +264,7 @@ func TestTCPProxyUpdateDelete(t *testing.T) {
...
@@ -264,7 +264,7 @@ func TestTCPProxyUpdateDelete(t *testing.T) {
lb
:=
NewLoadBalancerRR
()
lb
:=
NewLoadBalancerRR
()
lb
.
OnUpdate
([]
api
.
Endpoints
{
lb
.
OnUpdate
([]
api
.
Endpoints
{
{
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"echo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"echo"
},
Endpoints
:
[]
string
{
net
.
JoinHostPort
(
"127.0.0.1"
,
tcpServerPort
)},
Endpoints
:
[]
string
{
net
.
JoinHostPort
(
"127.0.0.1"
,
tcpServerPort
)},
},
},
})
})
...
@@ -291,7 +291,7 @@ func TestUDPProxyUpdateDelete(t *testing.T) {
...
@@ -291,7 +291,7 @@ func TestUDPProxyUpdateDelete(t *testing.T) {
lb
:=
NewLoadBalancerRR
()
lb
:=
NewLoadBalancerRR
()
lb
.
OnUpdate
([]
api
.
Endpoints
{
lb
.
OnUpdate
([]
api
.
Endpoints
{
{
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"echo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"echo"
},
Endpoints
:
[]
string
{
net
.
JoinHostPort
(
"127.0.0.1"
,
udpServerPort
)},
Endpoints
:
[]
string
{
net
.
JoinHostPort
(
"127.0.0.1"
,
udpServerPort
)},
},
},
})
})
...
@@ -318,7 +318,7 @@ func TestTCPProxyUpdateDeleteUpdate(t *testing.T) {
...
@@ -318,7 +318,7 @@ func TestTCPProxyUpdateDeleteUpdate(t *testing.T) {
lb
:=
NewLoadBalancerRR
()
lb
:=
NewLoadBalancerRR
()
lb
.
OnUpdate
([]
api
.
Endpoints
{
lb
.
OnUpdate
([]
api
.
Endpoints
{
{
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"echo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"echo"
},
Endpoints
:
[]
string
{
net
.
JoinHostPort
(
"127.0.0.1"
,
tcpServerPort
)},
Endpoints
:
[]
string
{
net
.
JoinHostPort
(
"127.0.0.1"
,
tcpServerPort
)},
},
},
})
})
...
@@ -340,7 +340,7 @@ func TestTCPProxyUpdateDeleteUpdate(t *testing.T) {
...
@@ -340,7 +340,7 @@ func TestTCPProxyUpdateDeleteUpdate(t *testing.T) {
t
.
Fatalf
(
err
.
Error
())
t
.
Fatalf
(
err
.
Error
())
}
}
p
.
OnUpdate
([]
api
.
Service
{
p
.
OnUpdate
([]
api
.
Service
{
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"echo"
},
Port
:
svcInfo
.
proxyPort
,
ProxyPort
:
svcInfo
.
proxyPort
,
Protocol
:
"TCP"
},
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"echo"
},
Port
:
svcInfo
.
proxyPort
,
ProxyPort
:
svcInfo
.
proxyPort
,
Protocol
:
"TCP"
},
})
})
testEchoTCP
(
t
,
"127.0.0.1"
,
svcInfo
.
proxyPort
)
testEchoTCP
(
t
,
"127.0.0.1"
,
svcInfo
.
proxyPort
)
}
}
...
@@ -349,7 +349,7 @@ func TestUDPProxyUpdateDeleteUpdate(t *testing.T) {
...
@@ -349,7 +349,7 @@ func TestUDPProxyUpdateDeleteUpdate(t *testing.T) {
lb
:=
NewLoadBalancerRR
()
lb
:=
NewLoadBalancerRR
()
lb
.
OnUpdate
([]
api
.
Endpoints
{
lb
.
OnUpdate
([]
api
.
Endpoints
{
{
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"echo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"echo"
},
Endpoints
:
[]
string
{
net
.
JoinHostPort
(
"127.0.0.1"
,
udpServerPort
)},
Endpoints
:
[]
string
{
net
.
JoinHostPort
(
"127.0.0.1"
,
udpServerPort
)},
},
},
})
})
...
@@ -371,7 +371,7 @@ func TestUDPProxyUpdateDeleteUpdate(t *testing.T) {
...
@@ -371,7 +371,7 @@ func TestUDPProxyUpdateDeleteUpdate(t *testing.T) {
t
.
Fatalf
(
err
.
Error
())
t
.
Fatalf
(
err
.
Error
())
}
}
p
.
OnUpdate
([]
api
.
Service
{
p
.
OnUpdate
([]
api
.
Service
{
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"echo"
},
Port
:
svcInfo
.
proxyPort
,
ProxyPort
:
svcInfo
.
proxyPort
,
Protocol
:
"UDP"
},
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"echo"
},
Port
:
svcInfo
.
proxyPort
,
ProxyPort
:
svcInfo
.
proxyPort
,
Protocol
:
"UDP"
},
})
})
testEchoUDP
(
t
,
"127.0.0.1"
,
svcInfo
.
proxyPort
)
testEchoUDP
(
t
,
"127.0.0.1"
,
svcInfo
.
proxyPort
)
}
}
...
@@ -380,7 +380,7 @@ func TestTCPProxyUpdatePort(t *testing.T) {
...
@@ -380,7 +380,7 @@ func TestTCPProxyUpdatePort(t *testing.T) {
lb
:=
NewLoadBalancerRR
()
lb
:=
NewLoadBalancerRR
()
lb
.
OnUpdate
([]
api
.
Endpoints
{
lb
.
OnUpdate
([]
api
.
Endpoints
{
{
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"echo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"echo"
},
Endpoints
:
[]
string
{
net
.
JoinHostPort
(
"127.0.0.1"
,
tcpServerPort
)},
Endpoints
:
[]
string
{
net
.
JoinHostPort
(
"127.0.0.1"
,
tcpServerPort
)},
},
},
})
})
...
@@ -406,7 +406,7 @@ func TestTCPProxyUpdatePort(t *testing.T) {
...
@@ -406,7 +406,7 @@ func TestTCPProxyUpdatePort(t *testing.T) {
t
.
Errorf
(
"expected difference, got %d %d"
,
newPort
,
svcInfo
.
proxyPort
)
t
.
Errorf
(
"expected difference, got %d %d"
,
newPort
,
svcInfo
.
proxyPort
)
}
}
p
.
OnUpdate
([]
api
.
Service
{
p
.
OnUpdate
([]
api
.
Service
{
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"echo"
},
Port
:
newPort
,
ProxyPort
:
newPort
,
Protocol
:
"TCP"
},
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"echo"
},
Port
:
newPort
,
ProxyPort
:
newPort
,
Protocol
:
"TCP"
},
})
})
if
err
:=
waitForClosedPortTCP
(
p
,
svcInfo
.
proxyPort
);
err
!=
nil
{
if
err
:=
waitForClosedPortTCP
(
p
,
svcInfo
.
proxyPort
);
err
!=
nil
{
t
.
Fatalf
(
err
.
Error
())
t
.
Fatalf
(
err
.
Error
())
...
@@ -425,7 +425,7 @@ func TestUDPProxyUpdatePort(t *testing.T) {
...
@@ -425,7 +425,7 @@ func TestUDPProxyUpdatePort(t *testing.T) {
lb
:=
NewLoadBalancerRR
()
lb
:=
NewLoadBalancerRR
()
lb
.
OnUpdate
([]
api
.
Endpoints
{
lb
.
OnUpdate
([]
api
.
Endpoints
{
{
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"echo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"echo"
},
Endpoints
:
[]
string
{
net
.
JoinHostPort
(
"127.0.0.1"
,
udpServerPort
)},
Endpoints
:
[]
string
{
net
.
JoinHostPort
(
"127.0.0.1"
,
udpServerPort
)},
},
},
})
})
...
@@ -451,7 +451,7 @@ func TestUDPProxyUpdatePort(t *testing.T) {
...
@@ -451,7 +451,7 @@ func TestUDPProxyUpdatePort(t *testing.T) {
t
.
Errorf
(
"expected difference, got %d %d"
,
newPort
,
svcInfo
.
proxyPort
)
t
.
Errorf
(
"expected difference, got %d %d"
,
newPort
,
svcInfo
.
proxyPort
)
}
}
p
.
OnUpdate
([]
api
.
Service
{
p
.
OnUpdate
([]
api
.
Service
{
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"echo"
},
Port
:
newPort
,
ProxyPort
:
newPort
,
Protocol
:
"UDP"
},
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"echo"
},
Port
:
newPort
,
ProxyPort
:
newPort
,
Protocol
:
"UDP"
},
})
})
if
err
:=
waitForClosedPortUDP
(
p
,
svcInfo
.
proxyPort
);
err
!=
nil
{
if
err
:=
waitForClosedPortUDP
(
p
,
svcInfo
.
proxyPort
);
err
!=
nil
{
t
.
Fatalf
(
err
.
Error
())
t
.
Fatalf
(
err
.
Error
())
...
...
pkg/proxy/roundrobin_test.go
View file @
644eb700
...
@@ -86,7 +86,7 @@ func TestLoadBalanceWorksWithSingleEndpoint(t *testing.T) {
...
@@ -86,7 +86,7 @@ func TestLoadBalanceWorksWithSingleEndpoint(t *testing.T) {
}
}
endpoints
:=
make
([]
api
.
Endpoints
,
1
)
endpoints
:=
make
([]
api
.
Endpoints
,
1
)
endpoints
[
0
]
=
api
.
Endpoints
{
endpoints
[
0
]
=
api
.
Endpoints
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Endpoints
:
[]
string
{
"endpoint1:40"
},
Endpoints
:
[]
string
{
"endpoint1:40"
},
}
}
loadBalancer
.
OnUpdate
(
endpoints
)
loadBalancer
.
OnUpdate
(
endpoints
)
...
@@ -104,7 +104,7 @@ func TestLoadBalanceWorksWithMultipleEndpoints(t *testing.T) {
...
@@ -104,7 +104,7 @@ func TestLoadBalanceWorksWithMultipleEndpoints(t *testing.T) {
}
}
endpoints
:=
make
([]
api
.
Endpoints
,
1
)
endpoints
:=
make
([]
api
.
Endpoints
,
1
)
endpoints
[
0
]
=
api
.
Endpoints
{
endpoints
[
0
]
=
api
.
Endpoints
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Endpoints
:
[]
string
{
"endpoint:1"
,
"endpoint:2"
,
"endpoint:3"
},
Endpoints
:
[]
string
{
"endpoint:1"
,
"endpoint:2"
,
"endpoint:3"
},
}
}
loadBalancer
.
OnUpdate
(
endpoints
)
loadBalancer
.
OnUpdate
(
endpoints
)
...
@@ -122,7 +122,7 @@ func TestLoadBalanceWorksWithMultipleEndpointsAndUpdates(t *testing.T) {
...
@@ -122,7 +122,7 @@ func TestLoadBalanceWorksWithMultipleEndpointsAndUpdates(t *testing.T) {
}
}
endpoints
:=
make
([]
api
.
Endpoints
,
1
)
endpoints
:=
make
([]
api
.
Endpoints
,
1
)
endpoints
[
0
]
=
api
.
Endpoints
{
endpoints
[
0
]
=
api
.
Endpoints
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Endpoints
:
[]
string
{
"endpoint:1"
,
"endpoint:2"
,
"endpoint:3"
},
Endpoints
:
[]
string
{
"endpoint:1"
,
"endpoint:2"
,
"endpoint:3"
},
}
}
loadBalancer
.
OnUpdate
(
endpoints
)
loadBalancer
.
OnUpdate
(
endpoints
)
...
@@ -133,7 +133,7 @@ func TestLoadBalanceWorksWithMultipleEndpointsAndUpdates(t *testing.T) {
...
@@ -133,7 +133,7 @@ func TestLoadBalanceWorksWithMultipleEndpointsAndUpdates(t *testing.T) {
expectEndpoint
(
t
,
loadBalancer
,
"foo"
,
"endpoint:2"
)
expectEndpoint
(
t
,
loadBalancer
,
"foo"
,
"endpoint:2"
)
// Then update the configuration with one fewer endpoints, make sure
// Then update the configuration with one fewer endpoints, make sure
// we start in the beginning again
// we start in the beginning again
endpoints
[
0
]
=
api
.
Endpoints
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
endpoints
[
0
]
=
api
.
Endpoints
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Endpoints
:
[]
string
{
"endpoint:8"
,
"endpoint:9"
},
Endpoints
:
[]
string
{
"endpoint:8"
,
"endpoint:9"
},
}
}
loadBalancer
.
OnUpdate
(
endpoints
)
loadBalancer
.
OnUpdate
(
endpoints
)
...
@@ -142,7 +142,7 @@ func TestLoadBalanceWorksWithMultipleEndpointsAndUpdates(t *testing.T) {
...
@@ -142,7 +142,7 @@ func TestLoadBalanceWorksWithMultipleEndpointsAndUpdates(t *testing.T) {
expectEndpoint
(
t
,
loadBalancer
,
"foo"
,
"endpoint:8"
)
expectEndpoint
(
t
,
loadBalancer
,
"foo"
,
"endpoint:8"
)
expectEndpoint
(
t
,
loadBalancer
,
"foo"
,
"endpoint:9"
)
expectEndpoint
(
t
,
loadBalancer
,
"foo"
,
"endpoint:9"
)
// Clear endpoints
// Clear endpoints
endpoints
[
0
]
=
api
.
Endpoints
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
Endpoints
:
[]
string
{}}
endpoints
[
0
]
=
api
.
Endpoints
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Endpoints
:
[]
string
{}}
loadBalancer
.
OnUpdate
(
endpoints
)
loadBalancer
.
OnUpdate
(
endpoints
)
endpoint
,
err
=
loadBalancer
.
NextEndpoint
(
"foo"
,
nil
)
endpoint
,
err
=
loadBalancer
.
NextEndpoint
(
"foo"
,
nil
)
...
@@ -159,11 +159,11 @@ func TestLoadBalanceWorksWithServiceRemoval(t *testing.T) {
...
@@ -159,11 +159,11 @@ func TestLoadBalanceWorksWithServiceRemoval(t *testing.T) {
}
}
endpoints
:=
make
([]
api
.
Endpoints
,
2
)
endpoints
:=
make
([]
api
.
Endpoints
,
2
)
endpoints
[
0
]
=
api
.
Endpoints
{
endpoints
[
0
]
=
api
.
Endpoints
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Endpoints
:
[]
string
{
"endpoint:1"
,
"endpoint:2"
,
"endpoint:3"
},
Endpoints
:
[]
string
{
"endpoint:1"
,
"endpoint:2"
,
"endpoint:3"
},
}
}
endpoints
[
1
]
=
api
.
Endpoints
{
endpoints
[
1
]
=
api
.
Endpoints
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"bar"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"bar"
},
Endpoints
:
[]
string
{
"endpoint:4"
,
"endpoint:5"
},
Endpoints
:
[]
string
{
"endpoint:4"
,
"endpoint:5"
},
}
}
loadBalancer
.
OnUpdate
(
endpoints
)
loadBalancer
.
OnUpdate
(
endpoints
)
...
...
pkg/registry/controller/rest_test.go
View file @
644eb700
...
@@ -51,7 +51,7 @@ func TestListControllersError(t *testing.T) {
...
@@ -51,7 +51,7 @@ func TestListControllersError(t *testing.T) {
}
}
func
TestListEmptyControllerList
(
t
*
testing
.
T
)
{
func
TestListEmptyControllerList
(
t
*
testing
.
T
)
{
mockRegistry
:=
registrytest
.
ControllerRegistry
{
nil
,
&
api
.
ReplicationControllerList
{
TypeMeta
:
api
.
Type
Meta
{
ResourceVersion
:
"1"
}}}
mockRegistry
:=
registrytest
.
ControllerRegistry
{
nil
,
&
api
.
ReplicationControllerList
{
ListMeta
:
api
.
List
Meta
{
ResourceVersion
:
"1"
}}}
storage
:=
REST
{
storage
:=
REST
{
registry
:
&
mockRegistry
,
registry
:
&
mockRegistry
,
}
}
...
@@ -74,12 +74,12 @@ func TestListControllerList(t *testing.T) {
...
@@ -74,12 +74,12 @@ func TestListControllerList(t *testing.T) {
Controllers
:
&
api
.
ReplicationControllerList
{
Controllers
:
&
api
.
ReplicationControllerList
{
Items
:
[]
api
.
ReplicationController
{
Items
:
[]
api
.
ReplicationController
{
{
{
TypeMeta
:
api
.
Type
Meta
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
,
Name
:
"foo"
,
},
},
},
},
{
{
TypeMeta
:
api
.
Type
Meta
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"bar"
,
Name
:
"bar"
,
},
},
},
},
...
@@ -113,7 +113,7 @@ func TestControllerDecode(t *testing.T) {
...
@@ -113,7 +113,7 @@ func TestControllerDecode(t *testing.T) {
registry
:
&
mockRegistry
,
registry
:
&
mockRegistry
,
}
}
controller
:=
&
api
.
ReplicationController
{
controller
:=
&
api
.
ReplicationController
{
TypeMeta
:
api
.
Type
Meta
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
,
Name
:
"foo"
,
},
},
}
}
...
@@ -134,8 +134,11 @@ func TestControllerDecode(t *testing.T) {
...
@@ -134,8 +134,11 @@ func TestControllerDecode(t *testing.T) {
func
TestControllerParsing
(
t
*
testing
.
T
)
{
func
TestControllerParsing
(
t
*
testing
.
T
)
{
expectedController
:=
api
.
ReplicationController
{
expectedController
:=
api
.
ReplicationController
{
TypeMeta
:
api
.
Type
Meta
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"nginxController"
,
Name
:
"nginxController"
,
Labels
:
map
[
string
]
string
{
"name"
:
"nginx"
,
},
},
},
DesiredState
:
api
.
ReplicationControllerState
{
DesiredState
:
api
.
ReplicationControllerState
{
Replicas
:
2
,
Replicas
:
2
,
...
@@ -163,9 +166,6 @@ func TestControllerParsing(t *testing.T) {
...
@@ -163,9 +166,6 @@ func TestControllerParsing(t *testing.T) {
},
},
},
},
},
},
Labels
:
map
[
string
]
string
{
"name"
:
"nginx"
,
},
}
}
file
,
err
:=
ioutil
.
TempFile
(
""
,
"controller"
)
file
,
err
:=
ioutil
.
TempFile
(
""
,
"controller"
)
fileName
:=
file
.
Name
()
fileName
:=
file
.
Name
()
...
@@ -225,11 +225,13 @@ func TestCreateController(t *testing.T) {
...
@@ -225,11 +225,13 @@ func TestCreateController(t *testing.T) {
Pods
:
&
api
.
PodList
{
Pods
:
&
api
.
PodList
{
Items
:
[]
api
.
Pod
{
Items
:
[]
api
.
Pod
{
{
{
TypeMeta
:
api
.
TypeMeta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
,
Labels
:
map
[
string
]
string
{
"a"
:
"b"
},
Labels
:
map
[
string
]
string
{
"a"
:
"b"
},
},
},
},
},
},
},
},
}
}
storage
:=
REST
{
storage
:=
REST
{
registry
:
&
mockRegistry
,
registry
:
&
mockRegistry
,
...
@@ -237,7 +239,7 @@ func TestCreateController(t *testing.T) {
...
@@ -237,7 +239,7 @@ func TestCreateController(t *testing.T) {
pollPeriod
:
time
.
Millisecond
*
1
,
pollPeriod
:
time
.
Millisecond
*
1
,
}
}
controller
:=
&
api
.
ReplicationController
{
controller
:=
&
api
.
ReplicationController
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"test"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"test"
},
DesiredState
:
api
.
ReplicationControllerState
{
DesiredState
:
api
.
ReplicationControllerState
{
Replicas
:
2
,
Replicas
:
2
,
ReplicaSelector
:
map
[
string
]
string
{
"a"
:
"b"
},
ReplicaSelector
:
map
[
string
]
string
{
"a"
:
"b"
},
...
@@ -270,13 +272,13 @@ func TestControllerStorageValidatesCreate(t *testing.T) {
...
@@ -270,13 +272,13 @@ func TestControllerStorageValidatesCreate(t *testing.T) {
}
}
failureCases
:=
map
[
string
]
api
.
ReplicationController
{
failureCases
:=
map
[
string
]
api
.
ReplicationController
{
"empty ID"
:
{
"empty ID"
:
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
""
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
""
},
DesiredState
:
api
.
ReplicationControllerState
{
DesiredState
:
api
.
ReplicationControllerState
{
ReplicaSelector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
ReplicaSelector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
},
},
},
},
"empty selector"
:
{
"empty selector"
:
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"abc"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"abc"
},
DesiredState
:
api
.
ReplicationControllerState
{},
DesiredState
:
api
.
ReplicationControllerState
{},
},
},
}
}
...
@@ -301,13 +303,13 @@ func TestControllerStorageValidatesUpdate(t *testing.T) {
...
@@ -301,13 +303,13 @@ func TestControllerStorageValidatesUpdate(t *testing.T) {
}
}
failureCases
:=
map
[
string
]
api
.
ReplicationController
{
failureCases
:=
map
[
string
]
api
.
ReplicationController
{
"empty ID"
:
{
"empty ID"
:
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
""
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
""
},
DesiredState
:
api
.
ReplicationControllerState
{
DesiredState
:
api
.
ReplicationControllerState
{
ReplicaSelector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
ReplicaSelector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
},
},
},
},
"empty selector"
:
{
"empty selector"
:
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"abc"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"abc"
},
DesiredState
:
api
.
ReplicationControllerState
{},
DesiredState
:
api
.
ReplicationControllerState
{},
},
},
}
}
...
@@ -338,8 +340,8 @@ func TestFillCurrentState(t *testing.T) {
...
@@ -338,8 +340,8 @@ func TestFillCurrentState(t *testing.T) {
fakeLister
:=
fakePodLister
{
fakeLister
:=
fakePodLister
{
l
:
api
.
PodList
{
l
:
api
.
PodList
{
Items
:
[]
api
.
Pod
{
Items
:
[]
api
.
Pod
{
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
}},
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
}},
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"bar"
}},
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"bar"
}},
},
},
},
},
}
}
...
@@ -368,7 +370,7 @@ func TestFillCurrentState(t *testing.T) {
...
@@ -368,7 +370,7 @@ func TestFillCurrentState(t *testing.T) {
func
TestCreateControllerWithConflictingNamespace
(
t
*
testing
.
T
)
{
func
TestCreateControllerWithConflictingNamespace
(
t
*
testing
.
T
)
{
storage
:=
REST
{}
storage
:=
REST
{}
controller
:=
&
api
.
ReplicationController
{
controller
:=
&
api
.
ReplicationController
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"test"
,
Namespace
:
"not-default"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"test"
,
Namespace
:
"not-default"
},
}
}
ctx
:=
api
.
NewDefaultContext
()
ctx
:=
api
.
NewDefaultContext
()
...
@@ -386,7 +388,7 @@ func TestCreateControllerWithConflictingNamespace(t *testing.T) {
...
@@ -386,7 +388,7 @@ func TestCreateControllerWithConflictingNamespace(t *testing.T) {
func
TestUpdateControllerWithConflictingNamespace
(
t
*
testing
.
T
)
{
func
TestUpdateControllerWithConflictingNamespace
(
t
*
testing
.
T
)
{
storage
:=
REST
{}
storage
:=
REST
{}
controller
:=
&
api
.
ReplicationController
{
controller
:=
&
api
.
ReplicationController
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"test"
,
Namespace
:
"not-default"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"test"
,
Namespace
:
"not-default"
},
}
}
ctx
:=
api
.
NewDefaultContext
()
ctx
:=
api
.
NewDefaultContext
()
...
...
pkg/registry/endpoint/rest_test.go
View file @
644eb700
...
@@ -29,7 +29,7 @@ import (
...
@@ -29,7 +29,7 @@ import (
func
TestGetEndpoints
(
t
*
testing
.
T
)
{
func
TestGetEndpoints
(
t
*
testing
.
T
)
{
registry
:=
&
registrytest
.
ServiceRegistry
{
registry
:=
&
registrytest
.
ServiceRegistry
{
Endpoints
:
api
.
Endpoints
{
Endpoints
:
api
.
Endpoints
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Endpoints
:
[]
string
{
"127.0.0.1:9000"
},
Endpoints
:
[]
string
{
"127.0.0.1:9000"
},
},
},
}
}
...
@@ -59,7 +59,7 @@ func TestGetEndpointsMissingService(t *testing.T) {
...
@@ -59,7 +59,7 @@ func TestGetEndpointsMissingService(t *testing.T) {
// returns empty endpoints
// returns empty endpoints
registry
.
Err
=
nil
registry
.
Err
=
nil
registry
.
Service
=
&
api
.
Service
{
registry
.
Service
=
&
api
.
Service
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
}
}
obj
,
err
:=
storage
.
Get
(
ctx
,
"foo"
)
obj
,
err
:=
storage
.
Get
(
ctx
,
"foo"
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -74,10 +74,10 @@ func TestEndpointsRegistryList(t *testing.T) {
...
@@ -74,10 +74,10 @@ func TestEndpointsRegistryList(t *testing.T) {
registry
:=
registrytest
.
NewServiceRegistry
()
registry
:=
registrytest
.
NewServiceRegistry
()
storage
:=
NewREST
(
registry
)
storage
:=
NewREST
(
registry
)
registry
.
EndpointsList
=
api
.
EndpointsList
{
registry
.
EndpointsList
=
api
.
EndpointsList
{
TypeMeta
:
api
.
Type
Meta
{
ResourceVersion
:
"1"
},
ListMeta
:
api
.
List
Meta
{
ResourceVersion
:
"1"
},
Items
:
[]
api
.
Endpoints
{
Items
:
[]
api
.
Endpoints
{
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
}},
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
}},
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"bar"
}},
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"bar"
}},
},
},
}
}
ctx
:=
api
.
NewContext
()
ctx
:=
api
.
NewContext
()
...
...
pkg/registry/etcd/etcd_test.go
View file @
644eb700
This diff is collapsed.
Click to expand it.
pkg/registry/event/registry_test.go
View file @
644eb700
...
@@ -42,11 +42,11 @@ func NewTestEventEtcdRegistry(t *testing.T) (*tools.FakeEtcdClient, generic.Regi
...
@@ -42,11 +42,11 @@ func NewTestEventEtcdRegistry(t *testing.T) (*tools.FakeEtcdClient, generic.Regi
func
TestEventCreate
(
t
*
testing
.
T
)
{
func
TestEventCreate
(
t
*
testing
.
T
)
{
eventA
:=
&
api
.
Event
{
eventA
:=
&
api
.
Event
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Reason
:
"forTesting"
,
Reason
:
"forTesting"
,
}
}
eventB
:=
&
api
.
Event
{
eventB
:=
&
api
.
Event
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Reason
:
"forTesting"
,
Reason
:
"forTesting"
,
}
}
...
...
pkg/registry/event/rest_test.go
View file @
644eb700
...
@@ -40,7 +40,7 @@ func NewTestREST() (testRegistry, *REST) {
...
@@ -40,7 +40,7 @@ func NewTestREST() (testRegistry, *REST) {
func
TestRESTCreate
(
t
*
testing
.
T
)
{
func
TestRESTCreate
(
t
*
testing
.
T
)
{
_
,
rest
:=
NewTestREST
()
_
,
rest
:=
NewTestREST
()
eventA
:=
&
api
.
Event
{
eventA
:=
&
api
.
Event
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Reason
:
"forTesting"
,
Reason
:
"forTesting"
,
}
}
c
,
err
:=
rest
.
Create
(
api
.
NewContext
(),
eventA
)
c
,
err
:=
rest
.
Create
(
api
.
NewContext
(),
eventA
)
...
@@ -55,7 +55,7 @@ func TestRESTCreate(t *testing.T) {
...
@@ -55,7 +55,7 @@ func TestRESTCreate(t *testing.T) {
func
TestRESTDelete
(
t
*
testing
.
T
)
{
func
TestRESTDelete
(
t
*
testing
.
T
)
{
_
,
rest
:=
NewTestREST
()
_
,
rest
:=
NewTestREST
()
eventA
:=
&
api
.
Event
{
eventA
:=
&
api
.
Event
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Reason
:
"forTesting"
,
Reason
:
"forTesting"
,
}
}
c
,
err
:=
rest
.
Create
(
api
.
NewContext
(),
eventA
)
c
,
err
:=
rest
.
Create
(
api
.
NewContext
(),
eventA
)
...
@@ -75,7 +75,7 @@ func TestRESTDelete(t *testing.T) {
...
@@ -75,7 +75,7 @@ func TestRESTDelete(t *testing.T) {
func
TestRESTGet
(
t
*
testing
.
T
)
{
func
TestRESTGet
(
t
*
testing
.
T
)
{
_
,
rest
:=
NewTestREST
()
_
,
rest
:=
NewTestREST
()
eventA
:=
&
api
.
Event
{
eventA
:=
&
api
.
Event
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Reason
:
"forTesting"
,
Reason
:
"forTesting"
,
}
}
c
,
err
:=
rest
.
Create
(
api
.
NewContext
(),
eventA
)
c
,
err
:=
rest
.
Create
(
api
.
NewContext
(),
eventA
)
...
@@ -131,7 +131,7 @@ func TestRESTgetAttrs(t *testing.T) {
...
@@ -131,7 +131,7 @@ func TestRESTgetAttrs(t *testing.T) {
func
TestRESTUpdate
(
t
*
testing
.
T
)
{
func
TestRESTUpdate
(
t
*
testing
.
T
)
{
_
,
rest
:=
NewTestREST
()
_
,
rest
:=
NewTestREST
()
eventA
:=
&
api
.
Event
{
eventA
:=
&
api
.
Event
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Reason
:
"forTesting"
,
Reason
:
"forTesting"
,
}
}
c
,
err
:=
rest
.
Create
(
api
.
NewContext
(),
eventA
)
c
,
err
:=
rest
.
Create
(
api
.
NewContext
(),
eventA
)
...
...
pkg/registry/generic/etcd/etcd_test.go
View file @
644eb700
...
@@ -72,11 +72,11 @@ func (EverythingMatcher) Matches(obj runtime.Object) (bool, error) {
...
@@ -72,11 +72,11 @@ func (EverythingMatcher) Matches(obj runtime.Object) (bool, error) {
func
TestEtcdList
(
t
*
testing
.
T
)
{
func
TestEtcdList
(
t
*
testing
.
T
)
{
podA
:=
&
api
.
Pod
{
podA
:=
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
DesiredState
:
api
.
PodState
{
Host
:
"machine"
},
DesiredState
:
api
.
PodState
{
Host
:
"machine"
},
}
}
podB
:=
&
api
.
Pod
{
podB
:=
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"bar"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"bar"
},
DesiredState
:
api
.
PodState
{
Host
:
"machine"
},
DesiredState
:
api
.
PodState
{
Host
:
"machine"
},
}
}
...
@@ -154,11 +154,11 @@ func TestEtcdList(t *testing.T) {
...
@@ -154,11 +154,11 @@ func TestEtcdList(t *testing.T) {
func
TestEtcdCreate
(
t
*
testing
.
T
)
{
func
TestEtcdCreate
(
t
*
testing
.
T
)
{
podA
:=
&
api
.
Pod
{
podA
:=
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
DesiredState
:
api
.
PodState
{
Host
:
"machine"
},
DesiredState
:
api
.
PodState
{
Host
:
"machine"
},
}
}
podB
:=
&
api
.
Pod
{
podB
:=
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
DesiredState
:
api
.
PodState
{
Host
:
"machine2"
},
DesiredState
:
api
.
PodState
{
Host
:
"machine2"
},
}
}
...
@@ -217,11 +217,11 @@ func TestEtcdCreate(t *testing.T) {
...
@@ -217,11 +217,11 @@ func TestEtcdCreate(t *testing.T) {
func
TestEtcdUpdate
(
t
*
testing
.
T
)
{
func
TestEtcdUpdate
(
t
*
testing
.
T
)
{
podA
:=
&
api
.
Pod
{
podA
:=
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
DesiredState
:
api
.
PodState
{
Host
:
"machine"
},
DesiredState
:
api
.
PodState
{
Host
:
"machine"
},
}
}
podB
:=
&
api
.
Pod
{
podB
:=
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
,
ResourceVersion
:
"1"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
,
ResourceVersion
:
"1"
},
DesiredState
:
api
.
PodState
{
Host
:
"machine2"
},
DesiredState
:
api
.
PodState
{
Host
:
"machine2"
},
}
}
...
@@ -292,7 +292,7 @@ func TestEtcdUpdate(t *testing.T) {
...
@@ -292,7 +292,7 @@ func TestEtcdUpdate(t *testing.T) {
func
TestEtcdGet
(
t
*
testing
.
T
)
{
func
TestEtcdGet
(
t
*
testing
.
T
)
{
podA
:=
&
api
.
Pod
{
podA
:=
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
,
ResourceVersion
:
"1"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
,
ResourceVersion
:
"1"
},
DesiredState
:
api
.
PodState
{
Host
:
"machine"
},
DesiredState
:
api
.
PodState
{
Host
:
"machine"
},
}
}
...
@@ -348,7 +348,7 @@ func TestEtcdGet(t *testing.T) {
...
@@ -348,7 +348,7 @@ func TestEtcdGet(t *testing.T) {
func
TestEtcdDelete
(
t
*
testing
.
T
)
{
func
TestEtcdDelete
(
t
*
testing
.
T
)
{
podA
:=
&
api
.
Pod
{
podA
:=
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
,
ResourceVersion
:
"1"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
,
ResourceVersion
:
"1"
},
DesiredState
:
api
.
PodState
{
Host
:
"machine"
},
DesiredState
:
api
.
PodState
{
Host
:
"machine"
},
}
}
...
@@ -404,7 +404,7 @@ func TestEtcdDelete(t *testing.T) {
...
@@ -404,7 +404,7 @@ func TestEtcdDelete(t *testing.T) {
func
TestEtcdWatch
(
t
*
testing
.
T
)
{
func
TestEtcdWatch
(
t
*
testing
.
T
)
{
podA
:=
&
api
.
Pod
{
podA
:=
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
,
ResourceVersion
:
"1"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
,
ResourceVersion
:
"1"
},
DesiredState
:
api
.
PodState
{
Host
:
"machine"
},
DesiredState
:
api
.
PodState
{
Host
:
"machine"
},
}
}
respWithPodA
:=
&
etcd
.
Response
{
respWithPodA
:=
&
etcd
.
Response
{
...
...
pkg/registry/minion/healthy_registry_test.go
View file @
644eb700
...
@@ -46,7 +46,7 @@ func TestBasicDelegation(t *testing.T) {
...
@@ -46,7 +46,7 @@ func TestBasicDelegation(t *testing.T) {
t
.
Errorf
(
"Expected %v, Got %v"
,
mockMinionRegistry
.
Minions
,
list
)
t
.
Errorf
(
"Expected %v, Got %v"
,
mockMinionRegistry
.
Minions
,
list
)
}
}
err
=
healthy
.
CreateMinion
(
ctx
,
&
api
.
Minion
{
err
=
healthy
.
CreateMinion
(
ctx
,
&
api
.
Minion
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
})
})
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %v"
,
err
)
t
.
Errorf
(
"unexpected error: %v"
,
err
)
...
...
pkg/registry/minion/rest_test.go
View file @
644eb700
...
@@ -37,7 +37,7 @@ func TestMinionREST(t *testing.T) {
...
@@ -37,7 +37,7 @@ func TestMinionREST(t *testing.T) {
t
.
Errorf
(
"has unexpected object"
)
t
.
Errorf
(
"has unexpected object"
)
}
}
c
,
err
:=
ms
.
Create
(
ctx
,
&
api
.
Minion
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"baz"
}})
c
,
err
:=
ms
.
Create
(
ctx
,
&
api
.
Minion
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"baz"
}})
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"insert failed"
)
t
.
Errorf
(
"insert failed"
)
}
}
...
@@ -72,9 +72,9 @@ func TestMinionREST(t *testing.T) {
...
@@ -72,9 +72,9 @@ func TestMinionREST(t *testing.T) {
}
}
expect
:=
[]
api
.
Minion
{
expect
:=
[]
api
.
Minion
{
{
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
},
{
},
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"baz"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"baz"
},
},
},
}
}
nodeList
:=
list
.
(
*
api
.
MinionList
)
nodeList
:=
list
.
(
*
api
.
MinionList
)
...
...
pkg/registry/pod/bound_pod_factory_test.go
View file @
644eb700
...
@@ -32,7 +32,7 @@ func TestMakeBoundPodNoServices(t *testing.T) {
...
@@ -32,7 +32,7 @@ func TestMakeBoundPodNoServices(t *testing.T) {
}
}
pod
,
err
:=
factory
.
MakeBoundPod
(
"machine"
,
&
api
.
Pod
{
pod
,
err
:=
factory
.
MakeBoundPod
(
"machine"
,
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foobar"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foobar"
},
DesiredState
:
api
.
PodState
{
DesiredState
:
api
.
PodState
{
Manifest
:
api
.
ContainerManifest
{
Manifest
:
api
.
ContainerManifest
{
Containers
:
[]
api
.
Container
{
Containers
:
[]
api
.
Container
{
...
@@ -61,7 +61,7 @@ func TestMakeBoundPodServices(t *testing.T) {
...
@@ -61,7 +61,7 @@ func TestMakeBoundPodServices(t *testing.T) {
List
:
api
.
ServiceList
{
List
:
api
.
ServiceList
{
Items
:
[]
api
.
Service
{
Items
:
[]
api
.
Service
{
{
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"test"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"test"
},
Port
:
8080
,
Port
:
8080
,
ContainerPort
:
util
.
IntOrString
{
ContainerPort
:
util
.
IntOrString
{
Kind
:
util
.
IntstrInt
,
Kind
:
util
.
IntstrInt
,
...
@@ -137,7 +137,7 @@ func TestMakeBoundPodServicesExistingEnvVar(t *testing.T) {
...
@@ -137,7 +137,7 @@ func TestMakeBoundPodServicesExistingEnvVar(t *testing.T) {
List
:
api
.
ServiceList
{
List
:
api
.
ServiceList
{
Items
:
[]
api
.
Service
{
Items
:
[]
api
.
Service
{
{
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"test"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"test"
},
Port
:
8080
,
Port
:
8080
,
ContainerPort
:
util
.
IntOrString
{
ContainerPort
:
util
.
IntOrString
{
Kind
:
util
.
IntstrInt
,
Kind
:
util
.
IntstrInt
,
...
...
pkg/registry/pod/rest_test.go
View file @
644eb700
...
@@ -144,7 +144,7 @@ func TestListPodsError(t *testing.T) {
...
@@ -144,7 +144,7 @@ func TestListPodsError(t *testing.T) {
}
}
func
TestListEmptyPodList
(
t
*
testing
.
T
)
{
func
TestListEmptyPodList
(
t
*
testing
.
T
)
{
podRegistry
:=
registrytest
.
NewPodRegistry
(
&
api
.
PodList
{
TypeMeta
:
api
.
Type
Meta
{
ResourceVersion
:
"1"
}})
podRegistry
:=
registrytest
.
NewPodRegistry
(
&
api
.
PodList
{
ListMeta
:
api
.
List
Meta
{
ResourceVersion
:
"1"
}})
storage
:=
REST
{
storage
:=
REST
{
registry
:
podRegistry
,
registry
:
podRegistry
,
}
}
...
@@ -175,12 +175,12 @@ func TestListPodList(t *testing.T) {
...
@@ -175,12 +175,12 @@ func TestListPodList(t *testing.T) {
podRegistry
.
Pods
=
&
api
.
PodList
{
podRegistry
.
Pods
=
&
api
.
PodList
{
Items
:
[]
api
.
Pod
{
Items
:
[]
api
.
Pod
{
{
{
TypeMeta
:
api
.
Type
Meta
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
,
Name
:
"foo"
,
},
},
},
},
{
{
TypeMeta
:
api
.
Type
Meta
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"bar"
,
Name
:
"bar"
,
},
},
},
},
...
@@ -214,18 +214,20 @@ func TestListPodListSelection(t *testing.T) {
...
@@ -214,18 +214,20 @@ func TestListPodListSelection(t *testing.T) {
podRegistry
.
Pods
=
&
api
.
PodList
{
podRegistry
.
Pods
=
&
api
.
PodList
{
Items
:
[]
api
.
Pod
{
Items
:
[]
api
.
Pod
{
{
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
},
{
},
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"bar"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"bar"
},
DesiredState
:
api
.
PodState
{
Host
:
"barhost"
},
DesiredState
:
api
.
PodState
{
Host
:
"barhost"
},
},
{
},
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"baz"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"baz"
},
DesiredState
:
api
.
PodState
{
Status
:
"bazstatus"
},
DesiredState
:
api
.
PodState
{
Status
:
"bazstatus"
},
},
{
},
{
TypeMeta
:
api
.
TypeMeta
{
Name
:
"qux"
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"qux"
,
Labels
:
map
[
string
]
string
{
"label"
:
"qux"
},
Labels
:
map
[
string
]
string
{
"label"
:
"qux"
},
},
},
{
},
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"zot"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"zot"
},
},
},
},
},
}
}
...
@@ -298,7 +300,7 @@ func TestPodDecode(t *testing.T) {
...
@@ -298,7 +300,7 @@ func TestPodDecode(t *testing.T) {
registry
:
podRegistry
,
registry
:
podRegistry
,
}
}
expected
:=
&
api
.
Pod
{
expected
:=
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
,
Name
:
"foo"
,
},
},
}
}
...
@@ -319,7 +321,7 @@ func TestPodDecode(t *testing.T) {
...
@@ -319,7 +321,7 @@ func TestPodDecode(t *testing.T) {
func
TestGetPod
(
t
*
testing
.
T
)
{
func
TestGetPod
(
t
*
testing
.
T
)
{
podRegistry
:=
registrytest
.
NewPodRegistry
(
nil
)
podRegistry
:=
registrytest
.
NewPodRegistry
(
nil
)
podRegistry
.
Pod
=
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
}}
podRegistry
.
Pod
=
&
api
.
Pod
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
}}
storage
:=
REST
{
storage
:=
REST
{
registry
:
podRegistry
,
registry
:
podRegistry
,
ipCache
:
ipCache
{},
ipCache
:
ipCache
{},
...
@@ -340,7 +342,7 @@ func TestGetPod(t *testing.T) {
...
@@ -340,7 +342,7 @@ func TestGetPod(t *testing.T) {
func
TestGetPodCloud
(
t
*
testing
.
T
)
{
func
TestGetPodCloud
(
t
*
testing
.
T
)
{
fakeCloud
:=
&
fake_cloud
.
FakeCloud
{}
fakeCloud
:=
&
fake_cloud
.
FakeCloud
{}
podRegistry
:=
registrytest
.
NewPodRegistry
(
nil
)
podRegistry
:=
registrytest
.
NewPodRegistry
(
nil
)
podRegistry
.
Pod
=
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
CurrentState
:
api
.
PodState
{
Host
:
"machine"
}}
podRegistry
.
Pod
=
&
api
.
Pod
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
CurrentState
:
api
.
PodState
{
Host
:
"machine"
}}
clock
:=
&
fakeClock
{
t
:
time
.
Now
()}
clock
:=
&
fakeClock
{
t
:
time
.
Now
()}
...
@@ -386,7 +388,7 @@ func TestMakePodStatus(t *testing.T) {
...
@@ -386,7 +388,7 @@ func TestMakePodStatus(t *testing.T) {
Minions
:
api
.
MinionList
{
Minions
:
api
.
MinionList
{
Items
:
[]
api
.
Minion
{
Items
:
[]
api
.
Minion
{
{
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"machine"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"machine"
},
},
},
},
},
},
},
...
@@ -561,7 +563,7 @@ func TestPodStorageValidatesUpdate(t *testing.T) {
...
@@ -561,7 +563,7 @@ func TestPodStorageValidatesUpdate(t *testing.T) {
func
TestCreatePod
(
t
*
testing
.
T
)
{
func
TestCreatePod
(
t
*
testing
.
T
)
{
podRegistry
:=
registrytest
.
NewPodRegistry
(
nil
)
podRegistry
:=
registrytest
.
NewPodRegistry
(
nil
)
podRegistry
.
Pod
=
&
api
.
Pod
{
podRegistry
.
Pod
=
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
CurrentState
:
api
.
PodState
{
CurrentState
:
api
.
PodState
{
Host
:
"machine"
,
Host
:
"machine"
,
},
},
...
@@ -576,7 +578,7 @@ func TestCreatePod(t *testing.T) {
...
@@ -576,7 +578,7 @@ func TestCreatePod(t *testing.T) {
},
},
}
}
pod
:=
&
api
.
Pod
{
pod
:=
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
DesiredState
:
desiredState
,
DesiredState
:
desiredState
,
}
}
ctx
:=
api
.
NewDefaultContext
()
ctx
:=
api
.
NewDefaultContext
()
...
@@ -656,7 +658,7 @@ func TestFillPodInfoNoData(t *testing.T) {
...
@@ -656,7 +658,7 @@ func TestFillPodInfoNoData(t *testing.T) {
func
TestCreatePodWithConflictingNamespace
(
t
*
testing
.
T
)
{
func
TestCreatePodWithConflictingNamespace
(
t
*
testing
.
T
)
{
storage
:=
REST
{}
storage
:=
REST
{}
pod
:=
&
api
.
Pod
{
pod
:=
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"test"
,
Namespace
:
"not-default"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"test"
,
Namespace
:
"not-default"
},
}
}
ctx
:=
api
.
NewDefaultContext
()
ctx
:=
api
.
NewDefaultContext
()
...
@@ -674,7 +676,7 @@ func TestCreatePodWithConflictingNamespace(t *testing.T) {
...
@@ -674,7 +676,7 @@ func TestCreatePodWithConflictingNamespace(t *testing.T) {
func
TestUpdatePodWithConflictingNamespace
(
t
*
testing
.
T
)
{
func
TestUpdatePodWithConflictingNamespace
(
t
*
testing
.
T
)
{
storage
:=
REST
{}
storage
:=
REST
{}
pod
:=
&
api
.
Pod
{
pod
:=
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"test"
,
Namespace
:
"not-default"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"test"
,
Namespace
:
"not-default"
},
}
}
ctx
:=
api
.
NewDefaultContext
()
ctx
:=
api
.
NewDefaultContext
()
...
...
pkg/registry/service/rest_test.go
View file @
644eb700
...
@@ -46,7 +46,7 @@ func TestServiceRegistryCreate(t *testing.T) {
...
@@ -46,7 +46,7 @@ func TestServiceRegistryCreate(t *testing.T) {
storage
:=
NewREST
(
registry
,
fakeCloud
,
registrytest
.
NewMinionRegistry
(
machines
,
api
.
NodeResources
{}),
makeIPNet
(
t
))
storage
:=
NewREST
(
registry
,
fakeCloud
,
registrytest
.
NewMinionRegistry
(
machines
,
api
.
NodeResources
{}),
makeIPNet
(
t
))
svc
:=
&
api
.
Service
{
svc
:=
&
api
.
Service
{
Port
:
6502
,
Port
:
6502
,
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
}
}
ctx
:=
api
.
NewDefaultContext
()
ctx
:=
api
.
NewDefaultContext
()
...
@@ -83,11 +83,11 @@ func TestServiceStorageValidatesCreate(t *testing.T) {
...
@@ -83,11 +83,11 @@ func TestServiceStorageValidatesCreate(t *testing.T) {
failureCases
:=
map
[
string
]
api
.
Service
{
failureCases
:=
map
[
string
]
api
.
Service
{
"empty ID"
:
{
"empty ID"
:
{
Port
:
6502
,
Port
:
6502
,
TypeMeta
:
api
.
Type
Meta
{
Name
:
""
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
""
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
},
},
"empty selector"
:
{
"empty selector"
:
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Selector
:
map
[
string
]
string
{},
Selector
:
map
[
string
]
string
{},
},
},
}
}
...
@@ -109,13 +109,13 @@ func TestServiceRegistryUpdate(t *testing.T) {
...
@@ -109,13 +109,13 @@ func TestServiceRegistryUpdate(t *testing.T) {
registry
:=
registrytest
.
NewServiceRegistry
()
registry
:=
registrytest
.
NewServiceRegistry
()
registry
.
CreateService
(
ctx
,
&
api
.
Service
{
registry
.
CreateService
(
ctx
,
&
api
.
Service
{
Port
:
6502
,
Port
:
6502
,
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz1"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz1"
},
})
})
storage
:=
NewREST
(
registry
,
nil
,
nil
,
makeIPNet
(
t
))
storage
:=
NewREST
(
registry
,
nil
,
nil
,
makeIPNet
(
t
))
c
,
err
:=
storage
.
Update
(
ctx
,
&
api
.
Service
{
c
,
err
:=
storage
.
Update
(
ctx
,
&
api
.
Service
{
Port
:
6502
,
Port
:
6502
,
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz2"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz2"
},
})
})
if
c
==
nil
{
if
c
==
nil
{
...
@@ -139,19 +139,19 @@ func TestServiceStorageValidatesUpdate(t *testing.T) {
...
@@ -139,19 +139,19 @@ func TestServiceStorageValidatesUpdate(t *testing.T) {
registry
:=
registrytest
.
NewServiceRegistry
()
registry
:=
registrytest
.
NewServiceRegistry
()
registry
.
CreateService
(
ctx
,
&
api
.
Service
{
registry
.
CreateService
(
ctx
,
&
api
.
Service
{
Port
:
6502
,
Port
:
6502
,
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
})
})
storage
:=
NewREST
(
registry
,
nil
,
nil
,
makeIPNet
(
t
))
storage
:=
NewREST
(
registry
,
nil
,
nil
,
makeIPNet
(
t
))
failureCases
:=
map
[
string
]
api
.
Service
{
failureCases
:=
map
[
string
]
api
.
Service
{
"empty ID"
:
{
"empty ID"
:
{
Port
:
6502
,
Port
:
6502
,
TypeMeta
:
api
.
Type
Meta
{
Name
:
""
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
""
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
},
},
"empty selector"
:
{
"empty selector"
:
{
Port
:
6502
,
Port
:
6502
,
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Selector
:
map
[
string
]
string
{},
Selector
:
map
[
string
]
string
{},
},
},
}
}
...
@@ -174,7 +174,7 @@ func TestServiceRegistryExternalService(t *testing.T) {
...
@@ -174,7 +174,7 @@ func TestServiceRegistryExternalService(t *testing.T) {
storage
:=
NewREST
(
registry
,
fakeCloud
,
registrytest
.
NewMinionRegistry
(
machines
,
api
.
NodeResources
{}),
makeIPNet
(
t
))
storage
:=
NewREST
(
registry
,
fakeCloud
,
registrytest
.
NewMinionRegistry
(
machines
,
api
.
NodeResources
{}),
makeIPNet
(
t
))
svc
:=
&
api
.
Service
{
svc
:=
&
api
.
Service
{
Port
:
6502
,
Port
:
6502
,
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
CreateExternalLoadBalancer
:
true
,
CreateExternalLoadBalancer
:
true
,
}
}
...
@@ -201,7 +201,7 @@ func TestServiceRegistryExternalServiceError(t *testing.T) {
...
@@ -201,7 +201,7 @@ func TestServiceRegistryExternalServiceError(t *testing.T) {
storage
:=
NewREST
(
registry
,
fakeCloud
,
registrytest
.
NewMinionRegistry
(
machines
,
api
.
NodeResources
{}),
makeIPNet
(
t
))
storage
:=
NewREST
(
registry
,
fakeCloud
,
registrytest
.
NewMinionRegistry
(
machines
,
api
.
NodeResources
{}),
makeIPNet
(
t
))
svc
:=
&
api
.
Service
{
svc
:=
&
api
.
Service
{
Port
:
6502
,
Port
:
6502
,
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
CreateExternalLoadBalancer
:
true
,
CreateExternalLoadBalancer
:
true
,
}
}
...
@@ -223,7 +223,7 @@ func TestServiceRegistryDelete(t *testing.T) {
...
@@ -223,7 +223,7 @@ func TestServiceRegistryDelete(t *testing.T) {
machines
:=
[]
string
{
"foo"
,
"bar"
,
"baz"
}
machines
:=
[]
string
{
"foo"
,
"bar"
,
"baz"
}
storage
:=
NewREST
(
registry
,
fakeCloud
,
registrytest
.
NewMinionRegistry
(
machines
,
api
.
NodeResources
{}),
makeIPNet
(
t
))
storage
:=
NewREST
(
registry
,
fakeCloud
,
registrytest
.
NewMinionRegistry
(
machines
,
api
.
NodeResources
{}),
makeIPNet
(
t
))
svc
:=
&
api
.
Service
{
svc
:=
&
api
.
Service
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
}
}
registry
.
CreateService
(
ctx
,
svc
)
registry
.
CreateService
(
ctx
,
svc
)
...
@@ -244,7 +244,7 @@ func TestServiceRegistryDeleteExternal(t *testing.T) {
...
@@ -244,7 +244,7 @@ func TestServiceRegistryDeleteExternal(t *testing.T) {
machines
:=
[]
string
{
"foo"
,
"bar"
,
"baz"
}
machines
:=
[]
string
{
"foo"
,
"bar"
,
"baz"
}
storage
:=
NewREST
(
registry
,
fakeCloud
,
registrytest
.
NewMinionRegistry
(
machines
,
api
.
NodeResources
{}),
makeIPNet
(
t
))
storage
:=
NewREST
(
registry
,
fakeCloud
,
registrytest
.
NewMinionRegistry
(
machines
,
api
.
NodeResources
{}),
makeIPNet
(
t
))
svc
:=
&
api
.
Service
{
svc
:=
&
api
.
Service
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
CreateExternalLoadBalancer
:
true
,
CreateExternalLoadBalancer
:
true
,
}
}
...
@@ -265,21 +265,21 @@ func TestServiceRegistryMakeLinkVariables(t *testing.T) {
...
@@ -265,21 +265,21 @@ func TestServiceRegistryMakeLinkVariables(t *testing.T) {
registry
.
List
=
api
.
ServiceList
{
registry
.
List
=
api
.
ServiceList
{
Items
:
[]
api
.
Service
{
Items
:
[]
api
.
Service
{
{
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo-bar"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo-bar"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
Port
:
8080
,
Port
:
8080
,
Protocol
:
"TCP"
,
Protocol
:
"TCP"
,
PortalIP
:
"1.2.3.4"
,
PortalIP
:
"1.2.3.4"
,
},
},
{
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"abc-123"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"abc-123"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
Port
:
8081
,
Port
:
8081
,
Protocol
:
"UDP"
,
Protocol
:
"UDP"
,
PortalIP
:
"5.6.7.8"
,
PortalIP
:
"5.6.7.8"
,
},
},
{
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"q-u-u-x"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"q-u-u-x"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
Port
:
8082
,
Port
:
8082
,
Protocol
:
""
,
Protocol
:
""
,
...
@@ -333,7 +333,7 @@ func TestServiceRegistryGet(t *testing.T) {
...
@@ -333,7 +333,7 @@ func TestServiceRegistryGet(t *testing.T) {
machines
:=
[]
string
{
"foo"
,
"bar"
,
"baz"
}
machines
:=
[]
string
{
"foo"
,
"bar"
,
"baz"
}
storage
:=
NewREST
(
registry
,
fakeCloud
,
registrytest
.
NewMinionRegistry
(
machines
,
api
.
NodeResources
{}),
makeIPNet
(
t
))
storage
:=
NewREST
(
registry
,
fakeCloud
,
registrytest
.
NewMinionRegistry
(
machines
,
api
.
NodeResources
{}),
makeIPNet
(
t
))
registry
.
CreateService
(
ctx
,
&
api
.
Service
{
registry
.
CreateService
(
ctx
,
&
api
.
Service
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
})
})
storage
.
Get
(
ctx
,
"foo"
)
storage
.
Get
(
ctx
,
"foo"
)
...
@@ -353,7 +353,7 @@ func TestServiceRegistryResourceLocation(t *testing.T) {
...
@@ -353,7 +353,7 @@ func TestServiceRegistryResourceLocation(t *testing.T) {
machines
:=
[]
string
{
"foo"
,
"bar"
,
"baz"
}
machines
:=
[]
string
{
"foo"
,
"bar"
,
"baz"
}
storage
:=
NewREST
(
registry
,
fakeCloud
,
registrytest
.
NewMinionRegistry
(
machines
,
api
.
NodeResources
{}),
makeIPNet
(
t
))
storage
:=
NewREST
(
registry
,
fakeCloud
,
registrytest
.
NewMinionRegistry
(
machines
,
api
.
NodeResources
{}),
makeIPNet
(
t
))
registry
.
CreateService
(
ctx
,
&
api
.
Service
{
registry
.
CreateService
(
ctx
,
&
api
.
Service
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
})
})
redirector
:=
apiserver
.
Redirector
(
storage
)
redirector
:=
apiserver
.
Redirector
(
storage
)
...
@@ -382,11 +382,11 @@ func TestServiceRegistryList(t *testing.T) {
...
@@ -382,11 +382,11 @@ func TestServiceRegistryList(t *testing.T) {
machines
:=
[]
string
{
"foo"
,
"bar"
,
"baz"
}
machines
:=
[]
string
{
"foo"
,
"bar"
,
"baz"
}
storage
:=
NewREST
(
registry
,
fakeCloud
,
registrytest
.
NewMinionRegistry
(
machines
,
api
.
NodeResources
{}),
makeIPNet
(
t
))
storage
:=
NewREST
(
registry
,
fakeCloud
,
registrytest
.
NewMinionRegistry
(
machines
,
api
.
NodeResources
{}),
makeIPNet
(
t
))
registry
.
CreateService
(
ctx
,
&
api
.
Service
{
registry
.
CreateService
(
ctx
,
&
api
.
Service
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
})
})
registry
.
CreateService
(
ctx
,
&
api
.
Service
{
registry
.
CreateService
(
ctx
,
&
api
.
Service
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo2"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo2"
},
Selector
:
map
[
string
]
string
{
"bar2"
:
"baz2"
},
Selector
:
map
[
string
]
string
{
"bar2"
:
"baz2"
},
})
})
registry
.
List
.
ResourceVersion
=
"1"
registry
.
List
.
ResourceVersion
=
"1"
...
@@ -417,7 +417,7 @@ func TestServiceRegistryIPAllocation(t *testing.T) {
...
@@ -417,7 +417,7 @@ func TestServiceRegistryIPAllocation(t *testing.T) {
svc1
:=
&
api
.
Service
{
svc1
:=
&
api
.
Service
{
Port
:
6502
,
Port
:
6502
,
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
}
}
ctx
:=
api
.
NewDefaultContext
()
ctx
:=
api
.
NewDefaultContext
()
...
@@ -433,7 +433,7 @@ func TestServiceRegistryIPAllocation(t *testing.T) {
...
@@ -433,7 +433,7 @@ func TestServiceRegistryIPAllocation(t *testing.T) {
svc2
:=
&
api
.
Service
{
svc2
:=
&
api
.
Service
{
Port
:
6502
,
Port
:
6502
,
TypeMeta
:
api
.
Type
Meta
{
Name
:
"bar"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"bar"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
}
}
ctx
=
api
.
NewDefaultContext
()
ctx
=
api
.
NewDefaultContext
()
...
@@ -456,7 +456,7 @@ func TestServiceRegistryIPReallocation(t *testing.T) {
...
@@ -456,7 +456,7 @@ func TestServiceRegistryIPReallocation(t *testing.T) {
svc1
:=
&
api
.
Service
{
svc1
:=
&
api
.
Service
{
Port
:
6502
,
Port
:
6502
,
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
}
}
ctx
:=
api
.
NewDefaultContext
()
ctx
:=
api
.
NewDefaultContext
()
...
@@ -475,7 +475,7 @@ func TestServiceRegistryIPReallocation(t *testing.T) {
...
@@ -475,7 +475,7 @@ func TestServiceRegistryIPReallocation(t *testing.T) {
svc2
:=
&
api
.
Service
{
svc2
:=
&
api
.
Service
{
Port
:
6502
,
Port
:
6502
,
TypeMeta
:
api
.
Type
Meta
{
Name
:
"bar"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"bar"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
}
}
ctx
=
api
.
NewDefaultContext
()
ctx
=
api
.
NewDefaultContext
()
...
@@ -498,7 +498,7 @@ func TestServiceRegistryIPUpdate(t *testing.T) {
...
@@ -498,7 +498,7 @@ func TestServiceRegistryIPUpdate(t *testing.T) {
svc
:=
&
api
.
Service
{
svc
:=
&
api
.
Service
{
Port
:
6502
,
Port
:
6502
,
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
}
}
ctx
:=
api
.
NewDefaultContext
()
ctx
:=
api
.
NewDefaultContext
()
...
@@ -543,7 +543,7 @@ func TestServiceRegistryIPExternalLoadBalancer(t *testing.T) {
...
@@ -543,7 +543,7 @@ func TestServiceRegistryIPExternalLoadBalancer(t *testing.T) {
svc
:=
&
api
.
Service
{
svc
:=
&
api
.
Service
{
Port
:
6502
,
Port
:
6502
,
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
CreateExternalLoadBalancer
:
true
,
CreateExternalLoadBalancer
:
true
,
}
}
...
@@ -570,7 +570,7 @@ func TestServiceRegistryIPReloadFromStorage(t *testing.T) {
...
@@ -570,7 +570,7 @@ func TestServiceRegistryIPReloadFromStorage(t *testing.T) {
svc
:=
&
api
.
Service
{
svc
:=
&
api
.
Service
{
Port
:
6502
,
Port
:
6502
,
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
}
}
ctx
:=
api
.
NewDefaultContext
()
ctx
:=
api
.
NewDefaultContext
()
...
@@ -578,7 +578,7 @@ func TestServiceRegistryIPReloadFromStorage(t *testing.T) {
...
@@ -578,7 +578,7 @@ func TestServiceRegistryIPReloadFromStorage(t *testing.T) {
<-
c
<-
c
svc
=
&
api
.
Service
{
svc
=
&
api
.
Service
{
Port
:
6502
,
Port
:
6502
,
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
}
}
c
,
_
=
rest1
.
Create
(
ctx
,
svc
)
c
,
_
=
rest1
.
Create
(
ctx
,
svc
)
...
@@ -589,7 +589,7 @@ func TestServiceRegistryIPReloadFromStorage(t *testing.T) {
...
@@ -589,7 +589,7 @@ func TestServiceRegistryIPReloadFromStorage(t *testing.T) {
svc
=
&
api
.
Service
{
svc
=
&
api
.
Service
{
Port
:
6502
,
Port
:
6502
,
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
}
}
c
,
_
=
rest2
.
Create
(
ctx
,
svc
)
c
,
_
=
rest2
.
Create
(
ctx
,
svc
)
...
@@ -603,7 +603,7 @@ func TestServiceRegistryIPReloadFromStorage(t *testing.T) {
...
@@ -603,7 +603,7 @@ func TestServiceRegistryIPReloadFromStorage(t *testing.T) {
func
TestCreateServiceWithConflictingNamespace
(
t
*
testing
.
T
)
{
func
TestCreateServiceWithConflictingNamespace
(
t
*
testing
.
T
)
{
storage
:=
REST
{}
storage
:=
REST
{}
service
:=
&
api
.
Service
{
service
:=
&
api
.
Service
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"test"
,
Namespace
:
"not-default"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"test"
,
Namespace
:
"not-default"
},
}
}
ctx
:=
api
.
NewDefaultContext
()
ctx
:=
api
.
NewDefaultContext
()
...
@@ -621,7 +621,7 @@ func TestCreateServiceWithConflictingNamespace(t *testing.T) {
...
@@ -621,7 +621,7 @@ func TestCreateServiceWithConflictingNamespace(t *testing.T) {
func
TestUpdateServiceWithConflictingNamespace
(
t
*
testing
.
T
)
{
func
TestUpdateServiceWithConflictingNamespace
(
t
*
testing
.
T
)
{
storage
:=
REST
{}
storage
:=
REST
{}
service
:=
&
api
.
Service
{
service
:=
&
api
.
Service
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"test"
,
Namespace
:
"not-default"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"test"
,
Namespace
:
"not-default"
},
}
}
ctx
:=
api
.
NewDefaultContext
()
ctx
:=
api
.
NewDefaultContext
()
...
...
pkg/runtime/helper_test.go
View file @
644eb700
...
@@ -29,9 +29,9 @@ import (
...
@@ -29,9 +29,9 @@ import (
func
TestExtractList
(
t
*
testing
.
T
)
{
func
TestExtractList
(
t
*
testing
.
T
)
{
pl
:=
&
api
.
PodList
{
pl
:=
&
api
.
PodList
{
Items
:
[]
api
.
Pod
{
Items
:
[]
api
.
Pod
{
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"1"
}},
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"1"
}},
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"2"
}},
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"2"
}},
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"3"
}},
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"3"
}},
},
},
}
}
list
,
err
:=
runtime
.
ExtractList
(
pl
)
list
,
err
:=
runtime
.
ExtractList
(
pl
)
...
@@ -51,9 +51,9 @@ func TestExtractList(t *testing.T) {
...
@@ -51,9 +51,9 @@ func TestExtractList(t *testing.T) {
func
TestSetList
(
t
*
testing
.
T
)
{
func
TestSetList
(
t
*
testing
.
T
)
{
pl
:=
&
api
.
PodList
{}
pl
:=
&
api
.
PodList
{}
list
:=
[]
runtime
.
Object
{
list
:=
[]
runtime
.
Object
{
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"1"
}},
&
api
.
Pod
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"1"
}},
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"2"
}},
&
api
.
Pod
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"2"
}},
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"3"
}},
&
api
.
Pod
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"3"
}},
}
}
err
:=
runtime
.
SetList
(
pl
,
list
)
err
:=
runtime
.
SetList
(
pl
,
list
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
pkg/scheduler/generic_scheduler_test.go
View file @
644eb700
...
@@ -95,7 +95,7 @@ func TestGenericScheduler(t *testing.T) {
...
@@ -95,7 +95,7 @@ func TestGenericScheduler(t *testing.T) {
predicates
:
[]
FitPredicate
{
matchesPredicate
},
predicates
:
[]
FitPredicate
{
matchesPredicate
},
prioritizer
:
EqualPriority
,
prioritizer
:
EqualPriority
,
nodes
:
[]
string
{
"machine1"
,
"machine2"
},
nodes
:
[]
string
{
"machine1"
,
"machine2"
},
pod
:
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"machine2"
}},
pod
:
api
.
Pod
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"machine2"
}},
expectedHost
:
"machine2"
,
expectedHost
:
"machine2"
,
},
},
{
{
...
@@ -108,7 +108,7 @@ func TestGenericScheduler(t *testing.T) {
...
@@ -108,7 +108,7 @@ func TestGenericScheduler(t *testing.T) {
predicates
:
[]
FitPredicate
{
matchesPredicate
},
predicates
:
[]
FitPredicate
{
matchesPredicate
},
prioritizer
:
numericPriority
,
prioritizer
:
numericPriority
,
nodes
:
[]
string
{
"3"
,
"2"
,
"1"
},
nodes
:
[]
string
{
"3"
,
"2"
,
"1"
},
pod
:
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"2"
}},
pod
:
api
.
Pod
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"2"
}},
expectedHost
:
"2"
,
expectedHost
:
"2"
,
},
},
{
{
...
...
pkg/scheduler/priorities_test.go
View file @
644eb700
...
@@ -27,7 +27,7 @@ import (
...
@@ -27,7 +27,7 @@ import (
func
makeMinion
(
node
string
,
cpu
,
memory
int
)
api
.
Minion
{
func
makeMinion
(
node
string
,
cpu
,
memory
int
)
api
.
Minion
{
return
api
.
Minion
{
return
api
.
Minion
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
node
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
node
},
NodeResources
:
api
.
NodeResources
{
NodeResources
:
api
.
NodeResources
{
Capacity
:
api
.
ResourceList
{
Capacity
:
api
.
ResourceList
{
resources
.
CPU
:
util
.
NewIntOrStringFromInt
(
cpu
),
resources
.
CPU
:
util
.
NewIntOrStringFromInt
(
cpu
),
...
@@ -87,10 +87,10 @@ func TestLeastRequested(t *testing.T) {
...
@@ -87,10 +87,10 @@ func TestLeastRequested(t *testing.T) {
expectedList
:
[]
HostPriority
{{
"machine1"
,
0
},
{
"machine2"
,
0
}},
expectedList
:
[]
HostPriority
{{
"machine1"
,
0
},
{
"machine2"
,
0
}},
test
:
"no resources requested"
,
test
:
"no resources requested"
,
pods
:
[]
api
.
Pod
{
pods
:
[]
api
.
Pod
{
{
DesiredState
:
machine1State
,
Labels
:
labels2
},
{
DesiredState
:
machine1State
,
ObjectMeta
:
api
.
ObjectMeta
{
Labels
:
labels2
}
},
{
DesiredState
:
machine1State
,
Labels
:
labels1
},
{
DesiredState
:
machine1State
,
ObjectMeta
:
api
.
ObjectMeta
{
Labels
:
labels1
}
},
{
DesiredState
:
machine2State
,
Labels
:
labels1
},
{
DesiredState
:
machine2State
,
ObjectMeta
:
api
.
ObjectMeta
{
Labels
:
labels1
}
},
{
DesiredState
:
machine2State
,
Labels
:
labels1
},
{
DesiredState
:
machine2State
,
ObjectMeta
:
api
.
ObjectMeta
{
Labels
:
labels1
}
},
},
},
},
},
{
{
...
...
pkg/scheduler/spreading_test.go
View file @
644eb700
...
@@ -51,47 +51,47 @@ func TestSpreadPriority(t *testing.T) {
...
@@ -51,47 +51,47 @@ func TestSpreadPriority(t *testing.T) {
test
:
"nothing scheduled"
,
test
:
"nothing scheduled"
,
},
},
{
{
pod
:
api
.
Pod
{
Labels
:
labels1
},
pod
:
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
Labels
:
labels1
}
},
pods
:
[]
api
.
Pod
{{
CurrentState
:
machine1State
}},
pods
:
[]
api
.
Pod
{{
CurrentState
:
machine1State
}},
nodes
:
[]
string
{
"machine1"
,
"machine2"
},
nodes
:
[]
string
{
"machine1"
,
"machine2"
},
expectedList
:
[]
HostPriority
{{
"machine1"
,
0
},
{
"machine2"
,
0
}},
expectedList
:
[]
HostPriority
{{
"machine1"
,
0
},
{
"machine2"
,
0
}},
test
:
"no labels"
,
test
:
"no labels"
,
},
},
{
{
pod
:
api
.
Pod
{
Labels
:
labels1
},
pod
:
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
Labels
:
labels1
}
},
pods
:
[]
api
.
Pod
{{
CurrentState
:
machine1State
,
Labels
:
labels2
}},
pods
:
[]
api
.
Pod
{{
CurrentState
:
machine1State
,
ObjectMeta
:
api
.
ObjectMeta
{
Labels
:
labels2
}
}},
nodes
:
[]
string
{
"machine1"
,
"machine2"
},
nodes
:
[]
string
{
"machine1"
,
"machine2"
},
expectedList
:
[]
HostPriority
{{
"machine1"
,
0
},
{
"machine2"
,
0
}},
expectedList
:
[]
HostPriority
{{
"machine1"
,
0
},
{
"machine2"
,
0
}},
test
:
"different labels"
,
test
:
"different labels"
,
},
},
{
{
pod
:
api
.
Pod
{
Labels
:
labels1
},
pod
:
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
Labels
:
labels1
}
},
pods
:
[]
api
.
Pod
{
pods
:
[]
api
.
Pod
{
{
CurrentState
:
machine1State
,
Labels
:
labels2
},
{
CurrentState
:
machine1State
,
ObjectMeta
:
api
.
ObjectMeta
{
Labels
:
labels2
}
},
{
CurrentState
:
machine2State
,
Labels
:
labels1
},
{
CurrentState
:
machine2State
,
ObjectMeta
:
api
.
ObjectMeta
{
Labels
:
labels1
}
},
},
},
nodes
:
[]
string
{
"machine1"
,
"machine2"
},
nodes
:
[]
string
{
"machine1"
,
"machine2"
},
expectedList
:
[]
HostPriority
{{
"machine1"
,
0
},
{
"machine2"
,
1
}},
expectedList
:
[]
HostPriority
{{
"machine1"
,
0
},
{
"machine2"
,
1
}},
test
:
"one label match"
,
test
:
"one label match"
,
},
},
{
{
pod
:
api
.
Pod
{
Labels
:
labels1
},
pod
:
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
Labels
:
labels1
}
},
pods
:
[]
api
.
Pod
{
pods
:
[]
api
.
Pod
{
{
CurrentState
:
machine1State
,
Labels
:
labels2
},
{
CurrentState
:
machine1State
,
ObjectMeta
:
api
.
ObjectMeta
{
Labels
:
labels2
}
},
{
CurrentState
:
machine1State
,
Labels
:
labels1
},
{
CurrentState
:
machine1State
,
ObjectMeta
:
api
.
ObjectMeta
{
Labels
:
labels1
}
},
{
CurrentState
:
machine2State
,
Labels
:
labels1
},
{
CurrentState
:
machine2State
,
ObjectMeta
:
api
.
ObjectMeta
{
Labels
:
labels1
}
},
},
},
nodes
:
[]
string
{
"machine1"
,
"machine2"
},
nodes
:
[]
string
{
"machine1"
,
"machine2"
},
expectedList
:
[]
HostPriority
{{
"machine1"
,
1
},
{
"machine2"
,
1
}},
expectedList
:
[]
HostPriority
{{
"machine1"
,
1
},
{
"machine2"
,
1
}},
test
:
"two label matches on different machines"
,
test
:
"two label matches on different machines"
,
},
},
{
{
pod
:
api
.
Pod
{
Labels
:
labels1
},
pod
:
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
Labels
:
labels1
}
},
pods
:
[]
api
.
Pod
{
pods
:
[]
api
.
Pod
{
{
CurrentState
:
machine1State
,
Labels
:
labels2
},
{
CurrentState
:
machine1State
,
ObjectMeta
:
api
.
ObjectMeta
{
Labels
:
labels2
}
},
{
CurrentState
:
machine1State
,
Labels
:
labels1
},
{
CurrentState
:
machine1State
,
ObjectMeta
:
api
.
ObjectMeta
{
Labels
:
labels1
}
},
{
CurrentState
:
machine2State
,
Labels
:
labels1
},
{
CurrentState
:
machine2State
,
ObjectMeta
:
api
.
ObjectMeta
{
Labels
:
labels1
}
},
{
CurrentState
:
machine2State
,
Labels
:
labels1
},
{
CurrentState
:
machine2State
,
ObjectMeta
:
api
.
ObjectMeta
{
Labels
:
labels1
}
},
},
},
nodes
:
[]
string
{
"machine1"
,
"machine2"
},
nodes
:
[]
string
{
"machine1"
,
"machine2"
},
expectedList
:
[]
HostPriority
{{
"machine1"
,
1
},
{
"machine2"
,
2
}},
expectedList
:
[]
HostPriority
{{
"machine1"
,
1
},
{
"machine2"
,
2
}},
...
...
pkg/service/endpoints_controller_test.go
View file @
644eb700
...
@@ -34,10 +34,8 @@ func newPodList(count int) api.PodList {
...
@@ -34,10 +34,8 @@ func newPodList(count int) api.PodList {
pods
:=
[]
api
.
Pod
{}
pods
:=
[]
api
.
Pod
{}
for
i
:=
0
;
i
<
count
;
i
++
{
for
i
:=
0
;
i
<
count
;
i
++
{
pods
=
append
(
pods
,
api
.
Pod
{
pods
=
append
(
pods
,
api
.
Pod
{
TypeMeta
:
api
.
TypeMeta
{
TypeMeta
:
api
.
TypeMeta
{
APIVersion
:
testapi
.
Version
()},
Name
:
fmt
.
Sprintf
(
"pod%d"
,
i
),
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
fmt
.
Sprintf
(
"pod%d"
,
i
)},
APIVersion
:
testapi
.
Version
(),
},
DesiredState
:
api
.
PodState
{
DesiredState
:
api
.
PodState
{
Manifest
:
api
.
ContainerManifest
{
Manifest
:
api
.
ContainerManifest
{
Containers
:
[]
api
.
Container
{
Containers
:
[]
api
.
Container
{
...
@@ -181,7 +179,7 @@ func TestSyncEndpointsItemsPreexisting(t *testing.T) {
...
@@ -181,7 +179,7 @@ func TestSyncEndpointsItemsPreexisting(t *testing.T) {
serviceList
:=
api
.
ServiceList
{
serviceList
:=
api
.
ServiceList
{
Items
:
[]
api
.
Service
{
Items
:
[]
api
.
Service
{
{
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Selector
:
map
[
string
]
string
{
Selector
:
map
[
string
]
string
{
"foo"
:
"bar"
,
"foo"
:
"bar"
,
},
},
...
@@ -192,7 +190,7 @@ func TestSyncEndpointsItemsPreexisting(t *testing.T) {
...
@@ -192,7 +190,7 @@ func TestSyncEndpointsItemsPreexisting(t *testing.T) {
serverResponse
{
http
.
StatusOK
,
newPodList
(
1
)},
serverResponse
{
http
.
StatusOK
,
newPodList
(
1
)},
serverResponse
{
http
.
StatusOK
,
serviceList
},
serverResponse
{
http
.
StatusOK
,
serviceList
},
serverResponse
{
http
.
StatusOK
,
api
.
Endpoints
{
serverResponse
{
http
.
StatusOK
,
api
.
Endpoints
{
TypeMeta
:
api
.
Type
Meta
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
,
Name
:
"foo"
,
ResourceVersion
:
"1"
,
ResourceVersion
:
"1"
,
},
},
...
@@ -204,7 +202,7 @@ func TestSyncEndpointsItemsPreexisting(t *testing.T) {
...
@@ -204,7 +202,7 @@ func TestSyncEndpointsItemsPreexisting(t *testing.T) {
t
.
Errorf
(
"unexpected error: %v"
,
err
)
t
.
Errorf
(
"unexpected error: %v"
,
err
)
}
}
data
:=
runtime
.
EncodeOrDie
(
testapi
.
Codec
(),
&
api
.
Endpoints
{
data
:=
runtime
.
EncodeOrDie
(
testapi
.
Codec
(),
&
api
.
Endpoints
{
TypeMeta
:
api
.
Type
Meta
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
,
Name
:
"foo"
,
ResourceVersion
:
"1"
,
ResourceVersion
:
"1"
,
},
},
...
@@ -217,7 +215,7 @@ func TestSyncEndpointsItemsPreexistingIdentical(t *testing.T) {
...
@@ -217,7 +215,7 @@ func TestSyncEndpointsItemsPreexistingIdentical(t *testing.T) {
serviceList
:=
api
.
ServiceList
{
serviceList
:=
api
.
ServiceList
{
Items
:
[]
api
.
Service
{
Items
:
[]
api
.
Service
{
{
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Selector
:
map
[
string
]
string
{
Selector
:
map
[
string
]
string
{
"foo"
:
"bar"
,
"foo"
:
"bar"
,
},
},
...
@@ -228,7 +226,7 @@ func TestSyncEndpointsItemsPreexistingIdentical(t *testing.T) {
...
@@ -228,7 +226,7 @@ func TestSyncEndpointsItemsPreexistingIdentical(t *testing.T) {
serverResponse
{
http
.
StatusOK
,
newPodList
(
1
)},
serverResponse
{
http
.
StatusOK
,
newPodList
(
1
)},
serverResponse
{
http
.
StatusOK
,
serviceList
},
serverResponse
{
http
.
StatusOK
,
serviceList
},
serverResponse
{
http
.
StatusOK
,
api
.
Endpoints
{
serverResponse
{
http
.
StatusOK
,
api
.
Endpoints
{
TypeMeta
:
api
.
Type
Meta
{
ObjectMeta
:
api
.
Object
Meta
{
ResourceVersion
:
"1"
,
ResourceVersion
:
"1"
,
},
},
Endpoints
:
[]
string
{
"1.2.3.4:8080"
},
Endpoints
:
[]
string
{
"1.2.3.4:8080"
},
...
@@ -245,7 +243,7 @@ func TestSyncEndpointsItems(t *testing.T) {
...
@@ -245,7 +243,7 @@ func TestSyncEndpointsItems(t *testing.T) {
serviceList
:=
api
.
ServiceList
{
serviceList
:=
api
.
ServiceList
{
Items
:
[]
api
.
Service
{
Items
:
[]
api
.
Service
{
{
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Selector
:
map
[
string
]
string
{
Selector
:
map
[
string
]
string
{
"foo"
:
"bar"
,
"foo"
:
"bar"
,
},
},
...
@@ -262,7 +260,7 @@ func TestSyncEndpointsItems(t *testing.T) {
...
@@ -262,7 +260,7 @@ func TestSyncEndpointsItems(t *testing.T) {
t
.
Errorf
(
"unexpected error: %v"
,
err
)
t
.
Errorf
(
"unexpected error: %v"
,
err
)
}
}
data
:=
runtime
.
EncodeOrDie
(
testapi
.
Codec
(),
&
api
.
Endpoints
{
data
:=
runtime
.
EncodeOrDie
(
testapi
.
Codec
(),
&
api
.
Endpoints
{
TypeMeta
:
api
.
Type
Meta
{
ObjectMeta
:
api
.
Object
Meta
{
ResourceVersion
:
""
,
ResourceVersion
:
""
,
},
},
Endpoints
:
[]
string
{
"1.2.3.4:8080"
},
Endpoints
:
[]
string
{
"1.2.3.4:8080"
},
...
...
pkg/tools/etcd_tools_test.go
View file @
644eb700
...
@@ -38,6 +38,7 @@ type fakeClientGetSet struct {
...
@@ -38,6 +38,7 @@ type fakeClientGetSet struct {
type
TestResource
struct
{
type
TestResource
struct
{
api
.
TypeMeta
`json:",inline" yaml:",inline"`
api
.
TypeMeta
`json:",inline" yaml:",inline"`
api
.
ObjectMeta
`json:"metadata" yaml:"metadata"`
Value
int
`json:"value" yaml:"value,omitempty"`
Value
int
`json:"value" yaml:"value,omitempty"`
}
}
...
@@ -74,15 +75,15 @@ func TestExtractToList(t *testing.T) {
...
@@ -74,15 +75,15 @@ func TestExtractToList(t *testing.T) {
Node
:
&
etcd
.
Node
{
Node
:
&
etcd
.
Node
{
Nodes
:
[]
*
etcd
.
Node
{
Nodes
:
[]
*
etcd
.
Node
{
{
{
Value
:
`{"
name":"foo
"}`
,
Value
:
`{"
id":"foo","kind":"Pod","apiVersion":"v1beta1
"}`
,
ModifiedIndex
:
1
,
ModifiedIndex
:
1
,
},
},
{
{
Value
:
`{"
name":"bar
"}`
,
Value
:
`{"
id":"bar","kind":"Pod","apiVersion":"v1beta1
"}`
,
ModifiedIndex
:
2
,
ModifiedIndex
:
2
,
},
},
{
{
Value
:
`{"
name":"baz
"}`
,
Value
:
`{"
id":"baz","kind":"Pod","apiVersion":"v1beta1
"}`
,
ModifiedIndex
:
3
,
ModifiedIndex
:
3
,
},
},
},
},
...
@@ -90,11 +91,11 @@ func TestExtractToList(t *testing.T) {
...
@@ -90,11 +91,11 @@ func TestExtractToList(t *testing.T) {
},
},
}
}
expect
:=
api
.
PodList
{
expect
:=
api
.
PodList
{
TypeMeta
:
api
.
Type
Meta
{
ResourceVersion
:
"10"
},
ListMeta
:
api
.
List
Meta
{
ResourceVersion
:
"10"
},
Items
:
[]
api
.
Pod
{
Items
:
[]
api
.
Pod
{
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
,
ResourceVersion
:
"1"
}},
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
,
ResourceVersion
:
"1"
}},
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"bar"
,
ResourceVersion
:
"2"
}},
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"bar"
,
ResourceVersion
:
"2"
}},
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"baz"
,
ResourceVersion
:
"3"
}},
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"baz"
,
ResourceVersion
:
"3"
}},
},
},
}
}
...
@@ -122,7 +123,7 @@ func TestExtractToListAcrossDirectories(t *testing.T) {
...
@@ -122,7 +123,7 @@ func TestExtractToListAcrossDirectories(t *testing.T) {
Dir
:
true
,
Dir
:
true
,
Nodes
:
[]
*
etcd
.
Node
{
Nodes
:
[]
*
etcd
.
Node
{
{
{
Value
:
`{"
name":"foo
"}`
,
Value
:
`{"
id":"foo","kind":"Pod","apiVersion":"v1beta1
"}`
,
ModifiedIndex
:
1
,
ModifiedIndex
:
1
,
},
},
},
},
...
@@ -132,7 +133,7 @@ func TestExtractToListAcrossDirectories(t *testing.T) {
...
@@ -132,7 +133,7 @@ func TestExtractToListAcrossDirectories(t *testing.T) {
Dir
:
true
,
Dir
:
true
,
Nodes
:
[]
*
etcd
.
Node
{
Nodes
:
[]
*
etcd
.
Node
{
{
{
Value
:
`{"
name":"bar
"}`
,
Value
:
`{"
id":"bar","kind":"Pod","apiVersion":"v1beta1
"}`
,
ModifiedIndex
:
2
,
ModifiedIndex
:
2
,
},
},
},
},
...
@@ -142,10 +143,10 @@ func TestExtractToListAcrossDirectories(t *testing.T) {
...
@@ -142,10 +143,10 @@ func TestExtractToListAcrossDirectories(t *testing.T) {
},
},
}
}
expect
:=
api
.
PodList
{
expect
:=
api
.
PodList
{
TypeMeta
:
api
.
Type
Meta
{
ResourceVersion
:
"10"
},
ListMeta
:
api
.
List
Meta
{
ResourceVersion
:
"10"
},
Items
:
[]
api
.
Pod
{
Items
:
[]
api
.
Pod
{
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
,
ResourceVersion
:
"1"
}},
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
,
ResourceVersion
:
"1"
}},
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"bar"
,
ResourceVersion
:
"2"
}},
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"bar"
,
ResourceVersion
:
"2"
}},
},
},
}
}
...
@@ -168,15 +169,15 @@ func TestExtractToListExcludesDirectories(t *testing.T) {
...
@@ -168,15 +169,15 @@ func TestExtractToListExcludesDirectories(t *testing.T) {
Node
:
&
etcd
.
Node
{
Node
:
&
etcd
.
Node
{
Nodes
:
[]
*
etcd
.
Node
{
Nodes
:
[]
*
etcd
.
Node
{
{
{
Value
:
`{"
name":"foo
"}`
,
Value
:
`{"
id":"foo","kind":"Pod","apiVersion":"v1beta1
"}`
,
ModifiedIndex
:
1
,
ModifiedIndex
:
1
,
},
},
{
{
Value
:
`{"
name":"bar
"}`
,
Value
:
`{"
id":"bar","kind":"Pod","apiVersion":"v1beta1
"}`
,
ModifiedIndex
:
2
,
ModifiedIndex
:
2
,
},
},
{
{
Value
:
`{"
name":"baz
"}`
,
Value
:
`{"
id":"baz","kind":"Pod","apiVersion":"v1beta1
"}`
,
ModifiedIndex
:
3
,
ModifiedIndex
:
3
,
},
},
{
{
...
@@ -188,11 +189,11 @@ func TestExtractToListExcludesDirectories(t *testing.T) {
...
@@ -188,11 +189,11 @@ func TestExtractToListExcludesDirectories(t *testing.T) {
},
},
}
}
expect
:=
api
.
PodList
{
expect
:=
api
.
PodList
{
TypeMeta
:
api
.
Type
Meta
{
ResourceVersion
:
"10"
},
ListMeta
:
api
.
List
Meta
{
ResourceVersion
:
"10"
},
Items
:
[]
api
.
Pod
{
Items
:
[]
api
.
Pod
{
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
,
ResourceVersion
:
"1"
}},
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
,
ResourceVersion
:
"1"
}},
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"bar"
,
ResourceVersion
:
"2"
}},
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"bar"
,
ResourceVersion
:
"2"
}},
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"baz"
,
ResourceVersion
:
"3"
}},
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"baz"
,
ResourceVersion
:
"3"
}},
},
},
}
}
...
@@ -209,7 +210,7 @@ func TestExtractToListExcludesDirectories(t *testing.T) {
...
@@ -209,7 +210,7 @@ func TestExtractToListExcludesDirectories(t *testing.T) {
func
TestExtractObj
(
t
*
testing
.
T
)
{
func
TestExtractObj
(
t
*
testing
.
T
)
{
fakeClient
:=
NewFakeEtcdClient
(
t
)
fakeClient
:=
NewFakeEtcdClient
(
t
)
expect
:=
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
}}
expect
:=
api
.
Pod
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
}}
fakeClient
.
Set
(
"/some/key"
,
util
.
EncodeJSON
(
expect
),
0
)
fakeClient
.
Set
(
"/some/key"
,
util
.
EncodeJSON
(
expect
),
0
)
helper
:=
EtcdHelper
{
fakeClient
,
latest
.
Codec
,
versioner
}
helper
:=
EtcdHelper
{
fakeClient
,
latest
.
Codec
,
versioner
}
var
got
api
.
Pod
var
got
api
.
Pod
...
@@ -263,7 +264,7 @@ func TestExtractObjNotFoundErr(t *testing.T) {
...
@@ -263,7 +264,7 @@ func TestExtractObjNotFoundErr(t *testing.T) {
}
}
func
TestCreateObj
(
t
*
testing
.
T
)
{
func
TestCreateObj
(
t
*
testing
.
T
)
{
obj
:=
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
}}
obj
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
}}
fakeClient
:=
NewFakeEtcdClient
(
t
)
fakeClient
:=
NewFakeEtcdClient
(
t
)
helper
:=
EtcdHelper
{
fakeClient
,
latest
.
Codec
,
versioner
}
helper
:=
EtcdHelper
{
fakeClient
,
latest
.
Codec
,
versioner
}
err
:=
helper
.
CreateObj
(
"/some/key"
,
obj
,
5
)
err
:=
helper
.
CreateObj
(
"/some/key"
,
obj
,
5
)
...
@@ -284,7 +285,7 @@ func TestCreateObj(t *testing.T) {
...
@@ -284,7 +285,7 @@ func TestCreateObj(t *testing.T) {
}
}
func
TestSetObj
(
t
*
testing
.
T
)
{
func
TestSetObj
(
t
*
testing
.
T
)
{
obj
:=
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
}}
obj
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
}}
fakeClient
:=
NewFakeEtcdClient
(
t
)
fakeClient
:=
NewFakeEtcdClient
(
t
)
helper
:=
EtcdHelper
{
fakeClient
,
latest
.
Codec
,
versioner
}
helper
:=
EtcdHelper
{
fakeClient
,
latest
.
Codec
,
versioner
}
err
:=
helper
.
SetObj
(
"/some/key"
,
obj
)
err
:=
helper
.
SetObj
(
"/some/key"
,
obj
)
...
@@ -303,7 +304,7 @@ func TestSetObj(t *testing.T) {
...
@@ -303,7 +304,7 @@ func TestSetObj(t *testing.T) {
}
}
func
TestSetObjWithVersion
(
t
*
testing
.
T
)
{
func
TestSetObjWithVersion
(
t
*
testing
.
T
)
{
obj
:=
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
,
ResourceVersion
:
"1"
}}
obj
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
,
ResourceVersion
:
"1"
}}
fakeClient
:=
NewFakeEtcdClient
(
t
)
fakeClient
:=
NewFakeEtcdClient
(
t
)
fakeClient
.
TestIndex
=
true
fakeClient
.
TestIndex
=
true
fakeClient
.
Data
[
"/some/key"
]
=
EtcdResponseWithError
{
fakeClient
.
Data
[
"/some/key"
]
=
EtcdResponseWithError
{
...
@@ -332,7 +333,7 @@ func TestSetObjWithVersion(t *testing.T) {
...
@@ -332,7 +333,7 @@ func TestSetObjWithVersion(t *testing.T) {
}
}
func
TestSetObjWithoutResourceVersioner
(
t
*
testing
.
T
)
{
func
TestSetObjWithoutResourceVersioner
(
t
*
testing
.
T
)
{
obj
:=
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
}}
obj
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
}}
fakeClient
:=
NewFakeEtcdClient
(
t
)
fakeClient
:=
NewFakeEtcdClient
(
t
)
helper
:=
EtcdHelper
{
fakeClient
,
latest
.
Codec
,
nil
}
helper
:=
EtcdHelper
{
fakeClient
,
latest
.
Codec
,
nil
}
err
:=
helper
.
SetObj
(
"/some/key"
,
obj
)
err
:=
helper
.
SetObj
(
"/some/key"
,
obj
)
...
@@ -357,7 +358,7 @@ func TestAtomicUpdate(t *testing.T) {
...
@@ -357,7 +358,7 @@ func TestAtomicUpdate(t *testing.T) {
// Create a new node.
// Create a new node.
fakeClient
.
ExpectNotFoundGet
(
"/some/key"
)
fakeClient
.
ExpectNotFoundGet
(
"/some/key"
)
obj
:=
&
TestResource
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
Value
:
1
}
obj
:=
&
TestResource
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Value
:
1
}
err
:=
helper
.
AtomicUpdate
(
"/some/key"
,
&
TestResource
{},
func
(
in
runtime
.
Object
)
(
runtime
.
Object
,
error
)
{
err
:=
helper
.
AtomicUpdate
(
"/some/key"
,
&
TestResource
{},
func
(
in
runtime
.
Object
)
(
runtime
.
Object
,
error
)
{
return
obj
,
nil
return
obj
,
nil
})
})
...
@@ -376,7 +377,7 @@ func TestAtomicUpdate(t *testing.T) {
...
@@ -376,7 +377,7 @@ func TestAtomicUpdate(t *testing.T) {
// Update an existing node.
// Update an existing node.
callbackCalled
:=
false
callbackCalled
:=
false
objUpdate
:=
&
TestResource
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
Value
:
2
}
objUpdate
:=
&
TestResource
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Value
:
2
}
err
=
helper
.
AtomicUpdate
(
"/some/key"
,
&
TestResource
{},
func
(
in
runtime
.
Object
)
(
runtime
.
Object
,
error
)
{
err
=
helper
.
AtomicUpdate
(
"/some/key"
,
&
TestResource
{},
func
(
in
runtime
.
Object
)
(
runtime
.
Object
,
error
)
{
callbackCalled
=
true
callbackCalled
=
true
...
@@ -411,7 +412,7 @@ func TestAtomicUpdateNoChange(t *testing.T) {
...
@@ -411,7 +412,7 @@ func TestAtomicUpdateNoChange(t *testing.T) {
// Create a new node.
// Create a new node.
fakeClient
.
ExpectNotFoundGet
(
"/some/key"
)
fakeClient
.
ExpectNotFoundGet
(
"/some/key"
)
obj
:=
&
TestResource
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
Value
:
1
}
obj
:=
&
TestResource
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Value
:
1
}
err
:=
helper
.
AtomicUpdate
(
"/some/key"
,
&
TestResource
{},
func
(
in
runtime
.
Object
)
(
runtime
.
Object
,
error
)
{
err
:=
helper
.
AtomicUpdate
(
"/some/key"
,
&
TestResource
{},
func
(
in
runtime
.
Object
)
(
runtime
.
Object
,
error
)
{
return
obj
,
nil
return
obj
,
nil
})
})
...
@@ -421,7 +422,7 @@ func TestAtomicUpdateNoChange(t *testing.T) {
...
@@ -421,7 +422,7 @@ func TestAtomicUpdateNoChange(t *testing.T) {
// Update an existing node with the same data
// Update an existing node with the same data
callbackCalled
:=
false
callbackCalled
:=
false
objUpdate
:=
&
TestResource
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
Value
:
1
}
objUpdate
:=
&
TestResource
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Value
:
1
}
fakeClient
.
Err
=
errors
.
New
(
"should not be called"
)
fakeClient
.
Err
=
errors
.
New
(
"should not be called"
)
err
=
helper
.
AtomicUpdate
(
"/some/key"
,
&
TestResource
{},
func
(
in
runtime
.
Object
)
(
runtime
.
Object
,
error
)
{
err
=
helper
.
AtomicUpdate
(
"/some/key"
,
&
TestResource
{},
func
(
in
runtime
.
Object
)
(
runtime
.
Object
,
error
)
{
callbackCalled
=
true
callbackCalled
=
true
...
@@ -464,7 +465,7 @@ func TestAtomicUpdate_CreateCollision(t *testing.T) {
...
@@ -464,7 +465,7 @@ func TestAtomicUpdate_CreateCollision(t *testing.T) {
}
}
currValue
:=
in
.
(
*
TestResource
)
.
Value
currValue
:=
in
.
(
*
TestResource
)
.
Value
obj
:=
&
TestResource
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
Value
:
currValue
+
1
}
obj
:=
&
TestResource
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Value
:
currValue
+
1
}
return
obj
,
nil
return
obj
,
nil
})
})
if
err
!=
nil
{
if
err
!=
nil
{
...
...
pkg/tools/etcd_tools_watch_test.go
View file @
644eb700
...
@@ -32,9 +32,9 @@ import (
...
@@ -32,9 +32,9 @@ import (
func
TestWatchInterpretations
(
t
*
testing
.
T
)
{
func
TestWatchInterpretations
(
t
*
testing
.
T
)
{
codec
:=
latest
.
Codec
codec
:=
latest
.
Codec
// Declare some pods to make the test cases compact.
// Declare some pods to make the test cases compact.
podFoo
:=
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
}}
podFoo
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
}}
podBar
:=
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"bar"
}}
podBar
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"bar"
}}
podBaz
:=
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"baz"
}}
podBaz
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"baz"
}}
firstLetterIsB
:=
func
(
obj
runtime
.
Object
)
bool
{
firstLetterIsB
:=
func
(
obj
runtime
.
Object
)
bool
{
return
obj
.
(
*
api
.
Pod
)
.
Name
[
0
]
==
'b'
return
obj
.
(
*
api
.
Pod
)
.
Name
[
0
]
==
'b'
}
}
...
@@ -236,7 +236,7 @@ func TestWatch(t *testing.T) {
...
@@ -236,7 +236,7 @@ func TestWatch(t *testing.T) {
}
}
// Test normal case
// Test normal case
pod
:=
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
}}
pod
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
}}
podBytes
,
_
:=
codec
.
Encode
(
pod
)
podBytes
,
_
:=
codec
.
Encode
(
pod
)
fakeClient
.
WatchResponse
<-
&
etcd
.
Response
{
fakeClient
.
WatchResponse
<-
&
etcd
.
Response
{
Action
:
"set"
,
Action
:
"set"
,
...
@@ -294,7 +294,7 @@ func TestWatchEtcdState(t *testing.T) {
...
@@ -294,7 +294,7 @@ func TestWatchEtcdState(t *testing.T) {
{
{
Action
:
"create"
,
Action
:
"create"
,
Node
:
&
etcd
.
Node
{
Node
:
&
etcd
.
Node
{
Value
:
string
(
runtime
.
EncodeOrDie
(
codec
,
&
api
.
Endpoints
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
Endpoints
:
[]
string
{}})),
Value
:
string
(
runtime
.
EncodeOrDie
(
codec
,
&
api
.
Endpoints
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Endpoints
:
[]
string
{}})),
},
},
},
},
},
},
...
@@ -308,12 +308,12 @@ func TestWatchEtcdState(t *testing.T) {
...
@@ -308,12 +308,12 @@ func TestWatchEtcdState(t *testing.T) {
{
{
Action
:
"compareAndSwap"
,
Action
:
"compareAndSwap"
,
Node
:
&
etcd
.
Node
{
Node
:
&
etcd
.
Node
{
Value
:
string
(
runtime
.
EncodeOrDie
(
codec
,
&
api
.
Endpoints
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
Endpoints
:
[]
string
{
"127.0.0.1:9000"
}})),
Value
:
string
(
runtime
.
EncodeOrDie
(
codec
,
&
api
.
Endpoints
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Endpoints
:
[]
string
{
"127.0.0.1:9000"
}})),
CreatedIndex
:
1
,
CreatedIndex
:
1
,
ModifiedIndex
:
2
,
ModifiedIndex
:
2
,
},
},
PrevNode
:
&
etcd
.
Node
{
PrevNode
:
&
etcd
.
Node
{
Value
:
string
(
runtime
.
EncodeOrDie
(
codec
,
&
api
.
Endpoints
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
Endpoints
:
[]
string
{}})),
Value
:
string
(
runtime
.
EncodeOrDie
(
codec
,
&
api
.
Endpoints
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Endpoints
:
[]
string
{}})),
CreatedIndex
:
1
,
CreatedIndex
:
1
,
ModifiedIndex
:
1
,
ModifiedIndex
:
1
,
},
},
...
@@ -330,7 +330,7 @@ func TestWatchEtcdState(t *testing.T) {
...
@@ -330,7 +330,7 @@ func TestWatchEtcdState(t *testing.T) {
R
:
&
etcd
.
Response
{
R
:
&
etcd
.
Response
{
Action
:
"get"
,
Action
:
"get"
,
Node
:
&
etcd
.
Node
{
Node
:
&
etcd
.
Node
{
Value
:
string
(
runtime
.
EncodeOrDie
(
codec
,
&
api
.
Endpoints
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
Endpoints
:
[]
string
{}})),
Value
:
string
(
runtime
.
EncodeOrDie
(
codec
,
&
api
.
Endpoints
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Endpoints
:
[]
string
{}})),
CreatedIndex
:
1
,
CreatedIndex
:
1
,
ModifiedIndex
:
1
,
ModifiedIndex
:
1
,
},
},
...
@@ -343,12 +343,12 @@ func TestWatchEtcdState(t *testing.T) {
...
@@ -343,12 +343,12 @@ func TestWatchEtcdState(t *testing.T) {
{
{
Action
:
"compareAndSwap"
,
Action
:
"compareAndSwap"
,
Node
:
&
etcd
.
Node
{
Node
:
&
etcd
.
Node
{
Value
:
string
(
runtime
.
EncodeOrDie
(
codec
,
&
api
.
Endpoints
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
Endpoints
:
[]
string
{
"127.0.0.1:9000"
}})),
Value
:
string
(
runtime
.
EncodeOrDie
(
codec
,
&
api
.
Endpoints
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Endpoints
:
[]
string
{
"127.0.0.1:9000"
}})),
CreatedIndex
:
1
,
CreatedIndex
:
1
,
ModifiedIndex
:
2
,
ModifiedIndex
:
2
,
},
},
PrevNode
:
&
etcd
.
Node
{
PrevNode
:
&
etcd
.
Node
{
Value
:
string
(
runtime
.
EncodeOrDie
(
codec
,
&
api
.
Endpoints
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
},
Endpoints
:
[]
string
{}})),
Value
:
string
(
runtime
.
EncodeOrDie
(
codec
,
&
api
.
Endpoints
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
},
Endpoints
:
[]
string
{}})),
CreatedIndex
:
1
,
CreatedIndex
:
1
,
ModifiedIndex
:
1
,
ModifiedIndex
:
1
,
},
},
...
@@ -391,7 +391,7 @@ func TestWatchEtcdState(t *testing.T) {
...
@@ -391,7 +391,7 @@ func TestWatchEtcdState(t *testing.T) {
func
TestWatchFromZeroIndex
(
t
*
testing
.
T
)
{
func
TestWatchFromZeroIndex
(
t
*
testing
.
T
)
{
codec
:=
latest
.
Codec
codec
:=
latest
.
Codec
pod
:=
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
}}
pod
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
}}
testCases
:=
map
[
string
]
struct
{
testCases
:=
map
[
string
]
struct
{
Response
EtcdResponseWithError
Response
EtcdResponseWithError
...
@@ -464,7 +464,7 @@ func TestWatchFromZeroIndex(t *testing.T) {
...
@@ -464,7 +464,7 @@ func TestWatchFromZeroIndex(t *testing.T) {
func
TestWatchListFromZeroIndex
(
t
*
testing
.
T
)
{
func
TestWatchListFromZeroIndex
(
t
*
testing
.
T
)
{
codec
:=
latest
.
Codec
codec
:=
latest
.
Codec
pod
:=
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
}}
pod
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
}}
fakeClient
:=
NewFakeEtcdClient
(
t
)
fakeClient
:=
NewFakeEtcdClient
(
t
)
fakeClient
.
Data
[
"/some/key"
]
=
EtcdResponseWithError
{
fakeClient
.
Data
[
"/some/key"
]
=
EtcdResponseWithError
{
...
...
pkg/watch/json/decoder_test.go
View file @
644eb700
...
@@ -36,7 +36,7 @@ func TestDecoder(t *testing.T) {
...
@@ -36,7 +36,7 @@ func TestDecoder(t *testing.T) {
out
,
in
:=
io
.
Pipe
()
out
,
in
:=
io
.
Pipe
()
decoder
:=
NewDecoder
(
out
,
testapi
.
Codec
())
decoder
:=
NewDecoder
(
out
,
testapi
.
Codec
())
expect
:=
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
}}
expect
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
}}
encoder
:=
json
.
NewEncoder
(
in
)
encoder
:=
json
.
NewEncoder
(
in
)
go
func
()
{
go
func
()
{
data
,
err
:=
testapi
.
Codec
()
.
Encode
(
expect
)
data
,
err
:=
testapi
.
Codec
()
.
Encode
(
expect
)
...
...
pkg/watch/json/encoder_test.go
View file @
644eb700
...
@@ -37,17 +37,17 @@ func TestEncodeDecodeRoundTrip(t *testing.T) {
...
@@ -37,17 +37,17 @@ func TestEncodeDecodeRoundTrip(t *testing.T) {
}{
}{
{
{
watch
.
Added
,
watch
.
Added
,
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
}},
&
api
.
Pod
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
}},
v1beta1
.
Codec
,
v1beta1
.
Codec
,
},
},
{
{
watch
.
Modified
,
watch
.
Modified
,
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
}},
&
api
.
Pod
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
}},
v1beta2
.
Codec
,
v1beta2
.
Codec
,
},
},
{
{
watch
.
Deleted
,
watch
.
Deleted
,
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
}},
&
api
.
Pod
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
}},
api
.
Codec
,
api
.
Codec
,
},
},
}
}
...
...
plugin/pkg/scheduler/factory/factory_test.go
View file @
644eb700
...
@@ -145,8 +145,8 @@ func TestPollMinions(t *testing.T) {
...
@@ -145,8 +145,8 @@ func TestPollMinions(t *testing.T) {
}{
}{
{
{
minions
:
[]
api
.
Minion
{
minions
:
[]
api
.
Minion
{
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
}},
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
}},
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"bar"
}},
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"bar"
}},
},
},
},
},
}
}
...
@@ -179,7 +179,7 @@ func TestPollMinions(t *testing.T) {
...
@@ -179,7 +179,7 @@ func TestPollMinions(t *testing.T) {
}
}
func
TestDefaultErrorFunc
(
t
*
testing
.
T
)
{
func
TestDefaultErrorFunc
(
t
*
testing
.
T
)
{
testPod
:=
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
}}
testPod
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
}}
handler
:=
util
.
FakeHandler
{
handler
:=
util
.
FakeHandler
{
StatusCode
:
200
,
StatusCode
:
200
,
ResponseBody
:
runtime
.
EncodeOrDie
(
latest
.
Codec
,
testPod
),
ResponseBody
:
runtime
.
EncodeOrDie
(
latest
.
Codec
,
testPod
),
...
@@ -219,7 +219,7 @@ func TestStoreToMinionLister(t *testing.T) {
...
@@ -219,7 +219,7 @@ func TestStoreToMinionLister(t *testing.T) {
store
:=
cache
.
NewStore
()
store
:=
cache
.
NewStore
()
ids
:=
util
.
NewStringSet
(
"foo"
,
"bar"
,
"baz"
)
ids
:=
util
.
NewStringSet
(
"foo"
,
"bar"
,
"baz"
)
for
id
:=
range
ids
{
for
id
:=
range
ids
{
store
.
Add
(
id
,
&
api
.
Minion
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
id
}})
store
.
Add
(
id
,
&
api
.
Minion
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
id
}})
}
}
sml
:=
storeToMinionLister
{
store
}
sml
:=
storeToMinionLister
{
store
}
...
@@ -241,8 +241,10 @@ func TestStoreToPodLister(t *testing.T) {
...
@@ -241,8 +241,10 @@ func TestStoreToPodLister(t *testing.T) {
ids
:=
[]
string
{
"foo"
,
"bar"
,
"baz"
}
ids
:=
[]
string
{
"foo"
,
"bar"
,
"baz"
}
for
_
,
id
:=
range
ids
{
for
_
,
id
:=
range
ids
{
store
.
Add
(
id
,
&
api
.
Pod
{
store
.
Add
(
id
,
&
api
.
Pod
{
TypeMeta
:
api
.
TypeMeta
{
Name
:
id
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
id
,
Labels
:
map
[
string
]
string
{
"name"
:
id
},
Labels
:
map
[
string
]
string
{
"name"
:
id
},
},
})
})
}
}
spl
:=
storeToPodLister
{
store
}
spl
:=
storeToPodLister
{
store
}
...
@@ -267,9 +269,9 @@ func TestStoreToPodLister(t *testing.T) {
...
@@ -267,9 +269,9 @@ func TestStoreToPodLister(t *testing.T) {
func
TestMinionEnumerator
(
t
*
testing
.
T
)
{
func
TestMinionEnumerator
(
t
*
testing
.
T
)
{
testList
:=
&
api
.
MinionList
{
testList
:=
&
api
.
MinionList
{
Items
:
[]
api
.
Minion
{
Items
:
[]
api
.
Minion
{
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
}},
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
}},
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"bar"
}},
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"bar"
}},
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"baz"
}},
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"baz"
}},
},
},
}
}
me
:=
minionEnumerator
{
testList
}
me
:=
minionEnumerator
{
testList
}
...
...
plugin/pkg/scheduler/scheduler_test.go
View file @
644eb700
...
@@ -34,7 +34,7 @@ type fakeBinder struct {
...
@@ -34,7 +34,7 @@ type fakeBinder struct {
func
(
fb
fakeBinder
)
Bind
(
binding
*
api
.
Binding
)
error
{
return
fb
.
b
(
binding
)
}
func
(
fb
fakeBinder
)
Bind
(
binding
*
api
.
Binding
)
error
{
return
fb
.
b
(
binding
)
}
func
podWithID
(
id
string
)
*
api
.
Pod
{
func
podWithID
(
id
string
)
*
api
.
Pod
{
return
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
id
,
SelfLink
:
testapi
.
SelfLink
(
"pods"
,
id
)}}
return
&
api
.
Pod
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
id
,
SelfLink
:
testapi
.
SelfLink
(
"pods"
,
id
)}}
}
}
type
mockScheduler
struct
{
type
mockScheduler
struct
{
...
@@ -88,7 +88,7 @@ func TestScheduler(t *testing.T) {
...
@@ -88,7 +88,7 @@ func TestScheduler(t *testing.T) {
var
gotBinding
*
api
.
Binding
var
gotBinding
*
api
.
Binding
c
:=
&
Config
{
c
:=
&
Config
{
MinionLister
:
scheduler
.
FakeMinionLister
(
MinionLister
:
scheduler
.
FakeMinionLister
(
api
.
MinionList
{
Items
:
[]
api
.
Minion
{{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"machine1"
}}}},
api
.
MinionList
{
Items
:
[]
api
.
Minion
{{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"machine1"
}}}},
),
),
Algorithm
:
item
.
algo
,
Algorithm
:
item
.
algo
,
Binder
:
fakeBinder
{
func
(
b
*
api
.
Binding
)
error
{
Binder
:
fakeBinder
{
func
(
b
*
api
.
Binding
)
error
{
...
...
test/integration/etcd_tools_test.go
View file @
644eb700
...
@@ -95,7 +95,7 @@ func TestWatch(t *testing.T) {
...
@@ -95,7 +95,7 @@ func TestWatch(t *testing.T) {
client
:=
newEtcdClient
()
client
:=
newEtcdClient
()
helper
:=
tools
.
EtcdHelper
{
Client
:
client
,
Codec
:
latest
.
Codec
,
ResourceVersioner
:
tools
.
RuntimeVersionAdapter
{
latest
.
ResourceVersioner
}}
helper
:=
tools
.
EtcdHelper
{
Client
:
client
,
Codec
:
latest
.
Codec
,
ResourceVersioner
:
tools
.
RuntimeVersionAdapter
{
latest
.
ResourceVersioner
}}
withEtcdKey
(
func
(
key
string
)
{
withEtcdKey
(
func
(
key
string
)
{
resp
,
err
:=
client
.
Set
(
key
,
runtime
.
EncodeOrDie
(
v1beta1
.
Codec
,
&
api
.
Pod
{
TypeMeta
:
api
.
Type
Meta
{
Name
:
"foo"
}}),
0
)
resp
,
err
:=
client
.
Set
(
key
,
runtime
.
EncodeOrDie
(
v1beta1
.
Codec
,
&
api
.
Pod
{
ObjectMeta
:
api
.
Object
Meta
{
Name
:
"foo"
}}),
0
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment