mirror of https://github.com/k3s-io/k3s
Refactor tests to split ObjectMeta from TypeMeta
parent
7550c146dc
commit
644eb70085
|
@ -256,11 +256,16 @@ func runAtomicPutTest(c *client.Client) {
|
|||
var svc api.Service
|
||||
err := c.Post().Path("services").Body(
|
||||
&api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "atomicservice", APIVersion: latest.Version},
|
||||
Port: 12345,
|
||||
Labels: map[string]string{
|
||||
"name": "atomicService",
|
||||
TypeMeta: api.TypeMeta{
|
||||
APIVersion: latest.Version,
|
||||
},
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "atomicservice",
|
||||
Labels: map[string]string{
|
||||
"name": "atomicService",
|
||||
},
|
||||
},
|
||||
Port: 12345,
|
||||
// This is here because validation requires it.
|
||||
Selector: map[string]string{
|
||||
"foo": "bar",
|
||||
|
@ -330,7 +335,12 @@ func runAtomicPutTest(c *client.Client) {
|
|||
func runServiceTest(client *client.Client) {
|
||||
ctx := api.NewDefaultContext()
|
||||
pod := api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Labels: map[string]string{
|
||||
"name": "thisisalonglabel",
|
||||
},
|
||||
},
|
||||
DesiredState: api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
Version: "v1beta1",
|
||||
|
@ -348,9 +358,6 @@ func runServiceTest(client *client.Client) {
|
|||
CurrentState: api.PodState{
|
||||
PodIP: "1.2.3.4",
|
||||
},
|
||||
Labels: map[string]string{
|
||||
"name": "thisisalonglabel",
|
||||
},
|
||||
}
|
||||
_, err := client.CreatePod(ctx, &pod)
|
||||
if err != nil {
|
||||
|
@ -360,7 +367,7 @@ func runServiceTest(client *client.Client) {
|
|||
glog.Fatalf("FAILED: pod never started running %v", err)
|
||||
}
|
||||
svc1 := api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "service1"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "service1"},
|
||||
Selector: map[string]string{
|
||||
"name": "thisisalonglabel",
|
||||
},
|
||||
|
@ -375,7 +382,7 @@ func runServiceTest(client *client.Client) {
|
|||
}
|
||||
// A second service with the same port.
|
||||
svc2 := api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "service2"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "service2"},
|
||||
Selector: map[string]string{
|
||||
"name": "thisisalonglabel",
|
||||
},
|
||||
|
|
|
@ -41,14 +41,14 @@ func validateObject(obj runtime.Object) (errors []error) {
|
|||
errors = append(errors, validateObject(&t.Items[i])...)
|
||||
}
|
||||
case *api.Service:
|
||||
api.ValidNamespace(ctx, &t.TypeMeta)
|
||||
api.ValidNamespace(ctx, &t.ObjectMeta)
|
||||
errors = validation.ValidateService(t)
|
||||
case *api.ServiceList:
|
||||
for i := range t.Items {
|
||||
errors = append(errors, validateObject(&t.Items[i])...)
|
||||
}
|
||||
case *api.Pod:
|
||||
api.ValidNamespace(ctx, &t.TypeMeta)
|
||||
api.ValidNamespace(ctx, &t.ObjectMeta)
|
||||
errors = validation.ValidateManifest(&t.DesiredState.Manifest)
|
||||
case *api.PodList:
|
||||
for i := range t.Items {
|
||||
|
|
|
@ -45,18 +45,18 @@ func TestValidNamespace(t *testing.T) {
|
|||
ctx := api.NewDefaultContext()
|
||||
namespace, _ := api.NamespaceFrom(ctx)
|
||||
resource := api.ReplicationController{}
|
||||
if !api.ValidNamespace(ctx, &resource.TypeMeta) {
|
||||
if !api.ValidNamespace(ctx, &resource.ObjectMeta) {
|
||||
t.Errorf("expected success")
|
||||
}
|
||||
if namespace != resource.Namespace {
|
||||
t.Errorf("expected resource to have the default namespace assigned during validation")
|
||||
}
|
||||
resource = api.ReplicationController{TypeMeta: api.TypeMeta{Namespace: "other"}}
|
||||
if api.ValidNamespace(ctx, &resource.TypeMeta) {
|
||||
resource = api.ReplicationController{ObjectMeta: api.ObjectMeta{Namespace: "other"}}
|
||||
if api.ValidNamespace(ctx, &resource.ObjectMeta) {
|
||||
t.Errorf("Expected error that resource and context errors do not match because resource has different namespace")
|
||||
}
|
||||
ctx = api.NewContext()
|
||||
if api.ValidNamespace(ctx, &resource.TypeMeta) {
|
||||
if api.ValidNamespace(ctx, &resource.ObjectMeta) {
|
||||
t.Errorf("Expected error that resource and context errors do not match since context has no namespace")
|
||||
}
|
||||
|
||||
|
|
|
@ -37,6 +37,8 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
|
|||
// APIVersion and Kind must remain blank in memory.
|
||||
j.APIVersion = ""
|
||||
j.Kind = ""
|
||||
},
|
||||
func(j *internal.ObjectMeta, c fuzz.Continue) {
|
||||
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
|
||||
|
@ -49,6 +51,13 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
|
|||
c.Fuzz(&nsec)
|
||||
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) {
|
||||
// We have to customize the randomization of TypeMetas because their
|
||||
// APIVersion and Kind must remain blank in memory.
|
||||
|
@ -133,7 +142,7 @@ func TestInternalRoundTrip(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestResourceVersioner(t *testing.T) {
|
||||
pod := internal.Pod{TypeMeta: internal.TypeMeta{ResourceVersion: "10"}}
|
||||
pod := internal.Pod{ObjectMeta: internal.ObjectMeta{ResourceVersion: "10"}}
|
||||
version, err := ResourceVersioner.ResourceVersion(&pod)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
|
@ -141,6 +150,15 @@ func TestResourceVersioner(t *testing.T) {
|
|||
if version != "10" {
|
||||
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) {
|
||||
|
|
|
@ -35,7 +35,7 @@ func TestGetReference(t *testing.T) {
|
|||
}{
|
||||
"pod": {
|
||||
obj: &Pod{
|
||||
TypeMeta: TypeMeta{
|
||||
ObjectMeta: ObjectMeta{
|
||||
Name: "foo",
|
||||
UID: "bar",
|
||||
ResourceVersion: "42",
|
||||
|
@ -52,9 +52,7 @@ func TestGetReference(t *testing.T) {
|
|||
},
|
||||
"serviceList": {
|
||||
obj: &ServiceList{
|
||||
TypeMeta: TypeMeta{
|
||||
Name: "foo",
|
||||
UID: "bar",
|
||||
ListMeta: ListMeta{
|
||||
ResourceVersion: "42",
|
||||
SelfLink: "/api/v1beta2/services",
|
||||
},
|
||||
|
@ -62,15 +60,12 @@ func TestGetReference(t *testing.T) {
|
|||
ref: &ObjectReference{
|
||||
Kind: "ServiceList",
|
||||
APIVersion: "v1beta2",
|
||||
Name: "foo",
|
||||
UID: "bar",
|
||||
ResourceVersion: "42",
|
||||
},
|
||||
},
|
||||
"badSelfLink": {
|
||||
obj: &ServiceList{
|
||||
TypeMeta: TypeMeta{
|
||||
Name: "foo",
|
||||
ListMeta: ListMeta{
|
||||
ResourceVersion: "42",
|
||||
SelfLink: "v1beta2/services",
|
||||
},
|
||||
|
|
|
@ -47,12 +47,7 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
|
|||
// APIVersion and Kind must remain blank in memory.
|
||||
j.APIVersion = ""
|
||||
j.Kind = ""
|
||||
},
|
||||
func(j *api.TypeMeta, c fuzz.Continue) {
|
||||
// We have to customize the randomization of TypeMetas because their
|
||||
// APIVersion and Kind must remain blank in memory.
|
||||
j.APIVersion = ""
|
||||
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
|
||||
|
@ -65,6 +60,32 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
|
|||
c.Fuzz(&nsec)
|
||||
j.CreationTimestamp = util.Unix(sec, nsec).Rfc3339Copy()
|
||||
},
|
||||
func(j *api.TypeMeta, c fuzz.Continue) {
|
||||
// We have to customize the randomization of TypeMetas because their
|
||||
// APIVersion and Kind must remain blank in memory.
|
||||
j.APIVersion = ""
|
||||
j.Kind = ""
|
||||
},
|
||||
func(j *api.ObjectMeta, c fuzz.Continue) {
|
||||
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.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) {
|
||||
// util.IntOrString will panic if its kind is set wrong.
|
||||
if c.RandBool() {
|
||||
|
@ -173,7 +194,9 @@ func TestTypes(t *testing.T) {
|
|||
|
||||
func TestEncode_Ptr(t *testing.T) {
|
||||
pod := &api.Pod{
|
||||
Labels: map[string]string{"name": "foo"},
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Labels: map[string]string{"name": "foo"},
|
||||
},
|
||||
}
|
||||
obj := runtime.Object(pod)
|
||||
data, err := latest.Codec.Encode(obj)
|
||||
|
|
|
@ -119,7 +119,7 @@ func TestMinionListConversionToNew(t *testing.T) {
|
|||
return v1beta1.Minion{TypeMeta: v1beta1.TypeMeta{ID: id}}
|
||||
}
|
||||
newMinion := func(id string) newer.Minion {
|
||||
return newer.Minion{TypeMeta: newer.TypeMeta{Name: id}}
|
||||
return newer.Minion{ObjectMeta: newer.ObjectMeta{Name: id}}
|
||||
}
|
||||
oldMinions := []v1beta1.Minion{
|
||||
oldMinion("foo"),
|
||||
|
@ -166,7 +166,7 @@ func TestMinionListConversionToOld(t *testing.T) {
|
|||
return v1beta1.Minion{TypeMeta: v1beta1.TypeMeta{ID: id}}
|
||||
}
|
||||
newMinion := func(id string) newer.Minion {
|
||||
return newer.Minion{TypeMeta: newer.TypeMeta{Name: id}}
|
||||
return newer.Minion{ObjectMeta: newer.ObjectMeta{Name: id}}
|
||||
}
|
||||
oldMinions := []v1beta1.Minion{
|
||||
oldMinion("foo"),
|
||||
|
|
|
@ -367,9 +367,11 @@ func TestValidateManifest(t *testing.T) {
|
|||
|
||||
func TestValidatePod(t *testing.T) {
|
||||
errs := ValidatePod(&api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo", Namespace: api.NamespaceDefault},
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo", Namespace: api.NamespaceDefault,
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
},
|
||||
DesiredState: api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
|
@ -385,9 +387,12 @@ func TestValidatePod(t *testing.T) {
|
|||
t.Errorf("Unexpected non-zero error list: %#v", errs)
|
||||
}
|
||||
errs = ValidatePod(&api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo", Namespace: api.NamespaceDefault},
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Namespace: api.NamespaceDefault,
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
},
|
||||
DesiredState: api.PodState{
|
||||
Manifest: api.ContainerManifest{Version: "v1beta1", ID: "abc"},
|
||||
|
@ -398,9 +403,11 @@ func TestValidatePod(t *testing.T) {
|
|||
}
|
||||
|
||||
errs = ValidatePod(&api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo", Namespace: api.NamespaceDefault},
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo", Namespace: api.NamespaceDefault,
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
},
|
||||
DesiredState: api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
|
@ -426,25 +433,29 @@ func TestValidatePodUpdate(t *testing.T) {
|
|||
{api.Pod{}, api.Pod{}, true, "nothing"},
|
||||
{
|
||||
api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
},
|
||||
api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "bar"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "bar"},
|
||||
},
|
||||
false,
|
||||
"ids",
|
||||
},
|
||||
{
|
||||
api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
},
|
||||
},
|
||||
api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Labels: map[string]string{
|
||||
"bar": "foo",
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Labels: map[string]string{
|
||||
"bar": "foo",
|
||||
},
|
||||
},
|
||||
},
|
||||
true,
|
||||
|
@ -452,7 +463,9 @@ func TestValidatePodUpdate(t *testing.T) {
|
|||
},
|
||||
{
|
||||
api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
},
|
||||
DesiredState: api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
Containers: []api.Container{
|
||||
|
@ -464,7 +477,7 @@ func TestValidatePodUpdate(t *testing.T) {
|
|||
},
|
||||
},
|
||||
api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
DesiredState: api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
Containers: []api.Container{
|
||||
|
@ -483,7 +496,7 @@ func TestValidatePodUpdate(t *testing.T) {
|
|||
},
|
||||
{
|
||||
api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
DesiredState: api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
Containers: []api.Container{
|
||||
|
@ -495,7 +508,7 @@ func TestValidatePodUpdate(t *testing.T) {
|
|||
},
|
||||
},
|
||||
api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
DesiredState: api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
Containers: []api.Container{
|
||||
|
@ -511,7 +524,7 @@ func TestValidatePodUpdate(t *testing.T) {
|
|||
},
|
||||
{
|
||||
api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
DesiredState: api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
Containers: []api.Container{
|
||||
|
@ -524,7 +537,7 @@ func TestValidatePodUpdate(t *testing.T) {
|
|||
},
|
||||
},
|
||||
api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
DesiredState: api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
Containers: []api.Container{
|
||||
|
@ -541,7 +554,7 @@ func TestValidatePodUpdate(t *testing.T) {
|
|||
},
|
||||
{
|
||||
api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
DesiredState: api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
Containers: []api.Container{
|
||||
|
@ -556,7 +569,7 @@ func TestValidatePodUpdate(t *testing.T) {
|
|||
},
|
||||
},
|
||||
api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
DesiredState: api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
Containers: []api.Container{
|
||||
|
@ -598,9 +611,9 @@ func TestValidateService(t *testing.T) {
|
|||
{
|
||||
name: "missing id",
|
||||
svc: api.Service{
|
||||
TypeMeta: api.TypeMeta{Namespace: api.NamespaceDefault},
|
||||
Port: 8675,
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
ObjectMeta: api.ObjectMeta{Namespace: api.NamespaceDefault},
|
||||
Port: 8675,
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
},
|
||||
// Should fail because the ID is missing.
|
||||
numErrs: 1,
|
||||
|
@ -608,9 +621,9 @@ func TestValidateService(t *testing.T) {
|
|||
{
|
||||
name: "missing namespace",
|
||||
svc: api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Port: 8675,
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Port: 8675,
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
},
|
||||
// Should fail because the Namespace is missing.
|
||||
numErrs: 1,
|
||||
|
@ -618,9 +631,9 @@ func TestValidateService(t *testing.T) {
|
|||
{
|
||||
name: "invalid id",
|
||||
svc: api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "123abc", Namespace: api.NamespaceDefault},
|
||||
Port: 8675,
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "123abc", Namespace: api.NamespaceDefault},
|
||||
Port: 8675,
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
},
|
||||
// Should fail because the ID is invalid.
|
||||
numErrs: 1,
|
||||
|
@ -628,8 +641,8 @@ func TestValidateService(t *testing.T) {
|
|||
{
|
||||
name: "missing port",
|
||||
svc: api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "abc123", Namespace: api.NamespaceDefault},
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc123", Namespace: api.NamespaceDefault},
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
},
|
||||
// Should fail because the port number is missing/invalid.
|
||||
numErrs: 1,
|
||||
|
@ -637,9 +650,9 @@ func TestValidateService(t *testing.T) {
|
|||
{
|
||||
name: "invalid port",
|
||||
svc: api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "abc123", Namespace: api.NamespaceDefault},
|
||||
Port: 65536,
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc123", Namespace: api.NamespaceDefault},
|
||||
Port: 65536,
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
},
|
||||
// Should fail because the port number is invalid.
|
||||
numErrs: 1,
|
||||
|
@ -647,10 +660,10 @@ func TestValidateService(t *testing.T) {
|
|||
{
|
||||
name: "invalid protocol",
|
||||
svc: api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "abc123", Namespace: api.NamespaceDefault},
|
||||
Port: 8675,
|
||||
Protocol: "INVALID",
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc123", Namespace: api.NamespaceDefault},
|
||||
Port: 8675,
|
||||
Protocol: "INVALID",
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
},
|
||||
// Should fail because the protocol is invalid.
|
||||
numErrs: 1,
|
||||
|
@ -658,8 +671,8 @@ func TestValidateService(t *testing.T) {
|
|||
{
|
||||
name: "missing selector",
|
||||
svc: api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "foo", Namespace: api.NamespaceDefault},
|
||||
Port: 8675,
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: api.NamespaceDefault},
|
||||
Port: 8675,
|
||||
},
|
||||
// Should fail because the selector is missing.
|
||||
numErrs: 1,
|
||||
|
@ -667,29 +680,29 @@ func TestValidateService(t *testing.T) {
|
|||
{
|
||||
name: "valid 1",
|
||||
svc: api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "abc123", Namespace: api.NamespaceDefault},
|
||||
Port: 1,
|
||||
Protocol: "TCP",
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc123", Namespace: api.NamespaceDefault},
|
||||
Port: 1,
|
||||
Protocol: "TCP",
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
},
|
||||
numErrs: 0,
|
||||
},
|
||||
{
|
||||
name: "valid 2",
|
||||
svc: api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "abc123", Namespace: api.NamespaceDefault},
|
||||
Port: 65535,
|
||||
Protocol: "UDP",
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc123", Namespace: api.NamespaceDefault},
|
||||
Port: 65535,
|
||||
Protocol: "UDP",
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
},
|
||||
numErrs: 0,
|
||||
},
|
||||
{
|
||||
name: "valid 3",
|
||||
svc: api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "abc123", Namespace: api.NamespaceDefault},
|
||||
Port: 80,
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc123", Namespace: api.NamespaceDefault},
|
||||
Port: 80,
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
},
|
||||
numErrs: 0,
|
||||
},
|
||||
|
@ -703,9 +716,9 @@ func TestValidateService(t *testing.T) {
|
|||
}
|
||||
|
||||
svc := api.Service{
|
||||
Port: 6502,
|
||||
TypeMeta: api.TypeMeta{Name: "foo", Namespace: api.NamespaceDefault},
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
Port: 6502,
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: api.NamespaceDefault},
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
}
|
||||
errs := ValidateService(&svc)
|
||||
if len(errs) != 0 {
|
||||
|
@ -736,14 +749,14 @@ func TestValidateReplicationController(t *testing.T) {
|
|||
}
|
||||
successCases := []api.ReplicationController{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "abc", Namespace: api.NamespaceDefault},
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
ReplicaSelector: validSelector,
|
||||
PodTemplate: validPodTemplate,
|
||||
},
|
||||
},
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "abc-123", Namespace: api.NamespaceDefault},
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc-123", Namespace: api.NamespaceDefault},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
ReplicaSelector: validSelector,
|
||||
PodTemplate: validPodTemplate,
|
||||
|
@ -758,47 +771,47 @@ func TestValidateReplicationController(t *testing.T) {
|
|||
|
||||
errorCases := map[string]api.ReplicationController{
|
||||
"zero-length ID": {
|
||||
TypeMeta: api.TypeMeta{Name: "", Namespace: api.NamespaceDefault},
|
||||
ObjectMeta: api.ObjectMeta{Name: "", Namespace: api.NamespaceDefault},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
ReplicaSelector: validSelector,
|
||||
PodTemplate: validPodTemplate,
|
||||
},
|
||||
},
|
||||
"missing-namespace": {
|
||||
TypeMeta: api.TypeMeta{Name: "abc-123"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc-123"},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
ReplicaSelector: validSelector,
|
||||
PodTemplate: validPodTemplate,
|
||||
},
|
||||
},
|
||||
"empty selector": {
|
||||
TypeMeta: api.TypeMeta{Name: "abc", Namespace: api.NamespaceDefault},
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
PodTemplate: validPodTemplate,
|
||||
},
|
||||
},
|
||||
"selector_doesnt_match": {
|
||||
TypeMeta: api.TypeMeta{Name: "abc", Namespace: api.NamespaceDefault},
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
ReplicaSelector: map[string]string{"foo": "bar"},
|
||||
PodTemplate: validPodTemplate,
|
||||
},
|
||||
},
|
||||
"invalid manifest": {
|
||||
TypeMeta: api.TypeMeta{Name: "abc", Namespace: api.NamespaceDefault},
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
ReplicaSelector: validSelector,
|
||||
},
|
||||
},
|
||||
"read-write presistent disk": {
|
||||
TypeMeta: api.TypeMeta{Name: "abc"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc"},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
ReplicaSelector: validSelector,
|
||||
PodTemplate: invalidVolumePodTemplate,
|
||||
},
|
||||
},
|
||||
"negative_replicas": {
|
||||
TypeMeta: api.TypeMeta{Name: "abc", Namespace: api.NamespaceDefault},
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
Replicas: -1,
|
||||
ReplicaSelector: validSelector,
|
||||
|
@ -827,13 +840,13 @@ func TestValidateReplicationController(t *testing.T) {
|
|||
func TestValidateBoundPodNoName(t *testing.T) {
|
||||
errorCases := map[string]api.BoundPod{
|
||||
// manifest is tested in api/validation_test.go, ensure it is invoked
|
||||
"empty version": {TypeMeta: api.TypeMeta{Name: "test"}, Spec: api.PodSpec{Containers: []api.Container{{Name: ""}}}},
|
||||
"empty version": {ObjectMeta: api.ObjectMeta{Name: "test"}, Spec: api.PodSpec{Containers: []api.Container{{Name: ""}}}},
|
||||
|
||||
// Name
|
||||
"zero-length name": {TypeMeta: api.TypeMeta{Name: ""}},
|
||||
"name > 255 characters": {TypeMeta: api.TypeMeta{Name: strings.Repeat("a", 256)}},
|
||||
"name not a DNS subdomain": {TypeMeta: api.TypeMeta{Name: "a.b.c."}},
|
||||
"name with underscore": {TypeMeta: api.TypeMeta{Name: "a_b_c"}},
|
||||
"zero-length name": {ObjectMeta: api.ObjectMeta{Name: ""}},
|
||||
"name > 255 characters": {ObjectMeta: api.ObjectMeta{Name: strings.Repeat("a", 256)}},
|
||||
"name not a DNS subdomain": {ObjectMeta: api.ObjectMeta{Name: "a.b.c."}},
|
||||
"name with underscore": {ObjectMeta: api.ObjectMeta{Name: "a_b_c"}},
|
||||
}
|
||||
for k, v := range errorCases {
|
||||
if errs := ValidateBoundPod(&v); len(errs) == 0 {
|
||||
|
|
|
@ -53,14 +53,16 @@ func init() {
|
|||
}
|
||||
|
||||
type Simple struct {
|
||||
api.TypeMeta `yaml:",inline" json:",inline"`
|
||||
Other string `yaml:"other,omitempty" json:"other,omitempty"`
|
||||
api.TypeMeta `yaml:",inline" json:",inline"`
|
||||
api.ObjectMeta `yaml:"metadata,inline" json:"metadata,inline"`
|
||||
Other string `yaml:"other,omitempty" json:"other,omitempty"`
|
||||
}
|
||||
|
||||
func (*Simple) IsAnAPIObject() {}
|
||||
|
||||
type SimpleList struct {
|
||||
api.TypeMeta `yaml:",inline" json:",inline"`
|
||||
api.ListMeta `yaml:"metadata,inline" json:"metadata,inline"`
|
||||
Items []Simple `yaml:"items,omitempty" json:"items,omitempty"`
|
||||
}
|
||||
|
||||
|
@ -108,7 +110,7 @@ func (storage *SimpleRESTStorage) Delete(ctx api.Context, id string) (<-chan run
|
|||
}
|
||||
return MakeAsync(func() (runtime.Object, error) {
|
||||
if storage.injectedFunction != nil {
|
||||
return storage.injectedFunction(&Simple{TypeMeta: api.TypeMeta{Name: id}})
|
||||
return storage.injectedFunction(&Simple{ObjectMeta: api.ObjectMeta{Name: id}})
|
||||
}
|
||||
return &api.Status{Status: api.StatusSuccess}, nil
|
||||
}), nil
|
||||
|
@ -310,6 +312,8 @@ func TestNonEmptyList(t *testing.T) {
|
|||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
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
|
||||
|
|
|
@ -43,7 +43,7 @@ func TestOperation(t *testing.T) {
|
|||
time.Sleep(time.Millisecond)
|
||||
go func() {
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
c <- &Simple{TypeMeta: api.TypeMeta{Name: "All done"}}
|
||||
c <- &Simple{ObjectMeta: api.ObjectMeta{Name: "All done"}}
|
||||
}()
|
||||
|
||||
if op.expired(time.Now().Add(-time.Minute)) {
|
||||
|
@ -119,7 +119,7 @@ func TestOperationsList(t *testing.T) {
|
|||
client := http.Client{}
|
||||
|
||||
simple := &Simple{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
}
|
||||
data, err := codec.Encode(simple)
|
||||
if err != nil {
|
||||
|
@ -175,7 +175,7 @@ func TestOpGet(t *testing.T) {
|
|||
client := http.Client{}
|
||||
|
||||
simple := &Simple{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
}
|
||||
data, err := codec.Encode(simple)
|
||||
t.Log(string(data))
|
||||
|
|
|
@ -54,13 +54,13 @@ func TestReflector_watchHandler(t *testing.T) {
|
|||
s := NewStore()
|
||||
g := NewReflector(&testLW{}, &api.Pod{}, s)
|
||||
fw := watch.NewFake()
|
||||
s.Add("foo", &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}})
|
||||
s.Add("bar", &api.Pod{TypeMeta: api.TypeMeta{Name: "bar"}})
|
||||
s.Add("foo", &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}})
|
||||
s.Add("bar", &api.Pod{ObjectMeta: api.ObjectMeta{Name: "bar"}})
|
||||
go func() {
|
||||
fw.Add(&api.Service{TypeMeta: api.TypeMeta{Name: "rejected"}})
|
||||
fw.Delete(&api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}})
|
||||
fw.Modify(&api.Pod{TypeMeta: api.TypeMeta{Name: "bar", ResourceVersion: "55"}})
|
||||
fw.Add(&api.Pod{TypeMeta: api.TypeMeta{Name: "baz", ResourceVersion: "32"}})
|
||||
fw.Add(&api.Service{ObjectMeta: api.ObjectMeta{Name: "rejected"}})
|
||||
fw.Delete(&api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}})
|
||||
fw.Modify(&api.Pod{ObjectMeta: api.ObjectMeta{Name: "bar", ResourceVersion: "55"}})
|
||||
fw.Add(&api.Pod{ObjectMeta: api.ObjectMeta{Name: "baz", ResourceVersion: "32"}})
|
||||
fw.Stop()
|
||||
}()
|
||||
var resumeRV string
|
||||
|
@ -118,7 +118,7 @@ func TestReflector_listAndWatch(t *testing.T) {
|
|||
return fw, nil
|
||||
},
|
||||
ListFunc: func() (runtime.Object, error) {
|
||||
return &api.PodList{TypeMeta: api.TypeMeta{ResourceVersion: "1"}}, nil
|
||||
return &api.PodList{ListMeta: api.ListMeta{ResourceVersion: "1"}}, nil
|
||||
},
|
||||
}
|
||||
s := NewFIFO()
|
||||
|
@ -132,7 +132,7 @@ func TestReflector_listAndWatch(t *testing.T) {
|
|||
fw = <-createdFakes
|
||||
}
|
||||
sendingRV := strconv.FormatUint(uint64(i+2), 10)
|
||||
fw.Add(&api.Pod{TypeMeta: api.TypeMeta{Name: id, ResourceVersion: sendingRV}})
|
||||
fw.Add(&api.Pod{ObjectMeta: api.ObjectMeta{Name: id, ResourceVersion: sendingRV}})
|
||||
if sendingRV == "3" {
|
||||
// Inject a failure.
|
||||
fw.Stop()
|
||||
|
@ -158,10 +158,10 @@ func TestReflector_listAndWatch(t *testing.T) {
|
|||
|
||||
func TestReflector_listAndWatchWithErrors(t *testing.T) {
|
||||
mkPod := func(id string, rv string) *api.Pod {
|
||||
return &api.Pod{TypeMeta: api.TypeMeta{Name: id, ResourceVersion: rv}}
|
||||
return &api.Pod{ObjectMeta: api.ObjectMeta{Name: id, ResourceVersion: rv}}
|
||||
}
|
||||
mkList := func(rv string, pods ...*api.Pod) *api.PodList {
|
||||
list := &api.PodList{TypeMeta: api.TypeMeta{ResourceVersion: rv}}
|
||||
list := &api.PodList{ListMeta: api.ListMeta{ResourceVersion: rv}}
|
||||
for _, pod := range pods {
|
||||
list.Items = append(list.Items, *pod)
|
||||
}
|
||||
|
|
|
@ -166,9 +166,11 @@ func TestListPods(t *testing.T) {
|
|||
CurrentState: api.PodState{
|
||||
Status: "Foobar",
|
||||
},
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
"name": "baz",
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
"name": "baz",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -197,9 +199,11 @@ func TestListPodsLabels(t *testing.T) {
|
|||
CurrentState: api.PodState{
|
||||
Status: "Foobar",
|
||||
},
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
"name": "baz",
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
"name": "baz",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -223,9 +227,11 @@ func TestGetPod(t *testing.T) {
|
|||
CurrentState: api.PodState{
|
||||
Status: "Foobar",
|
||||
},
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
"name": "baz",
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
"name": "baz",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -248,9 +254,11 @@ func TestCreatePod(t *testing.T) {
|
|||
CurrentState: api.PodState{
|
||||
Status: "Foobar",
|
||||
},
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
"name": "baz",
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
"name": "baz",
|
||||
},
|
||||
},
|
||||
}
|
||||
c := &testClient{
|
||||
|
@ -266,14 +274,17 @@ func TestCreatePod(t *testing.T) {
|
|||
|
||||
func TestUpdatePod(t *testing.T) {
|
||||
requestPod := &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo", ResourceVersion: "1"},
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
ResourceVersion: "1",
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
"name": "baz",
|
||||
},
|
||||
},
|
||||
CurrentState: api.PodState{
|
||||
Status: "Foobar",
|
||||
},
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
"name": "baz",
|
||||
},
|
||||
}
|
||||
c := &testClient{
|
||||
Request: testRequest{Method: "PUT", Path: "/pods/foo"},
|
||||
|
@ -290,14 +301,16 @@ func TestListControllers(t *testing.T) {
|
|||
Body: &api.ReplicationControllerList{
|
||||
Items: []api.ReplicationController{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
"name": "baz",
|
||||
},
|
||||
},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
Replicas: 2,
|
||||
},
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
"name": "baz",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -314,14 +327,16 @@ func TestGetController(t *testing.T) {
|
|||
Response: Response{
|
||||
StatusCode: 200,
|
||||
Body: &api.ReplicationController{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
"name": "baz",
|
||||
},
|
||||
},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
Replicas: 2,
|
||||
},
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
"name": "baz",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -331,21 +346,23 @@ func TestGetController(t *testing.T) {
|
|||
|
||||
func TestUpdateController(t *testing.T) {
|
||||
requestController := &api.ReplicationController{
|
||||
TypeMeta: api.TypeMeta{Name: "foo", ResourceVersion: "1"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"},
|
||||
}
|
||||
c := &testClient{
|
||||
Request: testRequest{Method: "PUT", Path: "/replicationControllers/foo"},
|
||||
Response: Response{
|
||||
StatusCode: 200,
|
||||
Body: &api.ReplicationController{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
"name": "baz",
|
||||
},
|
||||
},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
Replicas: 2,
|
||||
},
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
"name": "baz",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -364,21 +381,23 @@ func TestDeleteController(t *testing.T) {
|
|||
|
||||
func TestCreateController(t *testing.T) {
|
||||
requestController := &api.ReplicationController{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
}
|
||||
c := &testClient{
|
||||
Request: testRequest{Method: "POST", Path: "/replicationControllers", Body: requestController},
|
||||
Response: Response{
|
||||
StatusCode: 200,
|
||||
Body: &api.ReplicationController{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
"name": "baz",
|
||||
},
|
||||
},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
Replicas: 2,
|
||||
},
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
"name": "baz",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -402,10 +421,12 @@ func TestListServices(t *testing.T) {
|
|||
Body: &api.ServiceList{
|
||||
Items: []api.Service{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "name"},
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
"name": "baz",
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "name",
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
"name": "baz",
|
||||
},
|
||||
},
|
||||
Selector: map[string]string{
|
||||
"one": "two",
|
||||
|
@ -416,6 +437,7 @@ func TestListServices(t *testing.T) {
|
|||
},
|
||||
}
|
||||
receivedServiceList, err := c.Setup().ListServices(api.NewDefaultContext(), labels.Everything())
|
||||
t.Logf("received services: %v %#v", err, receivedServiceList)
|
||||
c.Validate(t, receivedServiceList, err)
|
||||
}
|
||||
|
||||
|
@ -426,10 +448,12 @@ func TestListServicesLabels(t *testing.T) {
|
|||
Body: &api.ServiceList{
|
||||
Items: []api.Service{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "name"},
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
"name": "baz",
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "name",
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
"name": "baz",
|
||||
},
|
||||
},
|
||||
Selector: map[string]string{
|
||||
"one": "two",
|
||||
|
@ -449,7 +473,7 @@ func TestListServicesLabels(t *testing.T) {
|
|||
func TestGetService(t *testing.T) {
|
||||
c := &testClient{
|
||||
Request: testRequest{Method: "GET", Path: "/services/1"},
|
||||
Response: Response{StatusCode: 200, Body: &api.Service{TypeMeta: api.TypeMeta{Name: "service-1"}}},
|
||||
Response: Response{StatusCode: 200, Body: &api.Service{ObjectMeta: api.ObjectMeta{Name: "service-1"}}},
|
||||
}
|
||||
response, err := c.Setup().GetService(api.NewDefaultContext(), "1")
|
||||
c.Validate(t, response, err)
|
||||
|
@ -457,15 +481,15 @@ func TestGetService(t *testing.T) {
|
|||
|
||||
func TestCreateService(t *testing.T) {
|
||||
c := &testClient{
|
||||
Request: testRequest{Method: "POST", Path: "/services", Body: &api.Service{TypeMeta: api.TypeMeta{Name: "service-1"}}},
|
||||
Response: Response{StatusCode: 200, Body: &api.Service{TypeMeta: api.TypeMeta{Name: "service-1"}}},
|
||||
Request: testRequest{Method: "POST", Path: "/services", Body: &api.Service{ObjectMeta: api.ObjectMeta{Name: "service-1"}}},
|
||||
Response: Response{StatusCode: 200, Body: &api.Service{ObjectMeta: api.ObjectMeta{Name: "service-1"}}},
|
||||
}
|
||||
response, err := c.Setup().CreateService(api.NewDefaultContext(), &api.Service{TypeMeta: api.TypeMeta{Name: "service-1"}})
|
||||
response, err := c.Setup().CreateService(api.NewDefaultContext(), &api.Service{ObjectMeta: api.ObjectMeta{Name: "service-1"}})
|
||||
c.Validate(t, response, err)
|
||||
}
|
||||
|
||||
func TestUpdateService(t *testing.T) {
|
||||
svc := &api.Service{TypeMeta: api.TypeMeta{Name: "service-1", ResourceVersion: "1"}}
|
||||
svc := &api.Service{ObjectMeta: api.ObjectMeta{Name: "service-1", ResourceVersion: "1"}}
|
||||
c := &testClient{
|
||||
Request: testRequest{Method: "PUT", Path: "/services/service-1", Body: svc},
|
||||
Response: Response{StatusCode: 200, Body: svc},
|
||||
|
@ -490,8 +514,8 @@ func TestListEndpooints(t *testing.T) {
|
|||
Body: &api.EndpointsList{
|
||||
Items: []api.Endpoints{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "endpoint-1"},
|
||||
Endpoints: []string{"10.245.1.2:8080", "10.245.1.3:8080"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "endpoint-1"},
|
||||
Endpoints: []string{"10.245.1.2:8080", "10.245.1.3:8080"},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -504,7 +528,7 @@ func TestListEndpooints(t *testing.T) {
|
|||
func TestGetEndpoints(t *testing.T) {
|
||||
c := &testClient{
|
||||
Request: testRequest{Method: "GET", Path: "/endpoints/endpoint-1"},
|
||||
Response: Response{StatusCode: 200, Body: &api.Endpoints{TypeMeta: api.TypeMeta{Name: "endpoint-1"}}},
|
||||
Response: Response{StatusCode: 200, Body: &api.Endpoints{ObjectMeta: api.ObjectMeta{Name: "endpoint-1"}}},
|
||||
}
|
||||
response, err := c.Setup().GetEndpoints(api.NewDefaultContext(), "endpoint-1")
|
||||
c.Validate(t, response, err)
|
||||
|
@ -540,7 +564,7 @@ func TestGetServerVersion(t *testing.T) {
|
|||
func TestListMinions(t *testing.T) {
|
||||
c := &testClient{
|
||||
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()
|
||||
c.Validate(t, response, err)
|
||||
|
@ -548,7 +572,7 @@ func TestListMinions(t *testing.T) {
|
|||
|
||||
func TestCreateMinion(t *testing.T) {
|
||||
requestMinion := &api.Minion{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "minion-1",
|
||||
},
|
||||
HostIP: "123.321.456.654",
|
||||
|
|
|
@ -54,7 +54,7 @@ func TestEventf(t *testing.T) {
|
|||
}{
|
||||
{
|
||||
obj: &api.Pod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
SelfLink: "/api/v1beta1/pods/foo",
|
||||
Name: "foo",
|
||||
UID: "bar",
|
||||
|
|
|
@ -72,7 +72,7 @@ func TestDoRequestNewWay(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDoRequestNewWayReader(t *testing.T) {
|
||||
reqObj := &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}
|
||||
reqObj := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}
|
||||
reqBodyExpected, _ := v1beta1.Codec.Encode(reqObj)
|
||||
expectedObj := &api.Service{Port: 12345}
|
||||
expectedBody, _ := v1beta1.Codec.Encode(expectedObj)
|
||||
|
@ -108,7 +108,7 @@ func TestDoRequestNewWayReader(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDoRequestNewWayObj(t *testing.T) {
|
||||
reqObj := &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}
|
||||
reqObj := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}
|
||||
reqBodyExpected, _ := v1beta2.Codec.Encode(reqObj)
|
||||
expectedObj := &api.Service{Port: 12345}
|
||||
expectedBody, _ := v1beta2.Codec.Encode(expectedObj)
|
||||
|
@ -143,7 +143,7 @@ func TestDoRequestNewWayObj(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDoRequestNewWayFile(t *testing.T) {
|
||||
reqObj := &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}
|
||||
reqObj := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}
|
||||
reqBodyExpected, err := v1beta1.Codec.Encode(reqObj)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
|
@ -412,9 +412,9 @@ func TestWatch(t *testing.T) {
|
|||
t watch.EventType
|
||||
obj runtime.Object
|
||||
}{
|
||||
{watch.Added, &api.Pod{TypeMeta: api.TypeMeta{Name: "first"}}},
|
||||
{watch.Modified, &api.Pod{TypeMeta: api.TypeMeta{Name: "second"}}},
|
||||
{watch.Deleted, &api.Pod{TypeMeta: api.TypeMeta{Name: "last"}}},
|
||||
{watch.Added, &api.Pod{ObjectMeta: api.ObjectMeta{Name: "first"}}},
|
||||
{watch.Modified, &api.Pod{ObjectMeta: api.ObjectMeta{Name: "second"}}},
|
||||
{watch.Deleted, &api.Pod{ObjectMeta: api.ObjectMeta{Name: "last"}}},
|
||||
}
|
||||
|
||||
auth := &Config{Username: "user", Password: "pass"}
|
||||
|
|
|
@ -45,8 +45,8 @@ func NewTestEtcdRegistry(client tools.EtcdClient) *etcdregistry.Registry {
|
|||
func TestSyncCreateMinion(t *testing.T) {
|
||||
ctx := api.NewContext()
|
||||
fakeClient := tools.NewFakeEtcdClient(t)
|
||||
m1 := runtime.EncodeOrDie(latest.Codec, &api.Minion{TypeMeta: api.TypeMeta{Name: "m1"}})
|
||||
m2 := runtime.EncodeOrDie(latest.Codec, &api.Minion{TypeMeta: api.TypeMeta{Name: "m2"}})
|
||||
m1 := runtime.EncodeOrDie(latest.Codec, &api.Minion{ObjectMeta: api.ObjectMeta{Name: "m1"}})
|
||||
m2 := runtime.EncodeOrDie(latest.Codec, &api.Minion{ObjectMeta: api.ObjectMeta{Name: "m2"}})
|
||||
fakeClient.Set("/registry/minions/m1", m1, 0)
|
||||
fakeClient.Set("/registry/minions/m2", m2, 0)
|
||||
fakeClient.ExpectNotFoundGet("/registry/minions/m3")
|
||||
|
@ -88,9 +88,9 @@ func TestSyncCreateMinion(t *testing.T) {
|
|||
func TestSyncDeleteMinion(t *testing.T) {
|
||||
ctx := api.NewContext()
|
||||
fakeClient := tools.NewFakeEtcdClient(t)
|
||||
m1 := runtime.EncodeOrDie(latest.Codec, &api.Minion{TypeMeta: api.TypeMeta{Name: "m1"}})
|
||||
m2 := runtime.EncodeOrDie(latest.Codec, &api.Minion{TypeMeta: api.TypeMeta{Name: "m2"}})
|
||||
m3 := runtime.EncodeOrDie(latest.Codec, &api.Minion{TypeMeta: api.TypeMeta{Name: "m3"}})
|
||||
m1 := runtime.EncodeOrDie(latest.Codec, &api.Minion{ObjectMeta: api.ObjectMeta{Name: "m1"}})
|
||||
m2 := runtime.EncodeOrDie(latest.Codec, &api.Minion{ObjectMeta: api.ObjectMeta{Name: "m2"}})
|
||||
m3 := runtime.EncodeOrDie(latest.Codec, &api.Minion{ObjectMeta: api.ObjectMeta{Name: "m3"}})
|
||||
fakeClient.Set("/registry/minions/m1", m1, 0)
|
||||
fakeClient.Set("/registry/minions/m2", m2, 0)
|
||||
fakeClient.Set("/registry/minions/m3", m3, 0)
|
||||
|
|
|
@ -17,7 +17,6 @@ limitations under the License.
|
|||
package controller
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
|
@ -89,7 +88,7 @@ func newPodList(count int) *api.PodList {
|
|||
pods := []api.Pod{}
|
||||
for i := 0; i < count; i++ {
|
||||
pods = append(pods, api.Pod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: fmt.Sprintf("pod%d", i),
|
||||
},
|
||||
})
|
||||
|
@ -183,8 +182,8 @@ func TestCreateReplica(t *testing.T) {
|
|||
}
|
||||
|
||||
controllerSpec := api.ReplicationController{
|
||||
TypeMeta: api.TypeMeta{
|
||||
Kind: "ReplicationController",
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "test",
|
||||
},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
PodTemplate: api.PodTemplate{
|
||||
|
@ -198,8 +197,9 @@ func TestCreateReplica(t *testing.T) {
|
|||
},
|
||||
},
|
||||
Labels: map[string]string{
|
||||
"name": "foo",
|
||||
"type": "production",
|
||||
"name": "foo",
|
||||
"type": "production",
|
||||
"replicationController": "test",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -208,21 +208,19 @@ func TestCreateReplica(t *testing.T) {
|
|||
podControl.createReplica(ctx, controllerSpec)
|
||||
|
||||
expectedPod := api.Pod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
Kind: "Pod",
|
||||
APIVersion: testapi.Version(),
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Labels: controllerSpec.DesiredState.PodTemplate.Labels,
|
||||
},
|
||||
Labels: controllerSpec.DesiredState.PodTemplate.Labels,
|
||||
DesiredState: controllerSpec.DesiredState.PodTemplate.DesiredState,
|
||||
}
|
||||
fakeHandler.ValidateRequest(t, makeURL("/pods?namespace=default"), "POST", nil)
|
||||
actualPod := api.Pod{}
|
||||
if err := json.Unmarshal([]byte(fakeHandler.RequestBody), &actualPod); err != nil {
|
||||
actualPod, err := client.Codec.Decode([]byte(fakeHandler.RequestBody))
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error: %#v", err)
|
||||
}
|
||||
if !reflect.DeepEqual(expectedPod, actualPod) {
|
||||
if !reflect.DeepEqual(&expectedPod, actualPod) {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,8 +38,8 @@ func TestUpdateWithPods(t *testing.T) {
|
|||
fakeClient := client.Fake{
|
||||
Pods: api.PodList{
|
||||
Items: []api.Pod{
|
||||
{TypeMeta: api.TypeMeta{Name: "pod-1"}},
|
||||
{TypeMeta: api.TypeMeta{Name: "pod-2"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "pod-1"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "pod-2"}},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -69,8 +69,8 @@ func TestUpdateWithNewImage(t *testing.T) {
|
|||
fakeClient := client.Fake{
|
||||
Pods: api.PodList{
|
||||
Items: []api.Pod{
|
||||
{TypeMeta: api.TypeMeta{Name: "pod-1"}},
|
||||
{TypeMeta: api.TypeMeta{Name: "pod-2"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "pod-1"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "pod-2"}},
|
||||
},
|
||||
},
|
||||
Ctrl: api.ReplicationController{
|
||||
|
|
|
@ -69,7 +69,8 @@ var testParser = NewParser(map[string]runtime.Object{
|
|||
|
||||
func TestParsePod(t *testing.T) {
|
||||
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{
|
||||
Manifest: api.ContainerManifest{
|
||||
ID: "My manifest",
|
||||
|
@ -86,11 +87,14 @@ func TestParsePod(t *testing.T) {
|
|||
|
||||
func TestParseService(t *testing.T) {
|
||||
DoParseTest(t, "services", &api.Service{
|
||||
TypeMeta: api.TypeMeta{APIVersion: "v1beta1", Name: "my service", Kind: "Service"},
|
||||
Port: 8080,
|
||||
Labels: map[string]string{
|
||||
"area": "staging",
|
||||
TypeMeta: api.TypeMeta{APIVersion: "v1beta1", Kind: "Service"},
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "my service",
|
||||
Labels: map[string]string{
|
||||
"area": "staging",
|
||||
},
|
||||
},
|
||||
Port: 8080,
|
||||
Selector: map[string]string{
|
||||
"area": "staging",
|
||||
},
|
||||
|
@ -99,7 +103,8 @@ func TestParseService(t *testing.T) {
|
|||
|
||||
func TestParseController(t *testing.T) {
|
||||
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{
|
||||
Replicas: 9001,
|
||||
PodTemplate: api.PodTemplate{
|
||||
|
@ -120,8 +125,9 @@ func TestParseController(t *testing.T) {
|
|||
}
|
||||
|
||||
type TestParseType struct {
|
||||
api.TypeMeta `json:",inline" yaml:",inline"`
|
||||
Data string `json:"data" yaml:"data"`
|
||||
api.TypeMeta `json:",inline" yaml:",inline"`
|
||||
api.ObjectMeta `json:"metadata" yaml:"metadata"`
|
||||
Data string `json:"data" yaml:"data"`
|
||||
}
|
||||
|
||||
func (*TestParseType) IsAnAPIObject() {}
|
||||
|
@ -134,7 +140,8 @@ func TestParseCustomType(t *testing.T) {
|
|||
"custom": &TestParseType{},
|
||||
})
|
||||
DoParseTest(t, "custom", &TestParseType{
|
||||
TypeMeta: api.TypeMeta{APIVersion: "", Name: "my custom object", Kind: "TestParseType"},
|
||||
Data: "test data",
|
||||
TypeMeta: api.TypeMeta{APIVersion: "", Kind: "TestParseType"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "my custom object"},
|
||||
Data: "test data",
|
||||
}, v1beta1.Codec, parser)
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ func TestYAMLPrinterPrint(t *testing.T) {
|
|||
}
|
||||
|
||||
obj := &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
}
|
||||
buf.Reset()
|
||||
printer.PrintObj(obj, buf)
|
||||
|
@ -92,7 +92,7 @@ func TestIdentityPrinter(t *testing.T) {
|
|||
}
|
||||
|
||||
obj := &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
}
|
||||
buff.Reset()
|
||||
printer.PrintObj(obj, buff)
|
||||
|
|
|
@ -69,7 +69,7 @@ func testPrinter(t *testing.T, printer ResourcePrinter, unmarshalFunc func(data
|
|||
}
|
||||
|
||||
obj := &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
}
|
||||
buf.Reset()
|
||||
printer.PrintObj(obj, buf)
|
||||
|
|
|
@ -50,7 +50,7 @@ func (s sortedPods) Less(i, j int) bool {
|
|||
|
||||
func CreateValidPod(name, namespace, source string) api.BoundPod {
|
||||
return api.BoundPod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: name,
|
||||
Namespace: namespace,
|
||||
Annotations: map[string]string{kubelet.ConfigSourceAnnotationKey: source},
|
||||
|
@ -158,7 +158,7 @@ func TestInvalidPodFiltered(t *testing.T) {
|
|||
expectPodUpdate(t, ch, CreatePodUpdate(kubelet.ADD, CreateValidPod("foo", "new", "test")))
|
||||
|
||||
// add an invalid update
|
||||
podUpdate = CreatePodUpdate(kubelet.UPDATE, api.BoundPod{TypeMeta: api.TypeMeta{Name: "foo"}})
|
||||
podUpdate = CreatePodUpdate(kubelet.UPDATE, api.BoundPod{ObjectMeta: api.ObjectMeta{Name: "foo"}})
|
||||
channel <- podUpdate
|
||||
expectNoPodUpdate(t, ch)
|
||||
}
|
||||
|
@ -217,7 +217,7 @@ func TestNewPodAddedUpdatedRemoved(t *testing.T) {
|
|||
channel <- podUpdate
|
||||
expectPodUpdate(t, ch, CreatePodUpdate(kubelet.UPDATE, pod))
|
||||
|
||||
podUpdate = CreatePodUpdate(kubelet.REMOVE, api.BoundPod{TypeMeta: api.TypeMeta{Name: "foo", Namespace: "new"}})
|
||||
podUpdate = CreatePodUpdate(kubelet.REMOVE, api.BoundPod{ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: "new"}})
|
||||
channel <- podUpdate
|
||||
expectPodUpdate(t, ch, CreatePodUpdate(kubelet.REMOVE, pod))
|
||||
}
|
||||
|
|
|
@ -44,14 +44,14 @@ func TestEventToPods(t *testing.T) {
|
|||
input: watch.Event{
|
||||
Object: &api.BoundPods{
|
||||
Items: []api.BoundPod{
|
||||
{TypeMeta: api.TypeMeta{Name: "foo"}},
|
||||
{TypeMeta: api.TypeMeta{Name: "bar"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "foo"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "bar"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
pods: []api.BoundPod{
|
||||
{TypeMeta: api.TypeMeta{Name: "foo", Namespace: "default"}, Spec: api.PodSpec{}},
|
||||
{TypeMeta: api.TypeMeta{Name: "bar", Namespace: "default"}, Spec: api.PodSpec{}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: "default"}, Spec: api.PodSpec{}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "bar", Namespace: "default"}, Spec: api.PodSpec{}},
|
||||
},
|
||||
fail: false,
|
||||
},
|
||||
|
@ -59,14 +59,14 @@ func TestEventToPods(t *testing.T) {
|
|||
input: watch.Event{
|
||||
Object: &api.BoundPods{
|
||||
Items: []api.BoundPod{
|
||||
{TypeMeta: api.TypeMeta{Name: "1"}},
|
||||
{TypeMeta: api.TypeMeta{Name: "2", Namespace: "foo"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "1"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "2", Namespace: "foo"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
pods: []api.BoundPod{
|
||||
{TypeMeta: api.TypeMeta{Name: "1", Namespace: "default"}, Spec: api.PodSpec{}},
|
||||
{TypeMeta: api.TypeMeta{Name: "2", Namespace: "foo"}, Spec: api.PodSpec{}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "1", Namespace: "default"}, Spec: api.PodSpec{}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "2", Namespace: "foo"}, Spec: api.PodSpec{}},
|
||||
},
|
||||
fail: false,
|
||||
},
|
||||
|
|
|
@ -52,7 +52,7 @@ func ExampleManifestAndPod(id string) (api.ContainerManifest, api.BoundPod) {
|
|||
},
|
||||
}
|
||||
expectedPod := api.BoundPod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: id,
|
||||
UID: "uid",
|
||||
Namespace: "default",
|
||||
|
@ -118,7 +118,7 @@ func TestReadFromFile(t *testing.T) {
|
|||
case got := <-ch:
|
||||
update := got.(kubelet.PodUpdate)
|
||||
expected := CreatePodUpdate(kubelet.SET, api.BoundPod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: simpleSubdomainSafeHash(file.Name()),
|
||||
UID: simpleSubdomainSafeHash(file.Name()),
|
||||
Namespace: "default",
|
||||
|
|
|
@ -124,7 +124,7 @@ func TestExtractFromHTTP(t *testing.T) {
|
|||
manifests: api.ContainerManifest{Version: "v1beta1", ID: "foo"},
|
||||
expected: CreatePodUpdate(kubelet.SET,
|
||||
api.BoundPod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Namespace: "default",
|
||||
},
|
||||
|
@ -141,14 +141,14 @@ func TestExtractFromHTTP(t *testing.T) {
|
|||
},
|
||||
expected: CreatePodUpdate(kubelet.SET,
|
||||
api.BoundPod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "1",
|
||||
Namespace: "default",
|
||||
},
|
||||
Spec: api.PodSpec{Containers: []api.Container{{Name: "1", Image: "foo"}}},
|
||||
},
|
||||
api.BoundPod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "bar",
|
||||
Namespace: "default",
|
||||
},
|
||||
|
|
|
@ -167,7 +167,7 @@ func TestSyncPodsDoesNothing(t *testing.T) {
|
|||
}
|
||||
err := kubelet.SyncPods([]api.BoundPod{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Namespace: "new",
|
||||
Annotations: map[string]string{ConfigSourceAnnotationKey: "test"},
|
||||
|
@ -213,7 +213,7 @@ func TestSyncPodsCreatesNetAndContainer(t *testing.T) {
|
|||
fakeDocker.ContainerList = []docker.APIContainers{}
|
||||
err := kubelet.SyncPods([]api.BoundPod{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Namespace: "new",
|
||||
Annotations: map[string]string{ConfigSourceAnnotationKey: "test"},
|
||||
|
@ -261,7 +261,7 @@ func TestSyncPodsCreatesNetAndContainerPullsImage(t *testing.T) {
|
|||
fakeDocker.ContainerList = []docker.APIContainers{}
|
||||
err := kubelet.SyncPods([]api.BoundPod{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Namespace: "new",
|
||||
Annotations: map[string]string{ConfigSourceAnnotationKey: "test"},
|
||||
|
@ -306,7 +306,7 @@ func TestSyncPodsWithNetCreatesContainer(t *testing.T) {
|
|||
}
|
||||
err := kubelet.SyncPods([]api.BoundPod{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Namespace: "new",
|
||||
Annotations: map[string]string{ConfigSourceAnnotationKey: "test"},
|
||||
|
@ -347,7 +347,7 @@ func TestSyncPodsWithNetCreatesContainerCallsHandler(t *testing.T) {
|
|||
}
|
||||
err := kubelet.SyncPods([]api.BoundPod{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Namespace: "new",
|
||||
Annotations: map[string]string{ConfigSourceAnnotationKey: "test"},
|
||||
|
@ -400,7 +400,7 @@ func TestSyncPodsDeletesWithNoNetContainer(t *testing.T) {
|
|||
}
|
||||
err := kubelet.SyncPods([]api.BoundPod{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Namespace: "new",
|
||||
Annotations: map[string]string{ConfigSourceAnnotationKey: "test"},
|
||||
|
@ -495,7 +495,7 @@ func TestSyncPodDeletesDuplicate(t *testing.T) {
|
|||
},
|
||||
}
|
||||
err := kubelet.syncPod(&api.BoundPod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "bar",
|
||||
Namespace: "new",
|
||||
Annotations: map[string]string{ConfigSourceAnnotationKey: "test"},
|
||||
|
@ -544,7 +544,7 @@ func TestSyncPodBadHash(t *testing.T) {
|
|||
},
|
||||
}
|
||||
err := kubelet.syncPod(&api.BoundPod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Namespace: "new",
|
||||
Annotations: map[string]string{ConfigSourceAnnotationKey: "test"},
|
||||
|
@ -588,7 +588,7 @@ func TestSyncPodUnhealthy(t *testing.T) {
|
|||
},
|
||||
}
|
||||
err := kubelet.syncPod(&api.BoundPod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Namespace: "new",
|
||||
Annotations: map[string]string{ConfigSourceAnnotationKey: "test"},
|
||||
|
@ -648,7 +648,7 @@ func TestMakeEnvVariables(t *testing.T) {
|
|||
func TestMountExternalVolumes(t *testing.T) {
|
||||
kubelet, _, _ := newTestKubelet(t)
|
||||
pod := api.BoundPod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Namespace: "test",
|
||||
},
|
||||
|
@ -703,7 +703,7 @@ func TestMakeVolumesAndBinds(t *testing.T) {
|
|||
}
|
||||
|
||||
pod := api.BoundPod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "pod",
|
||||
Namespace: "test",
|
||||
},
|
||||
|
@ -991,7 +991,7 @@ func TestRunInContainerNoSuchPod(t *testing.T) {
|
|||
podNamespace := "etcd"
|
||||
containerName := "containerFoo"
|
||||
output, err := kubelet.RunInContainer(
|
||||
GetPodFullName(&api.BoundPod{TypeMeta: api.TypeMeta{Name: podName, Namespace: podNamespace}}),
|
||||
GetPodFullName(&api.BoundPod{ObjectMeta: api.ObjectMeta{Name: podName, Namespace: podNamespace}}),
|
||||
"",
|
||||
containerName,
|
||||
[]string{"ls"})
|
||||
|
@ -1023,7 +1023,7 @@ func TestRunInContainer(t *testing.T) {
|
|||
cmd := []string{"ls"}
|
||||
_, err := kubelet.RunInContainer(
|
||||
GetPodFullName(&api.BoundPod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: podName,
|
||||
Namespace: podNamespace,
|
||||
Annotations: map[string]string{ConfigSourceAnnotationKey: "test"},
|
||||
|
@ -1165,7 +1165,7 @@ func TestSyncPodEventHandlerFails(t *testing.T) {
|
|||
},
|
||||
}
|
||||
err := kubelet.syncPod(&api.BoundPod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Namespace: "new",
|
||||
Annotations: map[string]string{ConfigSourceAnnotationKey: "test"},
|
||||
|
|
|
@ -108,7 +108,7 @@ func TestRunOnce(t *testing.T) {
|
|||
kb.dockerPuller = &dockertools.FakeDockerPuller{}
|
||||
results, err := kb.runOnce([]api.BoundPod{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Namespace: "new",
|
||||
Annotations: map[string]string{ConfigSourceAnnotationKey: "test"},
|
||||
|
|
|
@ -132,7 +132,7 @@ func TestContainer(t *testing.T) {
|
|||
}
|
||||
expectedPods := []api.BoundPod{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "test_manifest",
|
||||
UID: "value",
|
||||
},
|
||||
|
@ -207,7 +207,7 @@ func TestContainers(t *testing.T) {
|
|||
}
|
||||
expectedPods := []api.BoundPod{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "1",
|
||||
},
|
||||
Spec: api.PodSpec{
|
||||
|
@ -227,7 +227,7 @@ func TestContainers(t *testing.T) {
|
|||
},
|
||||
},
|
||||
{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "2",
|
||||
},
|
||||
Spec: api.PodSpec{
|
||||
|
|
|
@ -124,7 +124,7 @@ func TestPodGetPodInfoGetter(t *testing.T) {
|
|||
|
||||
func TestPodUpdateAllContainers(t *testing.T) {
|
||||
pod := api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo", Namespace: api.NamespaceDefault},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: api.NamespaceDefault},
|
||||
CurrentState: api.PodState{
|
||||
Host: "machine",
|
||||
},
|
||||
|
|
|
@ -27,7 +27,7 @@ import (
|
|||
)
|
||||
|
||||
func TestServices(t *testing.T) {
|
||||
service := api.Service{TypeMeta: api.TypeMeta{Name: "bar", ResourceVersion: "2"}}
|
||||
service := api.Service{ObjectMeta: api.ObjectMeta{Name: "bar", ResourceVersion: "2"}}
|
||||
|
||||
fakeWatch := watch.NewFake()
|
||||
fakeClient := &client.Fake{Watch: fakeWatch}
|
||||
|
@ -72,13 +72,13 @@ func TestServices(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestServicesFromZero(t *testing.T) {
|
||||
service := api.Service{TypeMeta: api.TypeMeta{Name: "bar", ResourceVersion: "2"}}
|
||||
service := api.Service{ObjectMeta: api.ObjectMeta{Name: "bar", ResourceVersion: "2"}}
|
||||
|
||||
fakeWatch := watch.NewFake()
|
||||
fakeWatch.Stop()
|
||||
fakeClient := &client.Fake{Watch: fakeWatch}
|
||||
fakeClient.ServiceList = api.ServiceList{
|
||||
TypeMeta: api.TypeMeta{ResourceVersion: "2"},
|
||||
ListMeta: api.ListMeta{ResourceVersion: "2"},
|
||||
Items: []api.Service{
|
||||
service,
|
||||
},
|
||||
|
@ -152,7 +152,7 @@ func TestServicesFromZeroError(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestEndpoints(t *testing.T) {
|
||||
endpoint := api.Endpoints{TypeMeta: api.TypeMeta{Name: "bar", ResourceVersion: "2"}, Endpoints: []string{"127.0.0.1:9000"}}
|
||||
endpoint := api.Endpoints{ObjectMeta: api.ObjectMeta{Name: "bar", ResourceVersion: "2"}, Endpoints: []string{"127.0.0.1:9000"}}
|
||||
|
||||
fakeWatch := watch.NewFake()
|
||||
fakeClient := &client.Fake{Watch: fakeWatch}
|
||||
|
@ -197,13 +197,13 @@ func TestEndpoints(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestEndpointsFromZero(t *testing.T) {
|
||||
endpoint := api.Endpoints{TypeMeta: api.TypeMeta{Name: "bar", ResourceVersion: "2"}, Endpoints: []string{"127.0.0.1:9000"}}
|
||||
endpoint := api.Endpoints{ObjectMeta: api.ObjectMeta{Name: "bar", ResourceVersion: "2"}, Endpoints: []string{"127.0.0.1:9000"}}
|
||||
|
||||
fakeWatch := watch.NewFake()
|
||||
fakeWatch.Stop()
|
||||
fakeClient := &client.Fake{Watch: fakeWatch}
|
||||
fakeClient.EndpointsList = api.EndpointsList{
|
||||
TypeMeta: api.TypeMeta{ResourceVersion: "2"},
|
||||
ListMeta: api.ListMeta{ResourceVersion: "2"},
|
||||
Items: []api.Endpoints{
|
||||
endpoint,
|
||||
},
|
||||
|
|
|
@ -136,7 +136,7 @@ func TestNewServiceAddedAndNotified(t *testing.T) {
|
|||
handler := NewServiceHandlerMock()
|
||||
handler.Wait(1)
|
||||
config.RegisterHandler(handler)
|
||||
serviceUpdate := CreateServiceUpdate(ADD, api.Service{TypeMeta: api.TypeMeta{Name: "foo"}, Port: 10})
|
||||
serviceUpdate := CreateServiceUpdate(ADD, api.Service{ObjectMeta: api.ObjectMeta{Name: "foo"}, Port: 10})
|
||||
channel <- serviceUpdate
|
||||
handler.ValidateServices(t, serviceUpdate.Services)
|
||||
|
||||
|
@ -147,24 +147,24 @@ func TestServiceAddedRemovedSetAndNotified(t *testing.T) {
|
|||
channel := config.Channel("one")
|
||||
handler := NewServiceHandlerMock()
|
||||
config.RegisterHandler(handler)
|
||||
serviceUpdate := CreateServiceUpdate(ADD, api.Service{TypeMeta: api.TypeMeta{Name: "foo"}, Port: 10})
|
||||
serviceUpdate := CreateServiceUpdate(ADD, api.Service{ObjectMeta: api.ObjectMeta{Name: "foo"}, Port: 10})
|
||||
handler.Wait(1)
|
||||
channel <- serviceUpdate
|
||||
handler.ValidateServices(t, serviceUpdate.Services)
|
||||
|
||||
serviceUpdate2 := CreateServiceUpdate(ADD, api.Service{TypeMeta: api.TypeMeta{Name: "bar"}, Port: 20})
|
||||
serviceUpdate2 := CreateServiceUpdate(ADD, api.Service{ObjectMeta: api.ObjectMeta{Name: "bar"}, Port: 20})
|
||||
handler.Wait(1)
|
||||
channel <- serviceUpdate2
|
||||
services := []api.Service{serviceUpdate2.Services[0], serviceUpdate.Services[0]}
|
||||
handler.ValidateServices(t, services)
|
||||
|
||||
serviceUpdate3 := CreateServiceUpdate(REMOVE, api.Service{TypeMeta: api.TypeMeta{Name: "foo"}})
|
||||
serviceUpdate3 := CreateServiceUpdate(REMOVE, api.Service{ObjectMeta: api.ObjectMeta{Name: "foo"}})
|
||||
handler.Wait(1)
|
||||
channel <- serviceUpdate3
|
||||
services = []api.Service{serviceUpdate2.Services[0]}
|
||||
handler.ValidateServices(t, services)
|
||||
|
||||
serviceUpdate4 := CreateServiceUpdate(SET, api.Service{TypeMeta: api.TypeMeta{Name: "foobar"}, Port: 99})
|
||||
serviceUpdate4 := CreateServiceUpdate(SET, api.Service{ObjectMeta: api.ObjectMeta{Name: "foobar"}, Port: 99})
|
||||
handler.Wait(1)
|
||||
channel <- serviceUpdate4
|
||||
services = []api.Service{serviceUpdate4.Services[0]}
|
||||
|
@ -180,8 +180,8 @@ func TestNewMultipleSourcesServicesAddedAndNotified(t *testing.T) {
|
|||
}
|
||||
handler := NewServiceHandlerMock()
|
||||
config.RegisterHandler(handler)
|
||||
serviceUpdate1 := CreateServiceUpdate(ADD, api.Service{TypeMeta: api.TypeMeta{Name: "foo"}, Port: 10})
|
||||
serviceUpdate2 := CreateServiceUpdate(ADD, api.Service{TypeMeta: api.TypeMeta{Name: "bar"}, Port: 20})
|
||||
serviceUpdate1 := CreateServiceUpdate(ADD, api.Service{ObjectMeta: api.ObjectMeta{Name: "foo"}, Port: 10})
|
||||
serviceUpdate2 := CreateServiceUpdate(ADD, api.Service{ObjectMeta: api.ObjectMeta{Name: "bar"}, Port: 20})
|
||||
handler.Wait(2)
|
||||
channelOne <- serviceUpdate1
|
||||
channelTwo <- serviceUpdate2
|
||||
|
@ -197,8 +197,8 @@ func TestNewMultipleSourcesServicesMultipleHandlersAddedAndNotified(t *testing.T
|
|||
handler2 := NewServiceHandlerMock()
|
||||
config.RegisterHandler(handler)
|
||||
config.RegisterHandler(handler2)
|
||||
serviceUpdate1 := CreateServiceUpdate(ADD, api.Service{TypeMeta: api.TypeMeta{Name: "foo"}, Port: 10})
|
||||
serviceUpdate2 := CreateServiceUpdate(ADD, api.Service{TypeMeta: api.TypeMeta{Name: "bar"}, Port: 20})
|
||||
serviceUpdate1 := CreateServiceUpdate(ADD, api.Service{ObjectMeta: api.ObjectMeta{Name: "foo"}, Port: 10})
|
||||
serviceUpdate2 := CreateServiceUpdate(ADD, api.Service{ObjectMeta: api.ObjectMeta{Name: "bar"}, Port: 20})
|
||||
handler.Wait(2)
|
||||
handler2.Wait(2)
|
||||
channelOne <- serviceUpdate1
|
||||
|
@ -217,12 +217,12 @@ func TestNewMultipleSourcesEndpointsMultipleHandlersAddedAndNotified(t *testing.
|
|||
config.RegisterHandler(handler)
|
||||
config.RegisterHandler(handler2)
|
||||
endpointsUpdate1 := CreateEndpointsUpdate(ADD, api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Endpoints: []string{"endpoint1", "endpoint2"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Endpoints: []string{"endpoint1", "endpoint2"},
|
||||
})
|
||||
endpointsUpdate2 := CreateEndpointsUpdate(ADD, api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{Name: "bar"},
|
||||
Endpoints: []string{"endpoint3", "endpoint4"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "bar"},
|
||||
Endpoints: []string{"endpoint3", "endpoint4"},
|
||||
})
|
||||
handler.Wait(2)
|
||||
handler2.Wait(2)
|
||||
|
@ -243,12 +243,12 @@ func TestNewMultipleSourcesEndpointsMultipleHandlersAddRemoveSetAndNotified(t *t
|
|||
config.RegisterHandler(handler)
|
||||
config.RegisterHandler(handler2)
|
||||
endpointsUpdate1 := CreateEndpointsUpdate(ADD, api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Endpoints: []string{"endpoint1", "endpoint2"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Endpoints: []string{"endpoint1", "endpoint2"},
|
||||
})
|
||||
endpointsUpdate2 := CreateEndpointsUpdate(ADD, api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{Name: "bar"},
|
||||
Endpoints: []string{"endpoint3", "endpoint4"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "bar"},
|
||||
Endpoints: []string{"endpoint3", "endpoint4"},
|
||||
})
|
||||
handler.Wait(2)
|
||||
handler2.Wait(2)
|
||||
|
@ -261,8 +261,8 @@ func TestNewMultipleSourcesEndpointsMultipleHandlersAddRemoveSetAndNotified(t *t
|
|||
|
||||
// Add one more
|
||||
endpointsUpdate3 := CreateEndpointsUpdate(ADD, api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{Name: "foobar"},
|
||||
Endpoints: []string{"endpoint5", "endpoint6"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foobar"},
|
||||
Endpoints: []string{"endpoint5", "endpoint6"},
|
||||
})
|
||||
handler.Wait(1)
|
||||
handler2.Wait(1)
|
||||
|
@ -273,8 +273,8 @@ func TestNewMultipleSourcesEndpointsMultipleHandlersAddRemoveSetAndNotified(t *t
|
|||
|
||||
// Update the "foo" service with new endpoints
|
||||
endpointsUpdate1 = CreateEndpointsUpdate(ADD, api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Endpoints: []string{"endpoint77"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Endpoints: []string{"endpoint77"},
|
||||
})
|
||||
handler.Wait(1)
|
||||
handler2.Wait(1)
|
||||
|
@ -284,7 +284,7 @@ func TestNewMultipleSourcesEndpointsMultipleHandlersAddRemoveSetAndNotified(t *t
|
|||
handler2.ValidateEndpoints(t, endpoints)
|
||||
|
||||
// Remove "bar" service
|
||||
endpointsUpdate2 = CreateEndpointsUpdate(REMOVE, api.Endpoints{TypeMeta: api.TypeMeta{Name: "bar"}})
|
||||
endpointsUpdate2 = CreateEndpointsUpdate(REMOVE, api.Endpoints{ObjectMeta: api.ObjectMeta{Name: "bar"}})
|
||||
handler.Wait(1)
|
||||
handler2.Wait(1)
|
||||
channelTwo <- endpointsUpdate2
|
||||
|
|
|
@ -163,8 +163,8 @@ func TestTCPProxy(t *testing.T) {
|
|||
lb := NewLoadBalancerRR()
|
||||
lb.OnUpdate([]api.Endpoints{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", tcpServerPort)},
|
||||
ObjectMeta: api.ObjectMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", tcpServerPort)},
|
||||
},
|
||||
})
|
||||
|
||||
|
@ -181,8 +181,8 @@ func TestUDPProxy(t *testing.T) {
|
|||
lb := NewLoadBalancerRR()
|
||||
lb.OnUpdate([]api.Endpoints{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", udpServerPort)},
|
||||
ObjectMeta: api.ObjectMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", udpServerPort)},
|
||||
},
|
||||
})
|
||||
|
||||
|
@ -208,8 +208,8 @@ func TestTCPProxyStop(t *testing.T) {
|
|||
lb := NewLoadBalancerRR()
|
||||
lb.OnUpdate([]api.Endpoints{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", tcpServerPort)},
|
||||
ObjectMeta: api.ObjectMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", tcpServerPort)},
|
||||
},
|
||||
})
|
||||
|
||||
|
@ -236,8 +236,8 @@ func TestUDPProxyStop(t *testing.T) {
|
|||
lb := NewLoadBalancerRR()
|
||||
lb.OnUpdate([]api.Endpoints{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", udpServerPort)},
|
||||
ObjectMeta: api.ObjectMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", udpServerPort)},
|
||||
},
|
||||
})
|
||||
|
||||
|
@ -264,8 +264,8 @@ func TestTCPProxyUpdateDelete(t *testing.T) {
|
|||
lb := NewLoadBalancerRR()
|
||||
lb.OnUpdate([]api.Endpoints{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", tcpServerPort)},
|
||||
ObjectMeta: api.ObjectMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", tcpServerPort)},
|
||||
},
|
||||
})
|
||||
|
||||
|
@ -291,8 +291,8 @@ func TestUDPProxyUpdateDelete(t *testing.T) {
|
|||
lb := NewLoadBalancerRR()
|
||||
lb.OnUpdate([]api.Endpoints{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", udpServerPort)},
|
||||
ObjectMeta: api.ObjectMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", udpServerPort)},
|
||||
},
|
||||
})
|
||||
|
||||
|
@ -318,8 +318,8 @@ func TestTCPProxyUpdateDeleteUpdate(t *testing.T) {
|
|||
lb := NewLoadBalancerRR()
|
||||
lb.OnUpdate([]api.Endpoints{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", tcpServerPort)},
|
||||
ObjectMeta: api.ObjectMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", tcpServerPort)},
|
||||
},
|
||||
})
|
||||
|
||||
|
@ -340,7 +340,7 @@ func TestTCPProxyUpdateDeleteUpdate(t *testing.T) {
|
|||
t.Fatalf(err.Error())
|
||||
}
|
||||
p.OnUpdate([]api.Service{
|
||||
{TypeMeta: api.TypeMeta{Name: "echo"}, Port: svcInfo.proxyPort, ProxyPort: svcInfo.proxyPort, Protocol: "TCP"},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "echo"}, Port: svcInfo.proxyPort, ProxyPort: svcInfo.proxyPort, Protocol: "TCP"},
|
||||
})
|
||||
testEchoTCP(t, "127.0.0.1", svcInfo.proxyPort)
|
||||
}
|
||||
|
@ -349,8 +349,8 @@ func TestUDPProxyUpdateDeleteUpdate(t *testing.T) {
|
|||
lb := NewLoadBalancerRR()
|
||||
lb.OnUpdate([]api.Endpoints{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", udpServerPort)},
|
||||
ObjectMeta: api.ObjectMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", udpServerPort)},
|
||||
},
|
||||
})
|
||||
|
||||
|
@ -371,7 +371,7 @@ func TestUDPProxyUpdateDeleteUpdate(t *testing.T) {
|
|||
t.Fatalf(err.Error())
|
||||
}
|
||||
p.OnUpdate([]api.Service{
|
||||
{TypeMeta: api.TypeMeta{Name: "echo"}, Port: svcInfo.proxyPort, ProxyPort: svcInfo.proxyPort, Protocol: "UDP"},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "echo"}, Port: svcInfo.proxyPort, ProxyPort: svcInfo.proxyPort, Protocol: "UDP"},
|
||||
})
|
||||
testEchoUDP(t, "127.0.0.1", svcInfo.proxyPort)
|
||||
}
|
||||
|
@ -380,8 +380,8 @@ func TestTCPProxyUpdatePort(t *testing.T) {
|
|||
lb := NewLoadBalancerRR()
|
||||
lb.OnUpdate([]api.Endpoints{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", tcpServerPort)},
|
||||
ObjectMeta: api.ObjectMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", tcpServerPort)},
|
||||
},
|
||||
})
|
||||
|
||||
|
@ -406,7 +406,7 @@ func TestTCPProxyUpdatePort(t *testing.T) {
|
|||
t.Errorf("expected difference, got %d %d", newPort, svcInfo.proxyPort)
|
||||
}
|
||||
p.OnUpdate([]api.Service{
|
||||
{TypeMeta: api.TypeMeta{Name: "echo"}, Port: newPort, ProxyPort: newPort, Protocol: "TCP"},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "echo"}, Port: newPort, ProxyPort: newPort, Protocol: "TCP"},
|
||||
})
|
||||
if err := waitForClosedPortTCP(p, svcInfo.proxyPort); err != nil {
|
||||
t.Fatalf(err.Error())
|
||||
|
@ -425,8 +425,8 @@ func TestUDPProxyUpdatePort(t *testing.T) {
|
|||
lb := NewLoadBalancerRR()
|
||||
lb.OnUpdate([]api.Endpoints{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", udpServerPort)},
|
||||
ObjectMeta: api.ObjectMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", udpServerPort)},
|
||||
},
|
||||
})
|
||||
|
||||
|
@ -451,7 +451,7 @@ func TestUDPProxyUpdatePort(t *testing.T) {
|
|||
t.Errorf("expected difference, got %d %d", newPort, svcInfo.proxyPort)
|
||||
}
|
||||
p.OnUpdate([]api.Service{
|
||||
{TypeMeta: api.TypeMeta{Name: "echo"}, Port: newPort, ProxyPort: newPort, Protocol: "UDP"},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "echo"}, Port: newPort, ProxyPort: newPort, Protocol: "UDP"},
|
||||
})
|
||||
if err := waitForClosedPortUDP(p, svcInfo.proxyPort); err != nil {
|
||||
t.Fatalf(err.Error())
|
||||
|
|
|
@ -86,8 +86,8 @@ func TestLoadBalanceWorksWithSingleEndpoint(t *testing.T) {
|
|||
}
|
||||
endpoints := make([]api.Endpoints, 1)
|
||||
endpoints[0] = api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Endpoints: []string{"endpoint1:40"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Endpoints: []string{"endpoint1:40"},
|
||||
}
|
||||
loadBalancer.OnUpdate(endpoints)
|
||||
expectEndpoint(t, loadBalancer, "foo", "endpoint1:40")
|
||||
|
@ -104,8 +104,8 @@ func TestLoadBalanceWorksWithMultipleEndpoints(t *testing.T) {
|
|||
}
|
||||
endpoints := make([]api.Endpoints, 1)
|
||||
endpoints[0] = api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Endpoints: []string{"endpoint:1", "endpoint:2", "endpoint:3"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Endpoints: []string{"endpoint:1", "endpoint:2", "endpoint:3"},
|
||||
}
|
||||
loadBalancer.OnUpdate(endpoints)
|
||||
expectEndpoint(t, loadBalancer, "foo", "endpoint:1")
|
||||
|
@ -122,8 +122,8 @@ func TestLoadBalanceWorksWithMultipleEndpointsAndUpdates(t *testing.T) {
|
|||
}
|
||||
endpoints := make([]api.Endpoints, 1)
|
||||
endpoints[0] = api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Endpoints: []string{"endpoint:1", "endpoint:2", "endpoint:3"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Endpoints: []string{"endpoint:1", "endpoint:2", "endpoint:3"},
|
||||
}
|
||||
loadBalancer.OnUpdate(endpoints)
|
||||
expectEndpoint(t, loadBalancer, "foo", "endpoint:1")
|
||||
|
@ -133,7 +133,7 @@ func TestLoadBalanceWorksWithMultipleEndpointsAndUpdates(t *testing.T) {
|
|||
expectEndpoint(t, loadBalancer, "foo", "endpoint:2")
|
||||
// Then update the configuration with one fewer endpoints, make sure
|
||||
// we start in the beginning again
|
||||
endpoints[0] = api.Endpoints{TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
endpoints[0] = api.Endpoints{ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Endpoints: []string{"endpoint:8", "endpoint:9"},
|
||||
}
|
||||
loadBalancer.OnUpdate(endpoints)
|
||||
|
@ -142,7 +142,7 @@ func TestLoadBalanceWorksWithMultipleEndpointsAndUpdates(t *testing.T) {
|
|||
expectEndpoint(t, loadBalancer, "foo", "endpoint:8")
|
||||
expectEndpoint(t, loadBalancer, "foo", "endpoint:9")
|
||||
// Clear endpoints
|
||||
endpoints[0] = api.Endpoints{TypeMeta: api.TypeMeta{Name: "foo"}, Endpoints: []string{}}
|
||||
endpoints[0] = api.Endpoints{ObjectMeta: api.ObjectMeta{Name: "foo"}, Endpoints: []string{}}
|
||||
loadBalancer.OnUpdate(endpoints)
|
||||
|
||||
endpoint, err = loadBalancer.NextEndpoint("foo", nil)
|
||||
|
@ -159,12 +159,12 @@ func TestLoadBalanceWorksWithServiceRemoval(t *testing.T) {
|
|||
}
|
||||
endpoints := make([]api.Endpoints, 2)
|
||||
endpoints[0] = api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Endpoints: []string{"endpoint:1", "endpoint:2", "endpoint:3"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Endpoints: []string{"endpoint:1", "endpoint:2", "endpoint:3"},
|
||||
}
|
||||
endpoints[1] = api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{Name: "bar"},
|
||||
Endpoints: []string{"endpoint:4", "endpoint:5"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "bar"},
|
||||
Endpoints: []string{"endpoint:4", "endpoint:5"},
|
||||
}
|
||||
loadBalancer.OnUpdate(endpoints)
|
||||
expectEndpoint(t, loadBalancer, "foo", "endpoint:1")
|
||||
|
|
|
@ -51,7 +51,7 @@ func TestListControllersError(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestListEmptyControllerList(t *testing.T) {
|
||||
mockRegistry := registrytest.ControllerRegistry{nil, &api.ReplicationControllerList{TypeMeta: api.TypeMeta{ResourceVersion: "1"}}}
|
||||
mockRegistry := registrytest.ControllerRegistry{nil, &api.ReplicationControllerList{ListMeta: api.ListMeta{ResourceVersion: "1"}}}
|
||||
storage := REST{
|
||||
registry: &mockRegistry,
|
||||
}
|
||||
|
@ -74,12 +74,12 @@ func TestListControllerList(t *testing.T) {
|
|||
Controllers: &api.ReplicationControllerList{
|
||||
Items: []api.ReplicationController{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
},
|
||||
},
|
||||
{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "bar",
|
||||
},
|
||||
},
|
||||
|
@ -113,7 +113,7 @@ func TestControllerDecode(t *testing.T) {
|
|||
registry: &mockRegistry,
|
||||
}
|
||||
controller := &api.ReplicationController{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
},
|
||||
}
|
||||
|
@ -134,8 +134,11 @@ func TestControllerDecode(t *testing.T) {
|
|||
|
||||
func TestControllerParsing(t *testing.T) {
|
||||
expectedController := api.ReplicationController{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "nginxController",
|
||||
Labels: map[string]string{
|
||||
"name": "nginx",
|
||||
},
|
||||
},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
Replicas: 2,
|
||||
|
@ -163,9 +166,6 @@ func TestControllerParsing(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
Labels: map[string]string{
|
||||
"name": "nginx",
|
||||
},
|
||||
}
|
||||
file, err := ioutil.TempFile("", "controller")
|
||||
fileName := file.Name()
|
||||
|
@ -225,8 +225,10 @@ func TestCreateController(t *testing.T) {
|
|||
Pods: &api.PodList{
|
||||
Items: []api.Pod{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Labels: map[string]string{"a": "b"},
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Labels: map[string]string{"a": "b"},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -237,7 +239,7 @@ func TestCreateController(t *testing.T) {
|
|||
pollPeriod: time.Millisecond * 1,
|
||||
}
|
||||
controller := &api.ReplicationController{
|
||||
TypeMeta: api.TypeMeta{Name: "test"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "test"},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
Replicas: 2,
|
||||
ReplicaSelector: map[string]string{"a": "b"},
|
||||
|
@ -270,13 +272,13 @@ func TestControllerStorageValidatesCreate(t *testing.T) {
|
|||
}
|
||||
failureCases := map[string]api.ReplicationController{
|
||||
"empty ID": {
|
||||
TypeMeta: api.TypeMeta{Name: ""},
|
||||
ObjectMeta: api.ObjectMeta{Name: ""},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
ReplicaSelector: map[string]string{"bar": "baz"},
|
||||
},
|
||||
},
|
||||
"empty selector": {
|
||||
TypeMeta: api.TypeMeta{Name: "abc"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc"},
|
||||
DesiredState: api.ReplicationControllerState{},
|
||||
},
|
||||
}
|
||||
|
@ -301,13 +303,13 @@ func TestControllerStorageValidatesUpdate(t *testing.T) {
|
|||
}
|
||||
failureCases := map[string]api.ReplicationController{
|
||||
"empty ID": {
|
||||
TypeMeta: api.TypeMeta{Name: ""},
|
||||
ObjectMeta: api.ObjectMeta{Name: ""},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
ReplicaSelector: map[string]string{"bar": "baz"},
|
||||
},
|
||||
},
|
||||
"empty selector": {
|
||||
TypeMeta: api.TypeMeta{Name: "abc"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc"},
|
||||
DesiredState: api.ReplicationControllerState{},
|
||||
},
|
||||
}
|
||||
|
@ -338,8 +340,8 @@ func TestFillCurrentState(t *testing.T) {
|
|||
fakeLister := fakePodLister{
|
||||
l: api.PodList{
|
||||
Items: []api.Pod{
|
||||
{TypeMeta: api.TypeMeta{Name: "foo"}},
|
||||
{TypeMeta: api.TypeMeta{Name: "bar"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "foo"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "bar"}},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -368,7 +370,7 @@ func TestFillCurrentState(t *testing.T) {
|
|||
func TestCreateControllerWithConflictingNamespace(t *testing.T) {
|
||||
storage := REST{}
|
||||
controller := &api.ReplicationController{
|
||||
TypeMeta: api.TypeMeta{Name: "test", Namespace: "not-default"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "test", Namespace: "not-default"},
|
||||
}
|
||||
|
||||
ctx := api.NewDefaultContext()
|
||||
|
@ -386,7 +388,7 @@ func TestCreateControllerWithConflictingNamespace(t *testing.T) {
|
|||
func TestUpdateControllerWithConflictingNamespace(t *testing.T) {
|
||||
storage := REST{}
|
||||
controller := &api.ReplicationController{
|
||||
TypeMeta: api.TypeMeta{Name: "test", Namespace: "not-default"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "test", Namespace: "not-default"},
|
||||
}
|
||||
|
||||
ctx := api.NewDefaultContext()
|
||||
|
|
|
@ -29,8 +29,8 @@ import (
|
|||
func TestGetEndpoints(t *testing.T) {
|
||||
registry := ®istrytest.ServiceRegistry{
|
||||
Endpoints: api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Endpoints: []string{"127.0.0.1:9000"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Endpoints: []string{"127.0.0.1:9000"},
|
||||
},
|
||||
}
|
||||
storage := NewREST(registry)
|
||||
|
@ -59,7 +59,7 @@ func TestGetEndpointsMissingService(t *testing.T) {
|
|||
// returns empty endpoints
|
||||
registry.Err = nil
|
||||
registry.Service = &api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
}
|
||||
obj, err := storage.Get(ctx, "foo")
|
||||
if err != nil {
|
||||
|
@ -74,10 +74,10 @@ func TestEndpointsRegistryList(t *testing.T) {
|
|||
registry := registrytest.NewServiceRegistry()
|
||||
storage := NewREST(registry)
|
||||
registry.EndpointsList = api.EndpointsList{
|
||||
TypeMeta: api.TypeMeta{ResourceVersion: "1"},
|
||||
ListMeta: api.ListMeta{ResourceVersion: "1"},
|
||||
Items: []api.Endpoints{
|
||||
{TypeMeta: api.TypeMeta{Name: "foo"}},
|
||||
{TypeMeta: api.TypeMeta{Name: "bar"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "foo"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "bar"}},
|
||||
},
|
||||
}
|
||||
ctx := api.NewContext()
|
||||
|
|
|
@ -87,8 +87,8 @@ func TestEtcdGetPodDifferentNamespace(t *testing.T) {
|
|||
key1, _ := makePodKey(ctx1, "foo")
|
||||
key2, _ := makePodKey(ctx2, "foo")
|
||||
|
||||
fakeClient.Set(key1, runtime.EncodeOrDie(latest.Codec, &api.Pod{TypeMeta: api.TypeMeta{Namespace: "default", Name: "foo"}}), 0)
|
||||
fakeClient.Set(key2, runtime.EncodeOrDie(latest.Codec, &api.Pod{TypeMeta: api.TypeMeta{Namespace: "other", Name: "foo"}}), 0)
|
||||
fakeClient.Set(key1, runtime.EncodeOrDie(latest.Codec, &api.Pod{ObjectMeta: api.ObjectMeta{Namespace: "default", Name: "foo"}}), 0)
|
||||
fakeClient.Set(key2, runtime.EncodeOrDie(latest.Codec, &api.Pod{ObjectMeta: api.ObjectMeta{Namespace: "other", Name: "foo"}}), 0)
|
||||
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
|
||||
|
@ -120,7 +120,7 @@ func TestEtcdGetPod(t *testing.T) {
|
|||
ctx := api.NewDefaultContext()
|
||||
fakeClient := tools.NewFakeEtcdClient(t)
|
||||
key, _ := makePodKey(ctx, "foo")
|
||||
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}), 0)
|
||||
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}), 0)
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
pod, err := registry.GetPod(ctx, "foo")
|
||||
if err != nil {
|
||||
|
@ -163,7 +163,7 @@ func TestEtcdCreatePod(t *testing.T) {
|
|||
fakeClient.Set("/registry/nodes/machine/boundpods", runtime.EncodeOrDie(latest.Codec, &api.BoundPods{}), 0)
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
err := registry.CreatePod(ctx, &api.Pod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
},
|
||||
DesiredState: api.PodState{
|
||||
|
@ -181,7 +181,7 @@ func TestEtcdCreatePod(t *testing.T) {
|
|||
}
|
||||
|
||||
// Suddenly, a wild scheduler appears:
|
||||
err = registry.ApplyBinding(ctx, &api.Binding{PodID: "foo", Host: "machine", TypeMeta: api.TypeMeta{Namespace: api.NamespaceDefault}})
|
||||
err = registry.ApplyBinding(ctx, &api.Binding{PodID: "foo", Host: "machine", ObjectMeta: api.ObjectMeta{Namespace: api.NamespaceDefault}})
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ func TestEtcdCreatePodFailsWithoutNamespace(t *testing.T) {
|
|||
fakeClient.TestIndex = true
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
err := registry.CreatePod(api.NewContext(), &api.Pod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
},
|
||||
DesiredState: api.PodState{
|
||||
|
@ -242,14 +242,14 @@ func TestEtcdCreatePodAlreadyExisting(t *testing.T) {
|
|||
fakeClient.Data[key] = tools.EtcdResponseWithError{
|
||||
R: &etcd.Response{
|
||||
Node: &etcd.Node{
|
||||
Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}),
|
||||
Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}),
|
||||
},
|
||||
},
|
||||
E: nil,
|
||||
}
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
err := registry.CreatePod(ctx, &api.Pod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
},
|
||||
})
|
||||
|
@ -277,7 +277,7 @@ func TestEtcdCreatePodWithContainersError(t *testing.T) {
|
|||
}
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
err := registry.CreatePod(ctx, &api.Pod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
},
|
||||
})
|
||||
|
@ -319,7 +319,7 @@ func TestEtcdCreatePodWithContainersNotFound(t *testing.T) {
|
|||
}
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
err := registry.CreatePod(ctx, &api.Pod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
},
|
||||
DesiredState: api.PodState{
|
||||
|
@ -381,12 +381,12 @@ func TestEtcdCreatePodWithExistingContainers(t *testing.T) {
|
|||
}
|
||||
fakeClient.Set("/registry/nodes/machine/boundpods", runtime.EncodeOrDie(latest.Codec, &api.BoundPods{
|
||||
Items: []api.BoundPod{
|
||||
{TypeMeta: api.TypeMeta{Name: "bar"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "bar"}},
|
||||
},
|
||||
}), 0)
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
err := registry.CreatePod(ctx, &api.Pod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
},
|
||||
DesiredState: api.PodState{
|
||||
|
@ -448,9 +448,12 @@ func TestEtcdUpdatePodNotFound(t *testing.T) {
|
|||
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
podIn := api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo", ResourceVersion: "1"},
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
ResourceVersion: "1",
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
},
|
||||
}
|
||||
err := registry.UpdatePod(ctx, &podIn)
|
||||
|
@ -466,14 +469,17 @@ func TestEtcdUpdatePodNotScheduled(t *testing.T) {
|
|||
|
||||
key, _ := makePodKey(ctx, "foo")
|
||||
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
}), 1)
|
||||
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
podIn := api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo", ResourceVersion: "1"},
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
ResourceVersion: "1",
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
},
|
||||
}
|
||||
err := registry.UpdatePod(ctx, &podIn)
|
||||
|
@ -498,7 +504,7 @@ func TestEtcdUpdatePodScheduled(t *testing.T) {
|
|||
|
||||
key, _ := makePodKey(ctx, "foo")
|
||||
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
DesiredState: api.PodState{
|
||||
Host: "machine",
|
||||
Manifest: api.ContainerManifest{
|
||||
|
@ -536,7 +542,13 @@ func TestEtcdUpdatePodScheduled(t *testing.T) {
|
|||
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
podIn := api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo", ResourceVersion: "1"},
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
ResourceVersion: "1",
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
},
|
||||
DesiredState: api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
ID: "foo",
|
||||
|
@ -547,9 +559,6 @@ func TestEtcdUpdatePodScheduled(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
}
|
||||
err := registry.UpdatePod(ctx, &podIn)
|
||||
if err != nil {
|
||||
|
@ -584,12 +593,12 @@ func TestEtcdDeletePod(t *testing.T) {
|
|||
|
||||
key, _ := makePodKey(ctx, "foo")
|
||||
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
DesiredState: api.PodState{Host: "machine"},
|
||||
}), 0)
|
||||
fakeClient.Set("/registry/nodes/machine/boundpods", runtime.EncodeOrDie(latest.Codec, &api.BoundPods{
|
||||
Items: []api.BoundPod{
|
||||
{TypeMeta: api.TypeMeta{Name: "foo"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "foo"}},
|
||||
},
|
||||
}), 0)
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
|
@ -620,13 +629,13 @@ func TestEtcdDeletePodMultipleContainers(t *testing.T) {
|
|||
fakeClient.TestIndex = true
|
||||
key, _ := makePodKey(ctx, "foo")
|
||||
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
DesiredState: api.PodState{Host: "machine"},
|
||||
}), 0)
|
||||
fakeClient.Set("/registry/nodes/machine/boundpods", runtime.EncodeOrDie(latest.Codec, &api.BoundPods{
|
||||
Items: []api.BoundPod{
|
||||
{TypeMeta: api.TypeMeta{Name: "foo"}},
|
||||
{TypeMeta: api.TypeMeta{Name: "bar"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "foo"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "bar"}},
|
||||
},
|
||||
}), 0)
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
|
@ -706,13 +715,13 @@ func TestEtcdListPods(t *testing.T) {
|
|||
Nodes: []*etcd.Node{
|
||||
{
|
||||
Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
DesiredState: api.PodState{Host: "machine"},
|
||||
}),
|
||||
},
|
||||
{
|
||||
Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "bar"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "bar"},
|
||||
DesiredState: api.PodState{Host: "machine"},
|
||||
}),
|
||||
},
|
||||
|
@ -783,10 +792,10 @@ func TestEtcdListControllers(t *testing.T) {
|
|||
Node: &etcd.Node{
|
||||
Nodes: []*etcd.Node{
|
||||
{
|
||||
Value: runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{TypeMeta: api.TypeMeta{Name: "foo"}}),
|
||||
Value: runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{ObjectMeta: api.ObjectMeta{Name: "foo"}}),
|
||||
},
|
||||
{
|
||||
Value: runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{TypeMeta: api.TypeMeta{Name: "bar"}}),
|
||||
Value: runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{ObjectMeta: api.ObjectMeta{Name: "bar"}}),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -814,8 +823,8 @@ func TestEtcdGetControllerDifferentNamespace(t *testing.T) {
|
|||
key1, _ := makeControllerKey(ctx1, "foo")
|
||||
key2, _ := makeControllerKey(ctx2, "foo")
|
||||
|
||||
fakeClient.Set(key1, runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{TypeMeta: api.TypeMeta{Namespace: "default", Name: "foo"}}), 0)
|
||||
fakeClient.Set(key2, runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{TypeMeta: api.TypeMeta{Namespace: "other", Name: "foo"}}), 0)
|
||||
fakeClient.Set(key1, runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{ObjectMeta: api.ObjectMeta{Namespace: "default", Name: "foo"}}), 0)
|
||||
fakeClient.Set(key2, runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{ObjectMeta: api.ObjectMeta{Namespace: "other", Name: "foo"}}), 0)
|
||||
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
|
||||
|
@ -847,7 +856,7 @@ func TestEtcdGetController(t *testing.T) {
|
|||
ctx := api.NewDefaultContext()
|
||||
fakeClient := tools.NewFakeEtcdClient(t)
|
||||
key, _ := makeControllerKey(ctx, "foo")
|
||||
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{TypeMeta: api.TypeMeta{Name: "foo"}}), 0)
|
||||
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{ObjectMeta: api.ObjectMeta{Name: "foo"}}), 0)
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
ctrl, err := registry.GetController(ctx, "foo")
|
||||
if err != nil {
|
||||
|
@ -903,7 +912,7 @@ func TestEtcdCreateController(t *testing.T) {
|
|||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
key, _ := makeControllerKey(ctx, "foo")
|
||||
err := registry.CreateController(ctx, &api.ReplicationController{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
},
|
||||
})
|
||||
|
@ -929,11 +938,11 @@ func TestEtcdCreateControllerAlreadyExisting(t *testing.T) {
|
|||
ctx := api.NewDefaultContext()
|
||||
fakeClient := tools.NewFakeEtcdClient(t)
|
||||
key, _ := makeControllerKey(ctx, "foo")
|
||||
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{TypeMeta: api.TypeMeta{Name: "foo"}}), 0)
|
||||
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{ObjectMeta: api.ObjectMeta{Name: "foo"}}), 0)
|
||||
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
err := registry.CreateController(ctx, &api.ReplicationController{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
},
|
||||
})
|
||||
|
@ -947,10 +956,10 @@ func TestEtcdUpdateController(t *testing.T) {
|
|||
fakeClient := tools.NewFakeEtcdClient(t)
|
||||
fakeClient.TestIndex = true
|
||||
key, _ := makeControllerKey(ctx, "foo")
|
||||
resp, _ := fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{TypeMeta: api.TypeMeta{Name: "foo"}}), 0)
|
||||
resp, _ := fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{ObjectMeta: api.ObjectMeta{Name: "foo"}}), 0)
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
err := registry.UpdateController(ctx, &api.ReplicationController{
|
||||
TypeMeta: api.TypeMeta{Name: "foo", ResourceVersion: strconv.FormatUint(resp.Node.ModifiedIndex, 10)},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: strconv.FormatUint(resp.Node.ModifiedIndex, 10)},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
Replicas: 2,
|
||||
},
|
||||
|
@ -974,10 +983,10 @@ func TestEtcdListServices(t *testing.T) {
|
|||
Node: &etcd.Node{
|
||||
Nodes: []*etcd.Node{
|
||||
{
|
||||
Value: runtime.EncodeOrDie(latest.Codec, &api.Service{TypeMeta: api.TypeMeta{Name: "foo"}}),
|
||||
Value: runtime.EncodeOrDie(latest.Codec, &api.Service{ObjectMeta: api.ObjectMeta{Name: "foo"}}),
|
||||
},
|
||||
{
|
||||
Value: runtime.EncodeOrDie(latest.Codec, &api.Service{TypeMeta: api.TypeMeta{Name: "bar"}}),
|
||||
Value: runtime.EncodeOrDie(latest.Codec, &api.Service{ObjectMeta: api.ObjectMeta{Name: "bar"}}),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1000,7 +1009,7 @@ func TestEtcdCreateService(t *testing.T) {
|
|||
fakeClient := tools.NewFakeEtcdClient(t)
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
err := registry.CreateService(ctx, &api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
})
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
|
@ -1027,10 +1036,10 @@ func TestEtcdCreateServiceAlreadyExisting(t *testing.T) {
|
|||
ctx := api.NewDefaultContext()
|
||||
fakeClient := tools.NewFakeEtcdClient(t)
|
||||
key, _ := makeServiceKey(ctx, "foo")
|
||||
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Service{TypeMeta: api.TypeMeta{Name: "foo"}}), 0)
|
||||
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Service{ObjectMeta: api.ObjectMeta{Name: "foo"}}), 0)
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
err := registry.CreateService(ctx, &api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
})
|
||||
if !errors.IsAlreadyExists(err) {
|
||||
t.Errorf("expected already exists err, got %#v", err)
|
||||
|
@ -1047,8 +1056,8 @@ func TestEtcdGetServiceDifferentNamespace(t *testing.T) {
|
|||
key1, _ := makeServiceKey(ctx1, "foo")
|
||||
key2, _ := makeServiceKey(ctx2, "foo")
|
||||
|
||||
fakeClient.Set(key1, runtime.EncodeOrDie(latest.Codec, &api.Service{TypeMeta: api.TypeMeta{Namespace: "default", Name: "foo"}}), 0)
|
||||
fakeClient.Set(key2, runtime.EncodeOrDie(latest.Codec, &api.Service{TypeMeta: api.TypeMeta{Namespace: "other", Name: "foo"}}), 0)
|
||||
fakeClient.Set(key1, runtime.EncodeOrDie(latest.Codec, &api.Service{ObjectMeta: api.ObjectMeta{Namespace: "default", Name: "foo"}}), 0)
|
||||
fakeClient.Set(key2, runtime.EncodeOrDie(latest.Codec, &api.Service{ObjectMeta: api.ObjectMeta{Namespace: "other", Name: "foo"}}), 0)
|
||||
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
|
||||
|
@ -1080,7 +1089,7 @@ func TestEtcdGetService(t *testing.T) {
|
|||
ctx := api.NewDefaultContext()
|
||||
fakeClient := tools.NewFakeEtcdClient(t)
|
||||
key, _ := makeServiceKey(ctx, "foo")
|
||||
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Service{TypeMeta: api.TypeMeta{Name: "foo"}}), 0)
|
||||
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Service{ObjectMeta: api.ObjectMeta{Name: "foo"}}), 0)
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
service, err := registry.GetService(ctx, "foo")
|
||||
if err != nil {
|
||||
|
@ -1136,12 +1145,15 @@ func TestEtcdUpdateService(t *testing.T) {
|
|||
fakeClient := tools.NewFakeEtcdClient(t)
|
||||
fakeClient.TestIndex = true
|
||||
key, _ := makeServiceKey(ctx, "foo")
|
||||
resp, _ := fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Service{TypeMeta: api.TypeMeta{Name: "foo"}}), 0)
|
||||
resp, _ := fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Service{ObjectMeta: api.ObjectMeta{Name: "foo"}}), 0)
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
testService := api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "foo", ResourceVersion: strconv.FormatUint(resp.Node.ModifiedIndex, 10)},
|
||||
Labels: map[string]string{
|
||||
"baz": "bar",
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
ResourceVersion: strconv.FormatUint(resp.Node.ModifiedIndex, 10),
|
||||
Labels: map[string]string{
|
||||
"baz": "bar",
|
||||
},
|
||||
},
|
||||
Selector: map[string]string{
|
||||
"baz": "bar",
|
||||
|
@ -1174,10 +1186,10 @@ func TestEtcdListEndpoints(t *testing.T) {
|
|||
Node: &etcd.Node{
|
||||
Nodes: []*etcd.Node{
|
||||
{
|
||||
Value: runtime.EncodeOrDie(latest.Codec, &api.Endpoints{TypeMeta: api.TypeMeta{Name: "foo"}, Endpoints: []string{"127.0.0.1:8345"}}),
|
||||
Value: runtime.EncodeOrDie(latest.Codec, &api.Endpoints{ObjectMeta: api.ObjectMeta{Name: "foo"}, Endpoints: []string{"127.0.0.1:8345"}}),
|
||||
},
|
||||
{
|
||||
Value: runtime.EncodeOrDie(latest.Codec, &api.Endpoints{TypeMeta: api.TypeMeta{Name: "bar"}}),
|
||||
Value: runtime.EncodeOrDie(latest.Codec, &api.Endpoints{ObjectMeta: api.ObjectMeta{Name: "bar"}}),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1200,8 +1212,8 @@ func TestEtcdGetEndpoints(t *testing.T) {
|
|||
fakeClient := tools.NewFakeEtcdClient(t)
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
endpoints := &api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Endpoints: []string{"127.0.0.1:34855"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Endpoints: []string{"127.0.0.1:34855"},
|
||||
}
|
||||
|
||||
key, _ := makeServiceEndpointsKey(ctx, "foo")
|
||||
|
@ -1223,8 +1235,8 @@ func TestEtcdUpdateEndpoints(t *testing.T) {
|
|||
fakeClient.TestIndex = true
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
endpoints := api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Endpoints: []string{"baz", "bar"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Endpoints: []string{"baz", "bar"},
|
||||
}
|
||||
|
||||
key, _ := makeServiceEndpointsKey(ctx, "foo")
|
||||
|
@ -1392,12 +1404,12 @@ func TestEtcdListMinions(t *testing.T) {
|
|||
Nodes: []*etcd.Node{
|
||||
{
|
||||
Value: runtime.EncodeOrDie(latest.Codec, &api.Minion{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
}),
|
||||
},
|
||||
{
|
||||
Value: runtime.EncodeOrDie(latest.Codec, &api.Minion{
|
||||
TypeMeta: api.TypeMeta{Name: "bar"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "bar"},
|
||||
}),
|
||||
},
|
||||
},
|
||||
|
@ -1421,7 +1433,7 @@ func TestEtcdCreateMinion(t *testing.T) {
|
|||
fakeClient := tools.NewFakeEtcdClient(t)
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
err := registry.CreateMinion(ctx, &api.Minion{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
})
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
|
@ -1446,7 +1458,7 @@ func TestEtcdCreateMinion(t *testing.T) {
|
|||
func TestEtcdGetMinion(t *testing.T) {
|
||||
ctx := api.NewContext()
|
||||
fakeClient := tools.NewFakeEtcdClient(t)
|
||||
fakeClient.Set("/registry/minions/foo", runtime.EncodeOrDie(latest.Codec, &api.Minion{TypeMeta: api.TypeMeta{Name: "foo"}}), 0)
|
||||
fakeClient.Set("/registry/minions/foo", runtime.EncodeOrDie(latest.Codec, &api.Minion{ObjectMeta: api.ObjectMeta{Name: "foo"}}), 0)
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
minion, err := registry.GetMinion(ctx, "foo")
|
||||
if err != nil {
|
||||
|
|
|
@ -42,12 +42,12 @@ func NewTestEventEtcdRegistry(t *testing.T) (*tools.FakeEtcdClient, generic.Regi
|
|||
|
||||
func TestEventCreate(t *testing.T) {
|
||||
eventA := &api.Event{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Reason: "forTesting",
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Reason: "forTesting",
|
||||
}
|
||||
eventB := &api.Event{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Reason: "forTesting",
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Reason: "forTesting",
|
||||
}
|
||||
|
||||
nodeWithEventA := tools.EtcdResponseWithError{
|
||||
|
|
|
@ -40,8 +40,8 @@ func NewTestREST() (testRegistry, *REST) {
|
|||
func TestRESTCreate(t *testing.T) {
|
||||
_, rest := NewTestREST()
|
||||
eventA := &api.Event{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Reason: "forTesting",
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Reason: "forTesting",
|
||||
}
|
||||
c, err := rest.Create(api.NewContext(), eventA)
|
||||
if err != nil {
|
||||
|
@ -55,8 +55,8 @@ func TestRESTCreate(t *testing.T) {
|
|||
func TestRESTDelete(t *testing.T) {
|
||||
_, rest := NewTestREST()
|
||||
eventA := &api.Event{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Reason: "forTesting",
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Reason: "forTesting",
|
||||
}
|
||||
c, err := rest.Create(api.NewContext(), eventA)
|
||||
if err != nil {
|
||||
|
@ -75,8 +75,8 @@ func TestRESTDelete(t *testing.T) {
|
|||
func TestRESTGet(t *testing.T) {
|
||||
_, rest := NewTestREST()
|
||||
eventA := &api.Event{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Reason: "forTesting",
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Reason: "forTesting",
|
||||
}
|
||||
c, err := rest.Create(api.NewContext(), eventA)
|
||||
if err != nil {
|
||||
|
@ -131,8 +131,8 @@ func TestRESTgetAttrs(t *testing.T) {
|
|||
func TestRESTUpdate(t *testing.T) {
|
||||
_, rest := NewTestREST()
|
||||
eventA := &api.Event{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Reason: "forTesting",
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Reason: "forTesting",
|
||||
}
|
||||
c, err := rest.Create(api.NewContext(), eventA)
|
||||
if err != nil {
|
||||
|
|
|
@ -72,11 +72,11 @@ func (EverythingMatcher) Matches(obj runtime.Object) (bool, error) {
|
|||
|
||||
func TestEtcdList(t *testing.T) {
|
||||
podA := &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
DesiredState: api.PodState{Host: "machine"},
|
||||
}
|
||||
podB := &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "bar"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "bar"},
|
||||
DesiredState: api.PodState{Host: "machine"},
|
||||
}
|
||||
|
||||
|
@ -154,11 +154,11 @@ func TestEtcdList(t *testing.T) {
|
|||
|
||||
func TestEtcdCreate(t *testing.T) {
|
||||
podA := &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
DesiredState: api.PodState{Host: "machine"},
|
||||
}
|
||||
podB := &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
DesiredState: api.PodState{Host: "machine2"},
|
||||
}
|
||||
|
||||
|
@ -217,11 +217,11 @@ func TestEtcdCreate(t *testing.T) {
|
|||
|
||||
func TestEtcdUpdate(t *testing.T) {
|
||||
podA := &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
DesiredState: api.PodState{Host: "machine"},
|
||||
}
|
||||
podB := &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo", ResourceVersion: "1"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"},
|
||||
DesiredState: api.PodState{Host: "machine2"},
|
||||
}
|
||||
|
||||
|
@ -292,7 +292,7 @@ func TestEtcdUpdate(t *testing.T) {
|
|||
|
||||
func TestEtcdGet(t *testing.T) {
|
||||
podA := &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo", ResourceVersion: "1"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"},
|
||||
DesiredState: api.PodState{Host: "machine"},
|
||||
}
|
||||
|
||||
|
@ -348,7 +348,7 @@ func TestEtcdGet(t *testing.T) {
|
|||
|
||||
func TestEtcdDelete(t *testing.T) {
|
||||
podA := &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo", ResourceVersion: "1"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"},
|
||||
DesiredState: api.PodState{Host: "machine"},
|
||||
}
|
||||
|
||||
|
@ -404,7 +404,7 @@ func TestEtcdDelete(t *testing.T) {
|
|||
|
||||
func TestEtcdWatch(t *testing.T) {
|
||||
podA := &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo", ResourceVersion: "1"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"},
|
||||
DesiredState: api.PodState{Host: "machine"},
|
||||
}
|
||||
respWithPodA := &etcd.Response{
|
||||
|
|
|
@ -46,7 +46,7 @@ func TestBasicDelegation(t *testing.T) {
|
|||
t.Errorf("Expected %v, Got %v", mockMinionRegistry.Minions, list)
|
||||
}
|
||||
err = healthy.CreateMinion(ctx, &api.Minion{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
})
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
|
|
|
@ -37,7 +37,7 @@ func TestMinionREST(t *testing.T) {
|
|||
t.Errorf("has unexpected object")
|
||||
}
|
||||
|
||||
c, err := ms.Create(ctx, &api.Minion{TypeMeta: api.TypeMeta{Name: "baz"}})
|
||||
c, err := ms.Create(ctx, &api.Minion{ObjectMeta: api.ObjectMeta{Name: "baz"}})
|
||||
if err != nil {
|
||||
t.Errorf("insert failed")
|
||||
}
|
||||
|
@ -72,9 +72,9 @@ func TestMinionREST(t *testing.T) {
|
|||
}
|
||||
expect := []api.Minion{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
}, {
|
||||
TypeMeta: api.TypeMeta{Name: "baz"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "baz"},
|
||||
},
|
||||
}
|
||||
nodeList := list.(*api.MinionList)
|
||||
|
|
|
@ -32,7 +32,7 @@ func TestMakeBoundPodNoServices(t *testing.T) {
|
|||
}
|
||||
|
||||
pod, err := factory.MakeBoundPod("machine", &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foobar"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foobar"},
|
||||
DesiredState: api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
Containers: []api.Container{
|
||||
|
@ -61,8 +61,8 @@ func TestMakeBoundPodServices(t *testing.T) {
|
|||
List: api.ServiceList{
|
||||
Items: []api.Service{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "test"},
|
||||
Port: 8080,
|
||||
ObjectMeta: api.ObjectMeta{Name: "test"},
|
||||
Port: 8080,
|
||||
ContainerPort: util.IntOrString{
|
||||
Kind: util.IntstrInt,
|
||||
IntVal: 900,
|
||||
|
@ -137,8 +137,8 @@ func TestMakeBoundPodServicesExistingEnvVar(t *testing.T) {
|
|||
List: api.ServiceList{
|
||||
Items: []api.Service{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "test"},
|
||||
Port: 8080,
|
||||
ObjectMeta: api.ObjectMeta{Name: "test"},
|
||||
Port: 8080,
|
||||
ContainerPort: util.IntOrString{
|
||||
Kind: util.IntstrInt,
|
||||
IntVal: 900,
|
||||
|
|
|
@ -144,7 +144,7 @@ func TestListPodsError(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestListEmptyPodList(t *testing.T) {
|
||||
podRegistry := registrytest.NewPodRegistry(&api.PodList{TypeMeta: api.TypeMeta{ResourceVersion: "1"}})
|
||||
podRegistry := registrytest.NewPodRegistry(&api.PodList{ListMeta: api.ListMeta{ResourceVersion: "1"}})
|
||||
storage := REST{
|
||||
registry: podRegistry,
|
||||
}
|
||||
|
@ -175,12 +175,12 @@ func TestListPodList(t *testing.T) {
|
|||
podRegistry.Pods = &api.PodList{
|
||||
Items: []api.Pod{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
},
|
||||
},
|
||||
{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "bar",
|
||||
},
|
||||
},
|
||||
|
@ -214,18 +214,20 @@ func TestListPodListSelection(t *testing.T) {
|
|||
podRegistry.Pods = &api.PodList{
|
||||
Items: []api.Pod{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
}, {
|
||||
TypeMeta: api.TypeMeta{Name: "bar"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "bar"},
|
||||
DesiredState: api.PodState{Host: "barhost"},
|
||||
}, {
|
||||
TypeMeta: api.TypeMeta{Name: "baz"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "baz"},
|
||||
DesiredState: api.PodState{Status: "bazstatus"},
|
||||
}, {
|
||||
TypeMeta: api.TypeMeta{Name: "qux"},
|
||||
Labels: map[string]string{"label": "qux"},
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "qux",
|
||||
Labels: map[string]string{"label": "qux"},
|
||||
},
|
||||
}, {
|
||||
TypeMeta: api.TypeMeta{Name: "zot"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "zot"},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -298,7 +300,7 @@ func TestPodDecode(t *testing.T) {
|
|||
registry: podRegistry,
|
||||
}
|
||||
expected := &api.Pod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
},
|
||||
}
|
||||
|
@ -319,7 +321,7 @@ func TestPodDecode(t *testing.T) {
|
|||
|
||||
func TestGetPod(t *testing.T) {
|
||||
podRegistry := registrytest.NewPodRegistry(nil)
|
||||
podRegistry.Pod = &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}
|
||||
podRegistry.Pod = &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}
|
||||
storage := REST{
|
||||
registry: podRegistry,
|
||||
ipCache: ipCache{},
|
||||
|
@ -340,7 +342,7 @@ func TestGetPod(t *testing.T) {
|
|||
func TestGetPodCloud(t *testing.T) {
|
||||
fakeCloud := &fake_cloud.FakeCloud{}
|
||||
podRegistry := registrytest.NewPodRegistry(nil)
|
||||
podRegistry.Pod = &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}, CurrentState: api.PodState{Host: "machine"}}
|
||||
podRegistry.Pod = &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}, CurrentState: api.PodState{Host: "machine"}}
|
||||
|
||||
clock := &fakeClock{t: time.Now()}
|
||||
|
||||
|
@ -386,7 +388,7 @@ func TestMakePodStatus(t *testing.T) {
|
|||
Minions: api.MinionList{
|
||||
Items: []api.Minion{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "machine"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "machine"},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -561,7 +563,7 @@ func TestPodStorageValidatesUpdate(t *testing.T) {
|
|||
func TestCreatePod(t *testing.T) {
|
||||
podRegistry := registrytest.NewPodRegistry(nil)
|
||||
podRegistry.Pod = &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
CurrentState: api.PodState{
|
||||
Host: "machine",
|
||||
},
|
||||
|
@ -576,7 +578,7 @@ func TestCreatePod(t *testing.T) {
|
|||
},
|
||||
}
|
||||
pod := &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
DesiredState: desiredState,
|
||||
}
|
||||
ctx := api.NewDefaultContext()
|
||||
|
@ -656,7 +658,7 @@ func TestFillPodInfoNoData(t *testing.T) {
|
|||
func TestCreatePodWithConflictingNamespace(t *testing.T) {
|
||||
storage := REST{}
|
||||
pod := &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "test", Namespace: "not-default"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "test", Namespace: "not-default"},
|
||||
}
|
||||
|
||||
ctx := api.NewDefaultContext()
|
||||
|
@ -674,7 +676,7 @@ func TestCreatePodWithConflictingNamespace(t *testing.T) {
|
|||
func TestUpdatePodWithConflictingNamespace(t *testing.T) {
|
||||
storage := REST{}
|
||||
pod := &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "test", Namespace: "not-default"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "test", Namespace: "not-default"},
|
||||
}
|
||||
|
||||
ctx := api.NewDefaultContext()
|
||||
|
|
|
@ -45,9 +45,9 @@ func TestServiceRegistryCreate(t *testing.T) {
|
|||
machines := []string{"foo", "bar", "baz"}
|
||||
storage := NewREST(registry, fakeCloud, registrytest.NewMinionRegistry(machines, api.NodeResources{}), makeIPNet(t))
|
||||
svc := &api.Service{
|
||||
Port: 6502,
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
Port: 6502,
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
}
|
||||
ctx := api.NewDefaultContext()
|
||||
c, _ := storage.Create(ctx, svc)
|
||||
|
@ -82,13 +82,13 @@ func TestServiceStorageValidatesCreate(t *testing.T) {
|
|||
storage := NewREST(registry, nil, nil, makeIPNet(t))
|
||||
failureCases := map[string]api.Service{
|
||||
"empty ID": {
|
||||
Port: 6502,
|
||||
TypeMeta: api.TypeMeta{Name: ""},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
Port: 6502,
|
||||
ObjectMeta: api.ObjectMeta{Name: ""},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
},
|
||||
"empty selector": {
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Selector: map[string]string{},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{},
|
||||
},
|
||||
}
|
||||
ctx := api.NewDefaultContext()
|
||||
|
@ -108,15 +108,15 @@ func TestServiceRegistryUpdate(t *testing.T) {
|
|||
ctx := api.NewDefaultContext()
|
||||
registry := registrytest.NewServiceRegistry()
|
||||
registry.CreateService(ctx, &api.Service{
|
||||
Port: 6502,
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz1"},
|
||||
Port: 6502,
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz1"},
|
||||
})
|
||||
storage := NewREST(registry, nil, nil, makeIPNet(t))
|
||||
c, err := storage.Update(ctx, &api.Service{
|
||||
Port: 6502,
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz2"},
|
||||
Port: 6502,
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz2"},
|
||||
})
|
||||
if c == nil {
|
||||
t.Errorf("Expected non-nil channel")
|
||||
|
@ -138,21 +138,21 @@ func TestServiceStorageValidatesUpdate(t *testing.T) {
|
|||
ctx := api.NewDefaultContext()
|
||||
registry := registrytest.NewServiceRegistry()
|
||||
registry.CreateService(ctx, &api.Service{
|
||||
Port: 6502,
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
Port: 6502,
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
})
|
||||
storage := NewREST(registry, nil, nil, makeIPNet(t))
|
||||
failureCases := map[string]api.Service{
|
||||
"empty ID": {
|
||||
Port: 6502,
|
||||
TypeMeta: api.TypeMeta{Name: ""},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
Port: 6502,
|
||||
ObjectMeta: api.ObjectMeta{Name: ""},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
},
|
||||
"empty selector": {
|
||||
Port: 6502,
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Selector: map[string]string{},
|
||||
Port: 6502,
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{},
|
||||
},
|
||||
}
|
||||
for _, failureCase := range failureCases {
|
||||
|
@ -174,7 +174,7 @@ func TestServiceRegistryExternalService(t *testing.T) {
|
|||
storage := NewREST(registry, fakeCloud, registrytest.NewMinionRegistry(machines, api.NodeResources{}), makeIPNet(t))
|
||||
svc := &api.Service{
|
||||
Port: 6502,
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
CreateExternalLoadBalancer: true,
|
||||
}
|
||||
|
@ -201,7 +201,7 @@ func TestServiceRegistryExternalServiceError(t *testing.T) {
|
|||
storage := NewREST(registry, fakeCloud, registrytest.NewMinionRegistry(machines, api.NodeResources{}), makeIPNet(t))
|
||||
svc := &api.Service{
|
||||
Port: 6502,
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
CreateExternalLoadBalancer: true,
|
||||
}
|
||||
|
@ -223,8 +223,8 @@ func TestServiceRegistryDelete(t *testing.T) {
|
|||
machines := []string{"foo", "bar", "baz"}
|
||||
storage := NewREST(registry, fakeCloud, registrytest.NewMinionRegistry(machines, api.NodeResources{}), makeIPNet(t))
|
||||
svc := &api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
}
|
||||
registry.CreateService(ctx, svc)
|
||||
c, _ := storage.Delete(ctx, svc.Name)
|
||||
|
@ -244,7 +244,7 @@ func TestServiceRegistryDeleteExternal(t *testing.T) {
|
|||
machines := []string{"foo", "bar", "baz"}
|
||||
storage := NewREST(registry, fakeCloud, registrytest.NewMinionRegistry(machines, api.NodeResources{}), makeIPNet(t))
|
||||
svc := &api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
CreateExternalLoadBalancer: true,
|
||||
}
|
||||
|
@ -265,25 +265,25 @@ func TestServiceRegistryMakeLinkVariables(t *testing.T) {
|
|||
registry.List = api.ServiceList{
|
||||
Items: []api.Service{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "foo-bar"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
Port: 8080,
|
||||
Protocol: "TCP",
|
||||
PortalIP: "1.2.3.4",
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo-bar"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
Port: 8080,
|
||||
Protocol: "TCP",
|
||||
PortalIP: "1.2.3.4",
|
||||
},
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "abc-123"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
Port: 8081,
|
||||
Protocol: "UDP",
|
||||
PortalIP: "5.6.7.8",
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc-123"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
Port: 8081,
|
||||
Protocol: "UDP",
|
||||
PortalIP: "5.6.7.8",
|
||||
},
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "q-u-u-x"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
Port: 8082,
|
||||
Protocol: "",
|
||||
PortalIP: "9.8.7.6",
|
||||
ObjectMeta: api.ObjectMeta{Name: "q-u-u-x"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
Port: 8082,
|
||||
Protocol: "",
|
||||
PortalIP: "9.8.7.6",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -333,8 +333,8 @@ func TestServiceRegistryGet(t *testing.T) {
|
|||
machines := []string{"foo", "bar", "baz"}
|
||||
storage := NewREST(registry, fakeCloud, registrytest.NewMinionRegistry(machines, api.NodeResources{}), makeIPNet(t))
|
||||
registry.CreateService(ctx, &api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
})
|
||||
storage.Get(ctx, "foo")
|
||||
if len(fakeCloud.Calls) != 0 {
|
||||
|
@ -353,8 +353,8 @@ func TestServiceRegistryResourceLocation(t *testing.T) {
|
|||
machines := []string{"foo", "bar", "baz"}
|
||||
storage := NewREST(registry, fakeCloud, registrytest.NewMinionRegistry(machines, api.NodeResources{}), makeIPNet(t))
|
||||
registry.CreateService(ctx, &api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
})
|
||||
redirector := apiserver.Redirector(storage)
|
||||
location, err := redirector.ResourceLocation(ctx, "foo")
|
||||
|
@ -382,12 +382,12 @@ func TestServiceRegistryList(t *testing.T) {
|
|||
machines := []string{"foo", "bar", "baz"}
|
||||
storage := NewREST(registry, fakeCloud, registrytest.NewMinionRegistry(machines, api.NodeResources{}), makeIPNet(t))
|
||||
registry.CreateService(ctx, &api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
})
|
||||
registry.CreateService(ctx, &api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "foo2"},
|
||||
Selector: map[string]string{"bar2": "baz2"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo2"},
|
||||
Selector: map[string]string{"bar2": "baz2"},
|
||||
})
|
||||
registry.List.ResourceVersion = "1"
|
||||
s, _ := storage.List(ctx, labels.Everything(), labels.Everything())
|
||||
|
@ -416,9 +416,9 @@ func TestServiceRegistryIPAllocation(t *testing.T) {
|
|||
rest := NewREST(registry, fakeCloud, registrytest.NewMinionRegistry(machines, api.NodeResources{}), makeIPNet(t))
|
||||
|
||||
svc1 := &api.Service{
|
||||
Port: 6502,
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
Port: 6502,
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
}
|
||||
ctx := api.NewDefaultContext()
|
||||
c1, _ := rest.Create(ctx, svc1)
|
||||
|
@ -432,9 +432,9 @@ func TestServiceRegistryIPAllocation(t *testing.T) {
|
|||
}
|
||||
|
||||
svc2 := &api.Service{
|
||||
Port: 6502,
|
||||
TypeMeta: api.TypeMeta{Name: "bar"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
Port: 6502,
|
||||
ObjectMeta: api.ObjectMeta{Name: "bar"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
}
|
||||
ctx = api.NewDefaultContext()
|
||||
c2, _ := rest.Create(ctx, svc2)
|
||||
|
@ -455,9 +455,9 @@ func TestServiceRegistryIPReallocation(t *testing.T) {
|
|||
rest := NewREST(registry, fakeCloud, registrytest.NewMinionRegistry(machines, api.NodeResources{}), makeIPNet(t))
|
||||
|
||||
svc1 := &api.Service{
|
||||
Port: 6502,
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
Port: 6502,
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
}
|
||||
ctx := api.NewDefaultContext()
|
||||
c1, _ := rest.Create(ctx, svc1)
|
||||
|
@ -474,9 +474,9 @@ func TestServiceRegistryIPReallocation(t *testing.T) {
|
|||
<-c
|
||||
|
||||
svc2 := &api.Service{
|
||||
Port: 6502,
|
||||
TypeMeta: api.TypeMeta{Name: "bar"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
Port: 6502,
|
||||
ObjectMeta: api.ObjectMeta{Name: "bar"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
}
|
||||
ctx = api.NewDefaultContext()
|
||||
c2, _ := rest.Create(ctx, svc2)
|
||||
|
@ -497,9 +497,9 @@ func TestServiceRegistryIPUpdate(t *testing.T) {
|
|||
rest := NewREST(registry, fakeCloud, registrytest.NewMinionRegistry(machines, api.NodeResources{}), makeIPNet(t))
|
||||
|
||||
svc := &api.Service{
|
||||
Port: 6502,
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
Port: 6502,
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
}
|
||||
ctx := api.NewDefaultContext()
|
||||
c, _ := rest.Create(ctx, svc)
|
||||
|
@ -543,7 +543,7 @@ func TestServiceRegistryIPExternalLoadBalancer(t *testing.T) {
|
|||
|
||||
svc := &api.Service{
|
||||
Port: 6502,
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
CreateExternalLoadBalancer: true,
|
||||
}
|
||||
|
@ -569,17 +569,17 @@ func TestServiceRegistryIPReloadFromStorage(t *testing.T) {
|
|||
rest1 := NewREST(registry, fakeCloud, registrytest.NewMinionRegistry(machines, api.NodeResources{}), makeIPNet(t))
|
||||
|
||||
svc := &api.Service{
|
||||
Port: 6502,
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
Port: 6502,
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
}
|
||||
ctx := api.NewDefaultContext()
|
||||
c, _ := rest1.Create(ctx, svc)
|
||||
<-c
|
||||
svc = &api.Service{
|
||||
Port: 6502,
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
Port: 6502,
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
}
|
||||
c, _ = rest1.Create(ctx, svc)
|
||||
<-c
|
||||
|
@ -588,9 +588,9 @@ func TestServiceRegistryIPReloadFromStorage(t *testing.T) {
|
|||
rest2 := NewREST(registry, fakeCloud, registrytest.NewMinionRegistry(machines, api.NodeResources{}), makeIPNet(t))
|
||||
|
||||
svc = &api.Service{
|
||||
Port: 6502,
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
Port: 6502,
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
}
|
||||
c, _ = rest2.Create(ctx, svc)
|
||||
created_svc := <-c
|
||||
|
@ -603,7 +603,7 @@ func TestServiceRegistryIPReloadFromStorage(t *testing.T) {
|
|||
func TestCreateServiceWithConflictingNamespace(t *testing.T) {
|
||||
storage := REST{}
|
||||
service := &api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "test", Namespace: "not-default"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "test", Namespace: "not-default"},
|
||||
}
|
||||
|
||||
ctx := api.NewDefaultContext()
|
||||
|
@ -621,7 +621,7 @@ func TestCreateServiceWithConflictingNamespace(t *testing.T) {
|
|||
func TestUpdateServiceWithConflictingNamespace(t *testing.T) {
|
||||
storage := REST{}
|
||||
service := &api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "test", Namespace: "not-default"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "test", Namespace: "not-default"},
|
||||
}
|
||||
|
||||
ctx := api.NewDefaultContext()
|
||||
|
|
|
@ -29,9 +29,9 @@ import (
|
|||
func TestExtractList(t *testing.T) {
|
||||
pl := &api.PodList{
|
||||
Items: []api.Pod{
|
||||
{TypeMeta: api.TypeMeta{Name: "1"}},
|
||||
{TypeMeta: api.TypeMeta{Name: "2"}},
|
||||
{TypeMeta: api.TypeMeta{Name: "3"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "1"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "2"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "3"}},
|
||||
},
|
||||
}
|
||||
list, err := runtime.ExtractList(pl)
|
||||
|
@ -51,9 +51,9 @@ func TestExtractList(t *testing.T) {
|
|||
func TestSetList(t *testing.T) {
|
||||
pl := &api.PodList{}
|
||||
list := []runtime.Object{
|
||||
&api.Pod{TypeMeta: api.TypeMeta{Name: "1"}},
|
||||
&api.Pod{TypeMeta: api.TypeMeta{Name: "2"}},
|
||||
&api.Pod{TypeMeta: api.TypeMeta{Name: "3"}},
|
||||
&api.Pod{ObjectMeta: api.ObjectMeta{Name: "1"}},
|
||||
&api.Pod{ObjectMeta: api.ObjectMeta{Name: "2"}},
|
||||
&api.Pod{ObjectMeta: api.ObjectMeta{Name: "3"}},
|
||||
}
|
||||
err := runtime.SetList(pl, list)
|
||||
if err != nil {
|
||||
|
|
|
@ -95,7 +95,7 @@ func TestGenericScheduler(t *testing.T) {
|
|||
predicates: []FitPredicate{matchesPredicate},
|
||||
prioritizer: EqualPriority,
|
||||
nodes: []string{"machine1", "machine2"},
|
||||
pod: api.Pod{TypeMeta: api.TypeMeta{Name: "machine2"}},
|
||||
pod: api.Pod{ObjectMeta: api.ObjectMeta{Name: "machine2"}},
|
||||
expectedHost: "machine2",
|
||||
},
|
||||
{
|
||||
|
@ -108,7 +108,7 @@ func TestGenericScheduler(t *testing.T) {
|
|||
predicates: []FitPredicate{matchesPredicate},
|
||||
prioritizer: numericPriority,
|
||||
nodes: []string{"3", "2", "1"},
|
||||
pod: api.Pod{TypeMeta: api.TypeMeta{Name: "2"}},
|
||||
pod: api.Pod{ObjectMeta: api.ObjectMeta{Name: "2"}},
|
||||
expectedHost: "2",
|
||||
},
|
||||
{
|
||||
|
|
|
@ -27,7 +27,7 @@ import (
|
|||
|
||||
func makeMinion(node string, cpu, memory int) api.Minion {
|
||||
return api.Minion{
|
||||
TypeMeta: api.TypeMeta{Name: node},
|
||||
ObjectMeta: api.ObjectMeta{Name: node},
|
||||
NodeResources: api.NodeResources{
|
||||
Capacity: api.ResourceList{
|
||||
resources.CPU: util.NewIntOrStringFromInt(cpu),
|
||||
|
@ -87,10 +87,10 @@ func TestLeastRequested(t *testing.T) {
|
|||
expectedList: []HostPriority{{"machine1", 0}, {"machine2", 0}},
|
||||
test: "no resources requested",
|
||||
pods: []api.Pod{
|
||||
{DesiredState: machine1State, Labels: labels2},
|
||||
{DesiredState: machine1State, Labels: labels1},
|
||||
{DesiredState: machine2State, Labels: labels1},
|
||||
{DesiredState: machine2State, Labels: labels1},
|
||||
{DesiredState: machine1State, ObjectMeta: api.ObjectMeta{Labels: labels2}},
|
||||
{DesiredState: machine1State, ObjectMeta: api.ObjectMeta{Labels: labels1}},
|
||||
{DesiredState: machine2State, ObjectMeta: api.ObjectMeta{Labels: labels1}},
|
||||
{DesiredState: machine2State, ObjectMeta: api.ObjectMeta{Labels: labels1}},
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
|
@ -51,47 +51,47 @@ func TestSpreadPriority(t *testing.T) {
|
|||
test: "nothing scheduled",
|
||||
},
|
||||
{
|
||||
pod: api.Pod{Labels: labels1},
|
||||
pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}},
|
||||
pods: []api.Pod{{CurrentState: machine1State}},
|
||||
nodes: []string{"machine1", "machine2"},
|
||||
expectedList: []HostPriority{{"machine1", 0}, {"machine2", 0}},
|
||||
test: "no labels",
|
||||
},
|
||||
{
|
||||
pod: api.Pod{Labels: labels1},
|
||||
pods: []api.Pod{{CurrentState: machine1State, Labels: labels2}},
|
||||
pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}},
|
||||
pods: []api.Pod{{CurrentState: machine1State, ObjectMeta: api.ObjectMeta{Labels: labels2}}},
|
||||
nodes: []string{"machine1", "machine2"},
|
||||
expectedList: []HostPriority{{"machine1", 0}, {"machine2", 0}},
|
||||
test: "different labels",
|
||||
},
|
||||
{
|
||||
pod: api.Pod{Labels: labels1},
|
||||
pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}},
|
||||
pods: []api.Pod{
|
||||
{CurrentState: machine1State, Labels: labels2},
|
||||
{CurrentState: machine2State, Labels: labels1},
|
||||
{CurrentState: machine1State, ObjectMeta: api.ObjectMeta{Labels: labels2}},
|
||||
{CurrentState: machine2State, ObjectMeta: api.ObjectMeta{Labels: labels1}},
|
||||
},
|
||||
nodes: []string{"machine1", "machine2"},
|
||||
expectedList: []HostPriority{{"machine1", 0}, {"machine2", 1}},
|
||||
test: "one label match",
|
||||
},
|
||||
{
|
||||
pod: api.Pod{Labels: labels1},
|
||||
pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}},
|
||||
pods: []api.Pod{
|
||||
{CurrentState: machine1State, Labels: labels2},
|
||||
{CurrentState: machine1State, Labels: labels1},
|
||||
{CurrentState: machine2State, Labels: labels1},
|
||||
{CurrentState: machine1State, ObjectMeta: api.ObjectMeta{Labels: labels2}},
|
||||
{CurrentState: machine1State, ObjectMeta: api.ObjectMeta{Labels: labels1}},
|
||||
{CurrentState: machine2State, ObjectMeta: api.ObjectMeta{Labels: labels1}},
|
||||
},
|
||||
nodes: []string{"machine1", "machine2"},
|
||||
expectedList: []HostPriority{{"machine1", 1}, {"machine2", 1}},
|
||||
test: "two label matches on different machines",
|
||||
},
|
||||
{
|
||||
pod: api.Pod{Labels: labels1},
|
||||
pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}},
|
||||
pods: []api.Pod{
|
||||
{CurrentState: machine1State, Labels: labels2},
|
||||
{CurrentState: machine1State, Labels: labels1},
|
||||
{CurrentState: machine2State, Labels: labels1},
|
||||
{CurrentState: machine2State, Labels: labels1},
|
||||
{CurrentState: machine1State, ObjectMeta: api.ObjectMeta{Labels: labels2}},
|
||||
{CurrentState: machine1State, ObjectMeta: api.ObjectMeta{Labels: labels1}},
|
||||
{CurrentState: machine2State, ObjectMeta: api.ObjectMeta{Labels: labels1}},
|
||||
{CurrentState: machine2State, ObjectMeta: api.ObjectMeta{Labels: labels1}},
|
||||
},
|
||||
nodes: []string{"machine1", "machine2"},
|
||||
expectedList: []HostPriority{{"machine1", 1}, {"machine2", 2}},
|
||||
|
|
|
@ -34,10 +34,8 @@ func newPodList(count int) api.PodList {
|
|||
pods := []api.Pod{}
|
||||
for i := 0; i < count; i++ {
|
||||
pods = append(pods, api.Pod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
Name: fmt.Sprintf("pod%d", i),
|
||||
APIVersion: testapi.Version(),
|
||||
},
|
||||
TypeMeta: api.TypeMeta{APIVersion: testapi.Version()},
|
||||
ObjectMeta: api.ObjectMeta{Name: fmt.Sprintf("pod%d", i)},
|
||||
DesiredState: api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
Containers: []api.Container{
|
||||
|
@ -181,7 +179,7 @@ func TestSyncEndpointsItemsPreexisting(t *testing.T) {
|
|||
serviceList := api.ServiceList{
|
||||
Items: []api.Service{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
|
@ -192,7 +190,7 @@ func TestSyncEndpointsItemsPreexisting(t *testing.T) {
|
|||
serverResponse{http.StatusOK, newPodList(1)},
|
||||
serverResponse{http.StatusOK, serviceList},
|
||||
serverResponse{http.StatusOK, api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
ResourceVersion: "1",
|
||||
},
|
||||
|
@ -204,7 +202,7 @@ func TestSyncEndpointsItemsPreexisting(t *testing.T) {
|
|||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
data := runtime.EncodeOrDie(testapi.Codec(), &api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
ResourceVersion: "1",
|
||||
},
|
||||
|
@ -217,7 +215,7 @@ func TestSyncEndpointsItemsPreexistingIdentical(t *testing.T) {
|
|||
serviceList := api.ServiceList{
|
||||
Items: []api.Service{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
|
@ -228,7 +226,7 @@ func TestSyncEndpointsItemsPreexistingIdentical(t *testing.T) {
|
|||
serverResponse{http.StatusOK, newPodList(1)},
|
||||
serverResponse{http.StatusOK, serviceList},
|
||||
serverResponse{http.StatusOK, api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
ResourceVersion: "1",
|
||||
},
|
||||
Endpoints: []string{"1.2.3.4:8080"},
|
||||
|
@ -245,7 +243,7 @@ func TestSyncEndpointsItems(t *testing.T) {
|
|||
serviceList := api.ServiceList{
|
||||
Items: []api.Service{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
|
@ -262,7 +260,7 @@ func TestSyncEndpointsItems(t *testing.T) {
|
|||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
data := runtime.EncodeOrDie(testapi.Codec(), &api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
ResourceVersion: "",
|
||||
},
|
||||
Endpoints: []string{"1.2.3.4:8080"},
|
||||
|
|
|
@ -37,8 +37,9 @@ type fakeClientGetSet struct {
|
|||
}
|
||||
|
||||
type TestResource struct {
|
||||
api.TypeMeta `json:",inline" yaml:",inline"`
|
||||
Value int `json:"value" yaml:"value,omitempty"`
|
||||
api.TypeMeta `json:",inline" yaml:",inline"`
|
||||
api.ObjectMeta `json:"metadata" yaml:"metadata"`
|
||||
Value int `json:"value" yaml:"value,omitempty"`
|
||||
}
|
||||
|
||||
func (*TestResource) IsAnAPIObject() {}
|
||||
|
@ -74,15 +75,15 @@ func TestExtractToList(t *testing.T) {
|
|||
Node: &etcd.Node{
|
||||
Nodes: []*etcd.Node{
|
||||
{
|
||||
Value: `{"name":"foo"}`,
|
||||
Value: `{"id":"foo","kind":"Pod","apiVersion":"v1beta1"}`,
|
||||
ModifiedIndex: 1,
|
||||
},
|
||||
{
|
||||
Value: `{"name":"bar"}`,
|
||||
Value: `{"id":"bar","kind":"Pod","apiVersion":"v1beta1"}`,
|
||||
ModifiedIndex: 2,
|
||||
},
|
||||
{
|
||||
Value: `{"name":"baz"}`,
|
||||
Value: `{"id":"baz","kind":"Pod","apiVersion":"v1beta1"}`,
|
||||
ModifiedIndex: 3,
|
||||
},
|
||||
},
|
||||
|
@ -90,11 +91,11 @@ func TestExtractToList(t *testing.T) {
|
|||
},
|
||||
}
|
||||
expect := api.PodList{
|
||||
TypeMeta: api.TypeMeta{ResourceVersion: "10"},
|
||||
ListMeta: api.ListMeta{ResourceVersion: "10"},
|
||||
Items: []api.Pod{
|
||||
{TypeMeta: api.TypeMeta{Name: "foo", ResourceVersion: "1"}},
|
||||
{TypeMeta: api.TypeMeta{Name: "bar", ResourceVersion: "2"}},
|
||||
{TypeMeta: api.TypeMeta{Name: "baz", ResourceVersion: "3"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "bar", ResourceVersion: "2"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "baz", ResourceVersion: "3"}},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -122,7 +123,7 @@ func TestExtractToListAcrossDirectories(t *testing.T) {
|
|||
Dir: true,
|
||||
Nodes: []*etcd.Node{
|
||||
{
|
||||
Value: `{"name":"foo"}`,
|
||||
Value: `{"id":"foo","kind":"Pod","apiVersion":"v1beta1"}`,
|
||||
ModifiedIndex: 1,
|
||||
},
|
||||
},
|
||||
|
@ -132,7 +133,7 @@ func TestExtractToListAcrossDirectories(t *testing.T) {
|
|||
Dir: true,
|
||||
Nodes: []*etcd.Node{
|
||||
{
|
||||
Value: `{"name":"bar"}`,
|
||||
Value: `{"id":"bar","kind":"Pod","apiVersion":"v1beta1"}`,
|
||||
ModifiedIndex: 2,
|
||||
},
|
||||
},
|
||||
|
@ -142,10 +143,10 @@ func TestExtractToListAcrossDirectories(t *testing.T) {
|
|||
},
|
||||
}
|
||||
expect := api.PodList{
|
||||
TypeMeta: api.TypeMeta{ResourceVersion: "10"},
|
||||
ListMeta: api.ListMeta{ResourceVersion: "10"},
|
||||
Items: []api.Pod{
|
||||
{TypeMeta: api.TypeMeta{Name: "foo", ResourceVersion: "1"}},
|
||||
{TypeMeta: api.TypeMeta{Name: "bar", ResourceVersion: "2"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "bar", ResourceVersion: "2"}},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -168,15 +169,15 @@ func TestExtractToListExcludesDirectories(t *testing.T) {
|
|||
Node: &etcd.Node{
|
||||
Nodes: []*etcd.Node{
|
||||
{
|
||||
Value: `{"name":"foo"}`,
|
||||
Value: `{"id":"foo","kind":"Pod","apiVersion":"v1beta1"}`,
|
||||
ModifiedIndex: 1,
|
||||
},
|
||||
{
|
||||
Value: `{"name":"bar"}`,
|
||||
Value: `{"id":"bar","kind":"Pod","apiVersion":"v1beta1"}`,
|
||||
ModifiedIndex: 2,
|
||||
},
|
||||
{
|
||||
Value: `{"name":"baz"}`,
|
||||
Value: `{"id":"baz","kind":"Pod","apiVersion":"v1beta1"}`,
|
||||
ModifiedIndex: 3,
|
||||
},
|
||||
{
|
||||
|
@ -188,11 +189,11 @@ func TestExtractToListExcludesDirectories(t *testing.T) {
|
|||
},
|
||||
}
|
||||
expect := api.PodList{
|
||||
TypeMeta: api.TypeMeta{ResourceVersion: "10"},
|
||||
ListMeta: api.ListMeta{ResourceVersion: "10"},
|
||||
Items: []api.Pod{
|
||||
{TypeMeta: api.TypeMeta{Name: "foo", ResourceVersion: "1"}},
|
||||
{TypeMeta: api.TypeMeta{Name: "bar", ResourceVersion: "2"}},
|
||||
{TypeMeta: api.TypeMeta{Name: "baz", ResourceVersion: "3"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "bar", ResourceVersion: "2"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "baz", ResourceVersion: "3"}},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -209,7 +210,7 @@ func TestExtractToListExcludesDirectories(t *testing.T) {
|
|||
|
||||
func TestExtractObj(t *testing.T) {
|
||||
fakeClient := NewFakeEtcdClient(t)
|
||||
expect := api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}
|
||||
expect := api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}
|
||||
fakeClient.Set("/some/key", util.EncodeJSON(expect), 0)
|
||||
helper := EtcdHelper{fakeClient, latest.Codec, versioner}
|
||||
var got api.Pod
|
||||
|
@ -263,7 +264,7 @@ func TestExtractObjNotFoundErr(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCreateObj(t *testing.T) {
|
||||
obj := &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}
|
||||
obj := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}
|
||||
fakeClient := NewFakeEtcdClient(t)
|
||||
helper := EtcdHelper{fakeClient, latest.Codec, versioner}
|
||||
err := helper.CreateObj("/some/key", obj, 5)
|
||||
|
@ -284,7 +285,7 @@ func TestCreateObj(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSetObj(t *testing.T) {
|
||||
obj := &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}
|
||||
obj := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}
|
||||
fakeClient := NewFakeEtcdClient(t)
|
||||
helper := EtcdHelper{fakeClient, latest.Codec, versioner}
|
||||
err := helper.SetObj("/some/key", obj)
|
||||
|
@ -303,7 +304,7 @@ func TestSetObj(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSetObjWithVersion(t *testing.T) {
|
||||
obj := &api.Pod{TypeMeta: api.TypeMeta{Name: "foo", ResourceVersion: "1"}}
|
||||
obj := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"}}
|
||||
fakeClient := NewFakeEtcdClient(t)
|
||||
fakeClient.TestIndex = true
|
||||
fakeClient.Data["/some/key"] = EtcdResponseWithError{
|
||||
|
@ -332,7 +333,7 @@ func TestSetObjWithVersion(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSetObjWithoutResourceVersioner(t *testing.T) {
|
||||
obj := &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}
|
||||
obj := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}
|
||||
fakeClient := NewFakeEtcdClient(t)
|
||||
helper := EtcdHelper{fakeClient, latest.Codec, nil}
|
||||
err := helper.SetObj("/some/key", obj)
|
||||
|
@ -357,7 +358,7 @@ func TestAtomicUpdate(t *testing.T) {
|
|||
|
||||
// Create a new node.
|
||||
fakeClient.ExpectNotFoundGet("/some/key")
|
||||
obj := &TestResource{TypeMeta: api.TypeMeta{Name: "foo"}, Value: 1}
|
||||
obj := &TestResource{ObjectMeta: api.ObjectMeta{Name: "foo"}, Value: 1}
|
||||
err := helper.AtomicUpdate("/some/key", &TestResource{}, func(in runtime.Object) (runtime.Object, error) {
|
||||
return obj, nil
|
||||
})
|
||||
|
@ -376,7 +377,7 @@ func TestAtomicUpdate(t *testing.T) {
|
|||
|
||||
// Update an existing node.
|
||||
callbackCalled := false
|
||||
objUpdate := &TestResource{TypeMeta: api.TypeMeta{Name: "foo"}, Value: 2}
|
||||
objUpdate := &TestResource{ObjectMeta: api.ObjectMeta{Name: "foo"}, Value: 2}
|
||||
err = helper.AtomicUpdate("/some/key", &TestResource{}, func(in runtime.Object) (runtime.Object, error) {
|
||||
callbackCalled = true
|
||||
|
||||
|
@ -411,7 +412,7 @@ func TestAtomicUpdateNoChange(t *testing.T) {
|
|||
|
||||
// Create a new node.
|
||||
fakeClient.ExpectNotFoundGet("/some/key")
|
||||
obj := &TestResource{TypeMeta: api.TypeMeta{Name: "foo"}, Value: 1}
|
||||
obj := &TestResource{ObjectMeta: api.ObjectMeta{Name: "foo"}, Value: 1}
|
||||
err := helper.AtomicUpdate("/some/key", &TestResource{}, func(in runtime.Object) (runtime.Object, error) {
|
||||
return obj, nil
|
||||
})
|
||||
|
@ -421,7 +422,7 @@ func TestAtomicUpdateNoChange(t *testing.T) {
|
|||
|
||||
// Update an existing node with the same data
|
||||
callbackCalled := false
|
||||
objUpdate := &TestResource{TypeMeta: api.TypeMeta{Name: "foo"}, Value: 1}
|
||||
objUpdate := &TestResource{ObjectMeta: api.ObjectMeta{Name: "foo"}, Value: 1}
|
||||
fakeClient.Err = errors.New("should not be called")
|
||||
err = helper.AtomicUpdate("/some/key", &TestResource{}, func(in runtime.Object) (runtime.Object, error) {
|
||||
callbackCalled = true
|
||||
|
@ -464,7 +465,7 @@ func TestAtomicUpdate_CreateCollision(t *testing.T) {
|
|||
}
|
||||
|
||||
currValue := in.(*TestResource).Value
|
||||
obj := &TestResource{TypeMeta: api.TypeMeta{Name: "foo"}, Value: currValue + 1}
|
||||
obj := &TestResource{ObjectMeta: api.ObjectMeta{Name: "foo"}, Value: currValue + 1}
|
||||
return obj, nil
|
||||
})
|
||||
if err != nil {
|
||||
|
|
|
@ -32,9 +32,9 @@ import (
|
|||
func TestWatchInterpretations(t *testing.T) {
|
||||
codec := latest.Codec
|
||||
// Declare some pods to make the test cases compact.
|
||||
podFoo := &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}
|
||||
podBar := &api.Pod{TypeMeta: api.TypeMeta{Name: "bar"}}
|
||||
podBaz := &api.Pod{TypeMeta: api.TypeMeta{Name: "baz"}}
|
||||
podFoo := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}
|
||||
podBar := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "bar"}}
|
||||
podBaz := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "baz"}}
|
||||
firstLetterIsB := func(obj runtime.Object) bool {
|
||||
return obj.(*api.Pod).Name[0] == 'b'
|
||||
}
|
||||
|
@ -236,7 +236,7 @@ func TestWatch(t *testing.T) {
|
|||
}
|
||||
|
||||
// Test normal case
|
||||
pod := &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}
|
||||
pod := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}
|
||||
podBytes, _ := codec.Encode(pod)
|
||||
fakeClient.WatchResponse <- &etcd.Response{
|
||||
Action: "set",
|
||||
|
@ -294,7 +294,7 @@ func TestWatchEtcdState(t *testing.T) {
|
|||
{
|
||||
Action: "create",
|
||||
Node: &etcd.Node{
|
||||
Value: string(runtime.EncodeOrDie(codec, &api.Endpoints{TypeMeta: api.TypeMeta{Name: "foo"}, Endpoints: []string{}})),
|
||||
Value: string(runtime.EncodeOrDie(codec, &api.Endpoints{ObjectMeta: api.ObjectMeta{Name: "foo"}, Endpoints: []string{}})),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -308,12 +308,12 @@ func TestWatchEtcdState(t *testing.T) {
|
|||
{
|
||||
Action: "compareAndSwap",
|
||||
Node: &etcd.Node{
|
||||
Value: string(runtime.EncodeOrDie(codec, &api.Endpoints{TypeMeta: api.TypeMeta{Name: "foo"}, Endpoints: []string{"127.0.0.1:9000"}})),
|
||||
Value: string(runtime.EncodeOrDie(codec, &api.Endpoints{ObjectMeta: api.ObjectMeta{Name: "foo"}, Endpoints: []string{"127.0.0.1:9000"}})),
|
||||
CreatedIndex: 1,
|
||||
ModifiedIndex: 2,
|
||||
},
|
||||
PrevNode: &etcd.Node{
|
||||
Value: string(runtime.EncodeOrDie(codec, &api.Endpoints{TypeMeta: api.TypeMeta{Name: "foo"}, Endpoints: []string{}})),
|
||||
Value: string(runtime.EncodeOrDie(codec, &api.Endpoints{ObjectMeta: api.ObjectMeta{Name: "foo"}, Endpoints: []string{}})),
|
||||
CreatedIndex: 1,
|
||||
ModifiedIndex: 1,
|
||||
},
|
||||
|
@ -330,7 +330,7 @@ func TestWatchEtcdState(t *testing.T) {
|
|||
R: &etcd.Response{
|
||||
Action: "get",
|
||||
Node: &etcd.Node{
|
||||
Value: string(runtime.EncodeOrDie(codec, &api.Endpoints{TypeMeta: api.TypeMeta{Name: "foo"}, Endpoints: []string{}})),
|
||||
Value: string(runtime.EncodeOrDie(codec, &api.Endpoints{ObjectMeta: api.ObjectMeta{Name: "foo"}, Endpoints: []string{}})),
|
||||
CreatedIndex: 1,
|
||||
ModifiedIndex: 1,
|
||||
},
|
||||
|
@ -343,12 +343,12 @@ func TestWatchEtcdState(t *testing.T) {
|
|||
{
|
||||
Action: "compareAndSwap",
|
||||
Node: &etcd.Node{
|
||||
Value: string(runtime.EncodeOrDie(codec, &api.Endpoints{TypeMeta: api.TypeMeta{Name: "foo"}, Endpoints: []string{"127.0.0.1:9000"}})),
|
||||
Value: string(runtime.EncodeOrDie(codec, &api.Endpoints{ObjectMeta: api.ObjectMeta{Name: "foo"}, Endpoints: []string{"127.0.0.1:9000"}})),
|
||||
CreatedIndex: 1,
|
||||
ModifiedIndex: 2,
|
||||
},
|
||||
PrevNode: &etcd.Node{
|
||||
Value: string(runtime.EncodeOrDie(codec, &api.Endpoints{TypeMeta: api.TypeMeta{Name: "foo"}, Endpoints: []string{}})),
|
||||
Value: string(runtime.EncodeOrDie(codec, &api.Endpoints{ObjectMeta: api.ObjectMeta{Name: "foo"}, Endpoints: []string{}})),
|
||||
CreatedIndex: 1,
|
||||
ModifiedIndex: 1,
|
||||
},
|
||||
|
@ -391,7 +391,7 @@ func TestWatchEtcdState(t *testing.T) {
|
|||
|
||||
func TestWatchFromZeroIndex(t *testing.T) {
|
||||
codec := latest.Codec
|
||||
pod := &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}
|
||||
pod := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}
|
||||
|
||||
testCases := map[string]struct {
|
||||
Response EtcdResponseWithError
|
||||
|
@ -464,7 +464,7 @@ func TestWatchFromZeroIndex(t *testing.T) {
|
|||
|
||||
func TestWatchListFromZeroIndex(t *testing.T) {
|
||||
codec := latest.Codec
|
||||
pod := &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}
|
||||
pod := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}
|
||||
|
||||
fakeClient := NewFakeEtcdClient(t)
|
||||
fakeClient.Data["/some/key"] = EtcdResponseWithError{
|
||||
|
|
|
@ -36,7 +36,7 @@ func TestDecoder(t *testing.T) {
|
|||
out, in := io.Pipe()
|
||||
decoder := NewDecoder(out, testapi.Codec())
|
||||
|
||||
expect := &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}
|
||||
expect := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}
|
||||
encoder := json.NewEncoder(in)
|
||||
go func() {
|
||||
data, err := testapi.Codec().Encode(expect)
|
||||
|
|
|
@ -37,17 +37,17 @@ func TestEncodeDecodeRoundTrip(t *testing.T) {
|
|||
}{
|
||||
{
|
||||
watch.Added,
|
||||
&api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}},
|
||||
&api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}},
|
||||
v1beta1.Codec,
|
||||
},
|
||||
{
|
||||
watch.Modified,
|
||||
&api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}},
|
||||
&api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}},
|
||||
v1beta2.Codec,
|
||||
},
|
||||
{
|
||||
watch.Deleted,
|
||||
&api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}},
|
||||
&api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}},
|
||||
api.Codec,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -145,8 +145,8 @@ func TestPollMinions(t *testing.T) {
|
|||
}{
|
||||
{
|
||||
minions: []api.Minion{
|
||||
{TypeMeta: api.TypeMeta{Name: "foo"}},
|
||||
{TypeMeta: api.TypeMeta{Name: "bar"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "foo"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "bar"}},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ func TestPollMinions(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDefaultErrorFunc(t *testing.T) {
|
||||
testPod := &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}
|
||||
testPod := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}
|
||||
handler := util.FakeHandler{
|
||||
StatusCode: 200,
|
||||
ResponseBody: runtime.EncodeOrDie(latest.Codec, testPod),
|
||||
|
@ -219,7 +219,7 @@ func TestStoreToMinionLister(t *testing.T) {
|
|||
store := cache.NewStore()
|
||||
ids := util.NewStringSet("foo", "bar", "baz")
|
||||
for id := range ids {
|
||||
store.Add(id, &api.Minion{TypeMeta: api.TypeMeta{Name: id}})
|
||||
store.Add(id, &api.Minion{ObjectMeta: api.ObjectMeta{Name: id}})
|
||||
}
|
||||
sml := storeToMinionLister{store}
|
||||
|
||||
|
@ -241,8 +241,10 @@ func TestStoreToPodLister(t *testing.T) {
|
|||
ids := []string{"foo", "bar", "baz"}
|
||||
for _, id := range ids {
|
||||
store.Add(id, &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: id},
|
||||
Labels: map[string]string{"name": id},
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: id,
|
||||
Labels: map[string]string{"name": id},
|
||||
},
|
||||
})
|
||||
}
|
||||
spl := storeToPodLister{store}
|
||||
|
@ -267,9 +269,9 @@ func TestStoreToPodLister(t *testing.T) {
|
|||
func TestMinionEnumerator(t *testing.T) {
|
||||
testList := &api.MinionList{
|
||||
Items: []api.Minion{
|
||||
{TypeMeta: api.TypeMeta{Name: "foo"}},
|
||||
{TypeMeta: api.TypeMeta{Name: "bar"}},
|
||||
{TypeMeta: api.TypeMeta{Name: "baz"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "foo"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "bar"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "baz"}},
|
||||
},
|
||||
}
|
||||
me := minionEnumerator{testList}
|
||||
|
|
|
@ -34,7 +34,7 @@ type fakeBinder struct {
|
|||
func (fb fakeBinder) Bind(binding *api.Binding) error { return fb.b(binding) }
|
||||
|
||||
func podWithID(id string) *api.Pod {
|
||||
return &api.Pod{TypeMeta: api.TypeMeta{Name: id, SelfLink: testapi.SelfLink("pods", id)}}
|
||||
return &api.Pod{ObjectMeta: api.ObjectMeta{Name: id, SelfLink: testapi.SelfLink("pods", id)}}
|
||||
}
|
||||
|
||||
type mockScheduler struct {
|
||||
|
@ -88,7 +88,7 @@ func TestScheduler(t *testing.T) {
|
|||
var gotBinding *api.Binding
|
||||
c := &Config{
|
||||
MinionLister: scheduler.FakeMinionLister(
|
||||
api.MinionList{Items: []api.Minion{{TypeMeta: api.TypeMeta{Name: "machine1"}}}},
|
||||
api.MinionList{Items: []api.Minion{{ObjectMeta: api.ObjectMeta{Name: "machine1"}}}},
|
||||
),
|
||||
Algorithm: item.algo,
|
||||
Binder: fakeBinder{func(b *api.Binding) error {
|
||||
|
|
|
@ -95,7 +95,7 @@ func TestWatch(t *testing.T) {
|
|||
client := newEtcdClient()
|
||||
helper := tools.EtcdHelper{Client: client, Codec: latest.Codec, ResourceVersioner: tools.RuntimeVersionAdapter{latest.ResourceVersioner}}
|
||||
withEtcdKey(func(key string) {
|
||||
resp, err := client.Set(key, runtime.EncodeOrDie(v1beta1.Codec, &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}), 0)
|
||||
resp, err := client.Set(key, runtime.EncodeOrDie(v1beta1.Codec, &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}), 0)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue