From b5000f608c3b62791a42db17dbabf2c08b9a8c1a Mon Sep 17 00:00:00 2001 From: Baha Aiman Date: Tue, 29 Aug 2023 09:47:29 -0700 Subject: [PATCH] test(datastore): Retry aggregation query testcase on failure (#8487) * test(datastore): remove explicit sleep --- datastore/integration_test.go | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/datastore/integration_test.go b/datastore/integration_test.go index f698eee50383..6149063c36d8 100644 --- a/datastore/integration_test.go +++ b/datastore/integration_test.go @@ -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 + } + }) } }