mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
tests: Extend common test to run previous release
Signed-off-by: Marek Siarkowicz <siarkowicz@google.com>
This commit is contained in:
parent
b08209447a
commit
71b40b3abf
@ -18,6 +18,7 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"go.etcd.io/etcd/client/pkg/v3/fileutil"
|
||||
"go.etcd.io/etcd/tests/v3/framework"
|
||||
"go.etcd.io/etcd/tests/v3/framework/config"
|
||||
"go.etcd.io/etcd/tests/v3/framework/e2e"
|
||||
@ -25,6 +26,52 @@ import (
|
||||
|
||||
func init() {
|
||||
testRunner = framework.E2eTestRunner
|
||||
clusterTestCases = e2eClusterTestCases
|
||||
}
|
||||
|
||||
func e2eClusterTestCases() []testCase {
|
||||
tcs := []testCase{
|
||||
{
|
||||
name: "NoTLS",
|
||||
config: config.ClusterConfig{ClusterSize: 1},
|
||||
},
|
||||
{
|
||||
name: "PeerTLS",
|
||||
config: config.ClusterConfig{ClusterSize: 3, PeerTLS: config.ManualTLS},
|
||||
},
|
||||
{
|
||||
name: "PeerAutoTLS",
|
||||
config: config.ClusterConfig{ClusterSize: 3, PeerTLS: config.AutoTLS},
|
||||
},
|
||||
{
|
||||
name: "ClientTLS",
|
||||
config: config.ClusterConfig{ClusterSize: 1, ClientTLS: config.ManualTLS},
|
||||
},
|
||||
{
|
||||
name: "ClientAutoTLS",
|
||||
config: config.ClusterConfig{ClusterSize: 1, ClientTLS: config.AutoTLS},
|
||||
},
|
||||
}
|
||||
if fileutil.Exist(e2e.BinPath.EtcdLastRelease) {
|
||||
tcs = append(tcs, testCase{
|
||||
name: "MinorityLastVersion",
|
||||
config: config.ClusterConfig{
|
||||
ClusterSize: 3,
|
||||
E2eConfig: &config.E2eClusterConfig{
|
||||
Version: config.MinorityLastVersion,
|
||||
},
|
||||
},
|
||||
}, testCase{
|
||||
name: "QuorumLastVersion",
|
||||
config: config.ClusterConfig{
|
||||
ClusterSize: 3,
|
||||
E2eConfig: &config.E2eClusterConfig{
|
||||
Version: config.QuorumLastVersion,
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
return tcs
|
||||
}
|
||||
|
||||
func WithAuth(userName, password string) config.ClientOption {
|
||||
|
@ -25,6 +25,32 @@ import (
|
||||
|
||||
func init() {
|
||||
testRunner = framework.IntegrationTestRunner
|
||||
clusterTestCases = integrationClusterTestCases
|
||||
}
|
||||
|
||||
func integrationClusterTestCases() []testCase {
|
||||
return []testCase{
|
||||
{
|
||||
name: "NoTLS",
|
||||
config: config.ClusterConfig{ClusterSize: 1},
|
||||
},
|
||||
{
|
||||
name: "PeerTLS",
|
||||
config: config.ClusterConfig{ClusterSize: 3, PeerTLS: config.ManualTLS},
|
||||
},
|
||||
{
|
||||
name: "PeerAutoTLS",
|
||||
config: config.ClusterConfig{ClusterSize: 3, PeerTLS: config.AutoTLS},
|
||||
},
|
||||
{
|
||||
name: "ClientTLS",
|
||||
config: config.ClusterConfig{ClusterSize: 1, ClientTLS: config.ManualTLS},
|
||||
},
|
||||
{
|
||||
name: "ClientAutoTLS",
|
||||
config: config.ClusterConfig{ClusterSize: 1, ClientTLS: config.AutoTLS},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func WithAuth(userName, password string) config.ClientOption {
|
||||
|
@ -27,7 +27,7 @@ import (
|
||||
|
||||
func TestKVPut(t *testing.T) {
|
||||
testRunner.BeforeTest(t)
|
||||
for _, tc := range clusterTestCases {
|
||||
for _, tc := range clusterTestCases() {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
@ -61,7 +61,7 @@ func TestKVPut(t *testing.T) {
|
||||
|
||||
func TestKVGet(t *testing.T) {
|
||||
testRunner.BeforeTest(t)
|
||||
for _, tc := range clusterTestCases {
|
||||
for _, tc := range clusterTestCases() {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
@ -121,7 +121,7 @@ func TestKVGet(t *testing.T) {
|
||||
|
||||
func TestKVDelete(t *testing.T) {
|
||||
testRunner.BeforeTest(t)
|
||||
for _, tc := range clusterTestCases {
|
||||
for _, tc := range clusterTestCases() {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
|
||||
defer cancel()
|
||||
|
@ -28,7 +28,7 @@ import (
|
||||
func TestLeaseGrantTimeToLive(t *testing.T) {
|
||||
testRunner.BeforeTest(t)
|
||||
|
||||
for _, tc := range clusterTestCases {
|
||||
for _, tc := range clusterTestCases() {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
@ -52,7 +52,7 @@ func TestLeaseGrantTimeToLive(t *testing.T) {
|
||||
func TestLeaseGrantAndList(t *testing.T) {
|
||||
testRunner.BeforeTest(t)
|
||||
|
||||
for _, tc := range clusterTestCases {
|
||||
for _, tc := range clusterTestCases() {
|
||||
nestedCases := []struct {
|
||||
name string
|
||||
leaseCount int
|
||||
@ -119,7 +119,7 @@ func TestLeaseGrantAndList(t *testing.T) {
|
||||
func TestLeaseGrantTimeToLiveExpired(t *testing.T) {
|
||||
testRunner.BeforeTest(t)
|
||||
|
||||
for _, tc := range clusterTestCases {
|
||||
for _, tc := range clusterTestCases() {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
@ -156,7 +156,7 @@ func TestLeaseGrantTimeToLiveExpired(t *testing.T) {
|
||||
func TestLeaseGrantKeepAliveOnce(t *testing.T) {
|
||||
testRunner.BeforeTest(t)
|
||||
|
||||
for _, tc := range clusterTestCases {
|
||||
for _, tc := range clusterTestCases() {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
@ -185,7 +185,7 @@ func TestLeaseGrantKeepAliveOnce(t *testing.T) {
|
||||
func TestLeaseGrantRevoke(t *testing.T) {
|
||||
testRunner.BeforeTest(t)
|
||||
|
||||
for _, tc := range clusterTestCases {
|
||||
for _, tc := range clusterTestCases() {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
|
@ -15,36 +15,14 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"go.etcd.io/etcd/tests/v3/framework"
|
||||
"testing"
|
||||
|
||||
"go.etcd.io/etcd/tests/v3/framework/config"
|
||||
intf "go.etcd.io/etcd/tests/v3/framework/interfaces"
|
||||
)
|
||||
|
||||
var testRunner intf.TestRunner
|
||||
|
||||
var clusterTestCases = []testCase{
|
||||
{
|
||||
name: "NoTLS",
|
||||
config: config.NewClusterConfig(config.WithClusterSize(1)),
|
||||
},
|
||||
{
|
||||
name: "PeerTLS",
|
||||
config: config.NewClusterConfig(config.WithPeerTLS(config.ManualTLS)),
|
||||
},
|
||||
{
|
||||
name: "PeerAutoTLS",
|
||||
config: config.NewClusterConfig(config.WithPeerTLS(config.AutoTLS)),
|
||||
},
|
||||
{
|
||||
name: "ClientTLS",
|
||||
config: config.NewClusterConfig(config.WithClusterSize(1), config.WithClientTLS(config.ManualTLS)),
|
||||
},
|
||||
{
|
||||
name: "ClientAutoTLS",
|
||||
config: config.NewClusterConfig(config.WithClusterSize(1), config.WithClientTLS(config.AutoTLS)),
|
||||
},
|
||||
}
|
||||
var testRunner = framework.UnitTestRunner
|
||||
var clusterTestCases = func() []testCase { return nil }
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
testRunner.TestMain(m)
|
||||
|
@ -30,7 +30,7 @@ import (
|
||||
func TestMemberList(t *testing.T) {
|
||||
testRunner.BeforeTest(t)
|
||||
|
||||
for _, tc := range clusterTestCases {
|
||||
for _, tc := range clusterTestCases() {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
@ -102,7 +102,7 @@ func TestMemberAdd(t *testing.T) {
|
||||
|
||||
for _, learnerTc := range learnerTcs {
|
||||
for _, quorumTc := range quorumTcs {
|
||||
for _, clusterTc := range clusterTestCases {
|
||||
for _, clusterTc := range clusterTestCases() {
|
||||
t.Run(learnerTc.name+"/"+quorumTc.name+"/"+clusterTc.name, func(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
@ -178,7 +178,7 @@ func TestMemberRemove(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, quorumTc := range tcs {
|
||||
for _, clusterTc := range clusterTestCases {
|
||||
for _, clusterTc := range clusterTestCases() {
|
||||
if !quorumTc.strictReconfigCheck && clusterTc.config.ClusterSize == 1 {
|
||||
// skip these test cases
|
||||
// when strictReconfigCheck is disabled, calling MemberRemove will cause the single node to panic
|
||||
|
@ -28,7 +28,7 @@ import (
|
||||
|
||||
func TestRoleAdd_Simple(t *testing.T) {
|
||||
testRunner.BeforeTest(t)
|
||||
for _, tc := range clusterTestCases {
|
||||
for _, tc := range clusterTestCases() {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
|
@ -27,7 +27,7 @@ func TestStatus(t *testing.T) {
|
||||
|
||||
testRunner.BeforeTest(t)
|
||||
|
||||
for _, tc := range clusterTestCases {
|
||||
for _, tc := range clusterTestCases() {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
|
@ -54,7 +54,7 @@ func TestTxnSucc(t *testing.T) {
|
||||
results: []string{"SUCCESS", `key "with" space`, "value \x23"},
|
||||
},
|
||||
}
|
||||
for _, cfg := range clusterTestCases {
|
||||
for _, cfg := range clusterTestCases() {
|
||||
t.Run(cfg.name, func(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
@ -98,7 +98,7 @@ func TestTxnFail(t *testing.T) {
|
||||
results: []string{"FAILURE", "OK"},
|
||||
},
|
||||
}
|
||||
for _, cfg := range clusterTestCases {
|
||||
for _, cfg := range clusterTestCases() {
|
||||
t.Run(cfg.name, func(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
|
@ -61,7 +61,7 @@ func TestUserAdd_Simple(t *testing.T) {
|
||||
password: "bar",
|
||||
},
|
||||
}
|
||||
for _, tc := range clusterTestCases {
|
||||
for _, tc := range clusterTestCases() {
|
||||
for _, nc := range tcs {
|
||||
t.Run(tc.name+"/"+nc.name, func(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
@ -96,7 +96,7 @@ func TestUserAdd_Simple(t *testing.T) {
|
||||
|
||||
func TestUserAdd_DuplicateUserNotAllowed(t *testing.T) {
|
||||
testRunner.BeforeTest(t)
|
||||
for _, tc := range clusterTestCases {
|
||||
for _, tc := range clusterTestCases() {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
@ -125,7 +125,7 @@ func TestUserAdd_DuplicateUserNotAllowed(t *testing.T) {
|
||||
|
||||
func TestUserList(t *testing.T) {
|
||||
testRunner.BeforeTest(t)
|
||||
for _, tc := range clusterTestCases {
|
||||
for _, tc := range clusterTestCases() {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
@ -166,7 +166,7 @@ func TestUserList(t *testing.T) {
|
||||
|
||||
func TestUserDelete(t *testing.T) {
|
||||
testRunner.BeforeTest(t)
|
||||
for _, tc := range clusterTestCases {
|
||||
for _, tc := range clusterTestCases() {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
@ -218,7 +218,7 @@ func TestUserDelete(t *testing.T) {
|
||||
|
||||
func TestUserChangePassword(t *testing.T) {
|
||||
testRunner.BeforeTest(t)
|
||||
for _, tc := range clusterTestCases {
|
||||
for _, tc := range clusterTestCases() {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
|
@ -25,7 +25,7 @@ import (
|
||||
func TestWaitLeader(t *testing.T) {
|
||||
testRunner.BeforeTest(t)
|
||||
|
||||
for _, tc := range clusterTestCases {
|
||||
for _, tc := range clusterTestCases() {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
|
@ -13,7 +13,7 @@ import (
|
||||
func TestWatch(t *testing.T) {
|
||||
testRunner.BeforeTest(t)
|
||||
watchTimeout := 1 * time.Second
|
||||
for _, tc := range clusterTestCases {
|
||||
for _, tc := range clusterTestCases() {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
|
||||
defer cancel()
|
||||
|
@ -57,7 +57,7 @@ func testDowngradeUpgrade(t *testing.T, clusterSize int) {
|
||||
e2e.BeforeTest(t)
|
||||
|
||||
t.Logf("Create cluster with version %s", currentVersionStr)
|
||||
epc := newCluster(t, currentEtcdBinary, clusterSize)
|
||||
epc := newCluster(t, clusterSize)
|
||||
for i := 0; i < len(epc.Procs); i++ {
|
||||
validateVersion(t, epc.Cfg, epc.Procs[i], version.Versions{
|
||||
Cluster: currentVersionStr,
|
||||
@ -119,9 +119,8 @@ func testDowngradeUpgrade(t *testing.T, clusterSize int) {
|
||||
t.Log("Upgrade complete")
|
||||
}
|
||||
|
||||
func newCluster(t *testing.T, execPath string, clusterSize int) *e2e.EtcdProcessCluster {
|
||||
func newCluster(t *testing.T, clusterSize int) *e2e.EtcdProcessCluster {
|
||||
epc, err := e2e.NewEtcdProcessCluster(context.TODO(), t, &e2e.EtcdProcessClusterConfig{
|
||||
ExecPath: execPath,
|
||||
ClusterSize: clusterSize,
|
||||
InitialToken: "new",
|
||||
KeepDataDir: true,
|
||||
|
@ -24,7 +24,6 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"go.etcd.io/etcd/api/v3/version"
|
||||
"go.etcd.io/etcd/client/pkg/v3/fileutil"
|
||||
"go.etcd.io/etcd/client/pkg/v3/testutil"
|
||||
"go.etcd.io/etcd/pkg/v3/flags"
|
||||
"go.etcd.io/etcd/tests/v3/framework/e2e"
|
||||
@ -51,13 +50,8 @@ func TestClusterVersion(t *testing.T) {
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
binary := e2e.BinPath.Etcd
|
||||
if !fileutil.Exist(binary) {
|
||||
t.Skipf("%q does not exist", binary)
|
||||
}
|
||||
e2e.BeforeTest(t)
|
||||
cfg := e2e.NewConfigNoTLS()
|
||||
cfg.ExecPath = binary
|
||||
cfg.SnapshotCount = 3
|
||||
cfg.BaseScheme = "unix" // to avoid port conflict
|
||||
cfg.RollingStart = tt.rollingStart
|
||||
|
@ -27,6 +27,7 @@ import (
|
||||
"go.etcd.io/etcd/client/pkg/v3/transport"
|
||||
"go.etcd.io/etcd/client/v2"
|
||||
"go.etcd.io/etcd/server/v3/etcdserver/api/rafthttp"
|
||||
"go.etcd.io/etcd/tests/v3/framework/config"
|
||||
"go.etcd.io/etcd/tests/v3/framework/e2e"
|
||||
"go.etcd.io/etcd/tests/v3/framework/integration"
|
||||
)
|
||||
@ -38,14 +39,13 @@ func TestTLSClusterOf3UsingDiscovery(t *testing.T) { testClusterUsingDiscovery(t
|
||||
func testClusterUsingDiscovery(t *testing.T, size int, peerTLS bool) {
|
||||
e2e.BeforeTest(t)
|
||||
|
||||
lastReleaseBinary := e2e.BinPath.EtcdLastRelease
|
||||
if !fileutil.Exist(lastReleaseBinary) {
|
||||
t.Skipf("%q does not exist", lastReleaseBinary)
|
||||
if !fileutil.Exist(e2e.BinPath.EtcdLastRelease) {
|
||||
t.Skipf("%q does not exist", e2e.BinPath.EtcdLastRelease)
|
||||
}
|
||||
|
||||
dc, err := e2e.NewEtcdProcessCluster(context.TODO(), t, &e2e.EtcdProcessClusterConfig{
|
||||
BasePort: 2000,
|
||||
ExecPath: lastReleaseBinary,
|
||||
Version: config.LastVersion,
|
||||
ClusterSize: 1,
|
||||
EnableV2: true,
|
||||
})
|
||||
|
@ -23,21 +23,21 @@ import (
|
||||
|
||||
"go.etcd.io/etcd/api/v3/version"
|
||||
"go.etcd.io/etcd/client/pkg/v3/fileutil"
|
||||
"go.etcd.io/etcd/tests/v3/framework/config"
|
||||
"go.etcd.io/etcd/tests/v3/framework/e2e"
|
||||
)
|
||||
|
||||
// TestReleaseUpgrade ensures that changes to master branch does not affect
|
||||
// upgrade from latest etcd releases.
|
||||
func TestReleaseUpgrade(t *testing.T) {
|
||||
lastReleaseBinary := e2e.BinPath.EtcdLastRelease
|
||||
if !fileutil.Exist(lastReleaseBinary) {
|
||||
t.Skipf("%q does not exist", lastReleaseBinary)
|
||||
if !fileutil.Exist(e2e.BinPath.EtcdLastRelease) {
|
||||
t.Skipf("%q does not exist", e2e.BinPath.EtcdLastRelease)
|
||||
}
|
||||
|
||||
e2e.BeforeTest(t)
|
||||
|
||||
copiedCfg := e2e.NewConfigNoTLS()
|
||||
copiedCfg.ExecPath = lastReleaseBinary
|
||||
copiedCfg.Version = config.LastVersion
|
||||
copiedCfg.SnapshotCount = 3
|
||||
copiedCfg.BaseScheme = "unix" // to avoid port conflict
|
||||
|
||||
@ -113,15 +113,14 @@ func TestReleaseUpgrade(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestReleaseUpgradeWithRestart(t *testing.T) {
|
||||
lastReleaseBinary := e2e.BinPath.EtcdLastRelease
|
||||
if !fileutil.Exist(lastReleaseBinary) {
|
||||
t.Skipf("%q does not exist", lastReleaseBinary)
|
||||
if !fileutil.Exist(e2e.BinPath.EtcdLastRelease) {
|
||||
t.Skipf("%q does not exist", e2e.BinPath.EtcdLastRelease)
|
||||
}
|
||||
|
||||
e2e.BeforeTest(t)
|
||||
|
||||
copiedCfg := e2e.NewConfigNoTLS()
|
||||
copiedCfg.ExecPath = lastReleaseBinary
|
||||
copiedCfg.Version = config.LastVersion
|
||||
copiedCfg.SnapshotCount = 10
|
||||
copiedCfg.BaseScheme = "unix"
|
||||
|
||||
|
@ -27,6 +27,7 @@ import (
|
||||
"go.etcd.io/etcd/client/pkg/v3/fileutil"
|
||||
"go.etcd.io/etcd/server/v3/storage/backend"
|
||||
"go.etcd.io/etcd/server/v3/storage/schema"
|
||||
"go.etcd.io/etcd/tests/v3/framework/config"
|
||||
"go.etcd.io/etcd/tests/v3/framework/e2e"
|
||||
"go.uber.org/zap/zaptest"
|
||||
)
|
||||
@ -35,10 +36,10 @@ func TestEtctlutlMigrate(t *testing.T) {
|
||||
lastReleaseBinary := e2e.BinPath.EtcdLastRelease
|
||||
|
||||
tcs := []struct {
|
||||
name string
|
||||
targetVersion string
|
||||
binary string
|
||||
force bool
|
||||
name string
|
||||
targetVersion string
|
||||
clusterVersion config.ClusterVersion
|
||||
force bool
|
||||
|
||||
expectLogsSubString string
|
||||
expectStorageVersion *semver.Version
|
||||
@ -69,13 +70,13 @@ func TestEtctlutlMigrate(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "Migrate v3.5 to v3.5 is no-op",
|
||||
binary: lastReleaseBinary,
|
||||
clusterVersion: config.LastVersion,
|
||||
targetVersion: "3.5",
|
||||
expectLogsSubString: "storage version up-to-date\t" + `{"storage-version": "3.5"}`,
|
||||
},
|
||||
{
|
||||
name: "Upgrade v3.5 to v3.6 should work",
|
||||
binary: lastReleaseBinary,
|
||||
clusterVersion: config.LastVersion,
|
||||
targetVersion: "3.6",
|
||||
expectStorageVersion: &version.V3_6,
|
||||
},
|
||||
@ -109,13 +110,13 @@ func TestEtctlutlMigrate(t *testing.T) {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
e2e.BeforeTest(t)
|
||||
lg := zaptest.NewLogger(t)
|
||||
if tc.binary != "" && !fileutil.Exist(tc.binary) {
|
||||
if tc.clusterVersion != config.CurrentVersion && !fileutil.Exist(e2e.BinPath.EtcdLastRelease) {
|
||||
t.Skipf("%q does not exist", lastReleaseBinary)
|
||||
}
|
||||
dataDirPath := t.TempDir()
|
||||
|
||||
epc, err := e2e.NewEtcdProcessCluster(context.TODO(), t, &e2e.EtcdProcessClusterConfig{
|
||||
ExecPath: tc.binary,
|
||||
Version: tc.clusterVersion,
|
||||
DataDirPath: dataDirPath,
|
||||
ClusterSize: 1,
|
||||
InitialToken: "new",
|
||||
|
@ -32,10 +32,10 @@ import (
|
||||
"go.uber.org/zap/zaptest"
|
||||
)
|
||||
|
||||
func createV2store(t testing.TB, lastReleaseBinary string, dataDirPath string) {
|
||||
func createV2store(t testing.TB, dataDirPath string) {
|
||||
t.Log("Creating not-yet v2-deprecated etcd")
|
||||
|
||||
cfg := e2e.ConfigStandalone(e2e.EtcdProcessClusterConfig{ExecPath: lastReleaseBinary, EnableV2: true, DataDirPath: dataDirPath, SnapshotCount: 5})
|
||||
cfg := e2e.ConfigStandalone(e2e.EtcdProcessClusterConfig{Version: config.LastVersion, EnableV2: true, DataDirPath: dataDirPath, SnapshotCount: 5})
|
||||
epc, err := e2e.NewEtcdProcessCluster(context.TODO(), t, cfg)
|
||||
assert.NoError(t, err)
|
||||
|
||||
@ -75,13 +75,12 @@ func TestV2DeprecationFlags(t *testing.T) {
|
||||
e2e.BeforeTest(t)
|
||||
dataDirPath := t.TempDir()
|
||||
|
||||
lastReleaseBinary := e2e.BinPath.EtcdLastRelease
|
||||
if !fileutil.Exist(lastReleaseBinary) {
|
||||
t.Skipf("%q does not exist", lastReleaseBinary)
|
||||
if !fileutil.Exist(e2e.BinPath.EtcdLastRelease) {
|
||||
t.Skipf("%q does not exist", e2e.BinPath.EtcdLastRelease)
|
||||
}
|
||||
|
||||
t.Run("create-storev2-data", func(t *testing.T) {
|
||||
createV2store(t, lastReleaseBinary, dataDirPath)
|
||||
createV2store(t, dataDirPath)
|
||||
})
|
||||
|
||||
t.Run("--v2-deprecation=not-yet fails", func(t *testing.T) {
|
||||
@ -101,19 +100,16 @@ func TestV2DeprecationSnapshotMatches(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
lastReleaseBinary := e2e.BinPath.EtcdLastRelease
|
||||
currentReleaseBinary := e2e.BinPath.Etcd
|
||||
|
||||
if !fileutil.Exist(lastReleaseBinary) {
|
||||
t.Skipf("%q does not exist", lastReleaseBinary)
|
||||
if !fileutil.Exist(e2e.BinPath.EtcdLastRelease) {
|
||||
t.Skipf("%q does not exist", e2e.BinPath.EtcdLastRelease)
|
||||
}
|
||||
snapshotCount := 10
|
||||
epc := runEtcdAndCreateSnapshot(t, lastReleaseBinary, lastReleaseData, snapshotCount)
|
||||
epc := runEtcdAndCreateSnapshot(t, config.LastVersion, lastReleaseData, snapshotCount)
|
||||
cc1, err := e2e.NewEtcdctl(epc.Cfg, epc.EndpointsV3())
|
||||
assert.NoError(t, err)
|
||||
members1 := addAndRemoveKeysAndMembers(ctx, t, cc1, snapshotCount)
|
||||
assert.NoError(t, epc.Close())
|
||||
epc = runEtcdAndCreateSnapshot(t, currentReleaseBinary, currentReleaseData, snapshotCount)
|
||||
epc = runEtcdAndCreateSnapshot(t, config.CurrentVersion, currentReleaseData, snapshotCount)
|
||||
cc2, err := e2e.NewEtcdctl(epc.Cfg, epc.EndpointsV3())
|
||||
assert.NoError(t, err)
|
||||
members2 := addAndRemoveKeysAndMembers(ctx, t, cc2, snapshotCount)
|
||||
@ -140,13 +136,10 @@ func TestV2DeprecationSnapshotRecover(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
lastReleaseBinary := e2e.BinPath.EtcdLastRelease
|
||||
currentReleaseBinary := e2e.BinPath.Etcd
|
||||
|
||||
if !fileutil.Exist(lastReleaseBinary) {
|
||||
t.Skipf("%q does not exist", lastReleaseBinary)
|
||||
if !fileutil.Exist(e2e.BinPath.EtcdLastRelease) {
|
||||
t.Skipf("%q does not exist", e2e.BinPath.EtcdLastRelease)
|
||||
}
|
||||
epc := runEtcdAndCreateSnapshot(t, lastReleaseBinary, dataDir, 10)
|
||||
epc := runEtcdAndCreateSnapshot(t, config.LastVersion, dataDir, 10)
|
||||
|
||||
cc, err := e2e.NewEtcdctl(epc.Cfg, epc.EndpointsV3())
|
||||
assert.NoError(t, err)
|
||||
@ -158,7 +151,7 @@ func TestV2DeprecationSnapshotRecover(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.NoError(t, epc.Close())
|
||||
cfg := e2e.ConfigStandalone(e2e.EtcdProcessClusterConfig{ExecPath: currentReleaseBinary, DataDirPath: dataDir})
|
||||
cfg := e2e.ConfigStandalone(e2e.EtcdProcessClusterConfig{Version: config.CurrentVersion, DataDirPath: dataDir})
|
||||
epc, err = e2e.NewEtcdProcessCluster(context.TODO(), t, cfg)
|
||||
assert.NoError(t, err)
|
||||
|
||||
@ -175,8 +168,8 @@ func TestV2DeprecationSnapshotRecover(t *testing.T) {
|
||||
assert.NoError(t, epc.Close())
|
||||
}
|
||||
|
||||
func runEtcdAndCreateSnapshot(t testing.TB, binary, dataDir string, snapshotCount int) *e2e.EtcdProcessCluster {
|
||||
cfg := e2e.ConfigStandalone(e2e.EtcdProcessClusterConfig{ExecPath: binary, DataDirPath: dataDir, SnapshotCount: snapshotCount, KeepDataDir: true})
|
||||
func runEtcdAndCreateSnapshot(t testing.TB, serverVersion config.ClusterVersion, dataDir string, snapshotCount int) *e2e.EtcdProcessCluster {
|
||||
cfg := e2e.ConfigStandalone(e2e.EtcdProcessClusterConfig{Version: serverVersion, DataDirPath: dataDir, SnapshotCount: snapshotCount, KeepDataDir: true})
|
||||
epc, err := e2e.NewEtcdProcessCluster(context.TODO(), t, cfg)
|
||||
assert.NoError(t, err)
|
||||
return epc
|
||||
|
@ -14,15 +14,23 @@
|
||||
|
||||
package config
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type TLSConfig string
|
||||
type ClusterVersion string
|
||||
|
||||
const (
|
||||
NoTLS TLSConfig = ""
|
||||
AutoTLS TLSConfig = "auto-tls"
|
||||
ManualTLS TLSConfig = "manual-tls"
|
||||
|
||||
CurrentVersion ClusterVersion = ""
|
||||
MinorityLastVersion ClusterVersion = "minority-last-version"
|
||||
QuorumLastVersion ClusterVersion = "quorum-last-version"
|
||||
LastVersion ClusterVersion = "last-version"
|
||||
|
||||
TickDuration = 10 * time.Millisecond
|
||||
)
|
||||
|
||||
@ -34,6 +42,12 @@ type ClusterConfig struct {
|
||||
StrictReconfigCheck bool
|
||||
AuthToken string
|
||||
SnapshotCount int
|
||||
|
||||
E2eConfig *E2eClusterConfig
|
||||
}
|
||||
|
||||
type E2eClusterConfig struct {
|
||||
Version ClusterVersion
|
||||
}
|
||||
|
||||
func DefaultClusterConfig() ClusterConfig {
|
||||
|
@ -138,7 +138,7 @@ type EtcdProcessCluster struct {
|
||||
|
||||
type EtcdProcessClusterConfig struct {
|
||||
Logger *zap.Logger
|
||||
ExecPath string
|
||||
Version config.ClusterVersion
|
||||
DataDirPath string
|
||||
KeepDataDir bool
|
||||
EnvVars map[string]string
|
||||
@ -208,9 +208,6 @@ func InitEtcdProcessCluster(t testing.TB, cfg *EtcdProcessClusterConfig) (*EtcdP
|
||||
if cfg.BasePort == 0 {
|
||||
cfg.BasePort = EtcdProcessBasePort
|
||||
}
|
||||
if cfg.ExecPath == "" {
|
||||
cfg.ExecPath = BinPath.Etcd
|
||||
}
|
||||
if cfg.SnapshotCount == 0 {
|
||||
cfg.SnapshotCount = etcdserver.DefaultSnapshotCount
|
||||
}
|
||||
@ -400,9 +397,31 @@ func (cfg *EtcdProcessClusterConfig) EtcdServerProcessConfig(tb testing.TB, i in
|
||||
envVars["GOFAIL_HTTP"] = fmt.Sprintf("127.0.0.1:%d", gofailPort)
|
||||
}
|
||||
|
||||
var execPath string
|
||||
switch cfg.Version {
|
||||
case config.CurrentVersion:
|
||||
execPath = BinPath.Etcd
|
||||
case config.MinorityLastVersion:
|
||||
if i <= cfg.ClusterSize/2 {
|
||||
execPath = BinPath.Etcd
|
||||
} else {
|
||||
execPath = BinPath.EtcdLastRelease
|
||||
}
|
||||
case config.QuorumLastVersion:
|
||||
if i <= cfg.ClusterSize/2 {
|
||||
execPath = BinPath.EtcdLastRelease
|
||||
} else {
|
||||
execPath = BinPath.Etcd
|
||||
}
|
||||
case config.LastVersion:
|
||||
execPath = BinPath.EtcdLastRelease
|
||||
default:
|
||||
panic(fmt.Sprintf("Unknown cluster version %v", cfg.Version))
|
||||
}
|
||||
|
||||
return &EtcdServerProcessConfig{
|
||||
lg: cfg.Logger,
|
||||
ExecPath: cfg.ExecPath,
|
||||
ExecPath: execPath,
|
||||
Args: args,
|
||||
EnvVars: envVars,
|
||||
TlsArgs: cfg.TlsArgs(),
|
||||
|
@ -56,6 +56,9 @@ func (e e2eRunner) NewCluster(ctx context.Context, t testing.TB, opts ...config.
|
||||
AuthTokenOpts: cfg.AuthToken,
|
||||
SnapshotCount: cfg.SnapshotCount,
|
||||
}
|
||||
if cfg.E2eConfig != nil {
|
||||
e2eConfig.Version = cfg.E2eConfig.Version
|
||||
}
|
||||
switch cfg.ClientTLS {
|
||||
case config.NoTLS:
|
||||
e2eConfig.ClientTLS = ClientNonTLS
|
||||
|
@ -50,6 +50,9 @@ func (e integrationRunner) BeforeTest(t testing.TB) {
|
||||
func (e integrationRunner) NewCluster(ctx context.Context, t testing.TB, opts ...config.ClusterOption) intf.Cluster {
|
||||
var err error
|
||||
cfg := config.NewClusterConfig(opts...)
|
||||
if cfg.E2eConfig != nil {
|
||||
t.Fatalf("E2e configuration not expected during integration tests, config: %+v", cfg)
|
||||
}
|
||||
integrationCfg := ClusterConfig{
|
||||
Size: cfg.ClusterSize,
|
||||
QuotaBackendBytes: cfg.QuotaBackendBytes,
|
||||
|
Loading…
x
Reference in New Issue
Block a user