Make new gateway tests compatible with enterprise (#7856)

This commit is contained in:
Chris Piraino 2020-05-12 13:48:20 -05:00 committed by GitHub
parent 4b8a21d6f5
commit 3eb4e4012a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 51 additions and 39 deletions

View File

@ -1279,20 +1279,22 @@ func TestInternal_GatewayServiceDump_Terminating(t *testing.T) {
Passing: 1,
Warning: 1,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
},
Checks: structs.HealthChecks{
{
Node: "baz",
CheckID: types.CheckID("db2-passing"),
Name: "db2-passing",
Status: "passing",
ServiceID: "db2",
ServiceName: "db",
Node: "baz",
CheckID: types.CheckID("db2-passing"),
Name: "db2-passing",
Status: "passing",
ServiceID: "db2",
ServiceName: "db",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
},
},
GatewayService: &structs.GatewayService{
Gateway: structs.ServiceID{ID: "terminating-gateway"},
Service: structs.ServiceID{ID: "db"},
Gateway: structs.NewServiceID("terminating-gateway", nil),
Service: structs.NewServiceID("db", nil),
GatewayKind: "terminating-gateway",
},
},
@ -1309,28 +1311,30 @@ func TestInternal_GatewayServiceDump_Terminating(t *testing.T) {
Passing: 1,
Warning: 1,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
},
Checks: structs.HealthChecks{
{
Node: "bar",
CheckID: types.CheckID("db-warning"),
Name: "db-warning",
Status: "warning",
ServiceID: "db",
ServiceName: "db",
Node: "bar",
CheckID: types.CheckID("db-warning"),
Name: "db-warning",
Status: "warning",
ServiceID: "db",
ServiceName: "db",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
},
},
GatewayService: &structs.GatewayService{
Gateway: structs.ServiceID{ID: "terminating-gateway"},
Service: structs.ServiceID{ID: "db"},
Gateway: structs.NewServiceID("terminating-gateway", nil),
Service: structs.NewServiceID("db", nil),
GatewayKind: "terminating-gateway",
},
},
{
// Only GatewayService should be returned when linked service isn't registered
GatewayService: &structs.GatewayService{
Gateway: structs.ServiceID{ID: "terminating-gateway"},
Service: structs.ServiceID{ID: "redis"},
Gateway: structs.NewServiceID("terminating-gateway", nil),
Service: structs.NewServiceID("redis", nil),
GatewayKind: "terminating-gateway",
CAFile: "/etc/certs/ca.pem",
CertFile: "/etc/certs/cert.pem",
@ -1608,20 +1612,22 @@ func TestInternal_GatewayServiceDump_Ingress(t *testing.T) {
Passing: 1,
Warning: 1,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
},
Checks: structs.HealthChecks{
{
Node: "bar",
CheckID: types.CheckID("db-warning"),
Name: "db-warning",
Status: "warning",
ServiceID: "db",
ServiceName: "db",
Node: "bar",
CheckID: types.CheckID("db-warning"),
Name: "db-warning",
Status: "warning",
ServiceID: "db",
ServiceName: "db",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
},
},
GatewayService: &structs.GatewayService{
Gateway: structs.ServiceID{ID: "ingress-gateway"},
Service: structs.ServiceID{ID: "db"},
Gateway: structs.NewServiceID("ingress-gateway", nil),
Service: structs.NewServiceID("db", nil),
GatewayKind: "ingress-gateway",
Port: 8888,
Protocol: "tcp",
@ -1640,20 +1646,22 @@ func TestInternal_GatewayServiceDump_Ingress(t *testing.T) {
Passing: 1,
Warning: 1,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
},
Checks: structs.HealthChecks{
{
Node: "baz",
CheckID: types.CheckID("db2-passing"),
Name: "db2-passing",
Status: "passing",
ServiceID: "db2",
ServiceName: "db",
Node: "baz",
CheckID: types.CheckID("db2-passing"),
Name: "db2-passing",
Status: "passing",
ServiceID: "db2",
ServiceName: "db",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
},
},
GatewayService: &structs.GatewayService{
Gateway: structs.ServiceID{ID: "ingress-gateway"},
Service: structs.ServiceID{ID: "db"},
Gateway: structs.NewServiceID("ingress-gateway", nil),
Service: structs.NewServiceID("db", nil),
GatewayKind: "ingress-gateway",
Port: 8888,
Protocol: "tcp",
@ -1662,8 +1670,8 @@ func TestInternal_GatewayServiceDump_Ingress(t *testing.T) {
{
// Only GatewayService should be returned when upstream isn't registered
GatewayService: &structs.GatewayService{
Gateway: structs.ServiceID{ID: "ingress-gateway"},
Service: structs.ServiceID{ID: "web"},
Gateway: structs.NewServiceID("ingress-gateway", nil),
Service: structs.NewServiceID("web", nil),
GatewayKind: "ingress-gateway",
Port: 8080,
Protocol: "tcp",

View File

@ -515,7 +515,8 @@ func TestUIGatewayServiceNodes_Terminating(t *testing.T) {
dump := obj.([]*ServiceSummary)
expect := []*ServiceSummary{
{
Name: "redis",
Name: "redis",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
},
{
Name: "db",
@ -525,6 +526,7 @@ func TestUIGatewayServiceNodes_Terminating(t *testing.T) {
ChecksPassing: 1,
ChecksWarning: 1,
ChecksCritical: 0,
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
},
}
assert.ElementsMatch(t, expect, dump)
@ -637,8 +639,9 @@ func TestUIGatewayServiceNodes_Ingress(t *testing.T) {
dump := obj.([]*ServiceSummary)
expect := []*ServiceSummary{
{
Name: "web",
GatewayConfig: GatewayConfig{ListenerPort: 8080},
Name: "web",
GatewayConfig: GatewayConfig{ListenerPort: 8080},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
},
{
Name: "db",
@ -649,6 +652,7 @@ func TestUIGatewayServiceNodes_Ingress(t *testing.T) {
ChecksWarning: 1,
ChecksCritical: 0,
GatewayConfig: GatewayConfig{ListenerPort: 8888},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
},
}
assert.ElementsMatch(t, expect, dump)