Skip to content

Commit

Permalink
test/e2e/gateway: check service as part of request condition
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
skriss committed Mar 6, 2024
1 parent e64a50a commit 21d4562
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
Expand Up @@ -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"))

Expand All @@ -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"]
Expand Down

0 comments on commit 21d4562

Please sign in to comment.