mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #13836 from kkkkun/set-etcdutl-default
test: set etcdutl to default
This commit is contained in:
commit
dcc226491f
@ -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)
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user