From 073b6c8411848a511779331877028fad1dfade3e Mon Sep 17 00:00:00 2001 From: Kyle Havlovitz Date: Thu, 12 Aug 2021 14:31:37 -0700 Subject: [PATCH] oss: Rename default partition --- agent/structs/config_entry_intentions_test.go | 76 +++++++++++-------- agent/structs/structs_oss.go | 4 +- api/catalog_test.go | 16 ++-- api/health_test.go | 1 + api/oss_test.go | 1 + api/txn_test.go | 5 +- .../connect/envoy/case-basic/verify.bats | 2 +- .../connect/envoy/case-http/verify.bats | 4 +- 8 files changed, 62 insertions(+), 47 deletions(-) diff --git a/agent/structs/config_entry_intentions_test.go b/agent/structs/config_entry_intentions_test.go index 68e54dcb80..9802f7df51 100644 --- a/agent/structs/config_entry_intentions_test.go +++ b/agent/structs/config_entry_intentions_test.go @@ -1296,6 +1296,7 @@ func TestMigrateIntentions(t *testing.T) { } anyTime := time.Now().UTC() + entMeta := NodeEnterpriseMetaInDefaultPartition() cases := map[string]testcase{ "nil": {}, @@ -1318,15 +1319,17 @@ func TestMigrateIntentions(t *testing.T) { }, expect: []*ServiceIntentionsConfigEntry{ { - Kind: ServiceIntentions, - Name: "bar", + Kind: ServiceIntentions, + Name: "bar", + EnterpriseMeta: *entMeta, Sources: []*SourceIntention{ { - LegacyID: legacyIDs[0], - Description: "desc", - Name: "foo", - Type: IntentionSourceConsul, - Action: IntentionActionAllow, + LegacyID: legacyIDs[0], + Description: "desc", + Name: "foo", + EnterpriseMeta: *entMeta, + Type: IntentionSourceConsul, + Action: IntentionActionAllow, LegacyMeta: map[string]string{ "key1": "val1", }, @@ -1370,15 +1373,17 @@ func TestMigrateIntentions(t *testing.T) { }, expect: []*ServiceIntentionsConfigEntry{ { - Kind: ServiceIntentions, - Name: "bar", + Kind: ServiceIntentions, + Name: "bar", + EnterpriseMeta: *entMeta, Sources: []*SourceIntention{ { - LegacyID: legacyIDs[0], - Description: "desc", - Name: "foo", - Type: IntentionSourceConsul, - Action: IntentionActionAllow, + LegacyID: legacyIDs[0], + Description: "desc", + Name: "foo", + EnterpriseMeta: *entMeta, + Type: IntentionSourceConsul, + Action: IntentionActionAllow, LegacyMeta: map[string]string{ "key1": "val1", }, @@ -1386,11 +1391,12 @@ func TestMigrateIntentions(t *testing.T) { LegacyUpdateTime: &anyTime, }, { - LegacyID: legacyIDs[1], - Description: "desc2", - Name: "*", - Type: IntentionSourceConsul, - Action: IntentionActionDeny, + LegacyID: legacyIDs[1], + Description: "desc2", + Name: "*", + EnterpriseMeta: *entMeta, + Type: IntentionSourceConsul, + Action: IntentionActionDeny, LegacyMeta: map[string]string{ "key2": "val2", }, @@ -1434,15 +1440,17 @@ func TestMigrateIntentions(t *testing.T) { }, expect: []*ServiceIntentionsConfigEntry{ { - Kind: ServiceIntentions, - Name: "bar", + Kind: ServiceIntentions, + Name: "bar", + EnterpriseMeta: *entMeta, Sources: []*SourceIntention{ { - LegacyID: legacyIDs[0], - Description: "desc", - Name: "foo", - Type: IntentionSourceConsul, - Action: IntentionActionAllow, + LegacyID: legacyIDs[0], + Description: "desc", + Name: "foo", + EnterpriseMeta: *entMeta, + Type: IntentionSourceConsul, + Action: IntentionActionAllow, LegacyMeta: map[string]string{ "key1": "val1", }, @@ -1452,15 +1460,17 @@ func TestMigrateIntentions(t *testing.T) { }, }, { - Kind: ServiceIntentions, - Name: "bar2", + Kind: ServiceIntentions, + Name: "bar2", + EnterpriseMeta: *entMeta, Sources: []*SourceIntention{ { - LegacyID: legacyIDs[1], - Description: "desc2", - Name: "*", - Type: IntentionSourceConsul, - Action: IntentionActionDeny, + LegacyID: legacyIDs[1], + Description: "desc2", + Name: "*", + EnterpriseMeta: *entMeta, + Type: IntentionSourceConsul, + Action: IntentionActionDeny, LegacyMeta: map[string]string{ "key2": "val2", }, diff --git a/agent/structs/structs_oss.go b/agent/structs/structs_oss.go index 79cf7cfe39..378a642aec 100644 --- a/agent/structs/structs_oss.go +++ b/agent/structs/structs_oss.go @@ -80,11 +80,11 @@ func (m *EnterpriseMeta) NamespaceOrEmpty() string { } func (m *EnterpriseMeta) PartitionOrDefault() string { - return "" + return "default" } func PartitionOrDefault(_ string) string { - return "" + return "default" } func (m *EnterpriseMeta) PartitionOrEmpty() string { diff --git a/api/catalog_test.go b/api/catalog_test.go index 39c6df1e57..2645ae5a05 100644 --- a/api/catalog_test.go +++ b/api/catalog_test.go @@ -1153,8 +1153,8 @@ func TestAPI_CatalogGatewayServices_Terminating(t *testing.T) { expect := []*GatewayService{ { - Service: CompoundServiceName{Name: "api", Namespace: defaultNamespace}, - Gateway: CompoundServiceName{Name: "terminating", Namespace: defaultNamespace}, + Service: CompoundServiceName{Name: "api", Namespace: defaultNamespace, Partition: defaultPartition}, + Gateway: CompoundServiceName{Name: "terminating", Namespace: defaultNamespace, Partition: defaultPartition}, GatewayKind: ServiceKindTerminatingGateway, CAFile: "api/ca.crt", CertFile: "api/client.crt", @@ -1162,8 +1162,8 @@ func TestAPI_CatalogGatewayServices_Terminating(t *testing.T) { SNI: "my-domain", }, { - Service: CompoundServiceName{Name: "redis", Namespace: defaultNamespace}, - Gateway: CompoundServiceName{Name: "terminating", Namespace: defaultNamespace}, + Service: CompoundServiceName{Name: "redis", Namespace: defaultNamespace, Partition: defaultPartition}, + Gateway: CompoundServiceName{Name: "terminating", Namespace: defaultNamespace, Partition: defaultPartition}, GatewayKind: ServiceKindTerminatingGateway, CAFile: "ca.crt", CertFile: "client.crt", @@ -1221,15 +1221,15 @@ func TestAPI_CatalogGatewayServices_Ingress(t *testing.T) { expect := []*GatewayService{ { - Service: CompoundServiceName{Name: "api", Namespace: defaultNamespace}, - Gateway: CompoundServiceName{Name: "ingress", Namespace: defaultNamespace}, + Service: CompoundServiceName{Name: "api", Namespace: defaultNamespace, Partition: defaultPartition}, + Gateway: CompoundServiceName{Name: "ingress", Namespace: defaultNamespace, Partition: defaultPartition}, GatewayKind: ServiceKindIngressGateway, Protocol: "tcp", Port: 8888, }, { - Service: CompoundServiceName{Name: "redis", Namespace: defaultNamespace}, - Gateway: CompoundServiceName{Name: "ingress", Namespace: defaultNamespace}, + Service: CompoundServiceName{Name: "redis", Namespace: defaultNamespace, Partition: defaultPartition}, + Gateway: CompoundServiceName{Name: "ingress", Namespace: defaultNamespace, Partition: defaultPartition}, GatewayKind: ServiceKindIngressGateway, Protocol: "tcp", Port: 9999, diff --git a/api/health_test.go b/api/health_test.go index 356105c65d..b69e9275fd 100644 --- a/api/health_test.go +++ b/api/health_test.go @@ -223,6 +223,7 @@ func TestAPI_HealthChecks(t *testing.T) { ServiceName: "foo", ServiceTags: []string{"bar"}, Type: "ttl", + Partition: defaultPartition, Namespace: defaultNamespace, }, } diff --git a/api/oss_test.go b/api/oss_test.go index 1d57914f5d..f1e25d9f94 100644 --- a/api/oss_test.go +++ b/api/oss_test.go @@ -3,3 +3,4 @@ package api var defaultNamespace = "" +var defaultPartition = "" diff --git a/api/txn_test.go b/api/txn_test.go index e5dac60bad..cf49fb7d08 100644 --- a/api/txn_test.go +++ b/api/txn_test.go @@ -181,6 +181,7 @@ func TestAPI_ClientTxn(t *testing.T) { ID: "foo1", CreateIndex: ret.Results[3].Service.CreateIndex, ModifyIndex: ret.Results[3].Service.CreateIndex, + Partition: defaultPartition, Namespace: defaultNamespace, }, }, @@ -199,6 +200,7 @@ func TestAPI_ClientTxn(t *testing.T) { DeregisterCriticalServiceAfterDuration: 20 * time.Second, }, Type: "tcp", + Partition: defaultPartition, Namespace: defaultNamespace, CreateIndex: ret.Results[4].Check.CreateIndex, ModifyIndex: ret.Results[4].Check.CreateIndex, @@ -219,13 +221,14 @@ func TestAPI_ClientTxn(t *testing.T) { DeregisterCriticalServiceAfterDuration: 160 * time.Second, }, Type: "tcp", + Partition: defaultPartition, Namespace: defaultNamespace, CreateIndex: ret.Results[4].Check.CreateIndex, ModifyIndex: ret.Results[4].Check.CreateIndex, }, }, } - require.Equal(t, ret.Results, expected) + require.Equal(t, expected, ret.Results) retry.Run(t, func(r *retry.R) { // Run a read-only transaction. diff --git a/test/integration/connect/envoy/case-basic/verify.bats b/test/integration/connect/envoy/case-basic/verify.bats index 47787f5560..65e70523d3 100644 --- a/test/integration/connect/envoy/case-basic/verify.bats +++ b/test/integration/connect/envoy/case-basic/verify.bats @@ -39,7 +39,7 @@ load helpers @test "s1 proxy should have been configured with one rbac listener filter at L4" { LISTEN_FILTERS=$(get_envoy_listener_filters localhost:19000) PUB=$(echo "$LISTEN_FILTERS" | grep -E "^public_listener:" | cut -f 2 -d ' ' ) - UPS=$(echo "$LISTEN_FILTERS" | grep -E "^(\/default\/)?s2:" | cut -f 2 -d ' ' ) + UPS=$(echo "$LISTEN_FILTERS" | grep -E "^(default\/default\/)?s2:" | cut -f 2 -d ' ' ) echo "LISTEN_FILTERS = $LISTEN_FILTERS" echo "PUB = $PUB" diff --git a/test/integration/connect/envoy/case-http/verify.bats b/test/integration/connect/envoy/case-http/verify.bats index ce20b268af..0f65d46d30 100644 --- a/test/integration/connect/envoy/case-http/verify.bats +++ b/test/integration/connect/envoy/case-http/verify.bats @@ -36,7 +36,7 @@ load helpers @test "s1 proxy should have been configured with http connection managers" { LISTEN_FILTERS=$(get_envoy_listener_filters localhost:19000) PUB=$(echo "$LISTEN_FILTERS" | grep -E "^public_listener:" | cut -f 2 -d ' ' ) - UPS=$(echo "$LISTEN_FILTERS" | grep -E "^(\/default\/)?s2:" | cut -f 2 -d ' ' ) + UPS=$(echo "$LISTEN_FILTERS" | grep -E "^(default\/default\/)?s2:" | cut -f 2 -d ' ' ) echo "LISTEN_FILTERS = $LISTEN_FILTERS" echo "PUB = $PUB" @@ -59,7 +59,7 @@ load helpers @test "s1 proxy should have been configured with http rbac filters" { HTTP_FILTERS=$(get_envoy_http_filters localhost:19000) PUB=$(echo "$HTTP_FILTERS" | grep -E "^public_listener:" | cut -f 2 -d ' ' ) - UPS=$(echo "$HTTP_FILTERS" | grep -E "^(\/default\/)?s2:" | cut -f 2 -d ' ' ) + UPS=$(echo "$HTTP_FILTERS" | grep -E "^(default\/default\/)?s2:" | cut -f 2 -d ' ' ) echo "HTTP_FILTERS = $HTTP_FILTERS" echo "PUB = $PUB"