mirror of https://github.com/status-im/consul.git
Make routes controller tests more robust when testing with multiple tenancies (#20743)
When executing the test with multiple tenancies the various mesh controllers remained running across multiple sub-tests. While the resourcetest.Client cleans up resources created with it, resources created by the controllers were not being cleaned up. This could result in subsequent sub tests encountering unexpected values and failing when they should pass.
This commit is contained in:
parent
90d3a7c16d
commit
1a454b7b47
|
@ -42,7 +42,7 @@ type testResourceRef struct {
|
||||||
barServiceRef *pbresource.Reference
|
barServiceRef *pbresource.Reference
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *controllerSuite) SetupTest() {
|
func (suite *controllerSuite) SetupSubTest() {
|
||||||
suite.ctx = testutil.TestContext(suite.T())
|
suite.ctx = testutil.TestContext(suite.T())
|
||||||
suite.tenancies = rtest.TestTenancies()
|
suite.tenancies = rtest.TestTenancies()
|
||||||
|
|
||||||
|
@ -1349,264 +1349,265 @@ func (suite *controllerSuite) TestController() {
|
||||||
|
|
||||||
func (suite *controllerSuite) TestController_Failover() {
|
func (suite *controllerSuite) TestController_Failover() {
|
||||||
for _, tenancy := range suite.tenancies {
|
for _, tenancy := range suite.tenancies {
|
||||||
|
suite.Run(suite.appendTenancyInfo(tenancy), func() {
|
||||||
|
computedRoutesID := rtest.Resource(pbmesh.ComputedRoutesType, "api").
|
||||||
|
WithTenancy(tenancy).
|
||||||
|
ID()
|
||||||
|
|
||||||
computedRoutesID := rtest.Resource(pbmesh.ComputedRoutesType, "api").
|
apiServiceRef := resource.Reference(rtest.Resource(pbcatalog.ServiceType, "api").WithTenancy(tenancy).ID(), "")
|
||||||
WithTenancy(tenancy).
|
|
||||||
ID()
|
|
||||||
|
|
||||||
apiServiceRef := resource.Reference(rtest.Resource(pbcatalog.ServiceType, "api").WithTenancy(tenancy).ID(), "")
|
apiServiceData := &pbcatalog.Service{
|
||||||
|
Workloads: &pbcatalog.WorkloadSelector{Prefixes: []string{"api-"}},
|
||||||
apiServiceData := &pbcatalog.Service{
|
Ports: []*pbcatalog.ServicePort{
|
||||||
Workloads: &pbcatalog.WorkloadSelector{Prefixes: []string{"api-"}},
|
{TargetPort: "http", Protocol: pbcatalog.Protocol_PROTOCOL_HTTP},
|
||||||
Ports: []*pbcatalog.ServicePort{
|
{TargetPort: "mesh", Protocol: pbcatalog.Protocol_PROTOCOL_MESH}},
|
||||||
{TargetPort: "http", Protocol: pbcatalog.Protocol_PROTOCOL_HTTP},
|
|
||||||
{TargetPort: "mesh", Protocol: pbcatalog.Protocol_PROTOCOL_MESH}},
|
|
||||||
}
|
|
||||||
|
|
||||||
_ = rtest.Resource(pbcatalog.ServiceType, "api").
|
|
||||||
WithTenancy(tenancy).
|
|
||||||
WithData(suite.T(), apiServiceData).
|
|
||||||
Write(suite.T(), suite.client)
|
|
||||||
|
|
||||||
var lastVersion string
|
|
||||||
testutil.RunStep(suite.T(), "default http route without failover policy", func(t *testing.T) {
|
|
||||||
// Check that the computed routes resource exists and it has one port that is the default.
|
|
||||||
expect := &pbmesh.ComputedRoutes{
|
|
||||||
BoundReferences: []*pbresource.Reference{
|
|
||||||
apiServiceRef,
|
|
||||||
},
|
|
||||||
PortedConfigs: map[string]*pbmesh.ComputedPortRoutes{
|
|
||||||
"http": {
|
|
||||||
UsingDefaultConfig: true,
|
|
||||||
Config: &pbmesh.ComputedPortRoutes_Http{
|
|
||||||
Http: &pbmesh.ComputedHTTPRoute{
|
|
||||||
Rules: []*pbmesh.ComputedHTTPRouteRule{{
|
|
||||||
Matches: []*pbmesh.HTTPRouteMatch{{
|
|
||||||
Path: &pbmesh.HTTPPathMatch{
|
|
||||||
Type: pbmesh.PathMatchType_PATH_MATCH_TYPE_PREFIX,
|
|
||||||
Value: "/",
|
|
||||||
},
|
|
||||||
}},
|
|
||||||
BackendRefs: []*pbmesh.ComputedHTTPBackendRef{{
|
|
||||||
BackendTarget: backendName("api", "http", apiServiceRef.Tenancy),
|
|
||||||
}},
|
|
||||||
}},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
ParentRef: newParentRef(apiServiceRef, "http"),
|
|
||||||
Protocol: pbcatalog.Protocol_PROTOCOL_HTTP,
|
|
||||||
Targets: map[string]*pbmesh.BackendTargetDetails{
|
|
||||||
backendName("api", "http", apiServiceRef.Tenancy): {
|
|
||||||
Type: pbmesh.BackendTargetDetailsType_BACKEND_TARGET_DETAILS_TYPE_DIRECT,
|
|
||||||
MeshPort: "mesh",
|
|
||||||
BackendRef: newBackendRef(apiServiceRef, "http", ""),
|
|
||||||
DestinationConfig: defaultDestConfig(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lastVersion = requireNewComputedRoutesVersion(t, suite.client, computedRoutesID, lastVersion, expect)
|
_ = rtest.Resource(pbcatalog.ServiceType, "api").
|
||||||
})
|
WithTenancy(tenancy).
|
||||||
|
WithData(suite.T(), apiServiceData).
|
||||||
|
Write(suite.T(), suite.client)
|
||||||
|
|
||||||
failoverPolicyData := &pbcatalog.ComputedFailoverPolicy{
|
var lastVersion string
|
||||||
PortConfigs: map[string]*pbcatalog.FailoverConfig{
|
testutil.RunStep(suite.T(), "default http route without failover policy", func(t *testing.T) {
|
||||||
"http": {
|
// Check that the computed routes resource exists and it has one port that is the default.
|
||||||
Destinations: []*pbcatalog.FailoverDestination{
|
expect := &pbmesh.ComputedRoutes{
|
||||||
{
|
BoundReferences: []*pbresource.Reference{
|
||||||
Ref: apiServiceRef,
|
apiServiceRef,
|
||||||
Port: "http",
|
},
|
||||||
|
PortedConfigs: map[string]*pbmesh.ComputedPortRoutes{
|
||||||
|
"http": {
|
||||||
|
UsingDefaultConfig: true,
|
||||||
|
Config: &pbmesh.ComputedPortRoutes_Http{
|
||||||
|
Http: &pbmesh.ComputedHTTPRoute{
|
||||||
|
Rules: []*pbmesh.ComputedHTTPRouteRule{{
|
||||||
|
Matches: []*pbmesh.HTTPRouteMatch{{
|
||||||
|
Path: &pbmesh.HTTPPathMatch{
|
||||||
|
Type: pbmesh.PathMatchType_PATH_MATCH_TYPE_PREFIX,
|
||||||
|
Value: "/",
|
||||||
|
},
|
||||||
|
}},
|
||||||
|
BackendRefs: []*pbmesh.ComputedHTTPBackendRef{{
|
||||||
|
BackendTarget: backendName("api", "http", apiServiceRef.Tenancy),
|
||||||
|
}},
|
||||||
|
}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
ParentRef: newParentRef(apiServiceRef, "http"),
|
||||||
|
Protocol: pbcatalog.Protocol_PROTOCOL_HTTP,
|
||||||
|
Targets: map[string]*pbmesh.BackendTargetDetails{
|
||||||
|
backendName("api", "http", apiServiceRef.Tenancy): {
|
||||||
|
Type: pbmesh.BackendTargetDetailsType_BACKEND_TARGET_DETAILS_TYPE_DIRECT,
|
||||||
|
MeshPort: "mesh",
|
||||||
|
BackendRef: newBackendRef(apiServiceRef, "http", ""),
|
||||||
|
DestinationConfig: defaultDestConfig(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
lastVersion = requireNewComputedRoutesVersion(t, suite.client, computedRoutesID, lastVersion, expect)
|
||||||
|
})
|
||||||
|
|
||||||
|
failoverPolicyData := &pbcatalog.ComputedFailoverPolicy{
|
||||||
|
PortConfigs: map[string]*pbcatalog.FailoverConfig{
|
||||||
|
"http": {
|
||||||
|
Destinations: []*pbcatalog.FailoverDestination{
|
||||||
|
{
|
||||||
|
Ref: apiServiceRef,
|
||||||
|
Port: "http",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
BoundReferences: []*pbresource.Reference{apiServiceRef},
|
||||||
BoundReferences: []*pbresource.Reference{apiServiceRef},
|
}
|
||||||
}
|
|
||||||
|
|
||||||
_ = rtest.Resource(pbcatalog.ComputedFailoverPolicyType, "api").
|
_ = rtest.Resource(pbcatalog.ComputedFailoverPolicyType, "api").
|
||||||
WithTenancy(tenancy).
|
WithTenancy(tenancy).
|
||||||
WithData(suite.T(), failoverPolicyData).
|
WithData(suite.T(), failoverPolicyData).
|
||||||
Write(suite.T(), suite.client)
|
Write(suite.T(), suite.client)
|
||||||
|
|
||||||
testutil.RunStep(suite.T(), "with failover policy", func(t *testing.T) {
|
testutil.RunStep(suite.T(), "with failover policy", func(t *testing.T) {
|
||||||
// Check that the computed routes resource exists and it has one port that is the default.
|
// Check that the computed routes resource exists and it has one port that is the default.
|
||||||
expect := &pbmesh.ComputedRoutes{
|
expect := &pbmesh.ComputedRoutes{
|
||||||
BoundReferences: []*pbresource.Reference{
|
BoundReferences: []*pbresource.Reference{
|
||||||
newRef(pbcatalog.ComputedFailoverPolicyType, "api", tenancy),
|
newRef(pbcatalog.ComputedFailoverPolicyType, "api", tenancy),
|
||||||
apiServiceRef,
|
apiServiceRef,
|
||||||
},
|
},
|
||||||
PortedConfigs: map[string]*pbmesh.ComputedPortRoutes{
|
PortedConfigs: map[string]*pbmesh.ComputedPortRoutes{
|
||||||
"http": {
|
"http": {
|
||||||
UsingDefaultConfig: true,
|
UsingDefaultConfig: true,
|
||||||
Config: &pbmesh.ComputedPortRoutes_Http{
|
Config: &pbmesh.ComputedPortRoutes_Http{
|
||||||
Http: &pbmesh.ComputedHTTPRoute{
|
Http: &pbmesh.ComputedHTTPRoute{
|
||||||
Rules: []*pbmesh.ComputedHTTPRouteRule{{
|
Rules: []*pbmesh.ComputedHTTPRouteRule{{
|
||||||
Matches: []*pbmesh.HTTPRouteMatch{{
|
Matches: []*pbmesh.HTTPRouteMatch{{
|
||||||
Path: &pbmesh.HTTPPathMatch{
|
Path: &pbmesh.HTTPPathMatch{
|
||||||
Type: pbmesh.PathMatchType_PATH_MATCH_TYPE_PREFIX,
|
Type: pbmesh.PathMatchType_PATH_MATCH_TYPE_PREFIX,
|
||||||
Value: "/",
|
Value: "/",
|
||||||
},
|
},
|
||||||
|
}},
|
||||||
|
BackendRefs: []*pbmesh.ComputedHTTPBackendRef{{
|
||||||
|
BackendTarget: backendName("api", "http", apiServiceRef.Tenancy),
|
||||||
|
}},
|
||||||
}},
|
}},
|
||||||
BackendRefs: []*pbmesh.ComputedHTTPBackendRef{{
|
},
|
||||||
BackendTarget: backendName("api", "http", apiServiceRef.Tenancy),
|
|
||||||
}},
|
|
||||||
}},
|
|
||||||
},
|
},
|
||||||
},
|
ParentRef: newParentRef(apiServiceRef, "http"),
|
||||||
ParentRef: newParentRef(apiServiceRef, "http"),
|
Protocol: pbcatalog.Protocol_PROTOCOL_HTTP,
|
||||||
Protocol: pbcatalog.Protocol_PROTOCOL_HTTP,
|
Targets: map[string]*pbmesh.BackendTargetDetails{
|
||||||
Targets: map[string]*pbmesh.BackendTargetDetails{
|
backendName("api", "http", apiServiceRef.Tenancy): {
|
||||||
backendName("api", "http", apiServiceRef.Tenancy): {
|
Type: pbmesh.BackendTargetDetailsType_BACKEND_TARGET_DETAILS_TYPE_DIRECT,
|
||||||
Type: pbmesh.BackendTargetDetailsType_BACKEND_TARGET_DETAILS_TYPE_DIRECT,
|
MeshPort: "mesh",
|
||||||
MeshPort: "mesh",
|
BackendRef: newBackendRef(apiServiceRef, "http", ""),
|
||||||
BackendRef: newBackendRef(apiServiceRef, "http", ""),
|
DestinationConfig: defaultDestConfig(),
|
||||||
DestinationConfig: defaultDestConfig(),
|
FailoverConfig: &pbmesh.ComputedFailoverConfig{
|
||||||
FailoverConfig: &pbmesh.ComputedFailoverConfig{
|
Destinations: []*pbmesh.ComputedFailoverDestination{
|
||||||
Destinations: []*pbmesh.ComputedFailoverDestination{
|
{BackendTarget: backendName("api", "http", tenancy)},
|
||||||
{BackendTarget: backendName("api", "http", tenancy)},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
lastVersion = requireNewComputedRoutesVersion(t, suite.client, computedRoutesID, lastVersion, expect)
|
||||||
|
})
|
||||||
|
|
||||||
|
otherServiceRef := resource.Reference(rtest.Resource(pbcatalog.ServiceType, "other").WithTenancy(tenancy).ID(), "")
|
||||||
|
|
||||||
|
otherServiceData := &pbcatalog.Service{
|
||||||
|
Workloads: &pbcatalog.WorkloadSelector{Prefixes: []string{"other-"}},
|
||||||
|
Ports: []*pbcatalog.ServicePort{
|
||||||
|
{TargetPort: "http", Protocol: pbcatalog.Protocol_PROTOCOL_HTTP},
|
||||||
|
{TargetPort: "mesh", Protocol: pbcatalog.Protocol_PROTOCOL_MESH},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
otherService := rtest.Resource(pbcatalog.ServiceType, "other").
|
||||||
|
WithData(suite.T(), otherServiceData).
|
||||||
|
WithTenancy(tenancy).
|
||||||
|
Write(suite.T(), suite.client)
|
||||||
|
|
||||||
lastVersion = requireNewComputedRoutesVersion(t, suite.client, computedRoutesID, lastVersion, expect)
|
failoverPolicyData = &pbcatalog.ComputedFailoverPolicy{
|
||||||
})
|
PortConfigs: map[string]*pbcatalog.FailoverConfig{
|
||||||
|
"http": {
|
||||||
otherServiceRef := resource.Reference(rtest.Resource(pbcatalog.ServiceType, "other").WithTenancy(tenancy).ID(), "")
|
Destinations: []*pbcatalog.FailoverDestination{
|
||||||
|
{
|
||||||
otherServiceData := &pbcatalog.Service{
|
Ref: otherServiceRef,
|
||||||
Workloads: &pbcatalog.WorkloadSelector{Prefixes: []string{"other-"}},
|
Port: "http",
|
||||||
Ports: []*pbcatalog.ServicePort{
|
},
|
||||||
{TargetPort: "http", Protocol: pbcatalog.Protocol_PROTOCOL_HTTP},
|
|
||||||
{TargetPort: "mesh", Protocol: pbcatalog.Protocol_PROTOCOL_MESH},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
otherService := rtest.Resource(pbcatalog.ServiceType, "other").
|
|
||||||
WithData(suite.T(), otherServiceData).
|
|
||||||
WithTenancy(tenancy).
|
|
||||||
Write(suite.T(), suite.client)
|
|
||||||
|
|
||||||
failoverPolicyData = &pbcatalog.ComputedFailoverPolicy{
|
|
||||||
PortConfigs: map[string]*pbcatalog.FailoverConfig{
|
|
||||||
"http": {
|
|
||||||
Destinations: []*pbcatalog.FailoverDestination{
|
|
||||||
{
|
|
||||||
Ref: otherServiceRef,
|
|
||||||
Port: "http",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
BoundReferences: []*pbresource.Reference{otherServiceRef},
|
||||||
BoundReferences: []*pbresource.Reference{otherServiceRef},
|
}
|
||||||
}
|
|
||||||
|
|
||||||
_ = rtest.Resource(pbcatalog.ComputedFailoverPolicyType, "api").
|
_ = rtest.Resource(pbcatalog.ComputedFailoverPolicyType, "api").
|
||||||
WithTenancy(tenancy).
|
WithTenancy(tenancy).
|
||||||
WithData(suite.T(), failoverPolicyData).
|
WithData(suite.T(), failoverPolicyData).
|
||||||
Write(suite.T(), suite.client)
|
Write(suite.T(), suite.client)
|
||||||
|
|
||||||
testutil.RunStep(suite.T(), "with other service and updated failover policy", func(t *testing.T) {
|
testutil.RunStep(suite.T(), "with other service and updated failover policy", func(t *testing.T) {
|
||||||
// Check that the computed routes resource exists and it has one port that is the default.
|
// Check that the computed routes resource exists and it has one port that is the default.
|
||||||
expect := &pbmesh.ComputedRoutes{
|
expect := &pbmesh.ComputedRoutes{
|
||||||
BoundReferences: []*pbresource.Reference{
|
BoundReferences: []*pbresource.Reference{
|
||||||
newRef(pbcatalog.ComputedFailoverPolicyType, "api", tenancy),
|
newRef(pbcatalog.ComputedFailoverPolicyType, "api", tenancy),
|
||||||
apiServiceRef,
|
apiServiceRef,
|
||||||
otherServiceRef,
|
otherServiceRef,
|
||||||
},
|
},
|
||||||
PortedConfigs: map[string]*pbmesh.ComputedPortRoutes{
|
PortedConfigs: map[string]*pbmesh.ComputedPortRoutes{
|
||||||
"http": {
|
"http": {
|
||||||
UsingDefaultConfig: true,
|
UsingDefaultConfig: true,
|
||||||
Config: &pbmesh.ComputedPortRoutes_Http{
|
Config: &pbmesh.ComputedPortRoutes_Http{
|
||||||
Http: &pbmesh.ComputedHTTPRoute{
|
Http: &pbmesh.ComputedHTTPRoute{
|
||||||
Rules: []*pbmesh.ComputedHTTPRouteRule{{
|
Rules: []*pbmesh.ComputedHTTPRouteRule{{
|
||||||
Matches: []*pbmesh.HTTPRouteMatch{{
|
Matches: []*pbmesh.HTTPRouteMatch{{
|
||||||
Path: &pbmesh.HTTPPathMatch{
|
Path: &pbmesh.HTTPPathMatch{
|
||||||
Type: pbmesh.PathMatchType_PATH_MATCH_TYPE_PREFIX,
|
Type: pbmesh.PathMatchType_PATH_MATCH_TYPE_PREFIX,
|
||||||
Value: "/",
|
Value: "/",
|
||||||
},
|
},
|
||||||
|
}},
|
||||||
|
BackendRefs: []*pbmesh.ComputedHTTPBackendRef{{
|
||||||
|
BackendTarget: backendName("api", "http", apiServiceRef.Tenancy),
|
||||||
|
}},
|
||||||
}},
|
}},
|
||||||
BackendRefs: []*pbmesh.ComputedHTTPBackendRef{{
|
|
||||||
BackendTarget: backendName("api", "http", apiServiceRef.Tenancy),
|
|
||||||
}},
|
|
||||||
}},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
ParentRef: newParentRef(apiServiceRef, "http"),
|
|
||||||
Protocol: pbcatalog.Protocol_PROTOCOL_HTTP,
|
|
||||||
Targets: map[string]*pbmesh.BackendTargetDetails{
|
|
||||||
backendName("api", "http", apiServiceRef.Tenancy): {
|
|
||||||
Type: pbmesh.BackendTargetDetailsType_BACKEND_TARGET_DETAILS_TYPE_DIRECT,
|
|
||||||
MeshPort: "mesh",
|
|
||||||
BackendRef: newBackendRef(apiServiceRef, "http", ""),
|
|
||||||
DestinationConfig: defaultDestConfig(),
|
|
||||||
FailoverConfig: &pbmesh.ComputedFailoverConfig{
|
|
||||||
Destinations: []*pbmesh.ComputedFailoverDestination{
|
|
||||||
{BackendTarget: backendName("other", "http", tenancy)},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
backendName("other", "http", otherServiceRef.Tenancy): {
|
ParentRef: newParentRef(apiServiceRef, "http"),
|
||||||
Type: pbmesh.BackendTargetDetailsType_BACKEND_TARGET_DETAILS_TYPE_INDIRECT,
|
Protocol: pbcatalog.Protocol_PROTOCOL_HTTP,
|
||||||
MeshPort: "mesh",
|
Targets: map[string]*pbmesh.BackendTargetDetails{
|
||||||
BackendRef: newBackendRef(otherServiceRef, "http", ""),
|
backendName("api", "http", apiServiceRef.Tenancy): {
|
||||||
DestinationConfig: defaultDestConfig(),
|
Type: pbmesh.BackendTargetDetailsType_BACKEND_TARGET_DETAILS_TYPE_DIRECT,
|
||||||
},
|
MeshPort: "mesh",
|
||||||
},
|
BackendRef: newBackendRef(apiServiceRef, "http", ""),
|
||||||
},
|
DestinationConfig: defaultDestConfig(),
|
||||||
},
|
FailoverConfig: &pbmesh.ComputedFailoverConfig{
|
||||||
}
|
Destinations: []*pbmesh.ComputedFailoverDestination{
|
||||||
|
{BackendTarget: backendName("other", "http", tenancy)},
|
||||||
lastVersion = requireNewComputedRoutesVersion(t, suite.client, computedRoutesID, lastVersion, expect)
|
|
||||||
})
|
|
||||||
|
|
||||||
suite.T().Log("delete other service")
|
|
||||||
suite.client.MustDelete(suite.T(), otherService.Id)
|
|
||||||
|
|
||||||
testutil.RunStep(suite.T(), "api computed routes is recoinciled", func(t *testing.T) {
|
|
||||||
// Check that the computed routes resource exists and it has one port that is the default.
|
|
||||||
expect := &pbmesh.ComputedRoutes{
|
|
||||||
BoundReferences: []*pbresource.Reference{
|
|
||||||
newRef(pbcatalog.ComputedFailoverPolicyType, "api", tenancy),
|
|
||||||
apiServiceRef,
|
|
||||||
},
|
|
||||||
PortedConfigs: map[string]*pbmesh.ComputedPortRoutes{
|
|
||||||
"http": {
|
|
||||||
UsingDefaultConfig: true,
|
|
||||||
Config: &pbmesh.ComputedPortRoutes_Http{
|
|
||||||
Http: &pbmesh.ComputedHTTPRoute{
|
|
||||||
Rules: []*pbmesh.ComputedHTTPRouteRule{{
|
|
||||||
Matches: []*pbmesh.HTTPRouteMatch{{
|
|
||||||
Path: &pbmesh.HTTPPathMatch{
|
|
||||||
Type: pbmesh.PathMatchType_PATH_MATCH_TYPE_PREFIX,
|
|
||||||
Value: "/",
|
|
||||||
},
|
},
|
||||||
}},
|
},
|
||||||
BackendRefs: []*pbmesh.ComputedHTTPBackendRef{{
|
},
|
||||||
BackendTarget: backendName("api", "http", apiServiceRef.Tenancy),
|
backendName("other", "http", otherServiceRef.Tenancy): {
|
||||||
}},
|
Type: pbmesh.BackendTargetDetailsType_BACKEND_TARGET_DETAILS_TYPE_INDIRECT,
|
||||||
}},
|
MeshPort: "mesh",
|
||||||
},
|
BackendRef: newBackendRef(otherServiceRef, "http", ""),
|
||||||
},
|
DestinationConfig: defaultDestConfig(),
|
||||||
ParentRef: newParentRef(apiServiceRef, "http"),
|
},
|
||||||
Protocol: pbcatalog.Protocol_PROTOCOL_HTTP,
|
|
||||||
Targets: map[string]*pbmesh.BackendTargetDetails{
|
|
||||||
backendName("api", "http", apiServiceRef.Tenancy): {
|
|
||||||
Type: pbmesh.BackendTargetDetailsType_BACKEND_TARGET_DETAILS_TYPE_DIRECT,
|
|
||||||
MeshPort: "mesh",
|
|
||||||
BackendRef: newBackendRef(apiServiceRef, "http", ""),
|
|
||||||
DestinationConfig: defaultDestConfig(),
|
|
||||||
FailoverConfig: &pbmesh.ComputedFailoverConfig{},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
}
|
||||||
}
|
|
||||||
|
|
||||||
lastVersion = requireNewComputedRoutesVersion(t, suite.client, computedRoutesID, lastVersion, expect)
|
lastVersion = requireNewComputedRoutesVersion(t, suite.client, computedRoutesID, lastVersion, expect)
|
||||||
|
})
|
||||||
|
|
||||||
|
suite.T().Log("delete other service")
|
||||||
|
suite.client.MustDelete(suite.T(), otherService.Id)
|
||||||
|
|
||||||
|
testutil.RunStep(suite.T(), "api computed routes is recoinciled", func(t *testing.T) {
|
||||||
|
// Check that the computed routes resource exists and it has one port that is the default.
|
||||||
|
expect := &pbmesh.ComputedRoutes{
|
||||||
|
BoundReferences: []*pbresource.Reference{
|
||||||
|
newRef(pbcatalog.ComputedFailoverPolicyType, "api", tenancy),
|
||||||
|
apiServiceRef,
|
||||||
|
},
|
||||||
|
PortedConfigs: map[string]*pbmesh.ComputedPortRoutes{
|
||||||
|
"http": {
|
||||||
|
UsingDefaultConfig: true,
|
||||||
|
Config: &pbmesh.ComputedPortRoutes_Http{
|
||||||
|
Http: &pbmesh.ComputedHTTPRoute{
|
||||||
|
Rules: []*pbmesh.ComputedHTTPRouteRule{{
|
||||||
|
Matches: []*pbmesh.HTTPRouteMatch{{
|
||||||
|
Path: &pbmesh.HTTPPathMatch{
|
||||||
|
Type: pbmesh.PathMatchType_PATH_MATCH_TYPE_PREFIX,
|
||||||
|
Value: "/",
|
||||||
|
},
|
||||||
|
}},
|
||||||
|
BackendRefs: []*pbmesh.ComputedHTTPBackendRef{{
|
||||||
|
BackendTarget: backendName("api", "http", apiServiceRef.Tenancy),
|
||||||
|
}},
|
||||||
|
}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
ParentRef: newParentRef(apiServiceRef, "http"),
|
||||||
|
Protocol: pbcatalog.Protocol_PROTOCOL_HTTP,
|
||||||
|
Targets: map[string]*pbmesh.BackendTargetDetails{
|
||||||
|
backendName("api", "http", apiServiceRef.Tenancy): {
|
||||||
|
Type: pbmesh.BackendTargetDetailsType_BACKEND_TARGET_DETAILS_TYPE_DIRECT,
|
||||||
|
MeshPort: "mesh",
|
||||||
|
BackendRef: newBackendRef(apiServiceRef, "http", ""),
|
||||||
|
DestinationConfig: defaultDestConfig(),
|
||||||
|
FailoverConfig: &pbmesh.ComputedFailoverConfig{},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
lastVersion = requireNewComputedRoutesVersion(t, suite.client, computedRoutesID, lastVersion, expect)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue