Skip to content

Commit

Permalink
test(bigquery/storage/managedwriter): refactor large insert tests (#8949
Browse files Browse the repository at this point in the history
)

The service has improved the handling and recovery related to large
inserts.  This PR updates the logic in accordance with those changes,
primarily that a large insert will not implicitly cause a reconnect.

Fixes: #8931
  • Loading branch information
shollyman authored Oct 31, 2023
1 parent 858254b commit 338f53f
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions bigquery/storage/managedwriter/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -937,20 +937,18 @@ func testLargeInsertNoRetry(ctx context.Context, t *testing.T, mwClient *Client,
t.Errorf("expected InvalidArgument status, got %v", status)
}
}
// our next append should fail (we don't have retries enabled).
if _, err = ms.AppendRows(ctx, [][]byte{b}); err == nil {
t.Fatalf("expected second append to fail, got success: %v", err)
}

// The send failure triggers reconnect, so an additional append will succeed.
// our next append is small and should succeed.
result, err = ms.AppendRows(ctx, [][]byte{b})
if err != nil {
t.Fatalf("third append expected to succeed, got error: %v", err)
t.Fatalf("second append failed: %v", err)
}
_, err = result.GetResult(ctx)
if err != nil {
t.Errorf("failure result from third append: %v", err)
t.Errorf("failure result from second append: %v", err)
}

validateTableConstraints(ctx, t, bqClient, testTable, "final",
withExactRowCount(1))
}

func testLargeInsertWithRetry(ctx context.Context, t *testing.T, mwClient *Client, bqClient *bigquery.Client, dataset *bigquery.Dataset) {
Expand Down Expand Up @@ -1005,7 +1003,7 @@ func testLargeInsertWithRetry(ctx context.Context, t *testing.T, mwClient *Clien
}
}

// The second append will succeed, but internally will show a retry.
// The second append will succeed.
result, err = ms.AppendRows(ctx, [][]byte{b})
if err != nil {
t.Fatalf("second append expected to succeed, got error: %v", err)
Expand All @@ -1014,8 +1012,8 @@ func testLargeInsertWithRetry(ctx context.Context, t *testing.T, mwClient *Clien
if err != nil {
t.Errorf("failure result from second append: %v", err)
}
if attempts, _ := result.TotalAttempts(ctx); attempts != 2 {
t.Errorf("expected 2 attempts, got %d", attempts)
if attempts, _ := result.TotalAttempts(ctx); attempts != 1 {
t.Errorf("expected 1 attempts, got %d", attempts)
}
}

Expand Down

0 comments on commit 338f53f

Please sign in to comment.