Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(e2e): use MeshService mode and generated hostname (backport of #11832) #11834

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions test/e2e_env/universal/meshhealthcheck/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

mesh_proto "github.com/kumahq/kuma/api/mesh/v1alpha1"
"github.com/kumahq/kuma/pkg/core/resources/apis/mesh"
"github.com/kumahq/kuma/pkg/test/resources/samples"
. "github.com/kumahq/kuma/test/framework"
"github.com/kumahq/kuma/test/framework/client"
"github.com/kumahq/kuma/test/framework/envs/universal"
Expand Down Expand Up @@ -55,12 +57,18 @@
Expect(err).ToNot(HaveOccurred())
})

<<<<<<< HEAD

Check failure on line 60 in test/e2e_env/universal/meshhealthcheck/policy.go

View workflow job for this annotation

GitHub Actions / lint

syntax error: unexpected <<, expected }
=======
AfterEachFailure(func() {

Check failure on line 62 in test/e2e_env/universal/meshhealthcheck/policy.go

View workflow job for this annotation

GitHub Actions / lint

syntax error: unexpected { at end of statement
DebugUniversal(universal.Cluster, meshName)
})

Check failure on line 64 in test/e2e_env/universal/meshhealthcheck/policy.go

View workflow job for this annotation

GitHub Actions / lint

syntax error: unexpected ) after top level declaration

E2EAfterAll(func() {

Check failure on line 66 in test/e2e_env/universal/meshhealthcheck/policy.go

View workflow job for this annotation

GitHub Actions / lint

method has no receiver

Check failure on line 66 in test/e2e_env/universal/meshhealthcheck/policy.go

View workflow job for this annotation

GitHub Actions / lint

syntax error: unexpected {, expected name
Expect(universal.Cluster.DeleteMeshApps(meshName)).To(Succeed())
Expect(universal.Cluster.DeleteMesh(meshName)).To(Succeed())
})

Check failure on line 69 in test/e2e_env/universal/meshhealthcheck/policy.go

View workflow job for this annotation

GitHub Actions / lint

syntax error: unexpected ) after top level declaration

It("should mark host as unhealthy if it doesn't reply on health checks", func() {

Check failure on line 71 in test/e2e_env/universal/meshhealthcheck/policy.go

View workflow job for this annotation

GitHub Actions / lint

method has no receiver

Check failure on line 71 in test/e2e_env/universal/meshhealthcheck/policy.go

View workflow job for this annotation

GitHub Actions / lint

syntax error: unexpected {, expected name
// check that test-server is healthy
Eventually(func(g Gomega) {
stdout, _, err := client.CollectResponse(
Expand Down Expand Up @@ -89,9 +97,93 @@
g.Expect(err).ToNot(HaveOccurred())
g.Expect(response.ResponseCode).To(Equal(503))
}).Should(Succeed())
})

Check failure on line 100 in test/e2e_env/universal/meshhealthcheck/policy.go

View workflow job for this annotation

GitHub Actions / lint

syntax error: unexpected ) after top level declaration
}, Ordered)

Describe("HTTP to real MeshService", func() {
meshName := "meshhealthcheck-http-ms"
healthCheck := func(mesh, method, status string) string {
return fmt.Sprintf(`
type: MeshHealthCheck
mesh: %s
name: everything-to-backend
spec:
to:
- targetRef:
kind: MeshService
name: test-server
default:
interval: 10s
timeout: 2s
unhealthyThreshold: 3
healthyThreshold: 1
failTrafficOnPanic: true
noTrafficInterval: 1s
healthyPanicThreshold: 0
reuseConnection: true
http:
path: /%s
expectedStatuses:
- %s`, mesh, method, status)
}

BeforeAll(func() {
err := NewClusterSetup().
Install(Yaml(samples.MeshDefaultBuilder().
WithName(meshName).
WithMeshServicesEnabled(mesh_proto.Mesh_MeshServices_Exclusive),
)).
Install(YamlUniversal(healthCheck(meshName, "health", "200"))).
Install(DemoClientUniversal("dp-demo-client", meshName,
WithTransparentProxy(true)),
).
Install(TestServerUniversal("test-server", meshName, WithArgs([]string{"health-check", "http"}), WithProtocol(mesh.ProtocolHTTP))).
Setup(universal.Cluster)
Expect(err).ToNot(HaveOccurred())
})

AfterEachFailure(func() {
DebugUniversal(universal.Cluster, meshName)
})

>>>>>>> 07ac2c772 (test(e2e): use MeshService mode and generated hostname (#11832))
E2EAfterAll(func() {
Expect(universal.Cluster.DeleteMeshApps(meshName)).To(Succeed())
Expect(universal.Cluster.DeleteMesh(meshName)).To(Succeed())
})

It("should mark host as unhealthy if it doesn't reply on health checks", func() {
// check that test-server is healthy
Eventually(func(g Gomega) {
stdout, _, err := client.CollectResponse(
universal.Cluster, "dp-demo-client", "test-server.svc.mesh.local/content",
)
g.Expect(err).ToNot(HaveOccurred())
g.Expect(stdout).To(ContainSubstring("response"))
}).Should(Succeed())

// update HealthCheck policy to check for another status code
Expect(YamlUniversal(healthCheck(meshName, "are-you-healthy", "500"))(universal.Cluster)).To(Succeed())

// wait cluster 'test-server' to be marked as unhealthy
Eventually(func(g Gomega) {
cmd := []string{"/bin/bash", "-c", "\"curl localhost:9901/clusters | grep test-server\""}
stdout, _, err := universal.Cluster.Exec("", "", "dp-demo-client", cmd...)
g.Expect(err).ToNot(HaveOccurred())
g.Expect(stdout).To(ContainSubstring("health_flags::/failed_active_hc"))
}, "30s", "500ms").Should(Succeed())

// check that test-server is unhealthy
Consistently(func(g Gomega) {
response, err := client.CollectFailure(
universal.Cluster, "dp-demo-client", "test-server.svc.mesh.local/content",
)
g.Expect(err).ToNot(HaveOccurred())
g.Expect(response.ResponseCode).To(Equal(503))
}).Should(Succeed())
})
}, Ordered)

Describe("TCP", func() {
healthCheck := func(mesh, serviceName, send, recv string) string {
sendBase64 := base64.StdEncoding.EncodeToString([]byte(send))
Expand Down
Loading