Move default uuid test into the consul package
This commit is contained in:
parent
dbc407cec9
commit
66af873639
|
@ -9,10 +9,8 @@ import (
|
||||||
|
|
||||||
"github.com/hashicorp/consul/agent/structs"
|
"github.com/hashicorp/consul/agent/structs"
|
||||||
"github.com/hashicorp/consul/testutil/retry"
|
"github.com/hashicorp/consul/testutil/retry"
|
||||||
"github.com/hashicorp/consul/types"
|
|
||||||
"github.com/hashicorp/serf/coordinate"
|
"github.com/hashicorp/serf/coordinate"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCatalogRegister_Service_InvalidAddress(t *testing.T) {
|
func TestCatalogRegister_Service_InvalidAddress(t *testing.T) {
|
||||||
|
@ -111,34 +109,6 @@ func TestCatalogNodes(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCatalog_RegisterNoID(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
a := NewTestAgent(t.Name(), "")
|
|
||||||
defer a.Shutdown()
|
|
||||||
|
|
||||||
// Register node
|
|
||||||
args := &structs.RegisterRequest{
|
|
||||||
Datacenter: "dc1",
|
|
||||||
Node: "foo",
|
|
||||||
Address: "127.0.0.1",
|
|
||||||
}
|
|
||||||
|
|
||||||
var out struct{}
|
|
||||||
require.NoError(t, a.RPC("Catalog.Register", args, &out))
|
|
||||||
|
|
||||||
req, _ := http.NewRequest("GET", "/v1/catalog/node/foo", nil)
|
|
||||||
resp := httptest.NewRecorder()
|
|
||||||
obj, err := a.srv.CatalogNodeServices(resp, req)
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
// Verify an index is set
|
|
||||||
assertIndex(t, resp)
|
|
||||||
|
|
||||||
node := obj.(*structs.NodeServices)
|
|
||||||
|
|
||||||
require.NotEqual(t, types.NodeID(""), node.Node.ID)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestCatalogNodes_MetaFilter(t *testing.T) {
|
func TestCatalogNodes_MetaFilter(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
a := NewTestAgent(t.Name(), "")
|
a := NewTestAgent(t.Name(), "")
|
||||||
|
|
|
@ -50,6 +50,37 @@ func TestCatalog_Register(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCatalog_RegisterNoID(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
dir1, s1 := testServer(t)
|
||||||
|
defer os.RemoveAll(dir1)
|
||||||
|
defer s1.Shutdown()
|
||||||
|
codec := rpcClient(t, s1)
|
||||||
|
defer codec.Close()
|
||||||
|
|
||||||
|
arg := structs.RegisterRequest{
|
||||||
|
Datacenter: "dc1",
|
||||||
|
Node: "foo",
|
||||||
|
Address: "127.0.0.1",
|
||||||
|
Service: &structs.NodeService{
|
||||||
|
Service: "db",
|
||||||
|
Tags: []string{"master"},
|
||||||
|
Port: 8000,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
var out struct{}
|
||||||
|
|
||||||
|
require.NoError(t, msgpackrpc.CallWithCodec(codec, "Catalog.Register", &arg, &out))
|
||||||
|
|
||||||
|
var ns structs.IndexedNodeServices
|
||||||
|
nodeArgs := structs.NodeSpecificRequest{
|
||||||
|
Datacenter: "dc1",
|
||||||
|
Node: "foo",
|
||||||
|
}
|
||||||
|
require.NoError(t, msgpackrpc.CallWithCodec(codec, "Catalog.NodeServices", &nodeArgs, &ns))
|
||||||
|
require.NotEqual(t, types.NodeID(""), ns.NodeServices.Node.ID)
|
||||||
|
}
|
||||||
|
|
||||||
func TestCatalog_RegisterService_InvalidAddress(t *testing.T) {
|
func TestCatalog_RegisterService_InvalidAddress(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
dir1, s1 := testServer(t)
|
dir1, s1 := testServer(t)
|
||||||
|
|
Loading…
Reference in New Issue