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