From a57e967d84fa80eca8aacd785cf6cd915c75cfdd Mon Sep 17 00:00:00 2001 From: Piotr Tabor Date: Tue, 16 Mar 2021 16:08:18 +0100 Subject: [PATCH] Integration test flakes fixes. --- .../clientv3/connectivity/network_partition_test.go | 6 +++--- tests/integration/snapshot/member_test.go | 3 +++ tests/integration/snapshot/v3_snapshot_test.go | 4 ++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/integration/clientv3/connectivity/network_partition_test.go b/tests/integration/clientv3/connectivity/network_partition_test.go index 8829a6cce..69cddd567 100644 --- a/tests/integration/clientv3/connectivity/network_partition_test.go +++ b/tests/integration/clientv3/connectivity/network_partition_test.go @@ -240,9 +240,9 @@ func testBalancerUnderNetworkPartitionWatch(t *testing.T, isolateLeader bool) { clientv3test.MustWaitPinReady(t, watchCli) t.Logf("successful connection with server: %v", target) - // add all eps to list, so that when the original pined one fails - // the client can switch to other available eps - watchCli.SetEndpoints(eps...) + // We stick to the original endpoint, so when the one fails we don't switch + // under the cover to other available eps, but expose the failure to the + // caller (test assertion). wch := watchCli.Watch(clientv3.WithRequireLeader(context.Background()), "foo", clientv3.WithCreatedNotify()) select { diff --git a/tests/integration/snapshot/member_test.go b/tests/integration/snapshot/member_test.go index 22997272d..632ca3c51 100644 --- a/tests/integration/snapshot/member_test.go +++ b/tests/integration/snapshot/member_test.go @@ -26,12 +26,15 @@ import ( "go.etcd.io/etcd/pkg/v3/testutil" "go.etcd.io/etcd/server/v3/embed" "go.etcd.io/etcd/server/v3/etcdserver" + "go.etcd.io/etcd/tests/v3/integration" ) // TestSnapshotV3RestoreMultiMemberAdd ensures that multiple members // can boot into the same cluster after being restored from a same // snapshot file, and also be able to add another member to the cluster. func TestSnapshotV3RestoreMultiMemberAdd(t *testing.T) { + integration.BeforeTest(t) + kvs := []kv{{"foo1", "bar1"}, {"foo2", "bar2"}, {"foo3", "bar3"}} dbPath := createSnapshotFile(t, kvs) diff --git a/tests/integration/snapshot/v3_snapshot_test.go b/tests/integration/snapshot/v3_snapshot_test.go index 0b7fcc52c..f70c6846b 100644 --- a/tests/integration/snapshot/v3_snapshot_test.go +++ b/tests/integration/snapshot/v3_snapshot_test.go @@ -29,12 +29,14 @@ import ( "go.etcd.io/etcd/etcdctl/v3/snapshot" "go.etcd.io/etcd/pkg/v3/testutil" "go.etcd.io/etcd/server/v3/embed" + "go.etcd.io/etcd/tests/v3/integration" "go.uber.org/zap/zaptest" ) // TestSnapshotV3RestoreSingle tests single node cluster restoring // from a snapshot file. func TestSnapshotV3RestoreSingle(t *testing.T) { + integration.BeforeTest(t) kvs := []kv{{"foo1", "bar1"}, {"foo2", "bar2"}, {"foo3", "bar3"}} dbPath := createSnapshotFile(t, kvs) defer os.RemoveAll(dbPath) @@ -106,6 +108,7 @@ func TestSnapshotV3RestoreSingle(t *testing.T) { // can boot into the same cluster after being restored from a same // snapshot file. func TestSnapshotV3RestoreMulti(t *testing.T) { + integration.BeforeTest(t) kvs := []kv{{"foo1", "bar1"}, {"foo2", "bar2"}, {"foo3", "bar3"}} dbPath := createSnapshotFile(t, kvs) defer os.RemoveAll(dbPath) @@ -143,6 +146,7 @@ func TestSnapshotV3RestoreMulti(t *testing.T) { // TestCorruptedBackupFileCheck tests if we can correctly identify a corrupted backup file. func TestCorruptedBackupFileCheck(t *testing.T) { + integration.BeforeTest(t) dbPath := "testdata/corrupted_backup.db" if _, err := os.Stat(dbPath); err != nil { t.Fatalf("test file [%s] does not exist: %v", dbPath, err)