Skip to content

Commit

Permalink
fix: taint master node in leave host test
Browse files Browse the repository at this point in the history
Signed-off-by: BruceAko <chongzhi@hust.edu.cn>
  • Loading branch information
BruceAko committed Oct 15, 2024
1 parent c63d357 commit dd556de
Showing 1 changed file with 29 additions and 5 deletions.
34 changes: 29 additions & 5 deletions test/e2e/v2/leave_host_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,46 +34,70 @@ import (
var _ = Describe("Clients Leaving", func() {
Context("normally", func() {
It("number of hosts should be ok", Label("host", "leave"), func() {
// create scheduler GRPC client
grpcCredentials := insecure.NewCredentials()
schedulerClient, err := schedulerclient.GetV2ByAddr(context.Background(), ":8002", grpc.WithTransportCredentials(grpcCredentials))
Expect(err).NotTo(HaveOccurred())

// get host count
hostCount := util.Servers[util.SeedClientServerName].Replicas + util.Servers[util.ClientServerName].Replicas
time.Sleep(10 * time.Minute)
Expect(getHostCountFromScheduler(schedulerClient)).To(Equal(hostCount))

// get client pod name in master node
podName, err := util.GetClientPodNameInMaster()
Expect(err).NotTo(HaveOccurred())

out, err := util.KubeCtlCommand("-n", util.DragonflyNamespace, "delete", "pod", podName).CombinedOutput()
// taint master node
out, err := util.KubeCtlCommand("-n", util.DragonflyNamespace, "taint", "nodes", "kind-control-plane", "master:NoSchedule").CombinedOutput()
fmt.Println(string(out))
Expect(err).NotTo(HaveOccurred())

// delete client pod in master, client will leave normally
out, err = util.KubeCtlCommand("-n", util.DragonflyNamespace, "delete", "pod", podName).CombinedOutput()
fmt.Println(string(out))
Expect(err).NotTo(HaveOccurred())

// wait fot the client to leave gracefully
time.Sleep(1 * time.Minute)
Expect(getHostCountFromScheduler(schedulerClient)).To(Equal(hostCount))
Expect(getHostCountFromScheduler(schedulerClient)).To(Equal(hostCount - 1))

// remove taint in master node
out, err = util.KubeCtlCommand("-n", util.DragonflyNamespace, "taint", "nodes", "kind-control-plane", "master:NoSchedule-").CombinedOutput()
fmt.Println(string(out))
Expect(err).NotTo(HaveOccurred())
})
})

Context("abnormally", func() {
It("number of hosts should be ok", Label("host", "leave"), func() {
// create scheduler GRPC client
grpcCredentials := insecure.NewCredentials()
schedulerClient, err := schedulerclient.GetV2ByAddr(context.Background(), ":8002", grpc.WithTransportCredentials(grpcCredentials))
Expect(err).NotTo(HaveOccurred())

// get host count
hostCount := util.Servers[util.SeedClientServerName].Replicas + util.Servers[util.ClientServerName].Replicas
time.Sleep(1 * time.Minute)
Expect(getHostCountFromScheduler(schedulerClient)).To(Equal(hostCount))

// get client pod name in master node
podName, err := util.GetClientPodNameInMaster()
Expect(err).NotTo(HaveOccurred())

out, err := util.KubeCtlCommand("-n", util.DragonflyNamespace, "delete", "pod", podName, "--force", "--grace-period=0").CombinedOutput()
// taint master node
out, err := util.KubeCtlCommand("-n", util.DragonflyNamespace, "taint", "nodes", "kind-control-plane", "master:NoSchedule").CombinedOutput()
fmt.Println(string(out))
Expect(err).NotTo(HaveOccurred())

// force delete client pod in master, client will leave abnormally
out, err = util.KubeCtlCommand("-n", util.DragonflyNamespace, "delete", "pod", podName, "--force", "--grace-period=0").CombinedOutput()
fmt.Println(string(out))
Expect(err).NotTo(HaveOccurred())

// wait for host gc
time.Sleep(6 * time.Minute)
Expect(getHostCountFromScheduler(schedulerClient)).To(Equal(hostCount))
time.Sleep(5 * time.Minute)
Expect(getHostCountFromScheduler(schedulerClient)).To(Equal(hostCount - 1))
})
})
})
Expand Down

0 comments on commit dd556de

Please sign in to comment.