add ut for remove pod of kube 23/34023/1
authorLvbo163 <lv.bo163@zte.com.cn>
Mon, 5 Mar 2018 09:22:55 +0000 (17:22 +0800)
committerLvbo163 <lv.bo163@zte.com.cn>
Mon, 5 Mar 2018 09:22:55 +0000 (17:22 +0800)
Issue-ID: MSB-161

Change-Id: I3ac8ceab987a5315ec46d61d1b286d2cbd558e14
Signed-off-by: Lvbo163 <lv.bo163@zte.com.cn>
src/kube2msb/kube_work_test.go

index a96f5c9..f67608a 100644 (file)
@@ -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