On delete, also attempt to update controller state, in case we

missed a previous update.  Add a test to validate that this works
This commit is contained in:
Brendan Burns
2014-06-18 20:25:25 -07:00
parent e2974a0a75
commit 84b2a9e9f3
2 changed files with 49 additions and 1 deletions

View File

@@ -231,7 +231,7 @@ func TestHandleWatchResponseNotSet(t *testing.T) {
manager := MakeReplicationManager(nil, &client)
manager.podControl = &fakePodControl
_, err := manager.handleWatchResponse(&etcd.Response{
Action: "delete",
Action: "update",
})
expectNoError(t, err)
}
@@ -319,6 +319,40 @@ func TestHandleWatchResponse(t *testing.T) {
}
}
func TestHandleWatchResponseDelete(t *testing.T) {
body, _ := json.Marshal(makePodList(2))
fakeHandler := util.FakeHandler{
StatusCode: 200,
ResponseBody: string(body),
}
testServer := httptest.NewTLSServer(&fakeHandler)
client := client.Client{
Host: testServer.URL,
}
fakePodControl := FakePodControl{}
manager := MakeReplicationManager(nil, &client)
manager.podControl = &fakePodControl
controller := makeReplicationController(2)
data, err := json.Marshal(controller)
expectNoError(t, err)
controllerOut, err := manager.handleWatchResponse(&etcd.Response{
Action: "delete",
PrevNode: &etcd.Node{
Value: string(data),
},
})
if err != nil {
t.Errorf("Unexpected error: %#v", err)
}
if !reflect.DeepEqual(controller, *controllerOut) {
t.Errorf("Unexpected mismatch. Expected %#v, Saw: %#v", controller, controllerOut)
}
}
func TestSyncronize(t *testing.T) {
controllerSpec1 := api.ReplicationController{
DesiredState: api.ReplicationControllerState{