Skip to content

Conversation

@yuokada
Copy link
Contributor

@yuokada yuokada commented Aug 4, 2025

No description provided.

@yuokada yuokada requested a review from Copilot August 4, 2025 03:41
@github-actions github-actions bot added the bug label Aug 4, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes the TestTDClient.testBulkImport test method to improve reliability by addressing timing issues that can cause test failures due to data propagation delays after bulk import operations.

  • Adds a 10-second wait after bulk import commit to allow for data propagation
  • Implements retry logic with exponential backoff to poll for the expected row count
  • Enhances logging to track row count progression and debug timing issues

Comment on lines +1273 to +1274
logger.warn("Row count mismatch: expected {}, got {}", expectedRowCount, imported.getRowCount());
break;
Copy link

Copilot AI Aug 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Breaking when row count is greater than 0 but not equal to expected count will cause the test to pass with incorrect data. The test should fail if the row count doesn't match expectations, not break and continue to assert equality.

Suggested change
logger.warn("Row count mismatch: expected {}, got {}", expectedRowCount, imported.getRowCount());
break;
fail("Row count mismatch: expected " + expectedRowCount + ", got " + imported.getRowCount());

Copilot uses AI. Check for mistakes.
Comment on lines +1250 to +1254
// Wait for data propagation after commit completion
logger.info("Bulk import committed, waiting for data propagation");
Thread.sleep(TimeUnit.SECONDS.toMillis(10));

assertEquals(numRowsInPart * 2, imported.getRowCount());
// Check the data with retry logic
Copy link

Copilot AI Aug 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using Thread.sleep() in tests can make them flaky and slow. Consider using a polling mechanism with shorter intervals instead of a fixed 10-second sleep before starting the retry loop.

Suggested change
// Wait for data propagation after commit completion
logger.info("Bulk import committed, waiting for data propagation");
Thread.sleep(TimeUnit.SECONDS.toMillis(10));
assertEquals(numRowsInPart * 2, imported.getRowCount());
// Check the data with retry logic
// Wait for data propagation after commit completion using polling
logger.info("Bulk import committed, waiting for data propagation (polling for row count)");
// Check the data with retry logic (polling)

Copilot uses AI. Check for mistakes.
}

logger.debug("Row count still 0, retrying after backoff");
Thread.sleep(rowCountBackoff.nextWaitTimeMillis());
Copy link

Copilot AI Aug 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thread.sleep() can throw InterruptedException which is not being handled. This should be wrapped in a try-catch block or the method signature should declare the exception.

Suggested change
Thread.sleep(rowCountBackoff.nextWaitTimeMillis());
try {
Thread.sleep(rowCountBackoff.nextWaitTimeMillis());
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
fail("Thread was interrupted while waiting for row count", e);
}

Copilot uses AI. Check for mistakes.
@yuokada yuokada closed this Aug 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants