-
Notifications
You must be signed in to change notification settings - Fork 626
conformance: Optimize mesh weight conformance tests using batch requests #4138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -79,6 +79,10 @@ func (m *MeshPod) MakeRequestAndExpectEventuallyConsistentResponse(t *testing.T, | |
| } | ||
|
|
||
| func makeRequest(t *testing.T, exp *http.ExpectedResponse) []string { | ||
| return makeRequestWithCount(t, exp, 0) | ||
| } | ||
|
|
||
| func makeRequestWithCount(t *testing.T, exp *http.ExpectedResponse, count int) []string { | ||
| if exp.Request.Host == "" { | ||
| exp.Request.Host = "echo" | ||
| } | ||
|
|
@@ -112,6 +116,9 @@ func makeRequest(t *testing.T, exp *http.ExpectedResponse) []string { | |
| for k, v := range r.Headers { | ||
| args = append(args, "-H", fmt.Sprintf("%v:%v", k, v)) | ||
| } | ||
| if count > 0 { | ||
| args = append(args, fmt.Sprintf("--count=%d", count)) | ||
| } | ||
| return args | ||
| } | ||
|
|
||
|
|
@@ -275,3 +282,23 @@ func (m *MeshPod) CaptureRequestResponseAndCompare(t *testing.T, exp http.Expect | |
| } | ||
| return req, resp, nil | ||
| } | ||
|
|
||
| // RequestBatch executes a batch of requests using the --count flag and returns all responses | ||
| func (m *MeshPod) RequestBatch(t *testing.T, exp http.ExpectedResponse, count int) ([]Response, error) { | ||
| req := makeRequestWithCount(t, &exp, count) | ||
|
|
||
| resp, err := m.request(req) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("batch request failed: %w", err) | ||
| } | ||
|
|
||
| // Split the output by response boundaries | ||
| // Each response is separated by a blank line in the output | ||
| responses := parseMultipleResponses(resp.RawContent) | ||
|
|
||
| if len(responses) != count { | ||
| tlog.Logf(t, "Warning: expected %d responses but got %d", count, len(responses)) | ||
|
||
| } | ||
|
|
||
| return responses, nil | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.