From 45f71af33eb93d8a3986ff43c090f04e1903464d Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Thu, 25 Sep 2014 10:40:40 -0700 Subject: [PATCH] pkg: move testutil to pkg --- etcdserver/server_test.go | 12 ++++++------ testutil/testutil.go => pkg/test_util.go | 2 +- raft/node_test.go | 12 ++++++------ 3 files changed, 13 insertions(+), 13 deletions(-) rename testutil/testutil.go => pkg/test_util.go (93%) diff --git a/etcdserver/server_test.go b/etcdserver/server_test.go index dcd1fd6b6..90615da6e 100644 --- a/etcdserver/server_test.go +++ b/etcdserver/server_test.go @@ -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) { diff --git a/testutil/testutil.go b/pkg/test_util.go similarity index 93% rename from testutil/testutil.go rename to pkg/test_util.go index 78ee24989..892544767 100644 --- a/testutil/testutil.go +++ b/pkg/test_util.go @@ -1,4 +1,4 @@ -package testutil +package pkg import ( "runtime" diff --git a/raft/node_test.go b/raft/node_test.go index 782653aab..41917e3e1 100644 --- a/raft/node_test.go +++ b/raft/node_test.go @@ -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 {