Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test/e2e/gateway: check service as part of request condition (project…
Browse files Browse the repository at this point in the history
…contour#6251)

For the RequestHeaderModifierBackendRef test, check
the service reached by the request as part of the
eventual consistency condition to avoid issues with
test pollution.

Signed-off-by: Steve Kriss <stephen.kriss@gmail.com>
skriss authored and lubronzhan committed Mar 13, 2024
1 parent 9f42e3a commit c758cd0
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions test/e2e/gateway/request_header_modifier_test.go
Original file line number Diff line number Diff line change
@@ -92,13 +92,18 @@ func testRequestHeaderModifierBackendRef(namespace string, gateway types.Namespa
"Replace-Header": "Tobe-Replaced",
}),
},
Condition: e2e.HasStatusCode(200),
Condition: func(h *e2e.HTTPResponse) bool {
if !e2e.HasStatusCode(200)(h) {
return false
}
body := f.GetEchoResponseBody(h.Body)
return body.Namespace == namespace && body.Service == "echo-header-filter"
},
})
require.NotNil(t, res, "request never succeeded")
require.Truef(t, ok, "expected 200 response code, got %d", res.StatusCode)
body := f.GetEchoResponseBody(res.Body)
assert.Equal(t, "echo-header-filter", body.Service)

body := f.GetEchoResponseBody(res.Body)
assert.Equal(t, "Foo", body.RequestHeaders.Get("My-Header"))
assert.Equal(t, "Bar", body.RequestHeaders.Get("Replace-Header"))

@@ -114,13 +119,17 @@ func testRequestHeaderModifierBackendRef(namespace string, gateway types.Namespa
"Other-Header": "Exist",
}),
},
Condition: e2e.HasStatusCode(200),
Condition: func(h *e2e.HTTPResponse) bool {
if !e2e.HasStatusCode(200)(h) {
return false
}
body := f.GetEchoResponseBody(h.Body)
return body.Namespace == namespace && body.Service == "echo-header-nofilter"
},
})
require.NotNil(t, res, "request never succeeded")
require.Truef(t, ok, "expected 200 response code, got %d", res.StatusCode)
body = f.GetEchoResponseBody(res.Body)
assert.Equal(t, "echo-header-nofilter", body.Service)

assert.Equal(t, "Exist", body.RequestHeaders.Get("Other-Header"))

_, found = body.RequestHeaders["My-Header"]

0 comments on commit c758cd0

Please sign in to comment.