Skip to content

Commit

Permalink
feat: add E2E tests for cases that peers going offline
Browse files Browse the repository at this point in the history
Signed-off-by: BruceAko <[email protected]>
  • Loading branch information
BruceAko committed Sep 24, 2024
1 parent b1875df commit bd92139
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 2 deletions.
2 changes: 1 addition & 1 deletion deploy/docker-compose/template/scheduler.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ scheduler:
# then the task will also be reclaimed.
taskGCInterval: 30m
# hostGCInterval is the interval of host gc.
hostGCInterval: 6h
hostGCInterval: 5m
# hostTTL is time to live of host. If host announces message to scheduler,
# then HostTTl will be reset.
hostTTL: 1h
Expand Down
2 changes: 1 addition & 1 deletion pkg/rpc/scheduler/client/client_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func GetV1(ctx context.Context, dynconfig config.Dynconfig, opts ...grpc.DialOpt
}, nil
}

// GetV1ByAddr returns v2 version of the scheduler client by address.
// GetV1ByAddr returns v1 version of the scheduler client by address.
func GetV1ByAddr(ctx context.Context, target string, opts ...grpc.DialOption) (V1, error) {
conn, err := grpc.DialContext(
ctx,
Expand Down
39 changes: 39 additions & 0 deletions test/e2e/v2/leave_host_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright 2024 The Dragonfly Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package e2e

import (
"context"
"fmt"

schedulerclient "d7y.io/dragonfly/v2/pkg/rpc/scheduler/client"
. "github.com/onsi/ginkgo/v2" //nolint
. "github.com/onsi/gomega" //nolint
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)

var _ = Describe("Clients go offline normally and abnormally", func() {
Context("scheduler clears peer metadata", func() {
It("number of hosts should be ok", Label("host", "leave"), func() {
grpcCredentials := insecure.NewCredentials()
schedulerClient, err := schedulerclient.GetV2ByAddr(context.Background(), "127.0.0.1:8002", grpc.WithTransportCredentials(grpcCredentials))
Expect(err).NotTo(HaveOccurred())
fmt.Println(schedulerClient)
})
})
})
1 change: 1 addition & 0 deletions test/testdata/charts/config-v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ seedClient:

client:
enable: true
replicas: 3
image:
repository: dragonflyoss/client
tag: latest
Expand Down

0 comments on commit bd92139

Please sign in to comment.