Skip to content

Commit 0277eb3

Browse files
committed
fix tests
Signed-off-by: Guy Daich <guy.daich@sap.com>
1 parent 4931a46 commit 0277eb3

4 files changed

Lines changed: 65 additions & 67 deletions

File tree

.claude/settings.local.json

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
apiVersion: gateway.networking.k8s.io/v1
2+
kind: HTTPRoute
3+
metadata:
4+
name: http-with-hc-event-log
5+
namespace: gateway-conformance-infra
6+
spec:
7+
parentRefs:
8+
- name: hc-event-log-gtw
9+
rules:
10+
- matches:
11+
- path:
12+
type: PathPrefix
13+
value: /hc-event-log
14+
backendRefs:
15+
- name: infra-backend-v1
16+
port: 8080
17+
---
18+
# BTP with an intentionally failing health check (/status/418 never returns 200).
19+
# With no matches set (log everything), every probe cycle produces a failure
20+
# event logged to stdout, which Loki collects and the test can assert against.
21+
apiVersion: gateway.envoyproxy.io/v1alpha1
22+
kind: BackendTrafficPolicy
23+
metadata:
24+
name: hc-event-log-btp
25+
namespace: gateway-conformance-infra
26+
spec:
27+
targetRefs:
28+
- group: gateway.networking.k8s.io
29+
kind: HTTPRoute
30+
name: http-with-hc-event-log
31+
healthCheck:
32+
active:
33+
timeout: 3s
34+
interval: 5s
35+
unhealthyThreshold: 3
36+
healthyThreshold: 1
37+
type: HTTP
38+
http:
39+
path: "/status/418"
40+
expectedStatuses:
41+
- 200

test/e2e/testdata/backend-health-check-event-log.yaml

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -49,45 +49,3 @@ spec:
4949
backendRefs:
5050
- name: infra-backend-v1
5151
port: 8080
52-
---
53-
apiVersion: gateway.networking.k8s.io/v1
54-
kind: HTTPRoute
55-
metadata:
56-
name: http-with-hc-event-log
57-
namespace: gateway-conformance-infra
58-
spec:
59-
parentRefs:
60-
- name: hc-event-log-gtw
61-
rules:
62-
- matches:
63-
- path:
64-
type: PathPrefix
65-
value: /hc-event-log
66-
backendRefs:
67-
- name: infra-backend-v1
68-
port: 8080
69-
---
70-
# BTP with an intentionally failing health check (/status/418 never returns 200).
71-
# With no matches set (log everything), every probe cycle produces a failure
72-
# event logged to stdout, which Loki collects and the test can assert against.
73-
apiVersion: gateway.envoyproxy.io/v1alpha1
74-
kind: BackendTrafficPolicy
75-
metadata:
76-
name: hc-event-log-btp
77-
namespace: gateway-conformance-infra
78-
spec:
79-
targetRefs:
80-
- group: gateway.networking.k8s.io
81-
kind: HTTPRoute
82-
name: http-with-hc-event-log
83-
healthCheck:
84-
active:
85-
timeout: 3s
86-
interval: 5s
87-
unhealthyThreshold: 3
88-
healthyThreshold: 1
89-
type: HTTP
90-
http:
91-
path: "/status/418"
92-
expectedStatuses:
93-
- 200

test/e2e/tests/backend_health_check.go

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -270,24 +270,11 @@ var BackendHealthCheckEventLogTest = suite.ConformanceTest{
270270
Test: func(t *testing.T, suite *suite.ConformanceTestSuite) {
271271
ns := "gateway-conformance-infra"
272272
noHCRouteNN := types.NamespacedName{Name: "http-without-hc-event-log", Namespace: ns}
273-
hcRouteNN := types.NamespacedName{Name: "http-with-hc-event-log", Namespace: ns}
274273
gwNN := types.NamespacedName{Name: "hc-event-log-gtw", Namespace: ns}
275274

276275
gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(
277276
t, suite.Client, suite.TimeoutConfig, suite.ControllerName,
278-
kubernetes.NewGatewayRef(gwNN), noHCRouteNN, hcRouteNN,
279-
)
280-
281-
ancestorRef := gwapiv1.ParentReference{
282-
Group: gatewayapi.GroupPtr(gwapiv1.GroupName),
283-
Kind: gatewayapi.KindPtr(resource.KindGateway),
284-
Namespace: gatewayapi.NamespacePtr(gwNN.Namespace),
285-
Name: gwapiv1.ObjectName(gwNN.Name),
286-
}
287-
BackendTrafficPolicyMustBeAccepted(
288-
t, suite.Client,
289-
types.NamespacedName{Name: "hc-event-log-btp", Namespace: ns},
290-
suite.ControllerName, ancestorRef,
277+
kubernetes.NewGatewayRef(gwNN), noHCRouteNN,
291278
)
292279

293280
gatewayNS := GetGatewayResourceNamespace()
@@ -297,10 +284,9 @@ var BackendHealthCheckEventLogTest = suite.ConformanceTest{
297284
"container": "envoy",
298285
}
299286

300-
// Phase 1: route without health checks — confirm no HC events exist yet.
287+
// Phase 1: only the no-HC route is live — no BTP means no health check
288+
// probes are running, so Loki must have zero HC events.
301289
t.Run("no health check events before HC route is active", func(t *testing.T) {
302-
// Send a few requests through the non-HC route to confirm it is reachable,
303-
// then verify Loki has not recorded any HC events.
304290
http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr, http.ExpectedResponse{
305291
Request: http.Request{Path: "/no-hc-event-log"},
306292
Response: http.Response{StatusCodes: []int{200}},
@@ -312,7 +298,27 @@ var BackendHealthCheckEventLogTest = suite.ConformanceTest{
312298
require.Equal(t, 0, count, "expected no HC events before HC-enabled route is active")
313299
})
314300

315-
// Phase 2: the HC-enabled route is already accepted; wait for events to appear.
301+
// Phase 2: apply the HC-enabled route and BTP, then wait for events.
302+
hcRouteNN := types.NamespacedName{Name: "http-with-hc-event-log", Namespace: ns}
303+
suite.Applier.MustApplyWithCleanup(t, suite.Client, suite.TimeoutConfig, "testdata/backend-health-check-event-log-hc.yaml", true)
304+
305+
kubernetes.GatewayAndHTTPRoutesMustBeAccepted(
306+
t, suite.Client, suite.TimeoutConfig, suite.ControllerName,
307+
kubernetes.NewGatewayRef(gwNN), hcRouteNN,
308+
)
309+
310+
ancestorRef := gwapiv1.ParentReference{
311+
Group: gatewayapi.GroupPtr(gwapiv1.GroupName),
312+
Kind: gatewayapi.KindPtr(resource.KindGateway),
313+
Namespace: gatewayapi.NamespacePtr(gwNN.Namespace),
314+
Name: gwapiv1.ObjectName(gwNN.Name),
315+
}
316+
BackendTrafficPolicyMustBeAccepted(
317+
t, suite.Client,
318+
types.NamespacedName{Name: "hc-event-log-btp", Namespace: ns},
319+
suite.ControllerName, ancestorRef,
320+
)
321+
316322
t.Run("health check events appear in logs", func(t *testing.T) {
317323
http.AwaitConvergence(
318324
t,

0 commit comments

Comments
 (0)