From b9b6447977c9cbf70edebdd68553cc609111fe10 Mon Sep 17 00:00:00 2001 From: freddygv Date: Fri, 22 Oct 2021 17:15:05 -0600 Subject: [PATCH] Finish removing useInDatacenter --- agent/cache-types/discovery_chain_test.go | 2 +- agent/consul/discoverychain/testing.go | 1 - agent/proxycfg/manager_test.go | 4 ++-- agent/proxycfg/state_test.go | 18 +++++++++--------- agent/proxycfg/testing.go | 8 ++++---- agent/xds/clusters_test.go | 2 +- agent/xds/listeners_test.go | 12 ++++++------ agent/xds/routes_test.go | 12 ++++++------ 8 files changed, 29 insertions(+), 30 deletions(-) diff --git a/agent/cache-types/discovery_chain_test.go b/agent/cache-types/discovery_chain_test.go index 057661e7f5..4242d4d4ac 100644 --- a/agent/cache-types/discovery_chain_test.go +++ b/agent/cache-types/discovery_chain_test.go @@ -16,7 +16,7 @@ func TestCompiledDiscoveryChain(t *testing.T) { typ := &CompiledDiscoveryChain{RPC: rpc} // just do the default chain - chain := discoverychain.TestCompileConfigEntries(t, "web", "default", "default", "dc1", "trustdomain.consul", "dc1", nil) + chain := discoverychain.TestCompileConfigEntries(t, "web", "default", "default", "dc1", "trustdomain.consul", nil) // Expect the proper RPC call. This also sets the expected value // since that is return-by-pointer in the arguments. diff --git a/agent/consul/discoverychain/testing.go b/agent/consul/discoverychain/testing.go index c3ab7ba7c4..427c38b5ee 100644 --- a/agent/consul/discoverychain/testing.go +++ b/agent/consul/discoverychain/testing.go @@ -12,7 +12,6 @@ func TestCompileConfigEntries(t testing.T, evaluateInPartition string, evaluateInDatacenter string, evaluateInTrustDomain string, - _ string, setup func(req *CompileRequest), entries ...structs.ConfigEntry) *structs.CompiledDiscoveryChain { set := structs.NewDiscoveryChainConfigEntries() diff --git a/agent/proxycfg/manager_test.go b/agent/proxycfg/manager_test.go index 7ffef78f88..0198289364 100644 --- a/agent/proxycfg/manager_test.go +++ b/agent/proxycfg/manager_test.go @@ -59,7 +59,7 @@ func TestManager_BasicLifecycle(t *testing.T) { roots, leaf := TestCerts(t) dbDefaultChain := func() *structs.CompiledDiscoveryChain { - return discoverychain.TestCompileConfigEntries(t, "db", "default", "default", "dc1", connect.TestClusterID+".consul", "dc1", func(req *discoverychain.CompileRequest) { + return discoverychain.TestCompileConfigEntries(t, "db", "default", "default", "dc1", connect.TestClusterID+".consul", func(req *discoverychain.CompileRequest) { // This is because structs.TestUpstreams uses an opaque config // to override connect timeouts. req.OverrideConnectTimeout = 1 * time.Second @@ -69,7 +69,7 @@ func TestManager_BasicLifecycle(t *testing.T) { }) } dbSplitChain := func() *structs.CompiledDiscoveryChain { - return discoverychain.TestCompileConfigEntries(t, "db", "default", "default", "dc1", "trustdomain.consul", "dc1", func(req *discoverychain.CompileRequest) { + return discoverychain.TestCompileConfigEntries(t, "db", "default", "default", "dc1", "trustdomain.consul", func(req *discoverychain.CompileRequest) { // This is because structs.TestUpstreams uses an opaque config // to override connect timeouts. req.OverrideConnectTimeout = 1 * time.Second diff --git a/agent/proxycfg/state_test.go b/agent/proxycfg/state_test.go index 81671ef3a0..896f3ac225 100644 --- a/agent/proxycfg/state_test.go +++ b/agent/proxycfg/state_test.go @@ -568,7 +568,7 @@ func TestState_WatchesAndUpdates(t *testing.T) { { CorrelationID: "discovery-chain:api", Result: &structs.DiscoveryChainResponse{ - Chain: discoverychain.TestCompileConfigEntries(t, "api", "default", "default", "dc1", "trustdomain.consul", "dc1", + Chain: discoverychain.TestCompileConfigEntries(t, "api", "default", "default", "dc1", "trustdomain.consul", func(req *discoverychain.CompileRequest) { req.OverrideMeshGateway.Mode = meshGatewayProxyConfigValue }), @@ -578,7 +578,7 @@ func TestState_WatchesAndUpdates(t *testing.T) { { CorrelationID: "discovery-chain:api-failover-remote?dc=dc2", Result: &structs.DiscoveryChainResponse{ - Chain: discoverychain.TestCompileConfigEntries(t, "api-failover-remote", "default", "default", "dc2", "trustdomain.consul", "dc1", + Chain: discoverychain.TestCompileConfigEntries(t, "api-failover-remote", "default", "default", "dc2", "trustdomain.consul", func(req *discoverychain.CompileRequest) { req.OverrideMeshGateway.Mode = structs.MeshGatewayModeRemote }), @@ -588,7 +588,7 @@ func TestState_WatchesAndUpdates(t *testing.T) { { CorrelationID: "discovery-chain:api-failover-local?dc=dc2", Result: &structs.DiscoveryChainResponse{ - Chain: discoverychain.TestCompileConfigEntries(t, "api-failover-local", "default", "default", "dc2", "trustdomain.consul", "dc1", + Chain: discoverychain.TestCompileConfigEntries(t, "api-failover-local", "default", "default", "dc2", "trustdomain.consul", func(req *discoverychain.CompileRequest) { req.OverrideMeshGateway.Mode = structs.MeshGatewayModeLocal }), @@ -598,7 +598,7 @@ func TestState_WatchesAndUpdates(t *testing.T) { { CorrelationID: "discovery-chain:api-failover-direct?dc=dc2", Result: &structs.DiscoveryChainResponse{ - Chain: discoverychain.TestCompileConfigEntries(t, "api-failover-direct", "default", "default", "dc2", "trustdomain.consul", "dc1", + Chain: discoverychain.TestCompileConfigEntries(t, "api-failover-direct", "default", "default", "dc2", "trustdomain.consul", func(req *discoverychain.CompileRequest) { req.OverrideMeshGateway.Mode = structs.MeshGatewayModeNone }), @@ -608,7 +608,7 @@ func TestState_WatchesAndUpdates(t *testing.T) { { CorrelationID: "discovery-chain:api-dc2", Result: &structs.DiscoveryChainResponse{ - Chain: discoverychain.TestCompileConfigEntries(t, "api-dc2", "default", "default", "dc1", "trustdomain.consul", "dc1", + Chain: discoverychain.TestCompileConfigEntries(t, "api-dc2", "default", "default", "dc1", "trustdomain.consul", func(req *discoverychain.CompileRequest) { req.OverrideMeshGateway.Mode = meshGatewayProxyConfigValue }, &structs.ServiceResolverConfigEntry{ @@ -1032,7 +1032,7 @@ func TestState_WatchesAndUpdates(t *testing.T) { { CorrelationID: "discovery-chain:" + api.String(), Result: &structs.DiscoveryChainResponse{ - Chain: discoverychain.TestCompileConfigEntries(t, "api", "default", "default", "dc1", "trustdomain.consul", "dc1", nil), + Chain: discoverychain.TestCompileConfigEntries(t, "api", "default", "default", "dc1", "trustdomain.consul", nil), }, Err: nil, }, @@ -1863,7 +1863,7 @@ func TestState_WatchesAndUpdates(t *testing.T) { { CorrelationID: "discovery-chain:" + db.String(), Result: &structs.DiscoveryChainResponse{ - Chain: discoverychain.TestCompileConfigEntries(t, "db", "default", "default", "dc1", "trustdomain.consul", "dc1", nil), + Chain: discoverychain.TestCompileConfigEntries(t, "db", "default", "default", "dc1", "trustdomain.consul", nil), }, Err: nil, }, @@ -2012,7 +2012,7 @@ func TestState_WatchesAndUpdates(t *testing.T) { { CorrelationID: "discovery-chain:" + db.String(), Result: &structs.DiscoveryChainResponse{ - Chain: discoverychain.TestCompileConfigEntries(t, "db", "default", "default", "dc1", "trustdomain.consul", "dc1", nil, &structs.ServiceResolverConfigEntry{ + Chain: discoverychain.TestCompileConfigEntries(t, "db", "default", "default", "dc1", "trustdomain.consul", nil, &structs.ServiceResolverConfigEntry{ Kind: structs.ServiceResolver, Name: "db", Redirect: &structs.ServiceResolverRedirect{ @@ -2180,7 +2180,7 @@ func TestState_WatchesAndUpdates(t *testing.T) { { CorrelationID: "discovery-chain:" + upstreamIDForDC2(db.String()), Result: &structs.DiscoveryChainResponse{ - Chain: discoverychain.TestCompileConfigEntries(t, "db", "default", "default", "dc2", "trustdomain.consul", "dc1", + Chain: discoverychain.TestCompileConfigEntries(t, "db", "default", "default", "dc2", "trustdomain.consul", func(req *discoverychain.CompileRequest) { req.OverrideMeshGateway.Mode = structs.MeshGatewayModeLocal }), diff --git a/agent/proxycfg/testing.go b/agent/proxycfg/testing.go index 3fcf4c2685..94275419ab 100644 --- a/agent/proxycfg/testing.go +++ b/agent/proxycfg/testing.go @@ -669,7 +669,7 @@ func TestConfigSnapshot(t testing.T) *ConfigSnapshot { roots, leaf := TestCerts(t) // no entries implies we'll get a default chain - dbChain := discoverychain.TestCompileConfigEntries(t, "db", "default", "default", "dc1", connect.TestClusterID+".consul", "dc1", nil) + dbChain := discoverychain.TestCompileConfigEntries(t, "db", "default", "default", "dc1", connect.TestClusterID+".consul", nil) upstreams := structs.TestUpstreams(t) @@ -1396,7 +1396,7 @@ func setupTestVariationConfigEntriesAndSnapshot( entries = append(entries, additionalEntries...) } - dbChain := discoverychain.TestCompileConfigEntries(t, "db", "default", "default", "dc1", connect.TestClusterID+".consul", "dc1", compileSetup, entries...) + dbChain := discoverychain.TestCompileConfigEntries(t, "db", "default", "default", "dc1", connect.TestClusterID+".consul", compileSetup, entries...) upstreams := structs.TestUpstreams(t) snap := ConfigSnapshotUpstreams{ @@ -2085,8 +2085,8 @@ func TestConfigSnapshotIngress_MultipleListenersDuplicateService(t testing.T) *C }, } - fooChain := discoverychain.TestCompileConfigEntries(t, "foo", "default", "default", "dc1", connect.TestClusterID+".consul", "dc1", nil) - barChain := discoverychain.TestCompileConfigEntries(t, "bar", "default", "default", "dc1", connect.TestClusterID+".consul", "dc1", nil) + fooChain := discoverychain.TestCompileConfigEntries(t, "foo", "default", "default", "dc1", connect.TestClusterID+".consul", nil) + barChain := discoverychain.TestCompileConfigEntries(t, "bar", "default", "default", "dc1", connect.TestClusterID+".consul", nil) snap.IngressGateway.DiscoveryChain = map[string]*structs.CompiledDiscoveryChain{ "foo": fooChain, diff --git a/agent/xds/clusters_test.go b/agent/xds/clusters_test.go index 5d06c5ed6f..e9c3cc6825 100644 --- a/agent/xds/clusters_test.go +++ b/agent/xds/clusters_test.go @@ -697,7 +697,7 @@ func TestClustersFromSnapshot(t *testing.T) { } // There should still be a cluster for non-passthrough requests - snap.ConnectProxy.DiscoveryChain["mongo"] = discoverychain.TestCompileConfigEntries(t, "mongo", "default", "default", "dc1", connect.TestClusterID+".consul", "dc1", nil) + snap.ConnectProxy.DiscoveryChain["mongo"] = discoverychain.TestCompileConfigEntries(t, "mongo", "default", "default", "dc1", connect.TestClusterID+".consul", nil) snap.ConnectProxy.WatchedUpstreamEndpoints["mongo"] = map[string]structs.CheckServiceNodes{ "mongo.default.dc1": { structs.CheckServiceNode{ diff --git a/agent/xds/listeners_test.go b/agent/xds/listeners_test.go index dfbf12acb3..f2fc11c163 100644 --- a/agent/xds/listeners_test.go +++ b/agent/xds/listeners_test.go @@ -810,7 +810,7 @@ func TestListenersFromSnapshot(t *testing.T) { snap.ConnectProxy.MeshConfigSet = true // DiscoveryChain without an UpstreamConfig should yield a filter chain when in transparent proxy mode - snap.ConnectProxy.DiscoveryChain["google"] = discoverychain.TestCompileConfigEntries(t, "google", "default", "default", "dc1", connect.TestClusterID+".consul", "dc1", nil) + snap.ConnectProxy.DiscoveryChain["google"] = discoverychain.TestCompileConfigEntries(t, "google", "default", "default", "dc1", connect.TestClusterID+".consul", nil) snap.ConnectProxy.WatchedUpstreamEndpoints["google"] = map[string]structs.CheckServiceNodes{ "google.default.default.dc1": { structs.CheckServiceNode{ @@ -847,7 +847,7 @@ func TestListenersFromSnapshot(t *testing.T) { } // DiscoveryChains without endpoints do not get a filter chain because there are no addresses to match on. - snap.ConnectProxy.DiscoveryChain["no-endpoints"] = discoverychain.TestCompileConfigEntries(t, "no-endpoints", "default", "default", "dc1", connect.TestClusterID+".consul", "dc1", nil) + snap.ConnectProxy.DiscoveryChain["no-endpoints"] = discoverychain.TestCompileConfigEntries(t, "no-endpoints", "default", "default", "dc1", connect.TestClusterID+".consul", nil) }, }, { @@ -864,7 +864,7 @@ func TestListenersFromSnapshot(t *testing.T) { } // DiscoveryChain without an UpstreamConfig should yield a filter chain when in transparent proxy mode - snap.ConnectProxy.DiscoveryChain["google"] = discoverychain.TestCompileConfigEntries(t, "google", "default", "default", "dc1", connect.TestClusterID+".consul", "dc1", nil) + snap.ConnectProxy.DiscoveryChain["google"] = discoverychain.TestCompileConfigEntries(t, "google", "default", "default", "dc1", connect.TestClusterID+".consul", nil) snap.ConnectProxy.WatchedUpstreamEndpoints["google"] = map[string]structs.CheckServiceNodes{ "google.default.default.dc1": { structs.CheckServiceNode{ @@ -885,7 +885,7 @@ func TestListenersFromSnapshot(t *testing.T) { } // DiscoveryChains without endpoints do not get a filter chain because there are no addresses to match on. - snap.ConnectProxy.DiscoveryChain["no-endpoints"] = discoverychain.TestCompileConfigEntries(t, "no-endpoints", "default", "default", "dc1", connect.TestClusterID+".consul", "dc1", nil) + snap.ConnectProxy.DiscoveryChain["no-endpoints"] = discoverychain.TestCompileConfigEntries(t, "no-endpoints", "default", "default", "dc1", connect.TestClusterID+".consul", nil) }, }, { @@ -894,9 +894,9 @@ func TestListenersFromSnapshot(t *testing.T) { setup: func(snap *proxycfg.ConfigSnapshot) { snap.Proxy.Mode = structs.ProxyModeTransparent - snap.ConnectProxy.DiscoveryChain["mongo"] = discoverychain.TestCompileConfigEntries(t, "mongo", "default", "default", "dc1", connect.TestClusterID+".consul", "dc1", nil) + snap.ConnectProxy.DiscoveryChain["mongo"] = discoverychain.TestCompileConfigEntries(t, "mongo", "default", "default", "dc1", connect.TestClusterID+".consul", nil) - snap.ConnectProxy.DiscoveryChain["kafka"] = discoverychain.TestCompileConfigEntries(t, "kafka", "default", "default", "dc1", connect.TestClusterID+".consul", "dc1", nil) + snap.ConnectProxy.DiscoveryChain["kafka"] = discoverychain.TestCompileConfigEntries(t, "kafka", "default", "default", "dc1", connect.TestClusterID+".consul", nil) kafka := structs.NewServiceName("kafka", structs.DefaultEnterpriseMetaInDefaultPartition()) mongo := structs.NewServiceName("mongo", structs.DefaultEnterpriseMetaInDefaultPartition()) diff --git a/agent/xds/routes_test.go b/agent/xds/routes_test.go index d90622c34b..e01e5f2d52 100644 --- a/agent/xds/routes_test.go +++ b/agent/xds/routes_test.go @@ -200,10 +200,10 @@ func TestRoutesFromSnapshot(t *testing.T) { ConnectTimeout: 22 * time.Second, }, } - fooChain := discoverychain.TestCompileConfigEntries(t, "foo", "default", "default", "dc1", connect.TestClusterID+".consul", "dc1", nil, entries...) - barChain := discoverychain.TestCompileConfigEntries(t, "bar", "default", "default", "dc1", connect.TestClusterID+".consul", "dc1", nil, entries...) - bazChain := discoverychain.TestCompileConfigEntries(t, "baz", "default", "default", "dc1", connect.TestClusterID+".consul", "dc1", nil, entries...) - quxChain := discoverychain.TestCompileConfigEntries(t, "qux", "default", "default", "dc1", connect.TestClusterID+".consul", "dc1", nil, entries...) + fooChain := discoverychain.TestCompileConfigEntries(t, "foo", "default", "default", "dc1", connect.TestClusterID+".consul", nil, entries...) + barChain := discoverychain.TestCompileConfigEntries(t, "bar", "default", "default", "dc1", connect.TestClusterID+".consul", nil, entries...) + bazChain := discoverychain.TestCompileConfigEntries(t, "baz", "default", "default", "dc1", connect.TestClusterID+".consul", nil, entries...) + quxChain := discoverychain.TestCompileConfigEntries(t, "qux", "default", "default", "dc1", connect.TestClusterID+".consul", nil, entries...) snap.IngressGateway.DiscoveryChain = map[string]*structs.CompiledDiscoveryChain{ "foo": fooChain, @@ -801,11 +801,11 @@ func setupIngressWithTwoHTTPServices(t *testing.T, o ingressSDSOpts) func(snap * webChain := discoverychain.TestCompileConfigEntries(t, "web", o.entMetas["web"].NamespaceOrDefault(), o.entMetas["web"].PartitionOrDefault(), "dc1", - connect.TestClusterID+".consul", "dc1", nil, entries...) + connect.TestClusterID+".consul", nil, entries...) fooChain := discoverychain.TestCompileConfigEntries(t, "foo", o.entMetas["foo"].NamespaceOrDefault(), o.entMetas["web"].PartitionOrDefault(), "dc1", - connect.TestClusterID+".consul", "dc1", nil, entries...) + connect.TestClusterID+".consul", nil, entries...) snap.IngressGateway.DiscoveryChain[webUpstream.Identifier()] = webChain snap.IngressGateway.DiscoveryChain[fooUpstream.Identifier()] = fooChain