Skip to content

Commit

Permalink
test(datastore): Retry aggregation query testcase on failure (#8487)
Browse files Browse the repository at this point in the history
* test(datastore): remove explicit sleep
  • Loading branch information
bhshkh authored Aug 29, 2023
1 parent 38a040e commit b5000f6
Showing 1 changed file with 13 additions and 11 deletions.
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) {
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

0 comments on commit b5000f6

Please sign in to comment.