|
16 | 16 |
|
17 | 17 | package e2e
|
18 | 18 |
|
19 |
| -//import ( |
20 |
| -// "context" |
21 |
| -// "fmt" |
22 |
| -// "strings" |
23 |
| -// "time" |
24 |
| -// |
25 |
| -// . "github.com/onsi/ginkgo/v2" //nolint |
26 |
| -// . "github.com/onsi/gomega" //nolint |
27 |
| -// "google.golang.org/grpc" |
28 |
| -// "google.golang.org/grpc/credentials/insecure" |
29 |
| -// |
30 |
| -// schedulerclient "d7y.io/dragonfly/v2/pkg/rpc/scheduler/client" |
31 |
| -// "d7y.io/dragonfly/v2/test/e2e/v2/util" |
32 |
| -//) |
33 |
| -// |
34 |
| -//var _ = Describe("Clients Leaving", func() { |
35 |
| -// Context("normally", func() { |
36 |
| -// It("number of hosts should be ok", Label("host", "leave"), func() { |
37 |
| -// grpcCredentials := insecure.NewCredentials() |
38 |
| -// schedulerClient, err := schedulerclient.GetV2ByAddr(context.Background(), ":8002", grpc.WithTransportCredentials(grpcCredentials)) |
39 |
| -// Expect(err).NotTo(HaveOccurred()) |
40 |
| -// |
41 |
| -// time.Sleep(3 * time.Minute) |
42 |
| -// hostCount := util.Servers[util.SeedClientServerName].Replicas + util.Servers[util.ClientServerName].Replicas |
43 |
| -// Expect(getHostCountFromScheduler(schedulerClient)).To(Equal(hostCount)) |
44 |
| -// |
45 |
| -// podName, err := util.GetClientPodName(0) |
46 |
| -// Expect(err).NotTo(HaveOccurred()) |
47 |
| -// |
48 |
| -// out, err := util.KubeCtlCommand("-n", util.DragonflyNamespace, "delete", "pod", podName).CombinedOutput() |
49 |
| -// fmt.Println(string(out)) |
50 |
| -// Expect(err).NotTo(HaveOccurred()) |
51 |
| -// time.Sleep(1 * time.Minute) |
52 |
| -// Expect(getHostCountFromScheduler(schedulerClient)).To(Equal(hostCount)) |
53 |
| -// }) |
54 |
| -// }) |
55 |
| -// |
56 |
| -// Context("abnormally", func() { |
57 |
| -// It("number of hosts should be ok", Label("host", "leave"), func() { |
58 |
| -// grpcCredentials := insecure.NewCredentials() |
59 |
| -// schedulerClient, err := schedulerclient.GetV2ByAddr(context.Background(), ":8002", grpc.WithTransportCredentials(grpcCredentials)) |
60 |
| -// Expect(err).NotTo(HaveOccurred()) |
61 |
| -// |
62 |
| -// time.Sleep(4 * time.Minute) |
63 |
| -// hostCount := util.Servers[util.SeedClientServerName].Replicas + util.Servers[util.ClientServerName].Replicas |
64 |
| -// Expect(getHostCountFromScheduler(schedulerClient)).To(Equal(hostCount)) |
65 |
| -// |
66 |
| -// podName, err := util.GetClientPodName(0) |
67 |
| -// Expect(err).NotTo(HaveOccurred()) |
68 |
| -// |
69 |
| -// out, err := util.KubeCtlCommand("-n", util.DragonflyNamespace, "delete", "pod", podName, "--force", "--grace-period=0").CombinedOutput() |
70 |
| -// fmt.Println(string(out)) |
71 |
| -// Expect(err).NotTo(HaveOccurred()) |
72 |
| -// time.Sleep(6 * time.Minute) |
73 |
| -// Expect(getHostCountFromScheduler(schedulerClient)).To(Equal(hostCount)) |
74 |
| -// }) |
75 |
| -// }) |
76 |
| -//}) |
77 |
| -// |
78 |
| -//func getHostCountFromScheduler(schedulerClient schedulerclient.V2) (hostCount int) { |
79 |
| -// response, err := schedulerClient.ListHosts(context.Background(), "") |
80 |
| -// fmt.Println(response, err) |
81 |
| -// Expect(err).NotTo(HaveOccurred()) |
82 |
| -// |
83 |
| -// hosts := response.Hosts |
84 |
| -// for _, host := range hosts { |
85 |
| -// // HostID: "10.244.0.13-dragonfly-seed-client-0-seed" |
86 |
| -// // PeerHostID: "3dba4916d8271d6b71bb20e95a0b5494c9a941ab7ef3567f805abca8614dc128" |
87 |
| -// if strings.Contains(host.Id, "-") { |
88 |
| -// hostCount++ |
89 |
| -// } |
90 |
| -// } |
91 |
| -// return |
92 |
| -//} |
| 19 | +import ( |
| 20 | + "context" |
| 21 | + "fmt" |
| 22 | + "strings" |
| 23 | + "time" |
| 24 | + |
| 25 | + . "github.com/onsi/ginkgo/v2" //nolint |
| 26 | + . "github.com/onsi/gomega" //nolint |
| 27 | + "google.golang.org/grpc" |
| 28 | + "google.golang.org/grpc/credentials/insecure" |
| 29 | + |
| 30 | + schedulerclient "d7y.io/dragonfly/v2/pkg/rpc/scheduler/client" |
| 31 | + "d7y.io/dragonfly/v2/test/e2e/v2/util" |
| 32 | +) |
| 33 | + |
| 34 | +var _ = Describe("Clients Leaving", func() { |
| 35 | + Context("normally", func() { |
| 36 | + It("number of hosts should be ok", Label("host", "leave"), func() { |
| 37 | + grpcCredentials := insecure.NewCredentials() |
| 38 | + schedulerClient, err := schedulerclient.GetV2ByAddr(context.Background(), ":8002", grpc.WithTransportCredentials(grpcCredentials)) |
| 39 | + Expect(err).NotTo(HaveOccurred()) |
| 40 | + |
| 41 | + time.Sleep(3 * time.Minute) |
| 42 | + hostCount := util.Servers[util.SeedClientServerName].Replicas + util.Servers[util.ClientServerName].Replicas |
| 43 | + Expect(getHostCountFromScheduler(schedulerClient)).To(Equal(hostCount)) |
| 44 | + |
| 45 | + podName, err := util.GetClientPodName(1) |
| 46 | + Expect(err).NotTo(HaveOccurred()) |
| 47 | + |
| 48 | + out, err := util.KubeCtlCommand("-n", util.DragonflyNamespace, "delete", "pod", podName).CombinedOutput() |
| 49 | + fmt.Println(string(out)) |
| 50 | + Expect(err).NotTo(HaveOccurred()) |
| 51 | + time.Sleep(1 * time.Minute) |
| 52 | + Expect(getHostCountFromScheduler(schedulerClient)).To(Equal(hostCount)) |
| 53 | + }) |
| 54 | + }) |
| 55 | + |
| 56 | + Context("abnormally", func() { |
| 57 | + It("number of hosts should be ok", Label("host", "leave"), func() { |
| 58 | + grpcCredentials := insecure.NewCredentials() |
| 59 | + schedulerClient, err := schedulerclient.GetV2ByAddr(context.Background(), ":8002", grpc.WithTransportCredentials(grpcCredentials)) |
| 60 | + Expect(err).NotTo(HaveOccurred()) |
| 61 | + |
| 62 | + time.Sleep(4 * time.Minute) |
| 63 | + hostCount := util.Servers[util.SeedClientServerName].Replicas + util.Servers[util.ClientServerName].Replicas |
| 64 | + Expect(getHostCountFromScheduler(schedulerClient)).To(Equal(hostCount)) |
| 65 | + |
| 66 | + podName, err := util.GetClientPodName(1) |
| 67 | + Expect(err).NotTo(HaveOccurred()) |
| 68 | + |
| 69 | + out, err := util.KubeCtlCommand("-n", util.DragonflyNamespace, "delete", "pod", podName, "--force", "--grace-period=0").CombinedOutput() |
| 70 | + fmt.Println(string(out)) |
| 71 | + Expect(err).NotTo(HaveOccurred()) |
| 72 | + time.Sleep(6 * time.Minute) |
| 73 | + Expect(getHostCountFromScheduler(schedulerClient)).To(Equal(hostCount)) |
| 74 | + }) |
| 75 | + }) |
| 76 | +}) |
| 77 | + |
| 78 | +func getHostCountFromScheduler(schedulerClient schedulerclient.V2) (hostCount int) { |
| 79 | + response, err := schedulerClient.ListHosts(context.Background(), "") |
| 80 | + fmt.Println(response, err) |
| 81 | + Expect(err).NotTo(HaveOccurred()) |
| 82 | + |
| 83 | + hosts := response.Hosts |
| 84 | + for _, host := range hosts { |
| 85 | + // HostID: "10.244.0.13-dragonfly-seed-client-0-seed" |
| 86 | + // PeerHostID: "3dba4916d8271d6b71bb20e95a0b5494c9a941ab7ef3567f805abca8614dc128" |
| 87 | + if strings.Contains(host.Id, "-") { |
| 88 | + hostCount++ |
| 89 | + } |
| 90 | + } |
| 91 | + return |
| 92 | +} |
0 commit comments