Fixup enterprise tests from tproxy changes
This commit is contained in:
parent
0b551a819f
commit
b56bd690aa
|
@ -998,6 +998,9 @@ func TestConfigEntry_ResolveServiceConfig_Upstreams(t *testing.T) {
|
||||||
}
|
}
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
|
mysql := structs.NewServiceID("mysql", structs.DefaultEnterpriseMeta())
|
||||||
|
cache := structs.NewServiceID("cache", structs.DefaultEnterpriseMeta())
|
||||||
|
|
||||||
tt := []struct {
|
tt := []struct {
|
||||||
name string
|
name string
|
||||||
entries []structs.ConfigEntry
|
entries []structs.ConfigEntry
|
||||||
|
@ -1017,10 +1020,10 @@ func TestConfigEntry_ResolveServiceConfig_Upstreams(t *testing.T) {
|
||||||
},
|
},
|
||||||
&structs.ServiceConfigEntry{
|
&structs.ServiceConfigEntry{
|
||||||
Kind: structs.ServiceDefaults,
|
Kind: structs.ServiceDefaults,
|
||||||
Name: "foo",
|
Name: "api",
|
||||||
Connect: &structs.ConnectConfiguration{
|
Connect: &structs.ConnectConfiguration{
|
||||||
UpstreamConfigs: map[string]*structs.UpstreamConfig{
|
UpstreamConfigs: map[string]*structs.UpstreamConfig{
|
||||||
"zip": {
|
mysql.String(): {
|
||||||
Protocol: "http",
|
Protocol: "http",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1028,19 +1031,19 @@ func TestConfigEntry_ResolveServiceConfig_Upstreams(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
request: structs.ServiceConfigRequest{
|
request: structs.ServiceConfigRequest{
|
||||||
Name: "foo",
|
Name: "api",
|
||||||
Datacenter: "dc1",
|
Datacenter: "dc1",
|
||||||
Upstreams: []string{"zap"},
|
Upstreams: []string{"cache"},
|
||||||
},
|
},
|
||||||
expect: structs.ServiceConfigResponse{
|
expect: structs.ServiceConfigResponse{
|
||||||
ProxyConfig: map[string]interface{}{
|
ProxyConfig: map[string]interface{}{
|
||||||
"protocol": "grpc",
|
"protocol": "grpc",
|
||||||
},
|
},
|
||||||
UpstreamConfigs: map[string]map[string]interface{}{
|
UpstreamConfigs: map[string]map[string]interface{}{
|
||||||
"zip": {
|
"mysql": {
|
||||||
"protocol": "http",
|
"protocol": "http",
|
||||||
},
|
},
|
||||||
"zap": {
|
"cache": {
|
||||||
"protocol": "grpc",
|
"protocol": "grpc",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1058,10 +1061,10 @@ func TestConfigEntry_ResolveServiceConfig_Upstreams(t *testing.T) {
|
||||||
},
|
},
|
||||||
&structs.ServiceConfigEntry{
|
&structs.ServiceConfigEntry{
|
||||||
Kind: structs.ServiceDefaults,
|
Kind: structs.ServiceDefaults,
|
||||||
Name: "foo",
|
Name: "api",
|
||||||
Connect: &structs.ConnectConfiguration{
|
Connect: &structs.ConnectConfiguration{
|
||||||
UpstreamConfigs: map[string]*structs.UpstreamConfig{
|
UpstreamConfigs: map[string]*structs.UpstreamConfig{
|
||||||
"zip": {
|
mysql.String(): {
|
||||||
Protocol: "http",
|
Protocol: "http",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1069,9 +1072,11 @@ func TestConfigEntry_ResolveServiceConfig_Upstreams(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
request: structs.ServiceConfigRequest{
|
request: structs.ServiceConfigRequest{
|
||||||
Name: "foo",
|
Name: "api",
|
||||||
Datacenter: "dc1",
|
Datacenter: "dc1",
|
||||||
UpstreamIDs: []structs.ServiceID{{ID: "zap"}},
|
UpstreamIDs: []structs.ServiceID{
|
||||||
|
cache,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
expect: structs.ServiceConfigResponse{
|
expect: structs.ServiceConfigResponse{
|
||||||
ProxyConfig: map[string]interface{}{
|
ProxyConfig: map[string]interface{}{
|
||||||
|
@ -1079,17 +1084,14 @@ func TestConfigEntry_ResolveServiceConfig_Upstreams(t *testing.T) {
|
||||||
},
|
},
|
||||||
UpstreamIDConfigs: structs.OpaqueUpstreamConfigs{
|
UpstreamIDConfigs: structs.OpaqueUpstreamConfigs{
|
||||||
{
|
{
|
||||||
Upstream: structs.ServiceID{
|
Upstream: cache,
|
||||||
ID: "zap",
|
|
||||||
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
|
|
||||||
},
|
|
||||||
Config: map[string]interface{}{
|
Config: map[string]interface{}{
|
||||||
"protocol": "grpc",
|
"protocol": "grpc",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Upstream: structs.ServiceID{
|
Upstream: structs.ServiceID{
|
||||||
ID: "zip",
|
ID: "mysql",
|
||||||
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
|
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
|
||||||
},
|
},
|
||||||
Config: map[string]interface{}{
|
Config: map[string]interface{}{
|
||||||
|
@ -1104,7 +1106,7 @@ func TestConfigEntry_ResolveServiceConfig_Upstreams(t *testing.T) {
|
||||||
entries: []structs.ConfigEntry{
|
entries: []structs.ConfigEntry{
|
||||||
&structs.ServiceConfigEntry{
|
&structs.ServiceConfigEntry{
|
||||||
Kind: structs.ServiceDefaults,
|
Kind: structs.ServiceDefaults,
|
||||||
Name: "foo",
|
Name: "api",
|
||||||
Connect: &structs.ConnectConfiguration{
|
Connect: &structs.ConnectConfiguration{
|
||||||
UpstreamDefaults: &structs.UpstreamConfig{
|
UpstreamDefaults: &structs.UpstreamConfig{
|
||||||
MeshGateway: structs.MeshGatewayConfig{Mode: structs.MeshGatewayModeRemote},
|
MeshGateway: structs.MeshGatewayConfig{Mode: structs.MeshGatewayModeRemote},
|
||||||
|
@ -1113,22 +1115,19 @@ func TestConfigEntry_ResolveServiceConfig_Upstreams(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
request: structs.ServiceConfigRequest{
|
request: structs.ServiceConfigRequest{
|
||||||
Name: "foo",
|
Name: "api",
|
||||||
Datacenter: "dc1",
|
Datacenter: "dc1",
|
||||||
MeshGateway: structs.MeshGatewayConfig{
|
MeshGateway: structs.MeshGatewayConfig{
|
||||||
Mode: structs.MeshGatewayModeNone,
|
Mode: structs.MeshGatewayModeNone,
|
||||||
},
|
},
|
||||||
UpstreamIDs: []structs.ServiceID{
|
UpstreamIDs: []structs.ServiceID{
|
||||||
{ID: "zap"},
|
mysql,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expect: structs.ServiceConfigResponse{
|
expect: structs.ServiceConfigResponse{
|
||||||
UpstreamIDConfigs: structs.OpaqueUpstreamConfigs{
|
UpstreamIDConfigs: structs.OpaqueUpstreamConfigs{
|
||||||
{
|
{
|
||||||
Upstream: structs.ServiceID{
|
Upstream: mysql,
|
||||||
ID: "zap",
|
|
||||||
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
|
|
||||||
},
|
|
||||||
Config: map[string]interface{}{
|
Config: map[string]interface{}{
|
||||||
"mesh_gateway": map[string]interface{}{
|
"mesh_gateway": map[string]interface{}{
|
||||||
"Mode": "none",
|
"Mode": "none",
|
||||||
|
@ -1150,12 +1149,12 @@ func TestConfigEntry_ResolveServiceConfig_Upstreams(t *testing.T) {
|
||||||
},
|
},
|
||||||
&structs.ServiceConfigEntry{
|
&structs.ServiceConfigEntry{
|
||||||
Kind: structs.ServiceDefaults,
|
Kind: structs.ServiceDefaults,
|
||||||
Name: "foo",
|
Name: "api",
|
||||||
Protocol: "tcp",
|
Protocol: "tcp",
|
||||||
},
|
},
|
||||||
&structs.ServiceConfigEntry{
|
&structs.ServiceConfigEntry{
|
||||||
Kind: structs.ServiceDefaults,
|
Kind: structs.ServiceDefaults,
|
||||||
Name: "foo",
|
Name: "api",
|
||||||
Connect: &structs.ConnectConfiguration{
|
Connect: &structs.ConnectConfiguration{
|
||||||
UpstreamDefaults: &structs.UpstreamConfig{
|
UpstreamDefaults: &structs.UpstreamConfig{
|
||||||
Protocol: "http",
|
Protocol: "http",
|
||||||
|
@ -1166,7 +1165,7 @@ func TestConfigEntry_ResolveServiceConfig_Upstreams(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UpstreamConfigs: map[string]*structs.UpstreamConfig{
|
UpstreamConfigs: map[string]*structs.UpstreamConfig{
|
||||||
"zap": {
|
mysql.String(): {
|
||||||
Protocol: "grpc",
|
Protocol: "grpc",
|
||||||
MeshGateway: structs.MeshGatewayConfig{Mode: structs.MeshGatewayModeLocal},
|
MeshGateway: structs.MeshGatewayConfig{Mode: structs.MeshGatewayModeLocal},
|
||||||
},
|
},
|
||||||
|
@ -1175,13 +1174,13 @@ func TestConfigEntry_ResolveServiceConfig_Upstreams(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
request: structs.ServiceConfigRequest{
|
request: structs.ServiceConfigRequest{
|
||||||
Name: "foo",
|
Name: "api",
|
||||||
Datacenter: "dc1",
|
Datacenter: "dc1",
|
||||||
MeshGateway: structs.MeshGatewayConfig{
|
MeshGateway: structs.MeshGatewayConfig{
|
||||||
Mode: structs.MeshGatewayModeNone,
|
Mode: structs.MeshGatewayModeNone,
|
||||||
},
|
},
|
||||||
UpstreamIDs: []structs.ServiceID{
|
UpstreamIDs: []structs.ServiceID{
|
||||||
{ID: "zap"},
|
mysql,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expect: structs.ServiceConfigResponse{
|
expect: structs.ServiceConfigResponse{
|
||||||
|
@ -1190,10 +1189,7 @@ func TestConfigEntry_ResolveServiceConfig_Upstreams(t *testing.T) {
|
||||||
},
|
},
|
||||||
UpstreamIDConfigs: structs.OpaqueUpstreamConfigs{
|
UpstreamIDConfigs: structs.OpaqueUpstreamConfigs{
|
||||||
{
|
{
|
||||||
Upstream: structs.ServiceID{
|
Upstream: mysql,
|
||||||
ID: "zap",
|
|
||||||
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
|
|
||||||
},
|
|
||||||
Config: map[string]interface{}{
|
Config: map[string]interface{}{
|
||||||
"passive_health_check": map[string]interface{}{
|
"passive_health_check": map[string]interface{}{
|
||||||
"Interval": int64(10),
|
"Interval": int64(10),
|
||||||
|
|
|
@ -1664,7 +1664,7 @@ func TestState_WatchesAndUpdates(t *testing.T) {
|
||||||
{
|
{
|
||||||
requiredWatches: map[string]verifyWatchRequest{
|
requiredWatches: map[string]verifyWatchRequest{
|
||||||
"discovery-chain:" + dbStr: genVerifyDiscoveryChainWatch(&structs.DiscoveryChainRequest{
|
"discovery-chain:" + dbStr: genVerifyDiscoveryChainWatch(&structs.DiscoveryChainRequest{
|
||||||
Name: dbStr,
|
Name: "db",
|
||||||
EvaluateInDatacenter: "dc1",
|
EvaluateInDatacenter: "dc1",
|
||||||
EvaluateInNamespace: "default",
|
EvaluateInNamespace: "default",
|
||||||
Datacenter: "dc1",
|
Datacenter: "dc1",
|
||||||
|
@ -1686,11 +1686,11 @@ func TestState_WatchesAndUpdates(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
requiredWatches: map[string]verifyWatchRequest{
|
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{
|
events: []cache.UpdateEvent{
|
||||||
{
|
{
|
||||||
CorrelationID: "upstream-target:db.default.dc1:db",
|
CorrelationID: "upstream-target:db.default.dc1:" + dbStr,
|
||||||
Result: &structs.IndexedCheckServiceNodes{
|
Result: &structs.IndexedCheckServiceNodes{
|
||||||
Nodes: structs.CheckServiceNodes{
|
Nodes: structs.CheckServiceNodes{
|
||||||
{
|
{
|
||||||
|
|
|
@ -112,8 +112,9 @@ func TestServiceManager_RegisterSidecar(t *testing.T) {
|
||||||
LocalServicePort: 8000,
|
LocalServicePort: 8000,
|
||||||
Upstreams: structs.Upstreams{
|
Upstreams: structs.Upstreams{
|
||||||
{
|
{
|
||||||
DestinationName: "redis",
|
DestinationName: "redis",
|
||||||
LocalBindPort: 5000,
|
DestinationNamespace: "default",
|
||||||
|
LocalBindPort: 5000,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -141,8 +142,9 @@ func TestServiceManager_RegisterSidecar(t *testing.T) {
|
||||||
},
|
},
|
||||||
Upstreams: structs.Upstreams{
|
Upstreams: structs.Upstreams{
|
||||||
{
|
{
|
||||||
DestinationName: "redis",
|
DestinationName: "redis",
|
||||||
LocalBindPort: 5000,
|
DestinationNamespace: "default",
|
||||||
|
LocalBindPort: 5000,
|
||||||
Config: map[string]interface{}{
|
Config: map[string]interface{}{
|
||||||
"protocol": "tcp",
|
"protocol": "tcp",
|
||||||
},
|
},
|
||||||
|
@ -341,8 +343,9 @@ func TestServiceManager_PersistService_API(t *testing.T) {
|
||||||
LocalServicePort: 8000,
|
LocalServicePort: 8000,
|
||||||
Upstreams: structs.Upstreams{
|
Upstreams: structs.Upstreams{
|
||||||
{
|
{
|
||||||
DestinationName: "redis",
|
DestinationName: "redis",
|
||||||
LocalBindPort: 5000,
|
DestinationNamespace: "default",
|
||||||
|
LocalBindPort: 5000,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -366,8 +369,9 @@ func TestServiceManager_PersistService_API(t *testing.T) {
|
||||||
},
|
},
|
||||||
Upstreams: structs.Upstreams{
|
Upstreams: structs.Upstreams{
|
||||||
{
|
{
|
||||||
DestinationName: "redis",
|
DestinationName: "redis",
|
||||||
LocalBindPort: 5000,
|
DestinationNamespace: "default",
|
||||||
|
LocalBindPort: 5000,
|
||||||
Config: map[string]interface{}{
|
Config: map[string]interface{}{
|
||||||
"protocol": "tcp",
|
"protocol": "tcp",
|
||||||
},
|
},
|
||||||
|
@ -550,6 +554,7 @@ func TestServiceManager_PersistService_ConfigFiles(t *testing.T) {
|
||||||
local_service_port = 8000
|
local_service_port = 8000
|
||||||
upstreams = [{
|
upstreams = [{
|
||||||
destination_name = "redis"
|
destination_name = "redis"
|
||||||
|
destination_namespace = "default"
|
||||||
local_bind_port = 5000
|
local_bind_port = 5000
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
|
@ -592,9 +597,10 @@ func TestServiceManager_PersistService_ConfigFiles(t *testing.T) {
|
||||||
},
|
},
|
||||||
Upstreams: structs.Upstreams{
|
Upstreams: structs.Upstreams{
|
||||||
{
|
{
|
||||||
DestinationType: "service",
|
DestinationType: "service",
|
||||||
DestinationName: "redis",
|
DestinationName: "redis",
|
||||||
LocalBindPort: 5000,
|
DestinationNamespace: "default",
|
||||||
|
LocalBindPort: 5000,
|
||||||
Config: map[string]interface{}{
|
Config: map[string]interface{}{
|
||||||
"protocol": "tcp",
|
"protocol": "tcp",
|
||||||
},
|
},
|
||||||
|
|
|
@ -1531,8 +1531,9 @@ func TestServiceConfigEntry_Normalize(t *testing.T) {
|
||||||
Name: "web",
|
Name: "web",
|
||||||
},
|
},
|
||||||
expect: ServiceConfigEntry{
|
expect: ServiceConfigEntry{
|
||||||
Kind: ServiceDefaults,
|
Kind: ServiceDefaults,
|
||||||
Name: "web",
|
Name: "web",
|
||||||
|
EnterpriseMeta: *DefaultEnterpriseMeta(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1543,9 +1544,10 @@ func TestServiceConfigEntry_Normalize(t *testing.T) {
|
||||||
Protocol: "PrOtoCoL",
|
Protocol: "PrOtoCoL",
|
||||||
},
|
},
|
||||||
expect: ServiceConfigEntry{
|
expect: ServiceConfigEntry{
|
||||||
Kind: ServiceDefaults,
|
Kind: ServiceDefaults,
|
||||||
Name: "web",
|
Name: "web",
|
||||||
Protocol: "protocol",
|
Protocol: "protocol",
|
||||||
|
EnterpriseMeta: *DefaultEnterpriseMeta(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1564,6 +1566,7 @@ func TestServiceConfigEntry_Normalize(t *testing.T) {
|
||||||
},
|
},
|
||||||
UpstreamDefaults: &UpstreamConfig{ConnectTimeoutMs: -20},
|
UpstreamDefaults: &UpstreamConfig{ConnectTimeoutMs: -20},
|
||||||
},
|
},
|
||||||
|
EnterpriseMeta: *DefaultEnterpriseMeta(),
|
||||||
},
|
},
|
||||||
expect: ServiceConfigEntry{
|
expect: ServiceConfigEntry{
|
||||||
Kind: ServiceDefaults,
|
Kind: ServiceDefaults,
|
||||||
|
@ -1582,6 +1585,7 @@ func TestServiceConfigEntry_Normalize(t *testing.T) {
|
||||||
ConnectTimeoutMs: 0,
|
ConnectTimeoutMs: 0,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
EnterpriseMeta: *DefaultEnterpriseMeta(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue