@@ -34,46 +34,76 @@ import (
34
34
var _ = Describe ("Clients Leaving" , func () {
35
35
Context ("normally" , func () {
36
36
It ("number of hosts should be ok" , Label ("host" , "leave" ), func () {
37
+ // create scheduler GRPC client
37
38
grpcCredentials := insecure .NewCredentials ()
38
39
schedulerClient , err := schedulerclient .GetV2ByAddr (context .Background (), ":8002" , grpc .WithTransportCredentials (grpcCredentials ))
39
40
Expect (err ).NotTo (HaveOccurred ())
40
41
42
+ // get host count
41
43
hostCount := util .Servers [util .SeedClientServerName ].Replicas + util .Servers [util .ClientServerName ].Replicas
42
44
time .Sleep (10 * time .Minute )
43
45
Expect (getHostCountFromScheduler (schedulerClient )).To (Equal (hostCount ))
44
46
47
+ // get client pod name in master node
45
48
podName , err := util .GetClientPodNameInMaster ()
46
49
Expect (err ).NotTo (HaveOccurred ())
47
50
48
- out , err := util .KubeCtlCommand ("-n" , util .DragonflyNamespace , "delete" , "pod" , podName ).CombinedOutput ()
51
+ // taint master node
52
+ out , err := util .KubeCtlCommand ("-n" , util .DragonflyNamespace , "taint" , "nodes" , "kind-control-plane" , "master:NoSchedule" ).CombinedOutput ()
53
+ fmt .Println (string (out ))
54
+ Expect (err ).NotTo (HaveOccurred ())
55
+
56
+ // delete client pod in master, client will leave normally
57
+ out , err = util .KubeCtlCommand ("-n" , util .DragonflyNamespace , "delete" , "pod" , podName , "--grace-period=30" ).CombinedOutput ()
49
58
fmt .Println (string (out ))
50
59
Expect (err ).NotTo (HaveOccurred ())
51
60
52
61
// wait fot the client to leave gracefully
53
- time .Sleep (1 * time .Minute )
54
- Expect (getHostCountFromScheduler (schedulerClient )).To (Equal (hostCount ))
62
+ time .Sleep (30 * time .Second )
63
+ Expect (getHostCountFromScheduler (schedulerClient )).To (Equal (hostCount - 1 ))
64
+
65
+ // remove taint in master node
66
+ out , err = util .KubeCtlCommand ("-n" , util .DragonflyNamespace , "taint" , "nodes" , "kind-control-plane" , "master:NoSchedule-" ).CombinedOutput ()
67
+ fmt .Println (string (out ))
68
+ Expect (err ).NotTo (HaveOccurred ())
55
69
})
56
70
})
57
71
58
72
Context ("abnormally" , func () {
59
73
It ("number of hosts should be ok" , Label ("host" , "leave" ), func () {
74
+ // create scheduler GRPC client
60
75
grpcCredentials := insecure .NewCredentials ()
61
76
schedulerClient , err := schedulerclient .GetV2ByAddr (context .Background (), ":8002" , grpc .WithTransportCredentials (grpcCredentials ))
62
77
Expect (err ).NotTo (HaveOccurred ())
63
78
79
+ // get host count
64
80
hostCount := util .Servers [util .SeedClientServerName ].Replicas + util .Servers [util .ClientServerName ].Replicas
81
+ time .Sleep (30 * time .Second )
65
82
Expect (getHostCountFromScheduler (schedulerClient )).To (Equal (hostCount ))
66
83
84
+ // get client pod name in master node
67
85
podName , err := util .GetClientPodNameInMaster ()
68
86
Expect (err ).NotTo (HaveOccurred ())
69
87
70
- out , err := util .KubeCtlCommand ("-n" , util .DragonflyNamespace , "delete" , "pod" , podName , "--force" , "--grace-period=0" ).CombinedOutput ()
88
+ // taint master node
89
+ out , err := util .KubeCtlCommand ("-n" , util .DragonflyNamespace , "taint" , "nodes" , "kind-control-plane" , "master:NoSchedule" ).CombinedOutput ()
90
+ fmt .Println (string (out ))
91
+ Expect (err ).NotTo (HaveOccurred ())
92
+
93
+ // force delete client pod in master, client will leave abnormally
94
+ out , err = util .KubeCtlCommand ("-n" , util .DragonflyNamespace , "delete" , "pod" , podName , "--force" , "--grace-period=0" ).CombinedOutput ()
71
95
fmt .Println (string (out ))
72
96
Expect (err ).NotTo (HaveOccurred ())
73
97
74
98
// wait for host gc
75
- time .Sleep (6 * time .Minute )
76
- Expect (getHostCountFromScheduler (schedulerClient )).To (Equal (hostCount ))
99
+ time .Sleep (2 * time .Minute )
100
+ Expect (getHostCountFromScheduler (schedulerClient )).To (Equal (hostCount - 1 ))
101
+
102
+ // remove taint in master node
103
+ out , err = util .KubeCtlCommand ("-n" , util .DragonflyNamespace , "taint" , "nodes" , "kind-control-plane" , "master:NoSchedule-" ).CombinedOutput ()
104
+ fmt .Println (string (out ))
105
+ Expect (err ).NotTo (HaveOccurred ())
106
+ time .Sleep (30 * time .Second )
77
107
})
78
108
})
79
109
})
0 commit comments