diff --git a/tests/common/e2e_test.go b/tests/common/e2e_test.go index e0f29ce399ce..1debbafaa00f 100644 --- a/tests/common/e2e_test.go +++ b/tests/common/e2e_test.go @@ -20,5 +20,5 @@ package common import "go.etcd.io/etcd/tests/v3/framework" func init() { - testFramework = framework.RunE2eTests + testRunner = framework.E2eTestRunner } diff --git a/tests/common/integration_test.go b/tests/common/integration_test.go index 7c7ccc2244ca..a2588a9cce5e 100644 --- a/tests/common/integration_test.go +++ b/tests/common/integration_test.go @@ -22,5 +22,5 @@ import ( ) func init() { - testFramework = framework.RunIntegrationTests + testRunner = framework.IntegrationTestRunner } diff --git a/tests/common/kv_test.go b/tests/common/kv_test.go index 868fa3f3efd7..b6a37fe5009b 100644 --- a/tests/common/kv_test.go +++ b/tests/common/kv_test.go @@ -22,8 +22,8 @@ import ( ) func TestKVPut(t *testing.T) { - testFramework.BeforeTest(t) - clus := testFramework.NewCluster(t) + testRunner.BeforeTest(t) + clus := testRunner.NewCluster(t) defer clus.Close() cc := clus.Client() diff --git a/tests/common/main_test.go b/tests/common/main_test.go index b3987e1b5913..73dbae69d47d 100644 --- a/tests/common/main_test.go +++ b/tests/common/main_test.go @@ -20,8 +20,8 @@ import ( "go.etcd.io/etcd/tests/v3/framework" ) -var testFramework = framework.TestFramework +var testRunner = framework.UnitTestRunner func TestMain(m *testing.M) { - testFramework.TestMain(m) + testRunner.TestMain(m) } diff --git a/tests/framework/e2e.go b/tests/framework/e2e.go index 4593506abfe6..094628a3761a 100644 --- a/tests/framework/e2e.go +++ b/tests/framework/e2e.go @@ -24,9 +24,9 @@ import ( "go.etcd.io/etcd/tests/v3/framework/testutils" ) -type e2eFramework struct{} +type e2eRunner struct{} -func (e e2eFramework) TestMain(m *testing.M) { +func (e e2eRunner) TestMain(m *testing.M) { e2e.InitFlags() v := m.Run() if v == 0 && testutil.CheckLeakedGoroutine() { @@ -35,11 +35,11 @@ func (e e2eFramework) TestMain(m *testing.M) { os.Exit(v) } -func (e e2eFramework) BeforeTest(t testing.TB) { +func (e e2eRunner) BeforeTest(t testing.TB) { e2e.BeforeTest(t) } -func (e e2eFramework) NewCluster(t testing.TB) Cluster { +func (e e2eRunner) NewCluster(t testing.TB) Cluster { epc, err := e2e.NewEtcdProcessCluster(t, e2e.ConfigStandalone(*e2e.NewConfigAutoTLS())) if err != nil { t.Fatalf("could not start etcd integrationCluster: %s", err) diff --git a/tests/framework/framework.go b/tests/framework/framework.go index d07968e738e7..cdb03f6102aa 100644 --- a/tests/framework/framework.go +++ b/tests/framework/framework.go @@ -15,7 +15,10 @@ package framework var ( - TestFramework testFramework = noFrameworkSelected{} - RunE2eTests testFramework = e2eFramework{} - RunIntegrationTests testFramework = integrationFramework{} + // UnitTestRunner only runs in `--short` mode, will fail otherwise. Attempts in cluster creation will result in tests being skipped. + UnitTestRunner = unitRunner{} + // E2eTestRunner runs etcd and etcdctl binaries in a separate process. + E2eTestRunner = e2eRunner{} + // IntegrationTestRunner runs etcdserver.EtcdServer in separate goroutine and uses client libraries to communicate. + IntegrationTestRunner = integrationRunner{} ) diff --git a/tests/framework/integration.go b/tests/framework/integration.go index 46eb83d83168..b37111aa4248 100644 --- a/tests/framework/integration.go +++ b/tests/framework/integration.go @@ -24,17 +24,17 @@ import ( "go.etcd.io/etcd/tests/v3/framework/testutils" ) -type integrationFramework struct{} +type integrationRunner struct{} -func (e integrationFramework) TestMain(m *testing.M) { +func (e integrationRunner) TestMain(m *testing.M) { testutil.MustTestMainWithLeakDetection(m) } -func (e integrationFramework) BeforeTest(t testing.TB) { +func (e integrationRunner) BeforeTest(t testing.TB) { integration.BeforeTest(t) } -func (e integrationFramework) NewCluster(t testing.TB) Cluster { +func (e integrationRunner) NewCluster(t testing.TB) Cluster { return &integrationCluster{ Cluster: integration.NewCluster(t, &integration.ClusterConfig{Size: 1}), t: t, diff --git a/tests/framework/interface.go b/tests/framework/interface.go index 273ed453224a..9eb9e34c28e5 100644 --- a/tests/framework/interface.go +++ b/tests/framework/interface.go @@ -21,7 +21,7 @@ import ( "go.etcd.io/etcd/tests/v3/framework/testutils" ) -type testFramework interface { +type testRunner interface { TestMain(m *testing.M) BeforeTest(testing.TB) NewCluster(testing.TB) Cluster diff --git a/tests/framework/default.go b/tests/framework/unit.go similarity index 79% rename from tests/framework/default.go rename to tests/framework/unit.go index d34dc64622cc..231e0f7df496 100644 --- a/tests/framework/default.go +++ b/tests/framework/unit.go @@ -23,11 +23,11 @@ import ( "go.etcd.io/etcd/client/pkg/v3/testutil" ) -type noFrameworkSelected struct{} +type unitRunner struct{} -var _ testFramework = (*noFrameworkSelected)(nil) +var _ testRunner = (*unitRunner)(nil) -func (e noFrameworkSelected) TestMain(m *testing.M) { +func (e unitRunner) TestMain(m *testing.M) { flag.Parse() if !testing.Short() { fmt.Println(`No test mode selected, please selected either e2e mode with "--tags e2e" or integration mode with "--tags integration"`) @@ -35,10 +35,10 @@ func (e noFrameworkSelected) TestMain(m *testing.M) { } } -func (e noFrameworkSelected) BeforeTest(t testing.TB) { - testutil.SkipTestIfShortMode(t, "Cannot create clusters in --short tests") +func (e unitRunner) BeforeTest(t testing.TB) { } -func (e noFrameworkSelected) NewCluster(t testing.TB) Cluster { +func (e unitRunner) NewCluster(t testing.TB) Cluster { + testutil.SkipTestIfShortMode(t, "Cannot create clusters in --short tests") return nil }