diff --git a/pkg/client/client_test.go b/pkg/client/client_test.go index 7a48fc78392..e75c2289df4 100644 --- a/pkg/client/client_test.go +++ b/pkg/client/client_test.go @@ -145,15 +145,17 @@ func (c *testClient) ValidateCommon(t *testing.T, err error) { } func TestListEmptyPods(t *testing.T) { + ctx := api.NewContext() c := &testClient{ Request: testRequest{Method: "GET", Path: "/pods"}, Response: Response{StatusCode: 200, Body: &api.PodList{}}, } - podList, err := c.Setup().ListPods(labels.Everything()) + podList, err := c.Setup().ListPods(ctx, labels.Everything()) c.Validate(t, podList, err) } func TestListPods(t *testing.T) { + ctx := api.NewDefaultContext() c := &testClient{ Request: testRequest{Method: "GET", Path: "/pods"}, Response: Response{StatusCode: 200, @@ -172,7 +174,7 @@ func TestListPods(t *testing.T) { }, }, } - receivedPodList, err := c.Setup().ListPods(labels.Everything()) + receivedPodList, err := c.Setup().ListPods(ctx, labels.Everything()) c.Validate(t, receivedPodList, err) } @@ -183,6 +185,7 @@ func validateLabels(a, b string) bool { } func TestListPodsLabels(t *testing.T) { + ctx := api.NewDefaultContext() c := &testClient{ Request: testRequest{Method: "GET", Path: "/pods", Query: url.Values{"labels": []string{"foo=bar,name=baz"}}}, Response: Response{ @@ -205,11 +208,12 @@ func TestListPodsLabels(t *testing.T) { c.Setup() c.QueryValidator["labels"] = validateLabels selector := labels.Set{"foo": "bar", "name": "baz"}.AsSelector() - receivedPodList, err := c.ListPods(selector) + receivedPodList, err := c.ListPods(ctx, selector) c.Validate(t, receivedPodList, err) } func TestGetPod(t *testing.T) { + ctx := api.NewDefaultContext() c := &testClient{ Request: testRequest{Method: "GET", Path: "/pods/foo"}, Response: Response{ @@ -225,7 +229,7 @@ func TestGetPod(t *testing.T) { }, }, } - receivedPod, err := c.Setup().GetPod("foo") + receivedPod, err := c.Setup().GetPod(ctx, "foo") c.Validate(t, receivedPod, err) } @@ -234,7 +238,7 @@ func TestDeletePod(t *testing.T) { Request: testRequest{Method: "DELETE", Path: "/pods/foo"}, Response: Response{StatusCode: 200}, } - err := c.Setup().DeletePod("foo") + err := c.Setup().DeletePod(api.NewDefaultContext(), "foo") c.Validate(t, nil, err) } @@ -255,7 +259,7 @@ func TestCreatePod(t *testing.T) { Body: requestPod, }, } - receivedPod, err := c.Setup().CreatePod(requestPod) + receivedPod, err := c.Setup().CreatePod(api.NewDefaultContext(), requestPod) c.Validate(t, receivedPod, err) } @@ -274,7 +278,7 @@ func TestUpdatePod(t *testing.T) { Request: testRequest{Method: "PUT", Path: "/pods/foo"}, Response: Response{StatusCode: 200, Body: requestPod}, } - receivedPod, err := c.Setup().UpdatePod(requestPod) + receivedPod, err := c.Setup().UpdatePod(api.NewDefaultContext(), requestPod) c.Validate(t, receivedPod, err) } @@ -298,7 +302,7 @@ func TestListControllers(t *testing.T) { }, }, } - receivedControllerList, err := c.Setup().ListReplicationControllers(labels.Everything()) + receivedControllerList, err := c.Setup().ListReplicationControllers(api.NewContext(), labels.Everything()) c.Validate(t, receivedControllerList, err) } @@ -320,7 +324,7 @@ func TestGetController(t *testing.T) { }, }, } - receivedController, err := c.Setup().GetReplicationController("foo") + receivedController, err := c.Setup().GetReplicationController(api.NewDefaultContext(), "foo") c.Validate(t, receivedController, err) } @@ -344,7 +348,7 @@ func TestUpdateController(t *testing.T) { }, }, } - receivedController, err := c.Setup().UpdateReplicationController(requestController) + receivedController, err := c.Setup().UpdateReplicationController(api.NewDefaultContext(), requestController) c.Validate(t, receivedController, err) } @@ -353,7 +357,7 @@ func TestDeleteController(t *testing.T) { Request: testRequest{Method: "DELETE", Path: "/replicationControllers/foo"}, Response: Response{StatusCode: 200}, } - err := c.Setup().DeleteReplicationController("foo") + err := c.Setup().DeleteReplicationController(api.NewDefaultContext(), "foo") c.Validate(t, nil, err) } @@ -377,7 +381,7 @@ func TestCreateController(t *testing.T) { }, }, } - receivedController, err := c.Setup().CreateReplicationController(requestController) + receivedController, err := c.Setup().CreateReplicationController(api.NewDefaultContext(), requestController) c.Validate(t, receivedController, err) } @@ -410,7 +414,7 @@ func TestListServices(t *testing.T) { }, }, } - receivedServiceList, err := c.Setup().ListServices(labels.Everything()) + receivedServiceList, err := c.Setup().ListServices(api.NewDefaultContext(), labels.Everything()) c.Validate(t, receivedServiceList, err) } @@ -437,7 +441,7 @@ func TestListServicesLabels(t *testing.T) { c.Setup() c.QueryValidator["labels"] = validateLabels selector := labels.Set{"foo": "bar", "name": "baz"}.AsSelector() - receivedServiceList, err := c.ListServices(selector) + receivedServiceList, err := c.ListServices(api.NewDefaultContext(), selector) c.Validate(t, receivedServiceList, err) } @@ -446,7 +450,7 @@ func TestGetService(t *testing.T) { Request: testRequest{Method: "GET", Path: "/services/1"}, Response: Response{StatusCode: 200, Body: &api.Service{JSONBase: api.JSONBase{ID: "service-1"}}}, } - response, err := c.Setup().GetService("1") + response, err := c.Setup().GetService(api.NewDefaultContext(), "1") c.Validate(t, response, err) } @@ -455,7 +459,7 @@ func TestCreateService(t *testing.T) { Request: testRequest{Method: "POST", Path: "/services", Body: &api.Service{JSONBase: api.JSONBase{ID: "service-1"}}}, Response: Response{StatusCode: 200, Body: &api.Service{JSONBase: api.JSONBase{ID: "service-1"}}}, } - response, err := c.Setup().CreateService(&api.Service{JSONBase: api.JSONBase{ID: "service-1"}}) + response, err := c.Setup().CreateService(api.NewDefaultContext(), &api.Service{JSONBase: api.JSONBase{ID: "service-1"}}) c.Validate(t, response, err) } @@ -465,7 +469,7 @@ func TestUpdateService(t *testing.T) { Request: testRequest{Method: "PUT", Path: "/services/service-1", Body: svc}, Response: Response{StatusCode: 200, Body: svc}, } - response, err := c.Setup().UpdateService(svc) + response, err := c.Setup().UpdateService(api.NewDefaultContext(), svc) c.Validate(t, response, err) } @@ -474,7 +478,7 @@ func TestDeleteService(t *testing.T) { Request: testRequest{Method: "DELETE", Path: "/services/1"}, Response: Response{StatusCode: 200}, } - err := c.Setup().DeleteService("1") + err := c.Setup().DeleteService(api.NewDefaultContext(), "1") c.Validate(t, nil, err) } @@ -492,7 +496,7 @@ func TestListEndpooints(t *testing.T) { }, }, } - receivedEndpointsList, err := c.Setup().ListEndpoints(labels.Everything()) + receivedEndpointsList, err := c.Setup().ListEndpoints(api.NewDefaultContext(), labels.Everything()) c.Validate(t, receivedEndpointsList, err) } @@ -501,7 +505,7 @@ func TestGetEndpoints(t *testing.T) { Request: testRequest{Method: "GET", Path: "/endpoints/endpoint-1"}, Response: Response{StatusCode: 200, Body: &api.Endpoints{JSONBase: api.JSONBase{ID: "endpoint-1"}}}, } - response, err := c.Setup().GetEndpoints("endpoint-1") + response, err := c.Setup().GetEndpoints(api.NewDefaultContext(), "endpoint-1") c.Validate(t, response, err) } diff --git a/pkg/controller/replication_controller_test.go b/pkg/controller/replication_controller_test.go index fb96b9d9154..58780b77e35 100644 --- a/pkg/controller/replication_controller_test.go +++ b/pkg/controller/replication_controller_test.go @@ -49,13 +49,13 @@ type FakePodControl struct { lock sync.Mutex } -func (f *FakePodControl) createReplica(spec api.ReplicationController) { +func (f *FakePodControl) createReplica(ctx api.Context, spec api.ReplicationController) { f.lock.Lock() defer f.lock.Unlock() f.controllerSpec = append(f.controllerSpec, spec) } -func (f *FakePodControl) deletePod(podID string) error { +func (f *FakePodControl) deletePod(ctx api.Context, podID string) error { f.lock.Lock() defer f.lock.Unlock() f.deletePodID = append(f.deletePodID, podID) @@ -169,6 +169,7 @@ func TestSyncReplicationControllerCreates(t *testing.T) { } func TestCreateReplica(t *testing.T) { + ctx := api.NewDefaultContext() body := runtime.EncodeOrDie(testapi.CodecForVersionOrDie(), &api.Pod{}) fakeHandler := util.FakeHandler{ StatusCode: 200, @@ -204,7 +205,7 @@ func TestCreateReplica(t *testing.T) { }, } - podControl.createReplica(controllerSpec) + podControl.createReplica(ctx, controllerSpec) expectedPod := api.Pod{ JSONBase: api.JSONBase{ @@ -323,7 +324,7 @@ type FakeWatcher struct { *client.Fake } -func (fw FakeWatcher) WatchReplicationControllers(l, f labels.Selector, rv uint64) (watch.Interface, error) { +func (fw FakeWatcher) WatchReplicationControllers(ctx api.Context, l, f labels.Selector, rv uint64) (watch.Interface, error) { return fw.w, nil } diff --git a/pkg/kubecfg/kubecfg_test.go b/pkg/kubecfg/kubecfg_test.go index 912cbfa723c..84b8d7c0abc 100644 --- a/pkg/kubecfg/kubecfg_test.go +++ b/pkg/kubecfg/kubecfg_test.go @@ -43,7 +43,7 @@ func TestUpdateWithPods(t *testing.T) { }, }, } - Update("foo", &fakeClient, 0, "") + Update(api.NewDefaultContext(), "foo", &fakeClient, 0, "") if len(fakeClient.Actions) != 5 { t.Fatalf("Unexpected action list %#v", fakeClient.Actions) } @@ -57,7 +57,7 @@ func TestUpdateWithPods(t *testing.T) { func TestUpdateNoPods(t *testing.T) { fakeClient := client.Fake{} - Update("foo", &fakeClient, 0, "") + Update(api.NewDefaultContext(), "foo", &fakeClient, 0, "") if len(fakeClient.Actions) != 2 { t.Errorf("Unexpected action list %#v", fakeClient.Actions) } @@ -87,7 +87,7 @@ func TestUpdateWithNewImage(t *testing.T) { }, }, } - Update("foo", &fakeClient, 0, "fooImage:2") + Update(api.NewDefaultContext(), "foo", &fakeClient, 0, "fooImage:2") if len(fakeClient.Actions) != 6 { t.Errorf("Unexpected action list %#v", fakeClient.Actions) } @@ -109,7 +109,7 @@ func TestRunController(t *testing.T) { name := "name" image := "foo/bar" replicas := 3 - RunController(image, name, replicas, &fakeClient, "8080:80", -1) + RunController(api.NewDefaultContext(), image, name, replicas, &fakeClient, "8080:80", -1) if len(fakeClient.Actions) != 1 || fakeClient.Actions[0].Action != "create-controller" { t.Errorf("Unexpected actions: %#v", fakeClient.Actions) } @@ -126,7 +126,7 @@ func TestRunControllerWithService(t *testing.T) { name := "name" image := "foo/bar" replicas := 3 - RunController(image, name, replicas, &fakeClient, "", 8000) + RunController(api.NewDefaultContext(), image, name, replicas, &fakeClient, "", 8000) if len(fakeClient.Actions) != 2 || fakeClient.Actions[0].Action != "create-controller" || fakeClient.Actions[1].Action != "create-service" { @@ -143,7 +143,7 @@ func TestRunControllerWithService(t *testing.T) { func TestStopController(t *testing.T) { fakeClient := client.Fake{} name := "name" - StopController(name, &fakeClient) + StopController(api.NewDefaultContext(), name, &fakeClient) if len(fakeClient.Actions) != 2 { t.Errorf("Unexpected actions: %#v", fakeClient.Actions) } @@ -162,7 +162,7 @@ func TestResizeController(t *testing.T) { fakeClient := client.Fake{} name := "name" replicas := 17 - ResizeController(name, replicas, &fakeClient) + ResizeController(api.NewDefaultContext(), name, replicas, &fakeClient) if len(fakeClient.Actions) != 2 { t.Errorf("Unexpected actions: %#v", fakeClient.Actions) } @@ -180,7 +180,7 @@ func TestResizeController(t *testing.T) { func TestCloudCfgDeleteController(t *testing.T) { fakeClient := client.Fake{} name := "name" - err := DeleteController(name, &fakeClient) + err := DeleteController(api.NewDefaultContext(), name, &fakeClient) if err != nil { t.Errorf("Unexpected error: %v", err) } @@ -206,7 +206,7 @@ func TestCloudCfgDeleteControllerWithReplicas(t *testing.T) { }, } name := "name" - err := DeleteController(name, &fakeClient) + err := DeleteController(api.NewDefaultContext(), name, &fakeClient) if len(fakeClient.Actions) != 1 { t.Errorf("Unexpected actions: %#v", fakeClient.Actions) }