Skip to content

Commit

Permalink
test(MeshHTTPRoute): fix MeshMultiZoneService test (#11979)
Browse files Browse the repository at this point in the history
We weren't checking the endpoints because a Dataplane wasn't correctly
created and we didn't use selectors.

Signed-off-by: Mike Beaumont <[email protected]>
  • Loading branch information
michaelbeaumont authored Nov 6, 2024
1 parent 7d59c7b commit b42cf6a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 12 deletions.
30 changes: 21 additions & 9 deletions pkg/plugins/policies/meshhttproute/plugin/v1alpha1/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,10 @@ var _ = Describe("MeshHTTPRoute", func() {
}
}()),
Entry("default-meshmultizoneservice", func() outboundsTestCase {
backendDP := samples.DataplaneWebBuilder().
backendDP := builders.Dataplane().
WithName("backend").
WithAddress("192.168.0.4").
AddInbound(builders.Inbound().
WithAddress("192.168.0.4").
WithPort(8084).
WithTags(map[string]string{
mesh_proto.ServiceTag: "backend",
Expand All @@ -274,9 +275,18 @@ var _ = Describe("MeshHTTPRoute", func() {
}),
).Build()
meshSvc := meshservice_api.MeshServiceResource{
Meta: &test_model.ResourceMeta{Name: "backend", Mesh: "default"},
Meta: &test_model.ResourceMeta{
Name: "backend", Mesh: "default",
Labels: map[string]string{
"service": "backend",
},
},
Spec: &meshservice_api.MeshService{
Selector: meshservice_api.Selector{},
Selector: meshservice_api.Selector{
DataplaneTags: meshservice_api.DataplaneTags{
mesh_proto.ServiceTag: "backend",
},
},
Ports: []meshservice_api.Port{{
Port: 80,
TargetPort: intstr.FromInt(8084),
Expand All @@ -287,10 +297,6 @@ var _ = Describe("MeshHTTPRoute", func() {
Type: meshservice_api.MeshServiceIdentityServiceTagType,
Value: "backend",
},
{
Type: meshservice_api.MeshServiceIdentityServiceTagType,
Value: "other-backend",
},
},
},
Status: &meshservice_api.MeshServiceStatus{
Expand All @@ -302,7 +308,13 @@ var _ = Describe("MeshHTTPRoute", func() {
meshMZSvc := meshmultizoneservice_api.MeshMultiZoneServiceResource{
Meta: &test_model.ResourceMeta{Name: "multi-backend", Mesh: "default"},
Spec: &meshmultizoneservice_api.MeshMultiZoneService{
Selector: meshmultizoneservice_api.Selector{},
Selector: meshmultizoneservice_api.Selector{
MeshService: meshmultizoneservice_api.MeshServiceSelector{
MatchLabels: map[string]string{
"service": "backend",
},
},
},
Ports: []meshmultizoneservice_api.Port{{
Port: 80,
AppProtocol: core_mesh.ProtocolHTTP,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ resources:
- matcher:
exact: spiffe://default/backend
sanType: URI
- matcher:
exact: spiffe://default/other-backend
sanType: URI
validationContextSdsSecretConfig:
name: mesh_ca:secret:default
sdsConfig:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,19 @@ resources:
resource:
'@type': type.googleapis.com/envoy.config.endpoint.v3.ClusterLoadAssignment
clusterName: default_multi-backend___mzsvc_80
endpoints:
- lbEndpoints:
- endpoint:
address:
socketAddress:
address: 192.168.0.4
portValue: 8084
loadBalancingWeight: 1
metadata:
filterMetadata:
envoy.lb:
app: backend
kuma.io/protocol: http
envoy.transport_socket_match:
app: backend
kuma.io/protocol: http

0 comments on commit b42cf6a

Please sign in to comment.