From 62641d33854e206f915398332dbc2b976e9ae5c8 Mon Sep 17 00:00:00 2001 From: Kun Zhang Date: Thu, 24 Mar 2022 16:20:28 +0800 Subject: [PATCH] set etcdutl to default --- tests/e2e/ctl_v3_defrag_test.go | 14 ++------------ tests/e2e/ctl_v3_snapshot_test.go | 26 +++++++++----------------- tests/e2e/ctl_v3_test.go | 15 ++------------- 3 files changed, 13 insertions(+), 42 deletions(-) diff --git a/tests/e2e/ctl_v3_defrag_test.go b/tests/e2e/ctl_v3_defrag_test.go index 889bbbd07..07f6bd443 100644 --- a/tests/e2e/ctl_v3_defrag_test.go +++ b/tests/e2e/ctl_v3_defrag_test.go @@ -15,14 +15,13 @@ package e2e import ( - "strconv" "testing" "go.etcd.io/etcd/tests/v3/framework/e2e" ) -func TestCtlV3DefragOfflineEtcdutl(t *testing.T) { - testCtlWithOffline(t, maintenanceInitKeys, defragOfflineTest, withEtcdutl()) +func TestCtlV3DefragOffline(t *testing.T) { + testCtlWithOffline(t, maintenanceInitKeys, defragOfflineTest) } func maintenanceInitKeys(cx ctlCtx) { @@ -54,12 +53,3 @@ func defragOfflineTest(cx ctlCtx) { cx.t.Fatalf("defragTest ctlV3Defrag error (%v)", err) } } - -func ctlV3Compact(cx ctlCtx, rev int64, physical bool) error { - rs := strconv.FormatInt(rev, 10) - cmdArgs := append(cx.PrefixArgs(), "compact", rs) - if physical { - cmdArgs = append(cmdArgs, "--physical") - } - return e2e.SpawnWithExpectWithEnv(cmdArgs, cx.envMap, "compacted revision "+rs) -} diff --git a/tests/e2e/ctl_v3_snapshot_test.go b/tests/e2e/ctl_v3_snapshot_test.go index f67c605c5..6db55fa4b 100644 --- a/tests/e2e/ctl_v3_snapshot_test.go +++ b/tests/e2e/ctl_v3_snapshot_test.go @@ -29,8 +29,7 @@ import ( "go.etcd.io/etcd/tests/v3/framework/e2e" ) -func TestCtlV3Snapshot(t *testing.T) { testCtl(t, snapshotTest) } -func TestCtlV3SnapshotEtcdutl(t *testing.T) { testCtl(t, snapshotTest, withEtcdutl()) } +func TestCtlV3Snapshot(t *testing.T) { testCtl(t, snapshotTest) } func snapshotTest(cx ctlCtx) { maintenanceInitKeys(cx) @@ -62,7 +61,7 @@ func snapshotTest(cx ctlCtx) { } } -func TestCtlV3SnapshotCorruptEtcdutl(t *testing.T) { testCtl(t, snapshotCorruptTest, withEtcdutl()) } +func TestCtlV3SnapshotCorrupt(t *testing.T) { testCtl(t, snapshotCorruptTest) } func snapshotCorruptTest(cx ctlCtx) { fpath := filepath.Join(cx.t.TempDir(), "snapshot") @@ -97,8 +96,8 @@ func snapshotCorruptTest(cx ctlCtx) { } // This test ensures that the snapshot status does not modify the snapshot file -func TestCtlV3SnapshotStatusBeforeRestoreEtcdutl(t *testing.T) { - testCtl(t, snapshotStatusBeforeRestoreTest, withEtcdutl()) +func TestCtlV3SnapshotStatusBeforeRestore(t *testing.T) { + testCtl(t, snapshotStatusBeforeRestoreTest) } func snapshotStatusBeforeRestoreTest(cx ctlCtx) { @@ -134,7 +133,6 @@ func ctlV3SnapshotSave(cx ctlCtx, fpath string) error { } func getSnapshotStatus(cx ctlCtx, fpath string) (snapshot.Status, error) { - cx.etcdutl = true cmdArgs := append(cx.PrefixArgsUtl(), "--write-out", "json", "snapshot", "status", fpath) proc, err := e2e.SpawnCmd(cmdArgs, nil) @@ -158,11 +156,11 @@ func getSnapshotStatus(cx ctlCtx, fpath string) (snapshot.Status, error) { return resp, nil } -func TestIssue6361etcdutl(t *testing.T) { testIssue6361(t, true) } +func TestIssue6361(t *testing.T) { testIssue6361(t) } // TestIssue6361 ensures new member that starts with snapshot correctly // syncs up with other members and serve correct data. -func testIssue6361(t *testing.T, etcdutl bool) { +func testIssue6361(t *testing.T) { { // This tests is pretty flaky on semaphoreci as of 2021-01-10. // TODO: Remove when the flakiness source is identified. @@ -216,14 +214,8 @@ func testIssue6361(t *testing.T, etcdutl bool) { } newDataDir := filepath.Join(t.TempDir(), "test.data") - - uctlBinPath := e2e.CtlBinPath - if etcdutl { - uctlBinPath = e2e.UtlBinPath - } - t.Log("etcdctl restoring the snapshot...") - err = e2e.SpawnWithExpect([]string{uctlBinPath, "snapshot", "restore", fpath, "--name", epc.Procs[0].Config().Name, "--initial-cluster", epc.Procs[0].Config().InitialCluster, "--initial-cluster-token", epc.Procs[0].Config().InitialToken, "--initial-advertise-peer-urls", epc.Procs[0].Config().Purl.String(), "--data-dir", newDataDir}, "added member") + err = e2e.SpawnWithExpect([]string{e2e.UtlBinPath, "snapshot", "restore", fpath, "--name", epc.Procs[0].Config().Name, "--initial-cluster", epc.Procs[0].Config().InitialCluster, "--initial-cluster-token", epc.Procs[0].Config().InitialToken, "--initial-advertise-peer-urls", epc.Procs[0].Config().Purl.String(), "--data-dir", newDataDir}, "added member") if err != nil { t.Fatal(err) } @@ -292,8 +284,8 @@ func testIssue6361(t *testing.T, etcdutl bool) { // For storageVersion to be stored, all fields expected 3.6 fields need to be set. This happens after first WAL snapshot. // In this test we lower SnapshotCount to 1 to ensure WAL snapshot is triggered. -func TestCtlV3SnapshotVersionEtcdutl(t *testing.T) { - testCtl(t, snapshotVersionTest, withEtcdutl(), withCfg(e2e.EtcdProcessClusterConfig{SnapshotCount: 1})) +func TestCtlV3SnapshotVersion(t *testing.T) { + testCtl(t, snapshotVersionTest, withCfg(e2e.EtcdProcessClusterConfig{SnapshotCount: 1})) } func snapshotVersionTest(cx ctlCtx) { diff --git a/tests/e2e/ctl_v3_test.go b/tests/e2e/ctl_v3_test.go index ee309cdeb..ebb24e597 100644 --- a/tests/e2e/ctl_v3_test.go +++ b/tests/e2e/ctl_v3_test.go @@ -145,9 +145,6 @@ type ctlCtx struct { // for compaction compactPhysical bool - // to run etcdutl instead of etcdctl for suitable commands. - etcdutl bool - // dir that was used during the test dataDir string } @@ -201,10 +198,6 @@ func withFlagByEnv() ctlOption { return func(cx *ctlCtx) { cx.envMap = make(map[string]string) } } -func withEtcdutl() ctlOption { - return func(cx *ctlCtx) { cx.etcdutl = true } -} - func testCtl(t *testing.T, testFunc func(ctlCtx), opts ...ctlOption) { testCtlWithOffline(t, testFunc, nil, opts...) } @@ -331,14 +324,10 @@ func (cx *ctlCtx) PrefixArgs() []string { return cx.prefixArgs(cx.epc.EndpointsV3()) } -// PrefixArgsUtl returns prefix of the command that is either etcdctl or etcdutl -// depending on cx configuration. +// PrefixArgsUtl returns prefix of the command that is etcdutl // Please not thet 'utl' compatible commands does not consume --endpoints flag. func (cx *ctlCtx) PrefixArgsUtl() []string { - if cx.etcdutl { - return []string{e2e.UtlBinPath} - } - return []string{e2e.CtlBinPath} + return []string{e2e.UtlBinPath} } func isGRPCTimedout(err error) bool {