mirror of https://github.com/status-im/consul.git
Merge pull request #9900 from hashicorp/ent-fixes
Fixup enterprise tests from tproxy changes
This commit is contained in:
commit
1c13aa23f1
|
@ -998,6 +998,9 @@ func TestConfigEntry_ResolveServiceConfig_Upstreams(t *testing.T) {
|
|||
}
|
||||
t.Parallel()
|
||||
|
||||
mysql := structs.NewServiceID("mysql", structs.DefaultEnterpriseMeta())
|
||||
cache := structs.NewServiceID("cache", structs.DefaultEnterpriseMeta())
|
||||
|
||||
tt := []struct {
|
||||
name string
|
||||
entries []structs.ConfigEntry
|
||||
|
@ -1017,10 +1020,10 @@ func TestConfigEntry_ResolveServiceConfig_Upstreams(t *testing.T) {
|
|||
},
|
||||
&structs.ServiceConfigEntry{
|
||||
Kind: structs.ServiceDefaults,
|
||||
Name: "foo",
|
||||
Name: "api",
|
||||
Connect: &structs.ConnectConfiguration{
|
||||
UpstreamConfigs: map[string]*structs.UpstreamConfig{
|
||||
"zip": {
|
||||
mysql.String(): {
|
||||
Protocol: "http",
|
||||
},
|
||||
},
|
||||
|
@ -1028,19 +1031,19 @@ func TestConfigEntry_ResolveServiceConfig_Upstreams(t *testing.T) {
|
|||
},
|
||||
},
|
||||
request: structs.ServiceConfigRequest{
|
||||
Name: "foo",
|
||||
Name: "api",
|
||||
Datacenter: "dc1",
|
||||
Upstreams: []string{"zap"},
|
||||
Upstreams: []string{"cache"},
|
||||
},
|
||||
expect: structs.ServiceConfigResponse{
|
||||
ProxyConfig: map[string]interface{}{
|
||||
"protocol": "grpc",
|
||||
},
|
||||
UpstreamConfigs: map[string]map[string]interface{}{
|
||||
"zip": {
|
||||
"mysql": {
|
||||
"protocol": "http",
|
||||
},
|
||||
"zap": {
|
||||
"cache": {
|
||||
"protocol": "grpc",
|
||||
},
|
||||
},
|
||||
|
@ -1058,10 +1061,10 @@ func TestConfigEntry_ResolveServiceConfig_Upstreams(t *testing.T) {
|
|||
},
|
||||
&structs.ServiceConfigEntry{
|
||||
Kind: structs.ServiceDefaults,
|
||||
Name: "foo",
|
||||
Name: "api",
|
||||
Connect: &structs.ConnectConfiguration{
|
||||
UpstreamConfigs: map[string]*structs.UpstreamConfig{
|
||||
"zip": {
|
||||
mysql.String(): {
|
||||
Protocol: "http",
|
||||
},
|
||||
},
|
||||
|
@ -1069,9 +1072,11 @@ func TestConfigEntry_ResolveServiceConfig_Upstreams(t *testing.T) {
|
|||
},
|
||||
},
|
||||
request: structs.ServiceConfigRequest{
|
||||
Name: "foo",
|
||||
Name: "api",
|
||||
Datacenter: "dc1",
|
||||
UpstreamIDs: []structs.ServiceID{{ID: "zap"}},
|
||||
UpstreamIDs: []structs.ServiceID{
|
||||
cache,
|
||||
},
|
||||
},
|
||||
expect: structs.ServiceConfigResponse{
|
||||
ProxyConfig: map[string]interface{}{
|
||||
|
@ -1079,17 +1084,14 @@ func TestConfigEntry_ResolveServiceConfig_Upstreams(t *testing.T) {
|
|||
},
|
||||
UpstreamIDConfigs: structs.OpaqueUpstreamConfigs{
|
||||
{
|
||||
Upstream: structs.ServiceID{
|
||||
ID: "zap",
|
||||
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
|
||||
},
|
||||
Upstream: cache,
|
||||
Config: map[string]interface{}{
|
||||
"protocol": "grpc",
|
||||
},
|
||||
},
|
||||
{
|
||||
Upstream: structs.ServiceID{
|
||||
ID: "zip",
|
||||
ID: "mysql",
|
||||
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
|
||||
},
|
||||
Config: map[string]interface{}{
|
||||
|
@ -1104,7 +1106,7 @@ func TestConfigEntry_ResolveServiceConfig_Upstreams(t *testing.T) {
|
|||
entries: []structs.ConfigEntry{
|
||||
&structs.ServiceConfigEntry{
|
||||
Kind: structs.ServiceDefaults,
|
||||
Name: "foo",
|
||||
Name: "api",
|
||||
Connect: &structs.ConnectConfiguration{
|
||||
UpstreamDefaults: &structs.UpstreamConfig{
|
||||
MeshGateway: structs.MeshGatewayConfig{Mode: structs.MeshGatewayModeRemote},
|
||||
|
@ -1113,22 +1115,19 @@ func TestConfigEntry_ResolveServiceConfig_Upstreams(t *testing.T) {
|
|||
},
|
||||
},
|
||||
request: structs.ServiceConfigRequest{
|
||||
Name: "foo",
|
||||
Name: "api",
|
||||
Datacenter: "dc1",
|
||||
MeshGateway: structs.MeshGatewayConfig{
|
||||
Mode: structs.MeshGatewayModeNone,
|
||||
},
|
||||
UpstreamIDs: []structs.ServiceID{
|
||||
{ID: "zap"},
|
||||
mysql,
|
||||
},
|
||||
},
|
||||
expect: structs.ServiceConfigResponse{
|
||||
UpstreamIDConfigs: structs.OpaqueUpstreamConfigs{
|
||||
{
|
||||
Upstream: structs.ServiceID{
|
||||
ID: "zap",
|
||||
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
|
||||
},
|
||||
Upstream: mysql,
|
||||
Config: map[string]interface{}{
|
||||
"mesh_gateway": map[string]interface{}{
|
||||
"Mode": "none",
|
||||
|
@ -1150,12 +1149,12 @@ func TestConfigEntry_ResolveServiceConfig_Upstreams(t *testing.T) {
|
|||
},
|
||||
&structs.ServiceConfigEntry{
|
||||
Kind: structs.ServiceDefaults,
|
||||
Name: "foo",
|
||||
Name: "api",
|
||||
Protocol: "tcp",
|
||||
},
|
||||
&structs.ServiceConfigEntry{
|
||||
Kind: structs.ServiceDefaults,
|
||||
Name: "foo",
|
||||
Name: "api",
|
||||
Connect: &structs.ConnectConfiguration{
|
||||
UpstreamDefaults: &structs.UpstreamConfig{
|
||||
Protocol: "http",
|
||||
|
@ -1166,7 +1165,7 @@ func TestConfigEntry_ResolveServiceConfig_Upstreams(t *testing.T) {
|
|||
},
|
||||
},
|
||||
UpstreamConfigs: map[string]*structs.UpstreamConfig{
|
||||
"zap": {
|
||||
mysql.String(): {
|
||||
Protocol: "grpc",
|
||||
MeshGateway: structs.MeshGatewayConfig{Mode: structs.MeshGatewayModeLocal},
|
||||
},
|
||||
|
@ -1175,13 +1174,13 @@ func TestConfigEntry_ResolveServiceConfig_Upstreams(t *testing.T) {
|
|||
},
|
||||
},
|
||||
request: structs.ServiceConfigRequest{
|
||||
Name: "foo",
|
||||
Name: "api",
|
||||
Datacenter: "dc1",
|
||||
MeshGateway: structs.MeshGatewayConfig{
|
||||
Mode: structs.MeshGatewayModeNone,
|
||||
},
|
||||
UpstreamIDs: []structs.ServiceID{
|
||||
{ID: "zap"},
|
||||
mysql,
|
||||
},
|
||||
},
|
||||
expect: structs.ServiceConfigResponse{
|
||||
|
@ -1190,10 +1189,7 @@ func TestConfigEntry_ResolveServiceConfig_Upstreams(t *testing.T) {
|
|||
},
|
||||
UpstreamIDConfigs: structs.OpaqueUpstreamConfigs{
|
||||
{
|
||||
Upstream: structs.ServiceID{
|
||||
ID: "zap",
|
||||
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
|
||||
},
|
||||
Upstream: mysql,
|
||||
Config: map[string]interface{}{
|
||||
"passive_health_check": map[string]interface{}{
|
||||
"Interval": int64(10),
|
||||
|
|
|
@ -1664,7 +1664,7 @@ func TestState_WatchesAndUpdates(t *testing.T) {
|
|||
{
|
||||
requiredWatches: map[string]verifyWatchRequest{
|
||||
"discovery-chain:" + dbStr: genVerifyDiscoveryChainWatch(&structs.DiscoveryChainRequest{
|
||||
Name: dbStr,
|
||||
Name: "db",
|
||||
EvaluateInDatacenter: "dc1",
|
||||
EvaluateInNamespace: "default",
|
||||
Datacenter: "dc1",
|
||||
|
@ -1686,11 +1686,11 @@ func TestState_WatchesAndUpdates(t *testing.T) {
|
|||
},
|
||||
{
|
||||
requiredWatches: map[string]verifyWatchRequest{
|
||||
"upstream-target:db.default.dc1:db": genVerifyServiceWatch("db", "", "dc1", true),
|
||||
"upstream-target:db.default.dc1:" + dbStr: genVerifyServiceWatch("db", "", "dc1", true),
|
||||
},
|
||||
events: []cache.UpdateEvent{
|
||||
{
|
||||
CorrelationID: "upstream-target:db.default.dc1:db",
|
||||
CorrelationID: "upstream-target:db.default.dc1:" + dbStr,
|
||||
Result: &structs.IndexedCheckServiceNodes{
|
||||
Nodes: structs.CheckServiceNodes{
|
||||
{
|
||||
|
|
|
@ -113,6 +113,7 @@ func TestServiceManager_RegisterSidecar(t *testing.T) {
|
|||
Upstreams: structs.Upstreams{
|
||||
{
|
||||
DestinationName: "redis",
|
||||
DestinationNamespace: "default",
|
||||
LocalBindPort: 5000,
|
||||
},
|
||||
},
|
||||
|
@ -142,6 +143,7 @@ func TestServiceManager_RegisterSidecar(t *testing.T) {
|
|||
Upstreams: structs.Upstreams{
|
||||
{
|
||||
DestinationName: "redis",
|
||||
DestinationNamespace: "default",
|
||||
LocalBindPort: 5000,
|
||||
Config: map[string]interface{}{
|
||||
"protocol": "tcp",
|
||||
|
@ -342,6 +344,7 @@ func TestServiceManager_PersistService_API(t *testing.T) {
|
|||
Upstreams: structs.Upstreams{
|
||||
{
|
||||
DestinationName: "redis",
|
||||
DestinationNamespace: "default",
|
||||
LocalBindPort: 5000,
|
||||
},
|
||||
},
|
||||
|
@ -367,6 +370,7 @@ func TestServiceManager_PersistService_API(t *testing.T) {
|
|||
Upstreams: structs.Upstreams{
|
||||
{
|
||||
DestinationName: "redis",
|
||||
DestinationNamespace: "default",
|
||||
LocalBindPort: 5000,
|
||||
Config: map[string]interface{}{
|
||||
"protocol": "tcp",
|
||||
|
@ -550,6 +554,7 @@ func TestServiceManager_PersistService_ConfigFiles(t *testing.T) {
|
|||
local_service_port = 8000
|
||||
upstreams = [{
|
||||
destination_name = "redis"
|
||||
destination_namespace = "default"
|
||||
local_bind_port = 5000
|
||||
}]
|
||||
}
|
||||
|
@ -594,6 +599,7 @@ func TestServiceManager_PersistService_ConfigFiles(t *testing.T) {
|
|||
{
|
||||
DestinationType: "service",
|
||||
DestinationName: "redis",
|
||||
DestinationNamespace: "default",
|
||||
LocalBindPort: 5000,
|
||||
Config: map[string]interface{}{
|
||||
"protocol": "tcp",
|
||||
|
|
|
@ -1533,6 +1533,7 @@ func TestServiceConfigEntry_Normalize(t *testing.T) {
|
|||
expect: ServiceConfigEntry{
|
||||
Kind: ServiceDefaults,
|
||||
Name: "web",
|
||||
EnterpriseMeta: *DefaultEnterpriseMeta(),
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -1546,6 +1547,7 @@ func TestServiceConfigEntry_Normalize(t *testing.T) {
|
|||
Kind: ServiceDefaults,
|
||||
Name: "web",
|
||||
Protocol: "protocol",
|
||||
EnterpriseMeta: *DefaultEnterpriseMeta(),
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -1564,6 +1566,7 @@ func TestServiceConfigEntry_Normalize(t *testing.T) {
|
|||
},
|
||||
UpstreamDefaults: &UpstreamConfig{ConnectTimeoutMs: -20},
|
||||
},
|
||||
EnterpriseMeta: *DefaultEnterpriseMeta(),
|
||||
},
|
||||
expect: ServiceConfigEntry{
|
||||
Kind: ServiceDefaults,
|
||||
|
@ -1582,6 +1585,7 @@ func TestServiceConfigEntry_Normalize(t *testing.T) {
|
|||
ConnectTimeoutMs: 0,
|
||||
},
|
||||
},
|
||||
EnterpriseMeta: *DefaultEnterpriseMeta(),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue