Skip to content

Commit

Permalink
test(e2e): test filtered ExternalService with MeshGateway
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Beaumont <mjboamail@gmail.com>
  • Loading branch information
michaelbeaumont committed Oct 24, 2022
1 parent 457808e commit 1b3202a
Showing 1 changed file with 43 additions and 1 deletion.
44 changes: 43 additions & 1 deletion test/e2e_env/kubernetes/gateway/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,14 @@ spec:
testserver.WithEchoArgs("echo", "--instance", "es-echo-server"),
)).
Install(YamlK8s(externalService)).
Install(YamlK8s(route("es-echo-server", "/external-service", "external-service"))).
Setup(env.Cluster)
Expect(err).ToNot(HaveOccurred())
})

It("should proxy to service via HTTP", func() {
setup := NewClusterSetup().Install(YamlK8s(route("es-echo-server", "/external-service", "external-service")))
Expect(setup.Setup(env.Cluster)).To(Succeed())

Eventually(func(g Gomega) {
response, err := client.CollectResponse(
env.Cluster, "demo-client",
Expand All @@ -240,5 +242,45 @@ spec:
g.Expect(response.Instance).To(Equal("es-echo-server"))
}, "30s", "1s").Should(Succeed())
})

It("should handle external-service excluded by tags", func() {
route := fmt.Sprintf(`
apiVersion: kuma.io/v1alpha1
kind: MeshGatewayRoute
metadata:
name: %s
mesh: simple-gateway
spec:
selectors:
- match:
kuma.io/service: simple-gateway
conf:
http:
rules:
- matches:
- path:
match: PREFIX
value: %s
backends:
- destination:
kuma.io/service: %s
nonexistent: tag
`, "es-echo-server", "/external-service", "external-service")

setup := NewClusterSetup().Install(YamlK8s(route))
Expect(setup.Setup(env.Cluster)).To(Succeed())

Eventually(func(g Gomega) {
response, err := client.CollectFailure(
env.Cluster, "demo-client",
"http://simple-gateway.simple-gateway:8080/external-service",
client.WithHeader("host", "example.kuma.io"),
client.FromKubernetesPod(clientNamespace, "demo-client"),
)

g.Expect(err).ToNot(HaveOccurred())
g.Expect(response.ResponseCode).To(Equal(503))
}, "30s", "1s").Should(Succeed())
})
})
}

0 comments on commit 1b3202a

Please sign in to comment.