tests: Rename framework to runner and document the runners
This commit is contained in:
@ -20,5 +20,5 @@ package common
|
||||
import "go.etcd.io/etcd/tests/v3/framework"
|
||||
|
||||
func init() {
|
||||
testFramework = framework.RunE2eTests
|
||||
testRunner = framework.E2eTestRunner
|
||||
}
|
||||
|
@ -22,5 +22,5 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
testFramework = framework.RunIntegrationTests
|
||||
testRunner = framework.IntegrationTestRunner
|
||||
}
|
||||
|
@ -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()
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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 testRunner = 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{}
|
||||
)
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
Reference in New Issue
Block a user