Skip to content
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

test(datastore): Retry aggregation query testcase on failure #8487

Merged
merged 8 commits into from
Aug 29, 2023
24 changes: 13 additions & 11 deletions datastore/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -874,18 +874,20 @@ func TestIntegration_AggregationQueries(t *testing.T) {
}

for _, testCase := range testCases {
gotAggResult, gotErr := client.RunAggregationQuery(ctx, testCase.aggQuery)
gotFailure := gotErr != nil
testutil.Retry(t, 10, time.Second, func(r *testutil.R) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a quick comment why we're adding a retry here?

gotAggResult, gotErr := client.RunAggregationQuery(ctx, testCase.aggQuery)
gotFailure := gotErr != nil

if gotFailure != testCase.wantFailure ||
(gotErr != nil && !strings.Contains(gotErr.Error(), testCase.wantErrMsg)) {
t.Errorf("%q: Mismatch in error got: %v, want: %q", testCase.desc, gotErr, testCase.wantErrMsg)
continue
}
if !reflect.DeepEqual(gotAggResult, testCase.wantAggResult) {
t.Errorf("%q: Mismatch in aggregation result got: %v, want: %v", testCase.desc, gotAggResult, testCase.wantAggResult)
continue
}
if gotFailure != testCase.wantFailure ||
(gotErr != nil && !strings.Contains(gotErr.Error(), testCase.wantErrMsg)) {
r.Errorf("%q: Mismatch in error got: %v, want: %q", testCase.desc, gotErr, testCase.wantErrMsg)
return
}
if gotErr == nil && !reflect.DeepEqual(gotAggResult, testCase.wantAggResult) {
r.Errorf("%q: Mismatch in aggregation result got: %v, want: %v", testCase.desc, gotAggResult, testCase.wantAggResult)
return
}
})
}

}
Expand Down