Skip to content

Commit

Permalink
test(e2e): remove unused mesh (#12308)
Browse files Browse the repository at this point in the history
## Motivation

We support `MeshExternalService` only with egress enabled so there was
no point to create use a different mesh for this case.

## Implementation information

We use the same `Mesh` for all tests; we just changed it to disable
traffic for MeshExternalService.

## Supporting documentation

<!-- Is there a MADR? An Issue? A related PR? -->

Fix #XX

<!--
> Changelog: skip
-->
<!--
Uncomment the above section to explicitly set a [`> Changelog:` entry
here](https://github.com/kumahq/kuma/blob/master/CONTRIBUTING.md#submitting-a-patch)?
-->

Signed-off-by: Lukasz Dziedziak <[email protected]>
  • Loading branch information
lukidzi authored Dec 18, 2024
1 parent 2d9ac8c commit 0bce68a
Showing 1 changed file with 34 additions and 34 deletions.
68 changes: 34 additions & 34 deletions test/e2e_env/kubernetes/meshexternalservice/meshexternalservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (

func MeshExternalServices() {
meshName := "mesh-external-services"
meshNameEgress := "mesh-external-services-egress"
namespace := "mesh-external-services"
clientNamespace := "client-mesh-external-services"

Expand All @@ -28,17 +27,9 @@ func MeshExternalServices() {
Install(YamlK8s(samples.MeshMTLSBuilder().
WithName(meshName).
WithEgressRoutingEnabled().KubeYaml())).
Install(YamlK8s(samples.MeshMTLSBuilder().
WithName(meshNameEgress).
WithoutPassthrough().
WithMeshExternalServiceTrafficForbidden().
WithEgressRoutingEnabled().KubeYaml())).
Install(Namespace(namespace)).
Install(NamespaceWithSidecarInjection(clientNamespace)).
Install(Parallel(
democlient.Install(democlient.WithNamespace(clientNamespace), democlient.WithMesh(meshName)),
democlient.Install(democlient.WithNamespace(clientNamespace), democlient.WithName("demo-client-egress"), democlient.WithMesh(meshNameEgress)),
)).
Install(democlient.Install(democlient.WithNamespace(clientNamespace), democlient.WithMesh(meshName))).
Setup(kubernetes.Cluster)
Expect(err).ToNot(HaveOccurred())
})
Expand Down Expand Up @@ -124,7 +115,7 @@ spec:
apiVersion: kuma.io/v1alpha1
kind: MeshExternalService
metadata:
name: mesh-external-service-egress
name: mesh-external-service-rbac
namespace: %s
labels:
kuma.io/mesh: %s
Expand All @@ -135,60 +126,69 @@ spec:
port: 80
protocol: http
endpoints:
- address: external-service-egress.mesh-external-services.svc.cluster.local
- address: external-service-rbac.mesh-external-services.svc.cluster.local
port: 80
`, Config.KumaNamespace, meshNameEgress)
`, Config.KumaNamespace, meshName)

filter := fmt.Sprintf(
"cluster.%s_%s_%s_default_extsvc_80.upstream_rq_total",
meshNameEgress,
"mesh-external-service-egress",
meshName,
"mesh-external-service-rbac",
Config.KumaNamespace,
)
BeforeAll(func() {
err := kubernetes.Cluster.Install(testserver.Install(
testserver.WithNamespace(namespace),
testserver.WithName("external-service-egress"),
testserver.WithName("external-service-rbac"),
))
Expect(err).ToNot(HaveOccurred())
})

AfterAll(func() {
Expect(kubernetes.Cluster.Install(YamlK8s(
samples.MeshMTLSBuilder().
WithName(meshName).
WithEgressRoutingEnabled().KubeYaml()),
)).To(Succeed())
})

It("should route to external-service", func() {
// when apply external service and hostname generator
Expect(kubernetes.Cluster.Install(YamlK8s(meshExternalService))).To(Succeed())

// then traffic doesn't work because of missing MeshTrafficPermission
// then traffic work
Eventually(func(g Gomega) {
response, err := client.CollectFailure(
kubernetes.Cluster, "demo-client-egress", "mesh-external-service-egress.extsvc.mesh.local",
client.FromKubernetesPod(clientNamespace, "demo-client-egress"),
_, err := client.CollectEchoResponse(
kubernetes.Cluster, "demo-client", "mesh-external-service-rbac.extsvc.mesh.local",
client.FromKubernetesPod(clientNamespace, "demo-client"),
)
g.Expect(err).ToNot(HaveOccurred())
g.Expect(response.ResponseCode).To(Equal(403))
}, "30s", "1s").Should(Succeed())

// when allow all traffic
// and flows through Egress
Eventually(func(g Gomega) {
stat, err := kubernetes.Cluster.GetZoneEgressEnvoyTunnel().GetStats(filter)
g.Expect(err).ToNot(HaveOccurred())
g.Expect(stat).To(stats.BeGreaterThanZero())
}, "30s", "1s").Should(Succeed())

// when disable all traffic
Expect(kubernetes.Cluster.Install(YamlK8s(
samples.MeshMTLSBuilder().
WithName(meshNameEgress).
WithName(meshName).
WithoutPassthrough().
WithMeshExternalServiceTrafficForbidden().
WithEgressRoutingEnabled().KubeYaml()),
)).To(Succeed())

// then traffic works
// then traffic doesn't work
Eventually(func(g Gomega) {
_, err := client.CollectEchoResponse(
kubernetes.Cluster, "demo-client-egress", "mesh-external-service-egress.extsvc.mesh.local",
client.FromKubernetesPod(clientNamespace, "demo-client-egress"),
response, err := client.CollectFailure(
kubernetes.Cluster, "demo-client", "mesh-external-service-rbac.extsvc.mesh.local",
client.FromKubernetesPod(clientNamespace, "demo-client"),
)
g.Expect(err).ToNot(HaveOccurred())
}, "30s", "1s").Should(Succeed())

// and flows through Egress
Eventually(func(g Gomega) {
stat, err := kubernetes.Cluster.GetZoneEgressEnvoyTunnel().GetStats(filter)
g.Expect(err).ToNot(HaveOccurred())
g.Expect(stat).To(stats.BeGreaterThanZero())
g.Expect(response.ResponseCode).To(Equal(403))
}, "30s", "1s").Should(Succeed())
})
})
Expand Down

0 comments on commit 0bce68a

Please sign in to comment.