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

Don't rely on test code execution time span for RemoteSegmentTransferTrackerTests #15187

Merged
merged 1 commit into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
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 @@ -65,7 +65,7 @@ public class RemoteSegmentTransferTracker extends RemoteTransferTracker {
private volatile long remoteRefreshSeqNo;

/**
* The refresh time of most recent remote refresh.
* The refresh time of the most recent remote refresh.
*/
private volatile long remoteRefreshTimeMs;

Expand All @@ -76,7 +76,7 @@ public class RemoteSegmentTransferTracker extends RemoteTransferTracker {
private volatile long remoteRefreshStartTimeMs = -1;

/**
* The refresh time(clock) of most recent remote refresh.
* The refresh time(clock) of the most recent remote refresh.
*/
private volatile long remoteRefreshClockTimeMs;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,18 @@ public void testComputeTimeLagOnUpdate() throws InterruptedException {
transferTracker.updateLocalRefreshTimeMs(currentTimeMsUsingSystemNanos());

transferTracker.updateLatestLocalFileNameLengthMap(List.of("test"), k -> 1L);
// Sleep for 100ms and then the lag should be within 100ms +/- 20ms
Thread.sleep(100);
assertTrue(Math.abs(transferTracker.getTimeMsLag() - 100) <= 20);
// Sleep for 100ms and then the lag should not be shorter
long span = 100;
Thread.sleep(span);
long lag = transferTracker.getTimeMsLag();
assertTrue("Actual lag [" + lag + "ms] is not expected to be shorter than span [" + span + "ms]", lag >= span);

transferTracker.updateRemoteRefreshTimeMs(transferTracker.getLocalRefreshTimeMs());
transferTracker.updateLocalRefreshTimeMs(currentTimeMsUsingSystemNanos());
long random = randomIntBetween(50, 200);
Thread.sleep(random);
assertTrue(Math.abs(transferTracker.getTimeMsLag() - random) <= 20);
long randomSpan = randomIntBetween(50, 200);
Thread.sleep(randomSpan);
lag = transferTracker.getTimeMsLag();
assertTrue("Actual lag [" + lag + "ms] is not expected to be shorter than span [" + randomSpan + "ms]", lag >= randomSpan);
}

public void testAddUploadBytesStarted() {
Expand Down
Loading