aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLvbo163 <lv.bo163@zte.com.cn>2018-03-05 17:22:55 +0800
committerLvbo163 <lv.bo163@zte.com.cn>2018-03-05 17:22:55 +0800
commit6dc335acbf4d9e9d3b036e2170a1d7b78801185a (patch)
treee5adeb73e5f7491032c7928a2a47755bd0d52952
parent79488acab14b9ab402bcb0079989a76164f813f6 (diff)
add ut for remove pod of kube
Issue-ID: MSB-161 Change-Id: I3ac8ceab987a5315ec46d61d1b286d2cbd558e14 Signed-off-by: Lvbo163 <lv.bo163@zte.com.cn>
-rw-r--r--src/kube2msb/kube_work_test.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/kube2msb/kube_work_test.go b/src/kube2msb/kube_work_test.go
index a96f5c9..f67608a 100644
--- a/src/kube2msb/kube_work_test.go
+++ b/src/kube2msb/kube_work_test.go
@@ -218,3 +218,32 @@ func TestAddPodKube(t *testing.T) {
}
}
+
+
+func TestRemovePodKube(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
+ podWithoutServiceKey := kapi.Pod{}
+ client.RemovePod(&podWithoutServiceKey)
+
+ // TODO Pod not exist , cannot check result for there would be no return
+ podNotExist := createMockPod("podNotExistTest", "192.168.10.10")
+ client.RemovePod(podNotExist)
+
+ // normal process
+ pod := createMockPod("removePodTest", "192.168.10.10")
+ client.AddPod(pod)
+ if _, ok := client.pods[pod.Name]; !ok {
+ t.Errorf("add pod error, pod not exists in client.pods")
+ }
+ msbWorkPodValidate(t, msbWorkQueue, pod, MSBWorkAddPod)
+ client.RemovePod(pod)
+ msbWorkPodValidate(t, msbWorkQueue, pod, MSBWorkRemovePod)
+ if _, ok := client.pods[pod.Name]; ok {
+ t.Errorf("remove pod error, pod still exists in client.pods")
+ }
+} \ No newline at end of file