mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #1176 from coreos/testutil
pkg: move testutil to pkg
This commit is contained in:
@@ -9,10 +9,10 @@ import (
|
||||
"time"
|
||||
|
||||
pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
|
||||
"github.com/coreos/etcd/pkg"
|
||||
"github.com/coreos/etcd/raft"
|
||||
"github.com/coreos/etcd/raft/raftpb"
|
||||
"github.com/coreos/etcd/store"
|
||||
"github.com/coreos/etcd/testutil"
|
||||
"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)
|
||||
}
|
||||
|
||||
testutil.ForceGosched()
|
||||
pkg.ForceGosched()
|
||||
data := n.data()
|
||||
if len(data) != 1 {
|
||||
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
|
||||
// TODO: use fake clock
|
||||
testutil.ForceGosched()
|
||||
pkg.ForceGosched()
|
||||
w := []action{action{name: "Propose blocked"}}
|
||||
if g := n.Action(); !reflect.DeepEqual(g, w) {
|
||||
t.Errorf("action = %v, want %v", g, w)
|
||||
@@ -743,7 +743,7 @@ func TestRecvSnapshot(t *testing.T) {
|
||||
s.Start()
|
||||
n.readyc <- raft.Ready{Snapshot: raftpb.Snapshot{Index: 1}}
|
||||
// make goroutines move forward to receive snapshot
|
||||
testutil.ForceGosched()
|
||||
pkg.ForceGosched()
|
||||
s.Stop()
|
||||
|
||||
wactions := []action{action{name: "Recovery"}}
|
||||
@@ -771,12 +771,12 @@ func TestRecvSlowSnapshot(t *testing.T) {
|
||||
s.Start()
|
||||
n.readyc <- raft.Ready{Snapshot: raftpb.Snapshot{Index: 1}}
|
||||
// make goroutines move forward to receive snapshot
|
||||
testutil.ForceGosched()
|
||||
pkg.ForceGosched()
|
||||
action := st.Action()
|
||||
|
||||
n.readyc <- raft.Ready{Snapshot: raftpb.Snapshot{Index: 1}}
|
||||
// make goroutines move forward to receive snapshot
|
||||
testutil.ForceGosched()
|
||||
pkg.ForceGosched()
|
||||
s.Stop()
|
||||
|
||||
if g := st.Action(); !reflect.DeepEqual(g, action) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package testutil
|
||||
package pkg
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/coreos/etcd/pkg"
|
||||
"github.com/coreos/etcd/raft/raftpb"
|
||||
"github.com/coreos/etcd/testutil"
|
||||
"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"))
|
||||
}()
|
||||
|
||||
testutil.ForceGosched()
|
||||
pkg.ForceGosched()
|
||||
select {
|
||||
case err := <-errc:
|
||||
t.Errorf("err = %v, want blocking", err)
|
||||
@@ -113,7 +113,7 @@ func TestBlockProposal(t *testing.T) {
|
||||
}
|
||||
|
||||
n.Campaign(context.TODO())
|
||||
testutil.ForceGosched()
|
||||
pkg.ForceGosched()
|
||||
select {
|
||||
case err := <-errc:
|
||||
if err != nil {
|
||||
@@ -225,7 +225,7 @@ func TestCompact(t *testing.T) {
|
||||
Nodes: []int64{1},
|
||||
}
|
||||
|
||||
testutil.ForceGosched()
|
||||
pkg.ForceGosched()
|
||||
select {
|
||||
case <-n.Ready():
|
||||
default:
|
||||
@@ -233,7 +233,7 @@ func TestCompact(t *testing.T) {
|
||||
}
|
||||
|
||||
n.Compact(w.Data)
|
||||
testutil.ForceGosched()
|
||||
pkg.ForceGosched()
|
||||
select {
|
||||
case rd := <-n.Ready():
|
||||
if !reflect.DeepEqual(rd.Snapshot, w) {
|
||||
@@ -242,7 +242,7 @@ func TestCompact(t *testing.T) {
|
||||
default:
|
||||
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
|
||||
// separately with other kinds of updates
|
||||
select {
|
||||
|
||||
Reference in New Issue
Block a user