From d4a8093ea59ec2339cf73312abdb844090a3dccc Mon Sep 17 00:00:00 2001 From: Piotr Tabor Date: Sun, 28 Mar 2021 12:58:30 +0200 Subject: [PATCH 1/2] Switch release-test (upgrade test) to use etcd 3.4 (instead of 3.3) as upgrade-base. --- Makefile | 2 +- test.sh | 2 +- tests/e2e/main_test.go | 16 ++++++++++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index ee0c3fd9b..c6352c776 100644 --- a/Makefile +++ b/Makefile @@ -157,7 +157,7 @@ test-smoke: test-full: $(info log-file: test-$(TEST_SUFFIX).log) - PASSES="fmt build unit integration functional e2e grpcproxy" ./test.sh 2<&1 | tee test-$(TEST_SUFFIX).log + PASSES="fmt build release unit integration functional e2e grpcproxy" ./test.sh 2<&1 | tee test-$(TEST_SUFFIX).log docker-test: $(info GO_VERSION: $(GO_VERSION)) diff --git a/test.sh b/test.sh index 715b335d2..2726255ca 100755 --- a/test.sh +++ b/test.sh @@ -613,7 +613,7 @@ function dep_pass { function release_pass { rm -f ./bin/etcd-last-release # to grab latest patch release; bump this up for every minor release - UPGRADE_VER=$(git tag -l --sort=-version:refname "v3.3.*" | head -1) + UPGRADE_VER=$(git tag -l --sort=-version:refname "v3.4.*" | head -1) if [ -n "$MANUAL_VER" ]; then # in case, we need to test against different version UPGRADE_VER=$MANUAL_VER diff --git a/tests/e2e/main_test.go b/tests/e2e/main_test.go index 791c9d58e..75adb1e8e 100644 --- a/tests/e2e/main_test.go +++ b/tests/e2e/main_test.go @@ -6,7 +6,9 @@ package e2e import ( "flag" + "log" "os" + "path/filepath" "runtime" "testing" @@ -36,8 +38,18 @@ func TestMain(m *testing.M) { os.Setenv("ETCD_UNSUPPORTED_ARCH", runtime.GOARCH) os.Unsetenv("ETCDCTL_API") - flag.StringVar(&binDir, "bin-dir", "../../bin", "The directory for store etcd and etcdctl binaries.") - flag.StringVar(&certDir, "cert-dir", "../fixtures", "The directory for store certificate files.") + binDirDef, err := filepath.Abs("../../bin") + if err != nil { + log.Fatal(err) + } + + certDirDef, err := filepath.Abs("../fixtures") + if err != nil { + log.Fatal(err) + } + + flag.StringVar(&binDir, "bin-dir", binDirDef, "The directory for store etcd and etcdctl binaries.") + flag.StringVar(&certDir, "cert-dir", certDirDef, "The directory for store certificate files.") flag.Parse() binPath = binDir + "/etcd" From cc0f812f51cbccf29f54d8f1b0cb1ee9d7541aee Mon Sep 17 00:00:00 2001 From: Piotr Tabor Date: Wed, 7 Apr 2021 20:38:16 +0200 Subject: [PATCH 2/2] server_test.go: Use context.Background() instead of TODO in tests. Suggected in: https://golang.org/pkg/context/#Background --- server/etcdserver/server_test.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/server/etcdserver/server_test.go b/server/etcdserver/server_test.go index 919e2c96e..38d6ef2cf 100644 --- a/server/etcdserver/server_test.go +++ b/server/etcdserver/server_test.go @@ -102,7 +102,7 @@ func TestDoLocalAction(t *testing.T) { v2store: st, reqIDGen: idutil.NewGenerator(0, time.Time{}), } - resp, err := srv.Do(context.TODO(), tt.req) + resp, err := srv.Do(context.Background(), tt.req) if err != tt.werr { t.Fatalf("#%d: err = %+v, want %+v", i, err, tt.werr) @@ -836,7 +836,7 @@ func TestDoProposalStopped(t *testing.T) { // TestSync tests sync 1. is nonblocking 2. proposes SYNC request. func TestSync(t *testing.T) { n := newNodeRecorder() - ctx, cancel := context.WithCancel(context.TODO()) + ctx, cancel := context.WithCancel(context.Background()) srv := &EtcdServer{ lgMu: new(sync.RWMutex), lg: zap.NewExample(), @@ -881,7 +881,7 @@ func TestSync(t *testing.T) { // after timeout func TestSyncTimeout(t *testing.T) { n := newProposalBlockerRecorder() - ctx, cancel := context.WithCancel(context.TODO()) + ctx, cancel := context.WithCancel(context.Background()) srv := &EtcdServer{ lgMu: new(sync.RWMutex), lg: zap.NewExample(), @@ -1317,7 +1317,7 @@ func TestAddMember(t *testing.T) { } s.start() m := membership.Member{ID: 1234, RaftAttributes: membership.RaftAttributes{PeerURLs: []string{"foo"}}} - _, err := s.AddMember(context.TODO(), m) + _, err := s.AddMember(context.Background(), m) gaction := n.Action() s.Stop() @@ -1361,7 +1361,7 @@ func TestRemoveMember(t *testing.T) { consistIndex: cindex.NewFakeConsistentIndex(0), } s.start() - _, err := s.RemoveMember(context.TODO(), 1234) + _, err := s.RemoveMember(context.Background(), 1234) gaction := n.Action() s.Stop() @@ -1406,7 +1406,7 @@ func TestUpdateMember(t *testing.T) { } s.start() wm := membership.Member{ID: 1234, RaftAttributes: membership.RaftAttributes{PeerURLs: []string{"http://127.0.0.1:1"}}} - _, err := s.UpdateMember(context.TODO(), wm) + _, err := s.UpdateMember(context.Background(), wm) gaction := n.Action() s.Stop() @@ -1430,7 +1430,7 @@ func TestPublish(t *testing.T) { // simulate that request has gone through consensus ch <- Response{} w := wait.NewWithResponse(ch) - ctx, cancel := context.WithCancel(context.TODO()) + ctx, cancel := context.WithCancel(context.Background()) srv := &EtcdServer{ lgMu: new(sync.RWMutex), lg: zap.NewExample(), @@ -1479,7 +1479,7 @@ func TestPublish(t *testing.T) { // TestPublishStopped tests that publish will be stopped if server is stopped. func TestPublishStopped(t *testing.T) { - ctx, cancel := context.WithCancel(context.TODO()) + ctx, cancel := context.WithCancel(context.Background()) r := newRaftNode(raftNodeConfig{ lg: zap.NewExample(), Node: newNodeNop(), @@ -1507,7 +1507,7 @@ func TestPublishStopped(t *testing.T) { // TestPublishRetry tests that publish will keep retry until success. func TestPublishRetry(t *testing.T) { - ctx, cancel := context.WithCancel(context.TODO()) + ctx, cancel := context.WithCancel(context.Background()) n := newNodeRecorderStream() srv := &EtcdServer{ lgMu: new(sync.RWMutex), @@ -1550,7 +1550,7 @@ func TestPublishV3(t *testing.T) { // simulate that request has gone through consensus ch <- &applyResult{} w := wait.NewWithResponse(ch) - ctx, cancel := context.WithCancel(context.TODO()) + ctx, cancel := context.WithCancel(context.Background()) lg := zaptest.NewLogger(t) be, _ := backend.NewDefaultTmpBackend(t) srv := &EtcdServer{ @@ -1590,7 +1590,7 @@ func TestPublishV3(t *testing.T) { // TestPublishStopped tests that publish will be stopped if server is stopped. func TestPublishV3Stopped(t *testing.T) { - ctx, cancel := context.WithCancel(context.TODO()) + ctx, cancel := context.WithCancel(context.Background()) r := newRaftNode(raftNodeConfig{ lg: zap.NewExample(), Node: newNodeNop(), @@ -1618,7 +1618,7 @@ func TestPublishV3Stopped(t *testing.T) { // TestPublishRetry tests that publish will keep retry until success. func TestPublishV3Retry(t *testing.T) { - ctx, cancel := context.WithCancel(context.TODO()) + ctx, cancel := context.WithCancel(context.Background()) n := newNodeRecorderStream() lg := zaptest.NewLogger(t)