Skip to content

Commit

Permalink
some conformance tests assume we're getting back a runtime request (#964
Browse files Browse the repository at this point in the history
)
  • Loading branch information
dprotaso authored Apr 10, 2024
1 parent 2a4859c commit 1a6e0da
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions test/conformance/ingress/headers.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,25 @@ func TestProbeHeaders(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

ros := []RequestOption{}
req, err := http.NewRequest("GET", fmt.Sprintf("http://%s.%s", name, test.NetworkingFlags.ServiceDomain), nil)
if err != nil {
t.Fatal("Error creating request:", err)
}
req.Header.Set(header.ProbeKey, header.ProbeValue)
req.Header.Set(header.HashKey, tt.req)

ros = append(ros, func(r *http.Request) {
// Add the header to indicate this is a probe request.
r.Header.Set(header.ProbeKey, header.ProbeValue)
r.Header.Set(header.HashKey, tt.req)
})
resp, err := client.Do(req)
if err != nil {
t.Fatal("Error making GET request:", err)
}
defer resp.Body.Close()

ri := RuntimeRequest(ctx, t, client, "http://"+name+"."+test.NetworkingFlags.ServiceDomain, ros...)
if ri == nil {
t.Error("Couldn't make request")
return
if resp.StatusCode != http.StatusOK {
t.Errorf("Unexpected status code: %d, wanted %d", resp.StatusCode, http.StatusOK)
DumpResponse(ctx, t, resp)
}

if got, want := ri.Request.Headers.Get(header.HashKey), tt.want; got != want {
if got, want := resp.Header.Get(header.HashKey), tt.want; got != want {
t.Errorf("Header[%q] = %q, wanted %q", header.HashKey, got, want)
}
})
Expand Down

0 comments on commit 1a6e0da

Please sign in to comment.