Skip to content

Commit

Permalink
tests/e2e: allow to use SIGTERM to verify graceful-stop
Browse files Browse the repository at this point in the history
Signed-off-by: Wei Fu <fuweid89@gmail.com>
  • Loading branch information
fuweid committed Jul 7, 2023
1 parent 66713f6 commit 15efc55
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
10 changes: 10 additions & 0 deletions tests/e2e/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ type etcdProcessClusterConfig struct {
WatchProcessNotifyInterval time.Duration

debug bool

stopSignal os.Signal
}

// newEtcdProcessCluster launches a new cluster from etcd processes, returning
Expand All @@ -151,12 +153,20 @@ func newEtcdProcessCluster(cfg *etcdProcessClusterConfig) (*etcdProcessCluster,
epc.Close()
return nil, err
}

epc.procs[i] = proc
}

if err := epc.Start(); err != nil {
return nil, err
}

// overwrite the default signal
if cfg.stopSignal != nil {
for _, proc := range epc.procs {
proc.WithStopSignal(cfg.stopSignal)
}
}
return epc, nil
}

Expand Down
14 changes: 12 additions & 2 deletions tests/e2e/cmux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"context"
"encoding/json"
"fmt"
"syscall"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -63,10 +64,19 @@ func TestConnectionMultiplexing(t *testing.T) {
} {
t.Run(tc.name, func(t *testing.T) {
ctx := context.Background()
cfg := etcdProcessClusterConfig{clusterSize: 1, clientTLS: tc.serverTLS, enableV2: true, clientHttpSeparate: tc.separateHttpPort}
cfg := etcdProcessClusterConfig{
clusterSize: 1,
clientTLS: tc.serverTLS,
enableV2: true,
clientHttpSeparate: tc.separateHttpPort,
stopSignal: syscall.SIGTERM, // check graceful stop
}
clus, err := newEtcdProcessCluster(&cfg)
require.NoError(t, err)
defer clus.Close()

defer func() {
require.NoError(t, clus.Close())
}()

var clientScenarios []clientConnType
switch tc.serverTLS {
Expand Down

0 comments on commit 15efc55

Please sign in to comment.