Skip to content

Commit 6dfa66b

Browse files
committed
DirectIOIT requires filesystem that supports Direct IO
1 parent 53a5f0a commit 6dfa66b

File tree

1 file changed

+28
-0
lines changed
  • server/src/internalClusterTest/java/org/elasticsearch/index/store

1 file changed

+28
-0
lines changed

server/src/internalClusterTest/java/org/elasticsearch/index/store/DirectIOIT.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
package org.elasticsearch.index.store;
1111

1212
import org.apache.logging.log4j.Level;
13+
import org.apache.lucene.misc.store.DirectIODirectory;
14+
import org.apache.lucene.store.Directory;
15+
import org.apache.lucene.store.FSDirectory;
16+
import org.apache.lucene.store.IOContext;
17+
import org.apache.lucene.store.IndexOutput;
1318
import org.apache.lucene.tests.util.LuceneTestCase;
1419
import org.elasticsearch.common.settings.Settings;
1520
import org.elasticsearch.plugins.Plugin;
@@ -19,9 +24,13 @@
1924
import org.elasticsearch.test.InternalSettingsPlugin;
2025
import org.elasticsearch.test.MockLog;
2126
import org.elasticsearch.test.junit.annotations.TestLogging;
27+
import org.junit.BeforeClass;
2228

29+
import java.io.IOException;
30+
import java.nio.file.Path;
2331
import java.util.Collection;
2432
import java.util.List;
33+
import java.util.OptionalLong;
2534
import java.util.stream.IntStream;
2635

2736
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
@@ -30,6 +39,25 @@
3039
@LuceneTestCase.SuppressCodecs("*") // only use our own codecs
3140
public class DirectIOIT extends ESIntegTestCase {
3241

42+
@BeforeClass
43+
public static void checkSupported() throws IOException {
44+
Path path = createTempDir("directIOProbe");
45+
try (Directory dir = open(path); IndexOutput out = dir.createOutput("out", IOContext.DEFAULT)) {
46+
out.writeString("test");
47+
} catch (IOException e) {
48+
assumeNoException("test requires filesystem that supports Direct IO", e);
49+
}
50+
}
51+
52+
static DirectIODirectory open(Path path) throws IOException {
53+
return new DirectIODirectory(FSDirectory.open(path)) {
54+
@Override
55+
protected boolean useDirectIO(String name, IOContext context, OptionalLong fileLength) {
56+
return true;
57+
}
58+
};
59+
}
60+
3361
@Override
3462
protected Collection<Class<? extends Plugin>> nodePlugins() {
3563
return List.of(InternalSettingsPlugin.class);

0 commit comments

Comments
 (0)