Browse Source

pkg: move testutil to pkg

Xiang Li 11 years ago
parent
commit
45f71af33e
3 changed files with 13 additions and 13 deletions
  1. 6 6
      etcdserver/server_test.go
  2. 1 1
      pkg/test_util.go
  3. 6 6
      raft/node_test.go

+ 6 - 6
etcdserver/server_test.go

@@ -9,10 +9,10 @@ import (
 	"time"
 	"time"
 
 
 	pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
 	pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+	"github.com/coreos/etcd/pkg"
 	"github.com/coreos/etcd/raft"
 	"github.com/coreos/etcd/raft"
 	"github.com/coreos/etcd/raft/raftpb"
 	"github.com/coreos/etcd/raft/raftpb"
 	"github.com/coreos/etcd/store"
 	"github.com/coreos/etcd/store"
-	"github.com/coreos/etcd/testutil"
 	"github.com/coreos/etcd/third_party/code.google.com/p/go.net/context"
 	"github.com/coreos/etcd/third_party/code.google.com/p/go.net/context"
 )
 )
 
 
@@ -572,7 +572,7 @@ func TestSync(t *testing.T) {
 		t.Errorf("CallSyncTime = %v, want < %v", d, time.Millisecond)
 		t.Errorf("CallSyncTime = %v, want < %v", d, time.Millisecond)
 	}
 	}
 
 
-	testutil.ForceGosched()
+	pkg.ForceGosched()
 	data := n.data()
 	data := n.data()
 	if len(data) != 1 {
 	if len(data) != 1 {
 		t.Fatalf("len(proposeData) = %d, want 1", len(data))
 		t.Fatalf("len(proposeData) = %d, want 1", len(data))
@@ -603,7 +603,7 @@ func TestSyncTimeout(t *testing.T) {
 
 
 	// give time for goroutine in sync to cancel
 	// give time for goroutine in sync to cancel
 	// TODO: use fake clock
 	// TODO: use fake clock
-	testutil.ForceGosched()
+	pkg.ForceGosched()
 	w := []action{action{name: "Propose blocked"}}
 	w := []action{action{name: "Propose blocked"}}
 	if g := n.Action(); !reflect.DeepEqual(g, w) {
 	if g := n.Action(); !reflect.DeepEqual(g, w) {
 		t.Errorf("action = %v, want %v", g, w)
 		t.Errorf("action = %v, want %v", g, w)
@@ -743,7 +743,7 @@ func TestRecvSnapshot(t *testing.T) {
 	s.Start()
 	s.Start()
 	n.readyc <- raft.Ready{Snapshot: raftpb.Snapshot{Index: 1}}
 	n.readyc <- raft.Ready{Snapshot: raftpb.Snapshot{Index: 1}}
 	// make goroutines move forward to receive snapshot
 	// make goroutines move forward to receive snapshot
-	testutil.ForceGosched()
+	pkg.ForceGosched()
 	s.Stop()
 	s.Stop()
 
 
 	wactions := []action{action{name: "Recovery"}}
 	wactions := []action{action{name: "Recovery"}}
@@ -771,12 +771,12 @@ func TestRecvSlowSnapshot(t *testing.T) {
 	s.Start()
 	s.Start()
 	n.readyc <- raft.Ready{Snapshot: raftpb.Snapshot{Index: 1}}
 	n.readyc <- raft.Ready{Snapshot: raftpb.Snapshot{Index: 1}}
 	// make goroutines move forward to receive snapshot
 	// make goroutines move forward to receive snapshot
-	testutil.ForceGosched()
+	pkg.ForceGosched()
 	action := st.Action()
 	action := st.Action()
 
 
 	n.readyc <- raft.Ready{Snapshot: raftpb.Snapshot{Index: 1}}
 	n.readyc <- raft.Ready{Snapshot: raftpb.Snapshot{Index: 1}}
 	// make goroutines move forward to receive snapshot
 	// make goroutines move forward to receive snapshot
-	testutil.ForceGosched()
+	pkg.ForceGosched()
 	s.Stop()
 	s.Stop()
 
 
 	if g := st.Action(); !reflect.DeepEqual(g, action) {
 	if g := st.Action(); !reflect.DeepEqual(g, action) {

+ 1 - 1
testutil/testutil.go → pkg/test_util.go

@@ -1,4 +1,4 @@
-package testutil
+package pkg
 
 
 import (
 import (
 	"runtime"
 	"runtime"

+ 6 - 6
raft/node_test.go

@@ -5,8 +5,8 @@ import (
 	"testing"
 	"testing"
 	"time"
 	"time"
 
 
+	"github.com/coreos/etcd/pkg"
 	"github.com/coreos/etcd/raft/raftpb"
 	"github.com/coreos/etcd/raft/raftpb"
-	"github.com/coreos/etcd/testutil"
 	"github.com/coreos/etcd/third_party/code.google.com/p/go.net/context"
 	"github.com/coreos/etcd/third_party/code.google.com/p/go.net/context"
 )
 )
 
 
@@ -105,7 +105,7 @@ func TestBlockProposal(t *testing.T) {
 		errc <- n.Propose(context.TODO(), []byte("somedata"))
 		errc <- n.Propose(context.TODO(), []byte("somedata"))
 	}()
 	}()
 
 
-	testutil.ForceGosched()
+	pkg.ForceGosched()
 	select {
 	select {
 	case err := <-errc:
 	case err := <-errc:
 		t.Errorf("err = %v, want blocking", err)
 		t.Errorf("err = %v, want blocking", err)
@@ -113,7 +113,7 @@ func TestBlockProposal(t *testing.T) {
 	}
 	}
 
 
 	n.Campaign(context.TODO())
 	n.Campaign(context.TODO())
-	testutil.ForceGosched()
+	pkg.ForceGosched()
 	select {
 	select {
 	case err := <-errc:
 	case err := <-errc:
 		if err != nil {
 		if err != nil {
@@ -225,7 +225,7 @@ func TestCompact(t *testing.T) {
 		Nodes: []int64{1},
 		Nodes: []int64{1},
 	}
 	}
 
 
-	testutil.ForceGosched()
+	pkg.ForceGosched()
 	select {
 	select {
 	case <-n.Ready():
 	case <-n.Ready():
 	default:
 	default:
@@ -233,7 +233,7 @@ func TestCompact(t *testing.T) {
 	}
 	}
 
 
 	n.Compact(w.Data)
 	n.Compact(w.Data)
-	testutil.ForceGosched()
+	pkg.ForceGosched()
 	select {
 	select {
 	case rd := <-n.Ready():
 	case rd := <-n.Ready():
 		if !reflect.DeepEqual(rd.Snapshot, w) {
 		if !reflect.DeepEqual(rd.Snapshot, w) {
@@ -242,7 +242,7 @@ func TestCompact(t *testing.T) {
 	default:
 	default:
 		t.Fatalf("unexpected compact failure: unable to create a snapshot")
 		t.Fatalf("unexpected compact failure: unable to create a snapshot")
 	}
 	}
-	testutil.ForceGosched()
+	pkg.ForceGosched()
 	// TODO: this test the run updates the snapi correctly... should be tested
 	// TODO: this test the run updates the snapi correctly... should be tested
 	// separately with other kinds of updates
 	// separately with other kinds of updates
 	select {
 	select {