Fix ThreadPoolMergeExecutorServiceDiskSpaceTests testAvailableDiskSpaceMonitorWhenFileSystemStatErrors (#130025)

The test method needs to distinguish between the available disk space update values, when they are coming from either FS.
So the update values from the 2 FSs mustn't be equal.

Fixes #129149
This commit is contained in:
Albert Zaharovits 2025-06-26 14:05:40 +03:00 committed by GitHub
parent c05794510d
commit a6004a6067
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 27 deletions

View file

@ -473,9 +473,6 @@ tests:
- class: org.elasticsearch.packaging.test.DockerTests - class: org.elasticsearch.packaging.test.DockerTests
method: test081SymlinksAreFollowedWithEnvironmentVariableFiles method: test081SymlinksAreFollowedWithEnvironmentVariableFiles
issue: https://github.com/elastic/elasticsearch/issues/128867 issue: https://github.com/elastic/elasticsearch/issues/128867
- class: org.elasticsearch.index.engine.ThreadPoolMergeExecutorServiceDiskSpaceTests
method: testAvailableDiskSpaceMonitorWhenFileSystemStatErrors
issue: https://github.com/elastic/elasticsearch/issues/129149
- class: org.elasticsearch.xpack.esql.qa.single_node.GenerativeForkIT - class: org.elasticsearch.xpack.esql.qa.single_node.GenerativeForkIT
method: test {lookup-join.EnrichLookupStatsBug ASYNC} method: test {lookup-join.EnrichLookupStatsBug ASYNC}
issue: https://github.com/elastic/elasticsearch/issues/129228 issue: https://github.com/elastic/elasticsearch/issues/129228

View file

@ -324,10 +324,19 @@ public class ThreadPoolMergeExecutorServiceDiskSpaceTests extends ESTestCase {
} }
public void testAvailableDiskSpaceMonitorWhenFileSystemStatErrors() throws Exception { public void testAvailableDiskSpaceMonitorWhenFileSystemStatErrors() throws Exception {
aFileStore.usableSpace = randomLongBetween(1L, 100L); long aUsableSpace;
aFileStore.totalSpace = randomLongBetween(1L, 100L); long bUsableSpace;
bFileStore.usableSpace = randomLongBetween(1L, 100L); do {
bFileStore.totalSpace = randomLongBetween(1L, 100L); aFileStore.usableSpace = randomLongBetween(1L, 1000L);
aFileStore.totalSpace = randomLongBetween(1L, 1000L);
bFileStore.usableSpace = randomLongBetween(1L, 1000L);
bFileStore.totalSpace = randomLongBetween(1L, 1000L);
// the default 5% (same as flood stage level)
aUsableSpace = Math.max(aFileStore.usableSpace - aFileStore.totalSpace / 20, 0L);
bUsableSpace = Math.max(bFileStore.usableSpace - bFileStore.totalSpace / 20, 0L);
} while (aUsableSpace == bUsableSpace); // they must be different in order to distinguish the available disk space updates
long finalBUsableSpace = bUsableSpace;
long finalAUsableSpace = aUsableSpace;
boolean aErrorsFirst = randomBoolean(); boolean aErrorsFirst = randomBoolean();
if (aErrorsFirst) { if (aErrorsFirst) {
// the "a" file system will error when collecting stats // the "a" file system will error when collecting stats
@ -355,18 +364,10 @@ public class ThreadPoolMergeExecutorServiceDiskSpaceTests extends ESTestCase {
assertThat(availableDiskSpaceUpdates.size(), is(1)); assertThat(availableDiskSpaceUpdates.size(), is(1));
if (aErrorsFirst) { if (aErrorsFirst) {
// uses the stats from "b" // uses the stats from "b"
assertThat( assertThat(availableDiskSpaceUpdates.getLast().getBytes(), is(finalBUsableSpace));
availableDiskSpaceUpdates.getLast().getBytes(),
// the default 5% (same as flood stage level)
is(Math.max(bFileStore.usableSpace - bFileStore.totalSpace / 20, 0L))
);
} else { } else {
// uses the stats from "a" // uses the stats from "a"
assertThat( assertThat(availableDiskSpaceUpdates.getLast().getBytes(), is(finalAUsableSpace));
availableDiskSpaceUpdates.getLast().getBytes(),
// the default 5% (same as flood stage level)
is(Math.max(aFileStore.usableSpace - aFileStore.totalSpace / 20, 0L))
);
} }
} }
}); });
@ -393,21 +394,14 @@ public class ThreadPoolMergeExecutorServiceDiskSpaceTests extends ESTestCase {
} }
assertBusy(() -> { assertBusy(() -> {
synchronized (availableDiskSpaceUpdates) { synchronized (availableDiskSpaceUpdates) {
// the updates are different values
assertThat(availableDiskSpaceUpdates.size(), is(3)); assertThat(availableDiskSpaceUpdates.size(), is(3));
if (aErrorsFirst) { if (aErrorsFirst) {
// uses the stats from "a" // uses the stats from "a"
assertThat( assertThat(availableDiskSpaceUpdates.getLast().getBytes(), is(finalAUsableSpace));
availableDiskSpaceUpdates.getLast().getBytes(),
// the default 5% (same as flood stage level)
is(Math.max(aFileStore.usableSpace - aFileStore.totalSpace / 20, 0L))
);
} else { } else {
// uses the stats from "b" // uses the stats from "b"
assertThat( assertThat(availableDiskSpaceUpdates.getLast().getBytes(), is(finalBUsableSpace));
availableDiskSpaceUpdates.getLast().getBytes(),
// the default 5% (same as flood stage level)
is(Math.max(bFileStore.usableSpace - bFileStore.totalSpace / 20, 0L))
);
} }
} }
}); });