Skip to content

Commit 3572bfd

Browse files
Fix testGetSnapshotsMultipleRepos (#43993)
The order tested in the equals check in the un-muted test needs exact timestamps. Otherwise two subsequent snapshots might have the same timestamps and hence will get ordered differently than the list of snapshot names that was built as the snapshots were created => Fixed by having exact timestamps in this test.
1 parent 778e47f commit 3572bfd

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

server/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreIT.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,13 @@ protected Collection<Class<? extends Plugin>> nodePlugins() {
157157
MockRepository.Plugin.class);
158158
}
159159

160+
@Override
161+
protected Settings nodeSettings(int nodeOrdinal) {
162+
return Settings.builder().put(super.nodeSettings(nodeOrdinal))
163+
.put(ThreadPool.ESTIMATED_TIME_INTERVAL_SETTING.getKey(), 0) // We have tests that check by-timestamp order
164+
.build();
165+
}
166+
160167
private Settings randomRepoSettings() {
161168
Settings.Builder repoSettings = Settings.builder();
162169
repoSettings.put("location", randomRepoPath());
@@ -1340,8 +1347,7 @@ public void testGetSnapshotsNoRepos() {
13401347
assertTrue(getSnapshotsResponse.getSuccessfulResponses().isEmpty());
13411348
}
13421349

1343-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/pull/43993")
1344-
public void testGetSnapshotsMultipleRepos() {
1350+
public void testGetSnapshotsMultipleRepos() throws Exception {
13451351
final Client client = client();
13461352

13471353
List<String> snapshotList = new ArrayList<>();
@@ -1370,6 +1376,11 @@ public void testGetSnapshotsMultipleRepos() {
13701376
for (int snapshotIndex = 0; snapshotIndex < randomIntBetween(2, 5); snapshotIndex++) {
13711377
final String snapshotName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
13721378
snapshotList.add(snapshotName);
1379+
// Wait for at least 1ms to ensure that snapshots can be ordered by timestamp deterministically
1380+
for (final ThreadPool threadPool : internalCluster().getInstances(ThreadPool.class)) {
1381+
final long startMillis = threadPool.absoluteTimeInMillis();
1382+
assertBusy(() -> assertThat(threadPool.absoluteTimeInMillis(), greaterThan(startMillis)));
1383+
}
13731384
logger.info("--> create snapshot with index {} and name {} in repository {}", snapshotIndex, snapshotName, repoName);
13741385
CreateSnapshotResponse createSnapshotResponse = client.admin()
13751386
.cluster()

0 commit comments

Comments
 (0)