diff options
author | Lvbo163 <lv.bo163@zte.com.cn> | 2018-03-05 16:58:25 +0800 |
---|---|---|
committer | Lvbo163 <lv.bo163@zte.com.cn> | 2018-03-05 16:58:25 +0800 |
commit | ae6d8b70401361d05f62757349a226931e614fba (patch) | |
tree | bfaa52cc8f40ef749dc3410cc65c945f6350d53c /src/kube2msb | |
parent | 5cc783ea45508ddfdfae656468662c4e538b7385 (diff) |
add ut for updateService of kubework
Issue-ID: MSB-159
Change-Id: I8682d1eb06724451fb707fa980a424156232f82a
Signed-off-by: Lvbo163 <lv.bo163@zte.com.cn>
Diffstat (limited to 'src/kube2msb')
-rw-r--r-- | src/kube2msb/kube_work_test.go | 31 |
1 files changed, 31 insertions, 0 deletions
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") +} |