From 33d7d48767ebb7b18a69f37eaa28e754403320ce Mon Sep 17 00:00:00 2001 From: "Chris S. Kim" Date: Tue, 27 Jul 2021 17:09:59 -0400 Subject: [PATCH] sync enterprise files with oss (#10705) --- agent/agent_endpoint_test.go | 20 +++++++++----------- agent/structs/service_definition.go | 2 +- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/agent/agent_endpoint_test.go b/agent/agent_endpoint_test.go index 7568a7d43..d4ab2b322 100644 --- a/agent/agent_endpoint_test.go +++ b/agent/agent_endpoint_test.go @@ -412,27 +412,22 @@ func TestAgent_Service(t *testing.T) { } fillAgentServiceEnterpriseMeta(expectedResponse, structs.DefaultEnterpriseMetaInDefaultPartition()) hash1, err := hashstructure.Hash(expectedResponse, nil) - if err != nil { - t.Fatalf("error generating hash: %v", err) - } + require.NoError(t, err, "failed to generate hash") expectedResponse.ContentHash = fmt.Sprintf("%x", hash1) // Copy and modify updatedResponse := *expectedResponse updatedResponse.Port = 9999 - updatedResponse.ContentHash = "" // clear field before generating a new hash + updatedResponse.ContentHash = "" // clear field before hashing hash2, err := hashstructure.Hash(updatedResponse, nil) - if err != nil { - t.Fatalf("error generating hash: %v", err) - } + require.NoError(t, err, "failed to generate hash") updatedResponse.ContentHash = fmt.Sprintf("%x", hash2) // Simple response for non-proxy service registered in TestAgent config expectWebResponse := &api.AgentService{ - ID: "web", - Service: "web", - Port: 8181, - ContentHash: "f012740ee2d8ce60", + ID: "web", + Service: "web", + Port: 8181, Weights: api.AgentWeights{ Passing: 1, Warning: 1, @@ -448,6 +443,9 @@ func TestAgent_Service(t *testing.T) { Datacenter: "dc1", } fillAgentServiceEnterpriseMeta(expectWebResponse, structs.DefaultEnterpriseMetaInDefaultPartition()) + hash3, err := hashstructure.Hash(expectWebResponse, nil) + require.NoError(t, err, "failed to generate hash") + expectWebResponse.ContentHash = fmt.Sprintf("%x", hash3) tests := []struct { name string diff --git a/agent/structs/service_definition.go b/agent/structs/service_definition.go index 552d5df5b..07a769d9c 100644 --- a/agent/structs/service_definition.go +++ b/agent/structs/service_definition.go @@ -86,7 +86,7 @@ func (s *ServiceDefinition) NodeService() *NodeService { ns.Proxy.Upstreams[i].DestinationType = UpstreamDestTypeService } - // If a proxy's namespace is not defined, inherit the server's namespace. + // If a proxy's namespace is not defined, inherit the proxied service's namespace. // Applicable only to Consul Enterprise. if ns.Proxy.Upstreams[i].DestinationNamespace == "" { ns.Proxy.Upstreams[i].DestinationNamespace = ns.EnterpriseMeta.NamespaceOrEmpty()