pull/19167/head
John Murret 2023-10-13 13:58:49 -06:00
parent 79eadd1afd
commit d269c63a99
2 changed files with 129 additions and 176 deletions

View File

@ -1020,20 +1020,22 @@ func (suite *xdsControllerTestSuite) TestBuildExplicitDestinations() {
//get service data
serviceData := &pbcatalog.Service{}
var vp uint32 = 7000
svcNames := map[string]map[string]string
requiredEps := make(map[string]*pbproxystate.EndpointRef)
// get service name and ports
for name := range pst.RequiredEndpoints {
for name := range pst.ProxyState.Clusters {
if name == "null_route_cluster" {
continue
}
vp++
nameSplit := strings.Split(name, ".")
port := nameSplit[0]
svcNames[nameSplit[1]] = name
svcName := nameSplit[1]
serviceData.Ports = append(serviceData.Ports, &pbcatalog.ServicePort{
TargetPort: port,
VirtualPort: vp,
Protocol: pbcatalog.Protocol_PROTOCOL_TCP,
})
}
svc := resourcetest.Resource(pbcatalog.ServiceType, svcName).
WithData(suite.T(), &pbcatalog.Service{}).
@ -1058,10 +1060,7 @@ func (suite *xdsControllerTestSuite) TestBuildExplicitDestinations() {
}}).
WithOwner(svc.Id).
Write(suite.T(), suite.client)
//
requiredEps := make(map[string]*pbproxystate.EndpointRef)
for epName := range pst.RequiredEndpoints {
requiredEps[epName] = &pbproxystate.EndpointRef{
requiredEps[name] = &pbproxystate.EndpointRef{
Id: eps.Id,
Port: "mesh",
}
@ -1093,7 +1092,9 @@ func (suite *xdsControllerTestSuite) TestBuildExplicitDestinations() {
require.NotNil(suite.T(), proxyStateTemplate)
actual := prototest.ProtoToJSON(suite.T(), proxyStateTemplate.Data)
reconciledPS := suite.updater.Get(proxyStateTemplate.Id.Name)
actual := prototest.ProtoToJSON(suite.T(), reconciledPS)
expected := golden.Get(suite.T(), actual, name+".golden")
require.JSONEq(suite.T(), expected, actual)

View File

@ -1,5 +1,4 @@
{
"proxyState": {
"clusters": {
"null_route_cluster": {
"endpointGroup": {
@ -112,51 +111,4 @@
]
}
]
},
"requiredEndpoints": {
"tcp.api-1.default.dc1.internal.foo.consul": {
"id": {
"name": "api-1",
"tenancy": {
"namespace": "default",
"partition": "default",
"peerName": "local"
},
"type": {
"group": "catalog",
"groupVersion": "v2beta1",
"kind": "ServiceEndpoints"
}
},
"port": "mesh"
},
"tcp.api-2.default.dc1.internal.foo.consul": {
"id": {
"name": "api-2",
"tenancy": {
"namespace": "default",
"partition": "default",
"peerName": "local"
},
"type": {
"group": "catalog",
"groupVersion": "v2beta1",
"kind": "ServiceEndpoints"
}
},
"port": "mesh"
}
},
"requiredLeafCertificates": {
"test-identity": {
"name": "test-identity",
"namespace": "default",
"partition": "default"
}
},
"requiredTrustBundles": {
"local": {
"peer": "local"
}
}
}