Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: update tag names for database services #8693

Merged
merged 2 commits into from Sep 16, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions agent/consul/catalog_endpoint_test.go
Expand Up @@ -35,7 +35,7 @@ func TestCatalog_Register(t *testing.T) {
Address: "127.0.0.1",
Service: &structs.NodeService{
Service: "db",
Tags: []string{"master"},
Tags: []string{"primary"},
Port: 8000,
},
Check: &structs.HealthCheck{
Expand Down Expand Up @@ -135,7 +135,7 @@ func TestCatalog_Register_NodeID(t *testing.T) {
Address: "127.0.0.1",
Service: &structs.NodeService{
Service: "db",
Tags: []string{"master"},
Tags: []string{"primary"},
Port: 8000,
},
Check: &structs.HealthCheck{
Expand Down Expand Up @@ -199,7 +199,7 @@ node "foo" {
Address: "127.0.0.1",
Service: &structs.NodeService{
Service: "db",
Tags: []string{"master"},
Tags: []string{"primary"},
Port: 8000,
},
WriteRequest: structs.WriteRequest{Token: id},
Expand Down Expand Up @@ -285,7 +285,7 @@ func TestCatalog_Register_ForwardLeader(t *testing.T) {
Address: "127.0.0.1",
Service: &structs.NodeService{
Service: "db",
Tags: []string{"master"},
Tags: []string{"primary"},
Port: 8000,
},
}
Expand Down Expand Up @@ -318,7 +318,7 @@ func TestCatalog_Register_ForwardDC(t *testing.T) {
Address: "127.0.0.1",
Service: &structs.NodeService{
Service: "db",
Tags: []string{"master"},
Tags: []string{"primary"},
Port: 8000,
},
}
Expand Down Expand Up @@ -1615,7 +1615,7 @@ func TestCatalog_ListServiceNodes(t *testing.T) {
args := structs.ServiceSpecificRequest{
Datacenter: "dc1",
ServiceName: "db",
ServiceTags: []string{"slave"},
ServiceTags: []string{"replica"},
TagFilter: false,
}
var out structs.IndexedServiceNodes
Expand Down
24 changes: 12 additions & 12 deletions agent/consul/health_endpoint_test.go
Expand Up @@ -539,7 +539,7 @@ func TestHealth_ServiceNodes(t *testing.T) {
Service: &structs.NodeService{
ID: "db",
Service: "db",
Tags: []string{"master"},
Tags: []string{"primary"},
},
Check: &structs.HealthCheck{
Name: "db connect",
Expand All @@ -559,7 +559,7 @@ func TestHealth_ServiceNodes(t *testing.T) {
Service: &structs.NodeService{
ID: "db",
Service: "db",
Tags: []string{"slave"},
Tags: []string{"replica"},
},
Check: &structs.HealthCheck{
Name: "db connect",
Expand All @@ -575,7 +575,7 @@ func TestHealth_ServiceNodes(t *testing.T) {
req := structs.ServiceSpecificRequest{
Datacenter: "dc1",
ServiceName: "db",
ServiceTags: []string{"master"},
ServiceTags: []string{"primary"},
TagFilter: false,
}
if err := msgpackrpc.CallWithCodec(codec, "Health.ServiceNodes", &req, &out2); err != nil {
Expand All @@ -592,10 +592,10 @@ func TestHealth_ServiceNodes(t *testing.T) {
if nodes[1].Node.Node != "foo" {
t.Fatalf("Bad: %v", nodes[1])
}
if !stringslice.Contains(nodes[0].Service.Tags, "slave") {
if !stringslice.Contains(nodes[0].Service.Tags, "replica") {
t.Fatalf("Bad: %v", nodes[0])
}
if !stringslice.Contains(nodes[1].Service.Tags, "master") {
if !stringslice.Contains(nodes[1].Service.Tags, "primary") {
t.Fatalf("Bad: %v", nodes[1])
}
if nodes[0].Checks[0].Status != api.HealthWarning {
Expand All @@ -613,7 +613,7 @@ func TestHealth_ServiceNodes(t *testing.T) {
req := structs.ServiceSpecificRequest{
Datacenter: "dc1",
ServiceName: "db",
ServiceTag: "master",
ServiceTag: "primary",
TagFilter: false,
}
if err := msgpackrpc.CallWithCodec(codec, "Health.ServiceNodes", &req, &out2); err != nil {
Expand All @@ -630,10 +630,10 @@ func TestHealth_ServiceNodes(t *testing.T) {
if nodes[1].Node.Node != "foo" {
t.Fatalf("Bad: %v", nodes[1])
}
if !stringslice.Contains(nodes[0].Service.Tags, "slave") {
if !stringslice.Contains(nodes[0].Service.Tags, "replica") {
t.Fatalf("Bad: %v", nodes[0])
}
if !stringslice.Contains(nodes[1].Service.Tags, "master") {
if !stringslice.Contains(nodes[1].Service.Tags, "primary") {
t.Fatalf("Bad: %v", nodes[1])
}
if nodes[0].Checks[0].Status != api.HealthWarning {
Expand Down Expand Up @@ -662,7 +662,7 @@ func TestHealth_ServiceNodes_MultipleServiceTags(t *testing.T) {
Service: &structs.NodeService{
ID: "db",
Service: "db",
Tags: []string{"master", "v2"},
Tags: []string{"primary", "v2"},
},
Check: &structs.HealthCheck{
Name: "db connect",
Expand All @@ -680,7 +680,7 @@ func TestHealth_ServiceNodes_MultipleServiceTags(t *testing.T) {
Service: &structs.NodeService{
ID: "db",
Service: "db",
Tags: []string{"slave", "v2"},
Tags: []string{"replica", "v2"},
},
Check: &structs.HealthCheck{
Name: "db connect",
Expand All @@ -694,7 +694,7 @@ func TestHealth_ServiceNodes_MultipleServiceTags(t *testing.T) {
req := structs.ServiceSpecificRequest{
Datacenter: "dc1",
ServiceName: "db",
ServiceTags: []string{"master", "v2"},
ServiceTags: []string{"primary", "v2"},
TagFilter: true,
}
require.NoError(t, msgpackrpc.CallWithCodec(codec, "Health.ServiceNodes", &req, &out2))
Expand All @@ -703,7 +703,7 @@ func TestHealth_ServiceNodes_MultipleServiceTags(t *testing.T) {
require.Len(t, nodes, 1)
require.Equal(t, nodes[0].Node.Node, "foo")
require.Contains(t, nodes[0].Service.Tags, "v2")
require.Contains(t, nodes[0].Service.Tags, "master")
require.Contains(t, nodes[0].Service.Tags, "primary")
require.Equal(t, nodes[0].Checks[0].Status, api.HealthPassing)
}

Expand Down
18 changes: 9 additions & 9 deletions agent/consul/internal_endpoint_test.go
Expand Up @@ -34,7 +34,7 @@ func TestInternal_NodeInfo(t *testing.T) {
Service: &structs.NodeService{
ID: "db",
Service: "db",
Tags: []string{"master"},
Tags: []string{"primary"},
},
Check: &structs.HealthCheck{
Name: "db connect",
Expand Down Expand Up @@ -63,7 +63,7 @@ func TestInternal_NodeInfo(t *testing.T) {
if nodes[0].Node != "foo" {
t.Fatalf("Bad: %v", nodes[0])
}
if !stringslice.Contains(nodes[0].Services[0].Tags, "master") {
if !stringslice.Contains(nodes[0].Services[0].Tags, "primary") {
t.Fatalf("Bad: %v", nodes[0])
}
if nodes[0].Checks[0].Status != api.HealthPassing {
Expand All @@ -88,7 +88,7 @@ func TestInternal_NodeDump(t *testing.T) {
Service: &structs.NodeService{
ID: "db",
Service: "db",
Tags: []string{"master"},
Tags: []string{"primary"},
},
Check: &structs.HealthCheck{
Name: "db connect",
Expand All @@ -108,7 +108,7 @@ func TestInternal_NodeDump(t *testing.T) {
Service: &structs.NodeService{
ID: "db",
Service: "db",
Tags: []string{"slave"},
Tags: []string{"replica"},
},
Check: &structs.HealthCheck{
Name: "db connect",
Expand Down Expand Up @@ -138,7 +138,7 @@ func TestInternal_NodeDump(t *testing.T) {
switch node.Node {
case "foo":
foundFoo = true
if !stringslice.Contains(node.Services[0].Tags, "master") {
if !stringslice.Contains(node.Services[0].Tags, "primary") {
t.Fatalf("Bad: %v", nodes[0])
}
if node.Checks[0].Status != api.HealthPassing {
Expand All @@ -147,7 +147,7 @@ func TestInternal_NodeDump(t *testing.T) {

case "bar":
foundBar = true
if !stringslice.Contains(node.Services[0].Tags, "slave") {
if !stringslice.Contains(node.Services[0].Tags, "replica") {
t.Fatalf("Bad: %v", nodes[1])
}
if node.Checks[0].Status != api.HealthWarning {
Expand Down Expand Up @@ -180,7 +180,7 @@ func TestInternal_NodeDump_Filter(t *testing.T) {
Service: &structs.NodeService{
ID: "db",
Service: "db",
Tags: []string{"master"},
Tags: []string{"primary"},
},
Check: &structs.HealthCheck{
Name: "db connect",
Expand All @@ -198,7 +198,7 @@ func TestInternal_NodeDump_Filter(t *testing.T) {
Service: &structs.NodeService{
ID: "db",
Service: "db",
Tags: []string{"slave"},
Tags: []string{"replica"},
},
Check: &structs.HealthCheck{
Name: "db connect",
Expand All @@ -212,7 +212,7 @@ func TestInternal_NodeDump_Filter(t *testing.T) {
var out2 structs.IndexedNodeDump
req := structs.DCSpecificRequest{
Datacenter: "dc1",
QueryOptions: structs.QueryOptions{Filter: "master in Services.Tags"},
QueryOptions: structs.QueryOptions{Filter: "primary in Services.Tags"},
}
require.NoError(t, msgpackrpc.CallWithCodec(codec, "Internal.NodeDump", &req, &out2))

Expand Down