sync enterprise files with oss (#10705)
This commit is contained in:
parent
df04f4fe52
commit
33d7d48767
|
@ -412,27 +412,22 @@ func TestAgent_Service(t *testing.T) {
|
||||||
}
|
}
|
||||||
fillAgentServiceEnterpriseMeta(expectedResponse, structs.DefaultEnterpriseMetaInDefaultPartition())
|
fillAgentServiceEnterpriseMeta(expectedResponse, structs.DefaultEnterpriseMetaInDefaultPartition())
|
||||||
hash1, err := hashstructure.Hash(expectedResponse, nil)
|
hash1, err := hashstructure.Hash(expectedResponse, nil)
|
||||||
if err != nil {
|
require.NoError(t, err, "failed to generate hash")
|
||||||
t.Fatalf("error generating hash: %v", err)
|
|
||||||
}
|
|
||||||
expectedResponse.ContentHash = fmt.Sprintf("%x", hash1)
|
expectedResponse.ContentHash = fmt.Sprintf("%x", hash1)
|
||||||
|
|
||||||
// Copy and modify
|
// Copy and modify
|
||||||
updatedResponse := *expectedResponse
|
updatedResponse := *expectedResponse
|
||||||
updatedResponse.Port = 9999
|
updatedResponse.Port = 9999
|
||||||
updatedResponse.ContentHash = "" // clear field before generating a new hash
|
updatedResponse.ContentHash = "" // clear field before hashing
|
||||||
hash2, err := hashstructure.Hash(updatedResponse, nil)
|
hash2, err := hashstructure.Hash(updatedResponse, nil)
|
||||||
if err != nil {
|
require.NoError(t, err, "failed to generate hash")
|
||||||
t.Fatalf("error generating hash: %v", err)
|
|
||||||
}
|
|
||||||
updatedResponse.ContentHash = fmt.Sprintf("%x", hash2)
|
updatedResponse.ContentHash = fmt.Sprintf("%x", hash2)
|
||||||
|
|
||||||
// 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{
|
||||||
ID: "web",
|
ID: "web",
|
||||||
Service: "web",
|
Service: "web",
|
||||||
Port: 8181,
|
Port: 8181,
|
||||||
ContentHash: "f012740ee2d8ce60",
|
|
||||||
Weights: api.AgentWeights{
|
Weights: api.AgentWeights{
|
||||||
Passing: 1,
|
Passing: 1,
|
||||||
Warning: 1,
|
Warning: 1,
|
||||||
|
@ -448,6 +443,9 @@ func TestAgent_Service(t *testing.T) {
|
||||||
Datacenter: "dc1",
|
Datacenter: "dc1",
|
||||||
}
|
}
|
||||||
fillAgentServiceEnterpriseMeta(expectWebResponse, structs.DefaultEnterpriseMetaInDefaultPartition())
|
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 {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
|
|
|
@ -86,7 +86,7 @@ func (s *ServiceDefinition) NodeService() *NodeService {
|
||||||
ns.Proxy.Upstreams[i].DestinationType = UpstreamDestTypeService
|
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.
|
// Applicable only to Consul Enterprise.
|
||||||
if ns.Proxy.Upstreams[i].DestinationNamespace == "" {
|
if ns.Proxy.Upstreams[i].DestinationNamespace == "" {
|
||||||
ns.Proxy.Upstreams[i].DestinationNamespace = ns.EnterpriseMeta.NamespaceOrEmpty()
|
ns.Proxy.Upstreams[i].DestinationNamespace = ns.EnterpriseMeta.NamespaceOrEmpty()
|
||||||
|
|
Loading…
Reference in New Issue