From ae6d8b70401361d05f62757349a226931e614fba Mon Sep 17 00:00:00 2001 From: Lvbo163 Date: Mon, 5 Mar 2018 16:58:25 +0800 Subject: add ut for updateService of kubework Issue-ID: MSB-159 Change-Id: I8682d1eb06724451fb707fa980a424156232f82a Signed-off-by: Lvbo163 --- src/kube2msb/kube_work_test.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/kube2msb/kube_work_test.go b/src/kube2msb/kube_work_test.go index 1c187c1..cc79439 100644 --- a/src/kube2msb/kube_work_test.go +++ b/src/kube2msb/kube_work_test.go @@ -129,3 +129,34 @@ func TestRemoveServiceKube(t *testing.T) { serviceLoadBalancer.Spec.LoadBalancerIP = "192.168.10.12" removeSingleServiceTest(t, client, msbWorkQueue, serviceLoadBalancer, "192.168.10.12") } + +func TestUpdateServiceKube(t *testing.T) { + client := newClientBookKeeper() + msbWorkQueue := make(chan MSBWork, 10) + client.msbQueue = msbWorkQueue + + // exception process + // TODO ServiceKey not set , cannot check result for there would be no return + serviceWithoutServiceKey := kapi.Service{ + ObjectMeta: kapi.ObjectMeta{ + Annotations: map[string]string{}, + }, + } + client.UpdateService(&serviceWithoutServiceKey) + + // normal process + // update exist service + service := createMockService("ServiceTypeNodePort", "192.168.10.11", kapi.ServiceTypeNodePort) + client.AddService(service) + msbWorkValidate(t, msbWorkQueue, service, MSBWorkAddService, "192.168.10.11") + // update service info + service.Spec.ClusterIP = "0.0.0.0" + client.UpdateService(service) + msbWorkValidate(t, msbWorkQueue, service, MSBWorkRemoveService, "0.0.0.0") + msbWorkValidate(t, msbWorkQueue, service, MSBWorkAddService, "0.0.0.0") + + // update not exist service + notExistService := createMockService("notExistService", "192.168.10.12", kapi.ServiceTypeNodePort) + client.UpdateService(notExistService) + msbWorkValidate(t, msbWorkQueue, notExistService, MSBWorkAddService, "192.168.10.12") +} -- cgit 1.2.3-korg