Skip to content

Commit 83600d7

Browse files
authored
test: make rate limit e2e less flaky (envoyproxy#1452)
**Description** Since envoyproxy#1410, the deployment created by EG for the rate limit server is in crashing loop until redis server is up and running in the rate limit e2e test setup, which caused a bit of flake in the test. This fixes it by restarting the deployment just in case. This also removes the only remaining use of t.Context in test cleanup function in e2e tests. Signed-off-by: Takeshi Yoneda <[email protected]>
1 parent def5109 commit 83600d7

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ HELM_CHART_VERSION ?= v0.0.0-latest
3232
# `GO_TEST_ARGS="-run TestName/foo/etc -v -race"`.
3333
GO_TEST_ARGS ?=
3434
# Arguments for go test in e2e tests in addition to GO_TEST_ARGS, applicable to test-e2e, test-extproc, and test-controller.
35-
GO_TEST_E2E_ARGS ?= -count=1
35+
GO_TEST_E2E_ARGS ?= -count=1 -timeout 30m
3636

3737
## help: Show this help info.
3838
.PHONY: help
@@ -200,7 +200,7 @@ test-e2e-namespaced: build-e2e
200200
.PHONY: test-e2e-aigw
201201
test-e2e-aigw: build.aigw ## Run the end-to-end tests for the aigw CLI.
202202
@echo "Run aigw CLI E2E tests"
203-
@go test -v ./tests/e2e-aigw/... -timeout 30m $(GO_TEST_E2E_ARGS)
203+
@go test -v ./tests/e2e-aigw/... $(GO_TEST_E2E_ARGS)
204204

205205
##@ Common
206206

tests/e2e/cross_namespace_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func TestCrossNamespace(t *testing.T) {
2828
const manifest = "testdata/cross_namespace.yaml"
2929
require.NoError(t, e2elib.KubectlApplyManifest(t.Context(), manifest))
3030
t.Cleanup(func() {
31-
_ = e2elib.KubectlDeleteManifest(t.Context(), manifest)
31+
_ = e2elib.KubectlDeleteManifest(context.Background(), manifest)
3232
})
3333

3434
// Wait for the Gateway pod to be ready with the correct selector.

tests/e2e/token_ratelimit_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ func Test_Examples_TokenRateLimit(t *testing.T) {
5555
e2elib.RequireWaitForGatewayPodReady(t, egSelector)
5656

5757
// Wait for the redis pod to be ready so that the rate limit can be performed correctly.
58+
// Until the redis pod is ready, envoy-ratelimit deployment will be in CrashLoopBackOff, so restart it so
59+
// we can have it up and running faster in a clean state.
60+
require.NoError(t, e2elib.KubectlRestartDeployment(t.Context(), e2elib.EnvoyGatewayNamespace, "envoy-ratelimit"))
5861
e2elib.RequireWaitForPodReady(t, e2elib.EnvoyGatewayNamespace, "app.kubernetes.io/component=ratelimit")
5962
e2elib.RequireWaitForPodReady(t, "redis-system", "app=redis")
6063

tests/internal/e2elib/e2elib.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ func InstallOrUpgradeAIGateway(ctx context.Context, aigw AIGatewayHelmOption) (e
458458
}
459459
// Restart the controller to pick up the new changes in the AI Gateway.
460460
initLog("\tRestart AI Gateway controller")
461-
if err = kubectlRestartDeployment(ctx, "envoy-ai-gateway-system", "ai-gateway-controller"); err != nil {
461+
if err = KubectlRestartDeployment(ctx, "envoy-ai-gateway-system", "ai-gateway-controller"); err != nil {
462462
return
463463
}
464464
return kubectlWaitForDeploymentReady(ctx, "envoy-ai-gateway-system", "ai-gateway-controller")
@@ -505,7 +505,7 @@ func KubectlDeleteManifest(ctx context.Context, manifest string) (err error) {
505505
return cmd.Run()
506506
}
507507

508-
func kubectlRestartDeployment(ctx context.Context, namespace, deployment string) error {
508+
func KubectlRestartDeployment(ctx context.Context, namespace, deployment string) error {
509509
cmd := Kubectl(ctx, "rollout", "restart", "deployment/"+deployment, "-n", namespace)
510510
return cmd.Run()
511511
}

0 commit comments

Comments
 (0)