mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Tests: Better isolation between store_v2v3 integration tests.
This commit is contained in:
parent
fb1d48e98e
commit
41f6cc7234
@ -15,30 +15,26 @@
|
||||
package v2store_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"go.etcd.io/etcd/pkg/v3/testutil"
|
||||
"go.etcd.io/etcd/tests/v3/integration"
|
||||
)
|
||||
|
||||
var endpoints []string
|
||||
//var endpoints []string
|
||||
|
||||
// TestMain sets up an etcd cluster for running the examples.
|
||||
func TestMain(m *testing.M) {
|
||||
cfg := integration.ClusterConfig{Size: 1}
|
||||
clus := integration.NewClusterV3(nil, &cfg)
|
||||
endpoints = []string{clus.Client(0).Endpoints()[0]}
|
||||
v := m.Run()
|
||||
clus.Terminate(nil)
|
||||
if err := testutil.CheckAfterTest(time.Second); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "%v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
if v == 0 && testutil.CheckLeakedGoroutine() {
|
||||
os.Exit(1)
|
||||
}
|
||||
os.Exit(v)
|
||||
//cfg := integration.ClusterConfig{Size: 1}
|
||||
//clus := integration.NewClusterV3(nil, &cfg)
|
||||
//endpoints = []string{clus.Client(0).Endpoints()[0]}
|
||||
// v := m.Run()
|
||||
//clus.Terminate(nil)
|
||||
//if err := testutil.CheckAfterTest(time.Second); err != nil {
|
||||
// fmt.Fprintf(os.Stderr, "%v", err)
|
||||
// os.Exit(1)
|
||||
//}
|
||||
testutil.MustTestMainWithLeakDetection(m)
|
||||
//if v == 0 && testutil.CheckLeakedGoroutine() {
|
||||
// os.Exit(1)
|
||||
//}
|
||||
//os.Exit(v)
|
||||
}
|
||||
|
@ -19,13 +19,27 @@ import (
|
||||
"testing"
|
||||
|
||||
"go.etcd.io/etcd/client/v3"
|
||||
"go.etcd.io/etcd/pkg/v3/testutil"
|
||||
"go.etcd.io/etcd/server/v3/etcdserver/api/v2store"
|
||||
"go.etcd.io/etcd/server/v3/etcdserver/api/v2v3"
|
||||
"go.etcd.io/etcd/tests/v3/integration"
|
||||
)
|
||||
|
||||
// TODO: fix tests
|
||||
|
||||
func TestCreateKV(t *testing.T) {
|
||||
func runWithCluster(t testing.TB, runner func(testing.TB, []string)) {
|
||||
testutil.BeforeTest(t)
|
||||
cfg := integration.ClusterConfig{Size: 1}
|
||||
clus := integration.NewClusterV3(nil, &cfg)
|
||||
defer clus.Terminate(t)
|
||||
endpoints := []string{clus.Client(0).Endpoints()[0]}
|
||||
runner(t, endpoints)
|
||||
|
||||
}
|
||||
|
||||
func TestCreateKV(t *testing.T) { runWithCluster(t, testCreateKV) }
|
||||
|
||||
func testCreateKV(t testing.TB, endpoints []string) {
|
||||
testCases := []struct {
|
||||
key string
|
||||
value string
|
||||
@ -77,7 +91,9 @@ func TestCreateKV(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetKV(t *testing.T) {
|
||||
func TestSetKV(t *testing.T) { runWithCluster(t, testSetKV) }
|
||||
|
||||
func testSetKV(t testing.TB, endpoints []string) {
|
||||
testCases := []struct {
|
||||
key string
|
||||
value string
|
||||
@ -113,7 +129,9 @@ func TestSetKV(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreateSetDir(t *testing.T) {
|
||||
func TestCreateSetDir(t *testing.T) { runWithCluster(t, testCreateSetDir) }
|
||||
|
||||
func testCreateSetDir(t testing.TB, endpoints []string) {
|
||||
testCases := []struct {
|
||||
dir string
|
||||
}{
|
||||
|
Loading…
x
Reference in New Issue
Block a user