Skip to content

Commit

Permalink
chore(debug): try reproducing es flake
Browse files Browse the repository at this point in the history
Signed-off-by: slonka <slonka@users.noreply.github.com>
  • Loading branch information
slonka committed Sep 25, 2024
1 parent 77a95fa commit 64da2bc
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-test-distribute.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
uses: ./.github/workflows/_test.yaml
with:
FULL_MATRIX: ${{ needs.check.outputs.FULL_MATRIX }}
RUNNERS_BY_ARCH: ${{ (github.event_name == 'push' || github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) && '{"amd64":"ubuntu-latest-kong","arm64":"ubuntu-latest-arm64-kong"}' || '{"amd64":"ubuntu-latest","arm64":""}' }}
RUNNERS_BY_ARCH: ${{ (github.event_name == 'push' || github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) && '{"amd64":"ubuntu-latest-kong","arm64":"ubuntu-latest-arm64-kong"}' || '{"amd64":"ubuntu-latest-kong","arm64":""}' }}
secrets: inherit
build_publish:
permissions:
Expand Down
45 changes: 24 additions & 21 deletions test/e2e_env/kubernetes/externalservices/externalservices.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package externalservices

import (
"fmt"
"github.com/google/uuid"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand All @@ -14,15 +15,17 @@ import (
)

func ExternalServices() {
meshName := "external-services"
namespace := "external-services"
clientNamespace := "client-external-services"
id := uuid.NewString()
meshName := "external-services" + id
esService := "external-service" + id
namespace := "external-services" + id
clientNamespace := "client-external-services" + id

mesh := `
apiVersion: kuma.io/v1alpha1
kind: Mesh
metadata:
name: external-services
name: %s
spec:
mtls:
enabledBackend: ca-1
Expand All @@ -35,8 +38,8 @@ spec:
routing:
zoneEgress: true
`
meshPassthroughEnabled := fmt.Sprintf(mesh, "true")
meshPassthroughDisabled := fmt.Sprintf(mesh, "false")
meshPassthroughEnabled := fmt.Sprintf(mesh, meshName, "true")
meshPassthroughDisabled := fmt.Sprintf(mesh, meshName, "false")

BeforeAll(func() {
err := NewClusterSetup().
Expand All @@ -59,24 +62,24 @@ spec:
})

Context("non-TLS", func() {
externalService := `
externalService := fmt.Sprintf(`
apiVersion: kuma.io/v1alpha1
kind: ExternalService
mesh: external-services
mesh: %s
metadata:
name: external-service-1
spec:
tags:
kuma.io/service: external-service
kuma.io/service: %s
kuma.io/protocol: http
networking:
address: external-service.external-services.svc.cluster.local:80 # .svc.cluster.local is needed, otherwise Kubernetes will resolve this to the real IP
`
address: external-service.%s.svc.cluster.local:80 # .svc.cluster.local is needed, otherwise Kubernetes will resolve this to the real IP
`, meshName, esService, namespace)

trafficPermission := `
trafficPermission := fmt.Sprintf(`
apiVersion: kuma.io/v1alpha1
kind: TrafficPermission
mesh: external-services
mesh: %s
metadata:
name: traffic-to-es
spec:
Expand All @@ -85,8 +88,8 @@ spec:
kuma.io/service: '*'
destinations:
- match:
kuma.io/service: external-service
`
kuma.io/service: %s
`, meshName, esService)

BeforeAll(func() {
err := kubernetes.Cluster.Install(testserver.Install(
Expand All @@ -96,11 +99,11 @@ spec:
Expect(err).ToNot(HaveOccurred())
})

It("should route to external-service", func() {
FIt("should route to external-service", func() {
// given working communication outside the mesh with passthrough enabled and no traffic permission
Eventually(func(g Gomega) {
_, err := client.CollectEchoResponse(
kubernetes.Cluster, "demo-client", "external-service.external-services",
kubernetes.Cluster, "demo-client", fmt.Sprintf("external-service.%s", namespace),
client.FromKubernetesPod(clientNamespace, "demo-client"),
)
g.Expect(err).ToNot(HaveOccurred())
Expand All @@ -112,7 +115,7 @@ spec:
// then accessing the external service is no longer possible
Eventually(func(g Gomega) {
response, err := client.CollectFailure(
kubernetes.Cluster, "demo-client", "external-service.external-services",
kubernetes.Cluster, "demo-client", fmt.Sprintf("external-service.%s", namespace),
client.FromKubernetesPod(clientNamespace, "demo-client"),
)
g.Expect(err).ToNot(HaveOccurred())
Expand All @@ -125,7 +128,7 @@ spec:
// then traffic is still blocked because of lack of the traffic permission
Eventually(func(g Gomega) {
response, err := client.CollectFailure(
kubernetes.Cluster, "demo-client", "external-service.external-services",
kubernetes.Cluster, "demo-client", fmt.Sprintf("external-service.%s", namespace),
client.FromKubernetesPod(clientNamespace, "demo-client"),
)
g.Expect(err).ToNot(HaveOccurred())
Expand All @@ -138,7 +141,7 @@ spec:
// then you can access external service again
Eventually(func(g Gomega) {
_, err := client.CollectEchoResponse(
kubernetes.Cluster, "demo-client", "external-service.external-services",
kubernetes.Cluster, "demo-client", fmt.Sprintf("external-service.%s", namespace),
client.FromKubernetesPod(clientNamespace, "demo-client"),
)
g.Expect(err).ToNot(HaveOccurred())
Expand All @@ -147,7 +150,7 @@ spec:
// and you can also use .mesh on port of the provided host
Eventually(func(g Gomega) {
_, err := client.CollectEchoResponse(
kubernetes.Cluster, "demo-client", "external-service.mesh",
kubernetes.Cluster, "demo-client", fmt.Sprintf("%s.mesh", esService),
client.FromKubernetesPod(clientNamespace, "demo-client"),
)
g.Expect(err).ToNot(HaveOccurred())
Expand Down
2 changes: 1 addition & 1 deletion test/e2e_env/kubernetes/kubernetes_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ var (
_ = Describe("K8S API Bypass", k8s_api_bypass.K8sApiBypass, Ordered)
_ = Describe("Reachable Services", reachableservices.ReachableServices, Ordered)
_ = Describe("Defaults", defaults.Defaults, Ordered)
_ = Describe("External Services", externalservices.ExternalServices, Ordered)
_ = FDescribe("External Services", externalservices.ExternalServices, Ordered)
_ = Describe("External Services Permissive MTLS", externalservices.PermissiveMTLS, Ordered)
_ = Describe("Mesh External Services", meshexternalservices.MeshExternalServices, Ordered)
_ = Describe("ExternalName Services", externalname_services.ExternalNameServices, Ordered)
Expand Down

0 comments on commit 64da2bc

Please sign in to comment.