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
This commit is contained in:
Matt Keeler 2019-07-01 19:47:58 -04:00 committed by GitHub
parent 8d953f5840
commit bdebe62fd0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 6 deletions

View File

@ -349,7 +349,7 @@ func TestAgent_Service(t *testing.T) {
Service: "web-sidecar-proxy", Service: "web-sidecar-proxy",
Port: 8000, Port: 8000,
Proxy: expectProxy.ToAPI(), Proxy: expectProxy.ToAPI(),
ContentHash: "ab93d2418205fe0d", ContentHash: "accc98ff3082d229",
Weights: api.AgentWeights{ Weights: api.AgentWeights{
Passing: 1, Passing: 1,
Warning: 1, Warning: 1,
@ -359,7 +359,7 @@ func TestAgent_Service(t *testing.T) {
// Copy and modify // Copy and modify
updatedResponse := *expectedResponse updatedResponse := *expectedResponse
updatedResponse.Port = 9999 updatedResponse.Port = 9999
updatedResponse.ContentHash = "96dab876aa16edaf" updatedResponse.ContentHash = "9185f2c81891c18b"
// Simple response for non-proxy service registered in TestAgent config // Simple response for non-proxy service registered in TestAgent config
expectWebResponse := &api.AgentService{ expectWebResponse := &api.AgentService{

View File

@ -114,10 +114,12 @@ func TestManager_BasicLifecycle(t *testing.T) {
Proxy: webProxy.Proxy, Proxy: webProxy.Proxy,
TaggedAddresses: make(map[string]structs.ServiceAddress), TaggedAddresses: make(map[string]structs.ServiceAddress),
Roots: roots, Roots: roots,
ConnectProxy: configSnapshotConnectProxy{
Leaf: leaf, Leaf: leaf,
UpstreamEndpoints: map[string]structs.CheckServiceNodes{ UpstreamEndpoints: map[string]structs.CheckServiceNodes{
"db": TestUpstreamNodes(t), "db": TestUpstreamNodes(t),
}, },
},
Datacenter: "dc1", Datacenter: "dc1",
} }
start := time.Now() start := time.Now()
@ -163,7 +165,7 @@ func TestManager_BasicLifecycle(t *testing.T) {
types.leaf.Set(newLeaf) types.leaf.Set(newLeaf)
// Expect new roots in snapshot // Expect new roots in snapshot
expectSnap.Leaf = newLeaf expectSnap.ConnectProxy.Leaf = newLeaf
assertWatchChanRecvs(t, wCh, expectSnap) assertWatchChanRecvs(t, wCh, expectSnap)
assertWatchChanRecvs(t, wCh2, expectSnap) assertWatchChanRecvs(t, wCh2, expectSnap)

View File

@ -35,6 +35,10 @@ type MeshGatewayConfig struct {
Mode MeshGatewayMode `json:",omitempty"` 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 // ConnectProxyConfig describes the configuration needed for any proxy managed
// or unmanaged. It describes a single logical service's listener and optionally // or unmanaged. It describes a single logical service's listener and optionally
// upstreams and sidecar-related config for a single instance. To describe a // 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, LocalServicePort: c.LocalServicePort,
Config: c.Config, Config: c.Config,
Upstreams: c.Upstreams.ToAPI(), Upstreams: c.Upstreams.ToAPI(),
MeshGateway: c.MeshGateway.ToAPI(),
} }
} }

View File

@ -131,6 +131,7 @@ type AgentServiceConnectProxyConfig struct {
LocalServicePort int `json:",omitempty"` LocalServicePort int `json:",omitempty"`
Config map[string]interface{} `json:",omitempty" bexpr:"-"` Config map[string]interface{} `json:",omitempty" bexpr:"-"`
Upstreams []Upstream `json:",omitempty"` Upstreams []Upstream `json:",omitempty"`
MeshGateway MeshGatewayConfig `json:",omitempty"`
} }
// AgentMember represents a cluster member known to the agent // AgentMember represents a cluster member known to the agent
@ -300,6 +301,7 @@ type Upstream struct {
LocalBindAddress string `json:",omitempty"` LocalBindAddress string `json:",omitempty"`
LocalBindPort int `json:",omitempty"` LocalBindPort int `json:",omitempty"`
Config map[string]interface{} `json:",omitempty" bexpr:"-"` Config map[string]interface{} `json:",omitempty" bexpr:"-"`
MeshGateway MeshGatewayConfig `json:",omitempty"`
} }
// Agent can be used to query the Agent endpoints // Agent can be used to query the Agent endpoints