Merge pull request #9900 from hashicorp/ent-fixes

Fixup enterprise tests from tproxy changes
This commit is contained in:
Freddy 2021-03-18 08:33:30 -06:00 committed by GitHub
commit 1c13aa23f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 57 additions and 51 deletions

View File

@ -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",
Datacenter: "dc1",
UpstreamIDs: []structs.ServiceID{{ID: "zap"}},
Name: "api",
Datacenter: "dc1",
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),

View File

@ -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{
{

View File

@ -112,8 +112,9 @@ func TestServiceManager_RegisterSidecar(t *testing.T) {
LocalServicePort: 8000,
Upstreams: structs.Upstreams{
{
DestinationName: "redis",
LocalBindPort: 5000,
DestinationName: "redis",
DestinationNamespace: "default",
LocalBindPort: 5000,
},
},
},
@ -141,8 +142,9 @@ func TestServiceManager_RegisterSidecar(t *testing.T) {
},
Upstreams: structs.Upstreams{
{
DestinationName: "redis",
LocalBindPort: 5000,
DestinationName: "redis",
DestinationNamespace: "default",
LocalBindPort: 5000,
Config: map[string]interface{}{
"protocol": "tcp",
},
@ -341,8 +343,9 @@ func TestServiceManager_PersistService_API(t *testing.T) {
LocalServicePort: 8000,
Upstreams: structs.Upstreams{
{
DestinationName: "redis",
LocalBindPort: 5000,
DestinationName: "redis",
DestinationNamespace: "default",
LocalBindPort: 5000,
},
},
},
@ -366,8 +369,9 @@ func TestServiceManager_PersistService_API(t *testing.T) {
},
Upstreams: structs.Upstreams{
{
DestinationName: "redis",
LocalBindPort: 5000,
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
}]
}
@ -592,9 +597,10 @@ func TestServiceManager_PersistService_ConfigFiles(t *testing.T) {
},
Upstreams: structs.Upstreams{
{
DestinationType: "service",
DestinationName: "redis",
LocalBindPort: 5000,
DestinationType: "service",
DestinationName: "redis",
DestinationNamespace: "default",
LocalBindPort: 5000,
Config: map[string]interface{}{
"protocol": "tcp",
},

View File

@ -1531,8 +1531,9 @@ func TestServiceConfigEntry_Normalize(t *testing.T) {
Name: "web",
},
expect: ServiceConfigEntry{
Kind: ServiceDefaults,
Name: "web",
Kind: ServiceDefaults,
Name: "web",
EnterpriseMeta: *DefaultEnterpriseMeta(),
},
},
{
@ -1543,9 +1544,10 @@ func TestServiceConfigEntry_Normalize(t *testing.T) {
Protocol: "PrOtoCoL",
},
expect: ServiceConfigEntry{
Kind: ServiceDefaults,
Name: "web",
Protocol: "protocol",
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(),
},
},
}