Skip to content

Commit 5f3e401

Browse files
Foo BarCopilot
andcommitted
test(e2e): fix TLS test retry with RequestAssert
The 'ApisixTls and Ingress with same certificate but different hosts' test was consistently failing due to two compounding issues: 1. Control-plane / data-plane propagation delay: the control plane confirms the api7.com SSL object, but APISIX data plane may not have loaded it yet when the HTTPS request is made. 2. Non-retryable Eventually block: NewAPISIXHttpsClient uses GinkgoT() as the httpexpect reporter. On TLS error, httpexpect calls GinkgoT().Fatalf() -> runtime.Goexit(), which exits the goroutine immediately. gomega's Eventually cannot retry because the goroutine is gone. Fix: replace the raw Eventually+httpexpect blocks with s.RequestAssert, which already exists in the scaffold and uses ErrorReporter (stores errors instead of calling FailNow). Transient TLS errors are now returned as retryable errors, letting Eventually poll until the data plane is fully ready. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 65b8f1d commit 5f3e401

4 files changed

Lines changed: 19 additions & 71 deletions

File tree

Makefile

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ kind-down:
194194
|| echo "kind cluster does not exist"
195195

196196
.PHONY: kind-load-images
197-
kind-load-images: pull-infra-images build-e2e-echo-server-image kind-load-ingress-image kind-load-adc-image
197+
kind-load-images: pull-infra-images kind-load-ingress-image kind-load-adc-image
198198
@kind load docker-image hkccr.ccs.tencentyun.com/api7-dev/api7-ee-3-gateway:dev --name $(KIND_NAME)
199199
@kind load docker-image hkccr.ccs.tencentyun.com/api7-dev/api7-ee-dp-manager:$(DASHBOARD_VERSION) --name $(KIND_NAME)
200200
@kind load docker-image hkccr.ccs.tencentyun.com/api7-dev/api7-ee-3-integrated:$(DASHBOARD_VERSION) --name $(KIND_NAME)
@@ -222,17 +222,13 @@ kind-load-adc-image:
222222
@docker tag ghcr.io/api7/adc:$(ADC_VERSION) ghcr.io/api7/adc:dev
223223
@kind load docker-image ghcr.io/api7/adc:dev --name $(KIND_NAME)
224224

225-
.PHONY: build-e2e-echo-server-image
226-
build-e2e-echo-server-image:
227-
@CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/e2e-echo-server ./cmd/e2e-echo-server
228-
@docker build -f test/e2e/images/echo-server.Dockerfile -t jmalloc/echo-server:latest .
229-
230225
.PHONY: pull-infra-images
231226
pull-infra-images:
232227
@docker pull hkccr.ccs.tencentyun.com/api7-dev/api7-ee-3-gateway:dev
233228
@docker pull hkccr.ccs.tencentyun.com/api7-dev/api7-ee-dp-manager:$(DASHBOARD_VERSION)
234229
@docker pull hkccr.ccs.tencentyun.com/api7-dev/api7-ee-3-integrated:$(DASHBOARD_VERSION)
235230
@docker pull kennethreitz/httpbin:latest
231+
@docker pull jmalloc/echo-server:latest
236232
@docker pull ghcr.io/api7/adc:dev
237233
@docker pull apache/apisix:dev
238234
@docker pull openresty/openresty:1.27.1.2-4-bullseye-fat

cmd/e2e-echo-server/main.go

Lines changed: 0 additions & 44 deletions
This file was deleted.

test/e2e/crds/v2/tls.go

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -424,22 +424,25 @@ spec:
424424
assert.True(GinkgoT(), sniFound["api7.com"], "api7.com should be in SNIs")
425425

426426
By("test HTTPS request to api6.com")
427-
Eventually(func() int {
428-
return s.NewAPISIXHttpsClient("api6.com").
429-
GET("/get").
430-
WithHost("api6.com").
431-
Expect().
432-
Raw().StatusCode
433-
}).WithTimeout(30 * time.Second).ProbeEvery(1 * time.Second).Should(Equal(http.StatusOK))
427+
s.RequestAssert(&scaffold.RequestAssert{
428+
Client: s.NewAPISIXHttpsClient("api6.com"),
429+
Path: "/get",
430+
Host: "api6.com",
431+
Checks: []scaffold.ResponseCheckFunc{scaffold.WithExpectedStatus(http.StatusOK)},
432+
Timeout: 30 * time.Second,
433+
})
434434

435435
By("test HTTPS request to api7.com")
436-
Eventually(func() int {
437-
return s.NewAPISIXHttpsClient("api7.com").
438-
GET("/get").
439-
WithHost("api7.com").
440-
Expect().
441-
Raw().StatusCode
442-
}).WithTimeout(30 * time.Second).ProbeEvery(1 * time.Second).Should(Equal(http.StatusOK))
436+
// Use RequestAssert so that transient TLS errors while the data plane
437+
// is loading the freshly-created SSL object are retried via ErrorReporter
438+
// instead of causing an immediate fatal failure through GinkgoT().
439+
s.RequestAssert(&scaffold.RequestAssert{
440+
Client: s.NewAPISIXHttpsClient("api7.com"),
441+
Path: "/get",
442+
Host: "api7.com",
443+
Checks: []scaffold.ResponseCheckFunc{scaffold.WithExpectedStatus(http.StatusOK)},
444+
Timeout: 30 * time.Second,
445+
})
443446
})
444447

445448
})

test/e2e/images/echo-server.Dockerfile

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)