Skip to content

Commit a23b80b

Browse files
committed
feat: add E2E tests for cases that peers going offline
Signed-off-by: BruceAko <chongzhi@hust.edu.cn>
1 parent 7bcbac9 commit a23b80b

File tree

4 files changed

+43
-2
lines changed

4 files changed

+43
-2
lines changed

deploy/docker-compose/template/scheduler.template.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ scheduler:
6161
# then the task will also be reclaimed.
6262
taskGCInterval: 30m
6363
# hostGCInterval is the interval of host gc.
64-
hostGCInterval: 6h
64+
hostGCInterval: 5m
6565
# hostTTL is time to live of host. If host announces message to scheduler,
6666
# then HostTTl will be reset.
6767
hostTTL: 1h

pkg/rpc/scheduler/client/client_v1.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func GetV1(ctx context.Context, dynconfig config.Dynconfig, opts ...grpc.DialOpt
9090
}, nil
9191
}
9292

93-
// GetV1ByAddr returns v2 version of the scheduler client by address.
93+
// GetV1ByAddr returns v1 version of the scheduler client by address.
9494
func GetV1ByAddr(ctx context.Context, target string, opts ...grpc.DialOption) (V1, error) {
9595
conn, err := grpc.DialContext(
9696
ctx,

test/e2e/v2/leave_host_test.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright 2024 The Dragonfly Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package e2e
18+
19+
import (
20+
"context"
21+
"fmt"
22+
23+
schedulerclient "d7y.io/dragonfly/v2/pkg/rpc/scheduler/client"
24+
. "github.com/onsi/ginkgo/v2" //nolint
25+
. "github.com/onsi/gomega" //nolint
26+
"google.golang.org/grpc"
27+
"google.golang.org/grpc/credentials/insecure"
28+
)
29+
30+
var _ = Describe("Clients go offline normally and abnormally", func() {
31+
Context("scheduler clears peer metadata", func() {
32+
It("number of hosts should be ok", Label("host", "leave"), func() {
33+
grpcCredentials := insecure.NewCredentials()
34+
schedulerClient, err := schedulerclient.GetV2ByAddr(context.Background(), "127.0.0.1:8002", grpc.WithTransportCredentials(grpcCredentials))
35+
Expect(err).NotTo(HaveOccurred())
36+
fmt.Println(schedulerClient)
37+
})
38+
})
39+
})
40+
s

test/testdata/charts/config-v2.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ seedClient:
9696

9797
client:
9898
enable: true
99+
replicas: 3
99100
image:
100101
repository: dragonflyoss/client
101102
tag: latest

0 commit comments

Comments
 (0)