Skip to content

Commit 7a2cd83

Browse files
committed
Add GPU Integration test
1 parent 5386fb8 commit 7a2cd83

File tree

1 file changed

+64
-0
lines changed
  • x-pack/plugin/gpu/src/internalClusterTest/java/org/elasticsearch/plugin/gpu

1 file changed

+64
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
package org.elasticsearch.plugin.gpu;
9+
10+
import org.elasticsearch.common.settings.Settings;
11+
import org.elasticsearch.plugins.Plugin;
12+
import org.elasticsearch.test.ESIntegTestCase;
13+
import org.elasticsearch.xpack.gpu.GPUPlugin;
14+
15+
import java.util.Collection;
16+
import java.util.List;
17+
18+
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
19+
20+
public class GPUIndexIT extends ESIntegTestCase {
21+
22+
@Override
23+
protected Collection<Class<? extends Plugin>> nodePlugins() {
24+
return List.of(GPUPlugin.class);
25+
}
26+
27+
public void testBasic() {
28+
var settings = Settings.builder().put(indexSettings());
29+
settings.put("index.number_of_shards", 1);
30+
settings.put("index.vectors.indexing.use_gpu", "true");
31+
assertAcked(prepareCreate("foo-index").setSettings(settings.build()).setMapping("""
32+
"properties": {
33+
"my_vector": {
34+
"type": "dense_vector",
35+
"dims": 5,
36+
"similarity": "l2_norm",
37+
"index_options": {
38+
"type": "hnsw"
39+
}
40+
}
41+
}
42+
"""));
43+
ensureGreen();
44+
45+
prepareIndex("foo-index").setId("1").setSource("my_vector", new float[] { 230.0f, 300.33f, -34.8988f, 15.555f, -200.0f }).get();
46+
47+
// TODO: add more docs...
48+
49+
ensureGreen();
50+
refresh();
51+
52+
// TODO: do some basic search
53+
// var knn = new KnnSearchBuilder("nested.vector", new float[] { -0.5f, 90.0f, -10f, 14.8f, -156.0f }, 2, 3, null, null);
54+
// var request = prepareSearch("test").addFetchField("name").setKnnSearch(List.of(knn));
55+
// assertNoFailuresAndResponse(request, response -> {
56+
// assertHitCount(response, 2);
57+
// assertEquals("2", response.getHits().getHits()[0].getId());
58+
// assertEquals("cat", response.getHits().getHits()[0].field("name").getValue());
59+
// assertEquals("3", response.getHits().getHits()[1].getId());
60+
// assertEquals("rat", response.getHits().getHits()[1].field("name").getValue());
61+
// });
62+
// }
63+
}
64+
}

0 commit comments

Comments
 (0)