From bdebe62fd0425969bb692900552de91c73b79014 Mon Sep 17 00:00:00 2001 From: Matt Keeler Date: Mon, 1 Jul 2019 19:47:58 -0400 Subject: [PATCH] Fix some tests that I broke when refactoring the ConfigSnapshot (#6051) * Fix some tests that I broke when refactoring the ConfigSnapshot * Make sure the MeshGateway config is added to all the right api structs * Fix some more tests --- agent/agent_endpoint_test.go | 4 ++-- agent/proxycfg/manager_test.go | 10 ++++++---- agent/structs/connect_proxy_config.go | 5 +++++ api/agent.go | 2 ++ 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/agent/agent_endpoint_test.go b/agent/agent_endpoint_test.go index 1f589a3e66..9dac1ec873 100644 --- a/agent/agent_endpoint_test.go +++ b/agent/agent_endpoint_test.go @@ -349,7 +349,7 @@ func TestAgent_Service(t *testing.T) { Service: "web-sidecar-proxy", Port: 8000, Proxy: expectProxy.ToAPI(), - ContentHash: "ab93d2418205fe0d", + ContentHash: "accc98ff3082d229", Weights: api.AgentWeights{ Passing: 1, Warning: 1, @@ -359,7 +359,7 @@ func TestAgent_Service(t *testing.T) { // Copy and modify updatedResponse := *expectedResponse updatedResponse.Port = 9999 - updatedResponse.ContentHash = "96dab876aa16edaf" + updatedResponse.ContentHash = "9185f2c81891c18b" // Simple response for non-proxy service registered in TestAgent config expectWebResponse := &api.AgentService{ diff --git a/agent/proxycfg/manager_test.go b/agent/proxycfg/manager_test.go index 5d23dca41c..9722cd8c9b 100644 --- a/agent/proxycfg/manager_test.go +++ b/agent/proxycfg/manager_test.go @@ -114,9 +114,11 @@ func TestManager_BasicLifecycle(t *testing.T) { Proxy: webProxy.Proxy, TaggedAddresses: make(map[string]structs.ServiceAddress), Roots: roots, - Leaf: leaf, - UpstreamEndpoints: map[string]structs.CheckServiceNodes{ - "db": TestUpstreamNodes(t), + ConnectProxy: configSnapshotConnectProxy{ + Leaf: leaf, + UpstreamEndpoints: map[string]structs.CheckServiceNodes{ + "db": TestUpstreamNodes(t), + }, }, Datacenter: "dc1", } @@ -163,7 +165,7 @@ func TestManager_BasicLifecycle(t *testing.T) { types.leaf.Set(newLeaf) // Expect new roots in snapshot - expectSnap.Leaf = newLeaf + expectSnap.ConnectProxy.Leaf = newLeaf assertWatchChanRecvs(t, wCh, expectSnap) assertWatchChanRecvs(t, wCh2, expectSnap) diff --git a/agent/structs/connect_proxy_config.go b/agent/structs/connect_proxy_config.go index 606eece35f..e2152e0efa 100644 --- a/agent/structs/connect_proxy_config.go +++ b/agent/structs/connect_proxy_config.go @@ -35,6 +35,10 @@ type MeshGatewayConfig struct { Mode MeshGatewayMode `json:",omitempty"` } +func (c *MeshGatewayConfig) ToAPI() api.MeshGatewayConfig { + return api.MeshGatewayConfig{Mode: api.MeshGatewayMode(c.Mode)} +} + // ConnectProxyConfig describes the configuration needed for any proxy managed // or unmanaged. It describes a single logical service's listener and optionally // upstreams and sidecar-related config for a single instance. To describe a @@ -89,6 +93,7 @@ func (c *ConnectProxyConfig) ToAPI() *api.AgentServiceConnectProxyConfig { LocalServicePort: c.LocalServicePort, Config: c.Config, Upstreams: c.Upstreams.ToAPI(), + MeshGateway: c.MeshGateway.ToAPI(), } } diff --git a/api/agent.go b/api/agent.go index 10a758933e..1ae4ecd49a 100644 --- a/api/agent.go +++ b/api/agent.go @@ -131,6 +131,7 @@ type AgentServiceConnectProxyConfig struct { LocalServicePort int `json:",omitempty"` Config map[string]interface{} `json:",omitempty" bexpr:"-"` Upstreams []Upstream `json:",omitempty"` + MeshGateway MeshGatewayConfig `json:",omitempty"` } // AgentMember represents a cluster member known to the agent @@ -300,6 +301,7 @@ type Upstream struct { LocalBindAddress string `json:",omitempty"` LocalBindPort int `json:",omitempty"` Config map[string]interface{} `json:",omitempty" bexpr:"-"` + MeshGateway MeshGatewayConfig `json:",omitempty"` } // Agent can be used to query the Agent endpoints