Skip to content

Commit

Permalink
testing(bigquery/storage/managedwriter): instrumentation retries (#6537)
Browse files Browse the repository at this point in the history
We've caught more than one instance of a race failure.  Add retries
for the opencensus metrics test to reduce the likelihood of this
failures.

Fixes: #6535
  • Loading branch information
shollyman committed Aug 18, 2022
1 parent 4aa43f9 commit b4d7a78
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion bigquery/storage/managedwriter/integration_test.go
Expand Up @@ -705,7 +705,21 @@ func testInstrumentation(ctx context.Context, t *testing.T, mwClient *Client, bq
time.Sleep(time.Second)

for _, tv := range testedViews {
metricData, err := view.RetrieveData(tv.Name)
// Attempt to further improve race failures by retrying metrics retrieval.
metricData, err := func() ([]*view.Row, error) {
attempt := 0
for {
data, err := view.RetrieveData(tv.Name)
attempt = attempt + 1
if attempt > 5 {
return data, err
}
if err == nil && len(data) == 1 {
return data, err
}
time.Sleep(time.Duration(attempt) * 500 * time.Millisecond)
}
}()
if err != nil {
t.Errorf("view %q RetrieveData: %v", tv.Name, err)
}
Expand Down

0 comments on commit b4d7a78

Please sign in to comment.