Skip to content

Commit 68d5cc6

Browse files
authored
Use all bbq index types in DirectIOIT (#128620)
This commit is a small change to use all bbq index types in DirectIOIT. While not strictly necessary, it is good add the additional coverage.
1 parent 3b54afd commit 68d5cc6

File tree

1 file changed

+14
-2
lines changed
  • server/src/internalClusterTest/java/org/elasticsearch/index/store

1 file changed

+14
-2
lines changed

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,14 @@
3030
import java.nio.file.Path;
3131
import java.util.Collection;
3232
import java.util.List;
33+
import java.util.Map;
3334
import java.util.OptionalLong;
3435
import java.util.stream.IntStream;
3536

3637
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
3738
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
39+
import static org.hamcrest.Matchers.equalTo;
40+
import static org.hamcrest.Matchers.is;
3841

3942
@LuceneTestCase.SuppressCodecs("*") // only use our own codecs
4043
public class DirectIOIT extends ESIntegTestCase {
@@ -64,6 +67,7 @@ protected Collection<Class<? extends Plugin>> nodePlugins() {
6467
}
6568

6669
private void indexVectors() {
70+
String type = randomFrom("bbq_flat", "bbq_hnsw");
6771
assertAcked(
6872
prepareCreate("foo-vectors").setSettings(Settings.builder().put(InternalSettingsPlugin.USE_COMPOUND_FILE.getKey(), false))
6973
.setMapping("""
@@ -76,19 +80,27 @@ private void indexVectors() {
7680
"index": true,
7781
"similarity": "l2_norm",
7882
"index_options": {
79-
"type": "bbq_flat"
83+
"type": "%type%"
8084
}
8185
}
8286
}
8387
}
84-
""")
88+
""".replace("%type%", type))
8589
);
8690
ensureGreen("foo-vectors");
8791

8892
for (int i = 0; i < 1000; i++) {
8993
indexDoc("foo-vectors", Integer.toString(i), "fooVector", IntStream.range(0, 64).mapToDouble(d -> randomFloat()).toArray());
9094
}
9195
refresh();
96+
assertBBQIndexType(type); // test assertion to ensure that the correct index type is being used
97+
}
98+
99+
@SuppressWarnings("unchecked")
100+
static void assertBBQIndexType(String type) {
101+
var response = indicesAdmin().prepareGetFieldMappings("foo-vectors").setFields("fooVector").get();
102+
var map = (Map<String, Object>) response.fieldMappings("foo-vectors", "fooVector").sourceAsMap().get("fooVector");
103+
assertThat((String) ((Map<String, Object>) map.get("index_options")).get("type"), is(equalTo(type)));
92104
}
93105

94106
@TestLogging(value = "org.elasticsearch.index.store.FsDirectoryFactory:DEBUG", reason = "to capture trace logging for direct IO")

0 commit comments

Comments
 (0)