Skip to content

Commit

Permalink
Skip preallocate tests on windows (elastic#110998)
Browse files Browse the repository at this point in the history
The preallocate tests assumed that preallocation was using the fallback
implementation which calls setLength on Windows. However, that fallback
only happens inside the SharedBytes class, so windows doesn't actually
do anything when tryPreallocate is called. This commit skips the test on
windows.

closes elastic#110948
  • Loading branch information
rjernst authored and salvatore-campagna committed Jul 23, 2024
1 parent 6686c54 commit 766102e
Showing 1 changed file with 1 addition and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@

public class PreallocateTests extends ESTestCase {
public void testPreallocate() throws IOException {
assumeFalse("no preallocate on windows", System.getProperty("os.name").startsWith("Windows"));
Path file = createTempFile();
long size = 1024 * 1024; // 1 MB
var nativeAccess = NativeAccess.instance();
nativeAccess.tryPreallocate(file, size);
OptionalLong foundSize = nativeAccess.allocatedSizeInBytes(file);
assertTrue(foundSize.isPresent());
// Note that on Windows the fallback setLength is used. Although that creates a sparse
// file on Linux/MacOS, it full allocates the file on Windows
assertThat(foundSize.getAsLong(), equalTo(size));
}
}

0 comments on commit 766102e

Please sign in to comment.