Commit 644eb700 authored by Clayton Coleman's avatar Clayton Coleman

Refactor tests to split ObjectMeta from TypeMeta

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