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

Fix StressTests Java BigQueryIO job flakiness #32803

Merged
merged 2 commits into from
Oct 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public final class BigQueryIOST extends IOStressTestBase {
private static final String READ_ELEMENT_METRIC_NAME = "read_count";
private static final String STORAGE_WRITE_API_METHOD = "STORAGE_WRITE_API";
private static final String STORAGE_API_AT_LEAST_ONCE_METHOD = "STORAGE_API_AT_LEAST_ONCE";
private static final double STORAGE_API_AT_LEAST_ONCE_MAX_ALLOWED_DIFFERENCE_FRACTION = 0.00001;

private static BigQueryResourceManager resourceManager;
private static String tableName;
Expand Down Expand Up @@ -334,11 +335,14 @@ private void generateDataAndWrite(BigQueryIO.Write<byte[]> writeIO) throws IOExc

// Depending on writing method there might be duplicates on different sides (read or write).
if (configuration.writeMethod.equals(STORAGE_API_AT_LEAST_ONCE_METHOD)) {
long allowedDifference =
(long) (numRecords * STORAGE_API_AT_LEAST_ONCE_MAX_ALLOWED_DIFFERENCE_FRACTION);
long actualDifference = (long) numRecords - rowCount;
assertTrue(
String.format(
"Number of rows in the table (%d) is less than the expected number (%d). Missing records: %d",
rowCount, (long) numRecords, (long) numRecords - rowCount),
rowCount >= numRecords);
"Row difference (%d) exceeds the limit of %d. Rows: %d, Expected: %d",
actualDifference, allowedDifference, rowCount, (long) numRecords),
actualDifference <= allowedDifference);
} else {
assertTrue(
String.format(
Expand Down
Loading