Remove all sleeps from `kvs_endpoint_test.go`

This commit is contained in:
William Tisäter 2014-05-07 23:17:10 +02:00
parent 58bb06ff54
commit 89ead7bc4e
1 changed files with 21 additions and 9 deletions

View File

@ -3,13 +3,13 @@ package agent
import (
"bytes"
"fmt"
"github.com/hashicorp/consul/testutil"
"github.com/hashicorp/consul/consul/structs"
"net/http"
"net/http/httptest"
"os"
"reflect"
"testing"
"time"
)
func TestKVSEndpoint_PUT_GET_DELETE(t *testing.T) {
@ -18,8 +18,11 @@ func TestKVSEndpoint_PUT_GET_DELETE(t *testing.T) {
defer srv.Shutdown()
defer srv.agent.Shutdown()
// Wait for a leader
time.Sleep(100 * time.Millisecond)
args := &structs.RegisterRequest{
Datacenter: "dc1",
}
testutil.WaitForLeader(t, srv.agent.RPC, args)
keys := []string{
"baz",
@ -94,8 +97,11 @@ func TestKVSEndpoint_Recurse(t *testing.T) {
defer srv.Shutdown()
defer srv.agent.Shutdown()
// Wait for a leader
time.Sleep(100 * time.Millisecond)
args := &structs.RegisterRequest{
Datacenter: "dc1",
}
testutil.WaitForLeader(t, srv.agent.RPC, args)
keys := []string{
"bar",
@ -191,8 +197,11 @@ func TestKVSEndpoint_CAS(t *testing.T) {
defer srv.Shutdown()
defer srv.agent.Shutdown()
// Wait for a leader
time.Sleep(100 * time.Millisecond)
args := &structs.RegisterRequest{
Datacenter: "dc1",
}
testutil.WaitForLeader(t, srv.agent.RPC, args)
{
buf := bytes.NewBuffer([]byte("test"))
@ -289,8 +298,11 @@ func TestKVSEndpoint_ListKeys(t *testing.T) {
defer srv.Shutdown()
defer srv.agent.Shutdown()
// Wait for a leader
time.Sleep(100 * time.Millisecond)
args := &structs.RegisterRequest{
Datacenter: "dc1",
}
testutil.WaitForLeader(t, srv.agent.RPC, args)
keys := []string{
"bar",