From 7f7ccd86e2ae4729e5bc17f477f411584a3270db Mon Sep 17 00:00:00 2001 From: Clark Date: Wed, 31 Aug 2022 01:41:48 +0800 Subject: [PATCH] tests: fix failed integration test cases after enabling `--strict-reconfig-check` by default Signed-off-by: Clark --- tests/e2e/ctl_v3_test.go | 6 +++--- tests/integration/clientv3/cluster_test.go | 12 +++++------ .../clientv3/examples/main_test.go | 3 ++- tests/integration/clientv3/kv_test.go | 4 ++-- tests/integration/cluster_test.go | 21 ++++++++++++------- tests/integration/v3_alarm_test.go | 10 ++++----- tests/integration/v3_leadership_test.go | 2 +- 7 files changed, 32 insertions(+), 26 deletions(-) diff --git a/tests/e2e/ctl_v3_test.go b/tests/e2e/ctl_v3_test.go index c4566383de4c..261aec66aea0 100644 --- a/tests/e2e/ctl_v3_test.go +++ b/tests/e2e/ctl_v3_test.go @@ -122,9 +122,9 @@ func dialWithSchemeTest(cx ctlCtx) { } type ctlCtx struct { - t *testing.T - apiPrefix string - cfg e2e.EtcdProcessClusterConfig + t *testing.T + apiPrefix string + cfg e2e.EtcdProcessClusterConfig corruptFunc func(string) error disableStrictReconfigCheck bool diff --git a/tests/integration/clientv3/cluster_test.go b/tests/integration/clientv3/cluster_test.go index a702e036451b..822855f1365c 100644 --- a/tests/integration/clientv3/cluster_test.go +++ b/tests/integration/clientv3/cluster_test.go @@ -48,7 +48,7 @@ func TestMemberList(t *testing.T) { func TestMemberAdd(t *testing.T) { integration2.BeforeTest(t) - clus := integration2.NewCluster(t, &integration2.ClusterConfig{Size: 3}) + clus := integration2.NewCluster(t, &integration2.ClusterConfig{Size: 3, DisableStrictReconfigCheck: true}) defer clus.Terminate(t) capi := clus.RandClient() @@ -67,7 +67,7 @@ func TestMemberAdd(t *testing.T) { func TestMemberAddWithExistingURLs(t *testing.T) { integration2.BeforeTest(t) - clus := integration2.NewCluster(t, &integration2.ClusterConfig{Size: 3}) + clus := integration2.NewCluster(t, &integration2.ClusterConfig{Size: 3, DisableStrictReconfigCheck: true}) defer clus.Terminate(t) capi := clus.RandClient() @@ -91,7 +91,7 @@ func TestMemberAddWithExistingURLs(t *testing.T) { func TestMemberRemove(t *testing.T) { integration2.BeforeTest(t) - clus := integration2.NewCluster(t, &integration2.ClusterConfig{Size: 3}) + clus := integration2.NewCluster(t, &integration2.ClusterConfig{Size: 3, DisableStrictReconfigCheck: true}) defer clus.Terminate(t) capi := clus.Client(1) @@ -190,7 +190,7 @@ func TestMemberAddUpdateWrongURLs(t *testing.T) { func TestMemberAddForLearner(t *testing.T) { integration2.BeforeTest(t) - clus := integration2.NewCluster(t, &integration2.ClusterConfig{Size: 3}) + clus := integration2.NewCluster(t, &integration2.ClusterConfig{Size: 3, DisableStrictReconfigCheck: true}) defer clus.Terminate(t) capi := clus.RandClient() @@ -219,7 +219,7 @@ func TestMemberAddForLearner(t *testing.T) { func TestMemberPromote(t *testing.T) { integration2.BeforeTest(t) - clus := integration2.NewCluster(t, &integration2.ClusterConfig{Size: 3}) + clus := integration2.NewCluster(t, &integration2.ClusterConfig{Size: 3, DisableStrictReconfigCheck: true}) defer clus.Terminate(t) // member promote request can be sent to any server in cluster, @@ -382,7 +382,7 @@ func TestMaxLearnerInCluster(t *testing.T) { integration2.BeforeTest(t) // 1. start with a cluster with 3 voting member and max learner 2 - clus := integration2.NewCluster(t, &integration2.ClusterConfig{Size: 3, ExperimentalMaxLearners: 2}) + clus := integration2.NewCluster(t, &integration2.ClusterConfig{Size: 3, ExperimentalMaxLearners: 2, DisableStrictReconfigCheck: true}) defer clus.Terminate(t) // 2. adding 2 learner members should succeed diff --git a/tests/integration/clientv3/examples/main_test.go b/tests/integration/clientv3/examples/main_test.go index 77adf8128758..b88b15723a64 100644 --- a/tests/integration/clientv3/examples/main_test.go +++ b/tests/integration/clientv3/examples/main_test.go @@ -33,7 +33,8 @@ const ( var lazyCluster = integration.NewLazyClusterWithConfig( integration2.ClusterConfig{ Size: 3, - WatchProgressNotifyInterval: 200 * time.Millisecond}) + WatchProgressNotifyInterval: 200 * time.Millisecond, + DisableStrictReconfigCheck: true}) func exampleEndpoints() []string { return lazyCluster.EndpointsV3() } diff --git a/tests/integration/clientv3/kv_test.go b/tests/integration/clientv3/kv_test.go index ddb8db99e551..96b5f31c6845 100644 --- a/tests/integration/clientv3/kv_test.go +++ b/tests/integration/clientv3/kv_test.go @@ -776,7 +776,7 @@ func TestKVLargeRequests(t *testing.T) { func TestKVForLearner(t *testing.T) { integration2.BeforeTest(t) - clus := integration2.NewCluster(t, &integration2.ClusterConfig{Size: 3}) + clus := integration2.NewCluster(t, &integration2.ClusterConfig{Size: 3, DisableStrictReconfigCheck: true}) defer clus.Terminate(t) // we have to add and launch learner member after initial cluster was created, because @@ -855,7 +855,7 @@ func TestKVForLearner(t *testing.T) { func TestBalancerSupportLearner(t *testing.T) { integration2.BeforeTest(t) - clus := integration2.NewCluster(t, &integration2.ClusterConfig{Size: 3}) + clus := integration2.NewCluster(t, &integration2.ClusterConfig{Size: 3, DisableStrictReconfigCheck: true}) defer clus.Terminate(t) // we have to add and launch learner member after initial cluster was created, because diff --git a/tests/integration/cluster_test.go b/tests/integration/cluster_test.go index 4f61493cc84f..30996a557db5 100644 --- a/tests/integration/cluster_test.go +++ b/tests/integration/cluster_test.go @@ -72,7 +72,7 @@ func TestDoubleClusterSizeOf3(t *testing.T) { testDoubleClusterSize(t, 3) } func testDoubleClusterSize(t *testing.T, size int) { integration.BeforeTest(t) - c := integration.NewCluster(t, &integration.ClusterConfig{Size: size}) + c := integration.NewCluster(t, &integration.ClusterConfig{Size: size, DisableStrictReconfigCheck: true}) defer c.Terminate(t) for i := 0; i < size; i++ { @@ -83,7 +83,12 @@ func testDoubleClusterSize(t *testing.T, size int) { func TestDoubleTLSClusterSizeOf3(t *testing.T) { integration.BeforeTest(t) - c := integration.NewCluster(t, &integration.ClusterConfig{Size: 1, PeerTLS: &integration.TestTLSInfo}) + cfg := &integration.ClusterConfig{ + Size: 1, + PeerTLS: &integration.TestTLSInfo, + DisableStrictReconfigCheck: true, + } + c := integration.NewCluster(t, cfg) defer c.Terminate(t) for i := 0; i < 3; i++ { @@ -97,7 +102,7 @@ func TestDecreaseClusterSizeOf5(t *testing.T) { testDecreaseClusterSize(t, 5) } func testDecreaseClusterSize(t *testing.T, size int) { integration.BeforeTest(t) - c := integration.NewCluster(t, &integration.ClusterConfig{Size: size}) + c := integration.NewCluster(t, &integration.ClusterConfig{Size: size, DisableStrictReconfigCheck: true}) defer c.Terminate(t) // TODO: remove the last but one member @@ -175,7 +180,7 @@ func TestForceNewCluster(t *testing.T) { func TestAddMemberAfterClusterFullRotation(t *testing.T) { integration.BeforeTest(t) - c := integration.NewCluster(t, &integration.ClusterConfig{Size: 3}) + c := integration.NewCluster(t, &integration.ClusterConfig{Size: 3, DisableStrictReconfigCheck: true}) defer c.Terminate(t) // remove all the previous three members and add in three new members. @@ -198,7 +203,7 @@ func TestAddMemberAfterClusterFullRotation(t *testing.T) { // Ensure we can remove a member then add a new one back immediately. func TestIssue2681(t *testing.T) { integration.BeforeTest(t) - c := integration.NewCluster(t, &integration.ClusterConfig{Size: 5}) + c := integration.NewCluster(t, &integration.ClusterConfig{Size: 5, DisableStrictReconfigCheck: true}) defer c.Terminate(t) if err := c.RemoveMember(t, c.Members[0].Client, uint64(c.Members[4].Server.MemberId())); err != nil { @@ -219,7 +224,7 @@ func TestIssue2746WithThree(t *testing.T) { testIssue2746(t, 3) } func testIssue2746(t *testing.T, members int) { integration.BeforeTest(t) - c := integration.NewCluster(t, &integration.ClusterConfig{Size: members, SnapshotCount: 10}) + c := integration.NewCluster(t, &integration.ClusterConfig{Size: members, SnapshotCount: 10, DisableStrictReconfigCheck: true}) defer c.Terminate(t) // force a snapshot @@ -241,7 +246,7 @@ func testIssue2746(t *testing.T, members int) { func TestIssue2904(t *testing.T) { integration.BeforeTest(t) // start 1-member Cluster to ensure member 0 is the leader of the Cluster. - c := integration.NewCluster(t, &integration.ClusterConfig{Size: 2, UseBridge: true}) + c := integration.NewCluster(t, &integration.ClusterConfig{Size: 2, UseBridge: true, DisableStrictReconfigCheck: true}) defer c.Terminate(t) c.WaitLeader(t) @@ -276,7 +281,7 @@ func TestIssue2904(t *testing.T) { func TestIssue3699(t *testing.T) { // start a Cluster of 3 nodes a, b, c integration.BeforeTest(t) - c := integration.NewCluster(t, &integration.ClusterConfig{Size: 3, UseBridge: true}) + c := integration.NewCluster(t, &integration.ClusterConfig{Size: 3, UseBridge: true, DisableStrictReconfigCheck: true}) defer c.Terminate(t) // make node a unavailable diff --git a/tests/integration/v3_alarm_test.go b/tests/integration/v3_alarm_test.go index 733b060f53a5..39e841a526d2 100644 --- a/tests/integration/v3_alarm_test.go +++ b/tests/integration/v3_alarm_test.go @@ -261,11 +261,11 @@ func TestV3CorruptAlarmWithLeaseCorrupted(t *testing.T) { integration.BeforeTest(t) lg := zaptest.NewLogger(t) clus := integration.NewCluster(t, &integration.ClusterConfig{ - CorruptCheckTime: time.Second, - Size: 3, - SnapshotCount: 10, - SnapshotCatchUpEntries: 5, - }) + CorruptCheckTime: time.Second, + Size: 3, + SnapshotCount: 10, + SnapshotCatchUpEntries: 5, + DisableStrictReconfigCheck: true}) defer clus.Terminate(t) ctx, cancel := context.WithCancel(context.Background()) diff --git a/tests/integration/v3_leadership_test.go b/tests/integration/v3_leadership_test.go index 519bb0a8fd93..c3cbb5543802 100644 --- a/tests/integration/v3_leadership_test.go +++ b/tests/integration/v3_leadership_test.go @@ -120,7 +120,7 @@ func TestMoveLeaderError(t *testing.T) { func TestMoveLeaderToLearnerError(t *testing.T) { integration.BeforeTest(t) - clus := integration.NewCluster(t, &integration.ClusterConfig{Size: 3}) + clus := integration.NewCluster(t, &integration.ClusterConfig{Size: 3, DisableStrictReconfigCheck: true}) defer clus.Terminate(t) // we have to add and launch learner member after initial cluster was created, because