Skip to content

Commit

Permalink
Potentially addressing bbq bwc failures and added logging (elastic#12…
Browse files Browse the repository at this point in the history
…2553)

I have ran this many times locally, and it never failed. Maybe there is
something "magical" in CI.

Added some additional info in the assertion logging.

(cherry picked from commit 894db68)
  • Loading branch information
benwtrent committed Feb 21, 2025
1 parent dc4e8f4 commit 44cee92
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 24 deletions.
14 changes: 0 additions & 14 deletions muted-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -238,20 +238,6 @@ tests:
- class: org.elasticsearch.xpack.test.rest.XPackRestIT
method: test {p0=ml/*}
issue: https://github.com/elastic/elasticsearch/issues/120816
- class: org.elasticsearch.upgrades.VectorSearchIT
method: testBBQVectorSearch {upgradedNodes=0}
issue: https://github.com/elastic/elasticsearch/issues/121253
- class: org.elasticsearch.test.rest.ClientYamlTestSuiteIT
issue: https://github.com/elastic/elasticsearch/issues/121269
- class: org.elasticsearch.upgrades.VectorSearchIT
method: testBBQVectorSearch {upgradedNodes=1}
issue: https://github.com/elastic/elasticsearch/issues/121271
- class: org.elasticsearch.upgrades.VectorSearchIT
method: testBBQVectorSearch {upgradedNodes=2}
issue: https://github.com/elastic/elasticsearch/issues/121272
- class: org.elasticsearch.upgrades.VectorSearchIT
method: testBBQVectorSearch {upgradedNodes=3}
issue: https://github.com/elastic/elasticsearch/issues/121273
- class: org.elasticsearch.xpack.security.authc.ldap.ActiveDirectorySessionFactoryTests
issue: https://github.com/elastic/elasticsearch/issues/121285
- class: org.elasticsearch.smoketest.DocsClientYamlTestSuiteIT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import org.elasticsearch.client.Request;
import org.elasticsearch.client.Response;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.support.XContentMapValues;

Expand Down Expand Up @@ -456,7 +457,11 @@ public void testBBQVectorSearch() throws Exception {
}
""";
// create index and index 10 random floating point vectors
createIndex(BBQ_INDEX_NAME, Settings.EMPTY, mapping);
createIndex(
BBQ_INDEX_NAME,
Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1).put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0).build(),
mapping
);
index64DimVectors(BBQ_INDEX_NAME);
// force merge the index
client().performRequest(new Request("POST", "/" + BBQ_INDEX_NAME + "/_forcemerge?max_num_segments=1"));
Expand Down Expand Up @@ -485,8 +490,8 @@ public void testBBQVectorSearch() throws Exception {
Map<String, Object> response = search(searchRequest);
assertThat(extractValue(response, "hits.total.value"), equalTo(7));
List<Map<String, Object>> hits = extractValue(response, "hits.hits");
assertThat(hits.get(0).get("_id"), equalTo("0"));
assertThat((double) hits.get(0).get("_score"), closeTo(1.9869276, 0.0001));
assertThat("hits: " + response, hits.get(0).get("_id"), equalTo("0"));
assertThat("hits: " + response, (double) hits.get(0).get("_score"), closeTo(1.9869276, 0.0001));

// search with knn
searchRequest = new Request("POST", "/" + BBQ_INDEX_NAME + "/_search");
Expand All @@ -504,8 +509,12 @@ public void testBBQVectorSearch() throws Exception {
response = search(searchRequest);
assertThat(extractValue(response, "hits.total.value"), equalTo(2));
hits = extractValue(response, "hits.hits");
assertThat(hits.get(0).get("_id"), equalTo("0"));
assertThat((double) hits.get(0).get("_score"), closeTo(0.9934857, 0.005));
assertThat("expected: 0 received" + hits.get(0).get("_id") + " hits: " + response, hits.get(0).get("_id"), equalTo("0"));
assertThat(
"expected_near: 0.99 received" + hits.get(0).get("_score") + "hits: " + response,
(double) hits.get(0).get("_score"),
closeTo(0.9934857, 0.005)
);
}

public void testFlatBBQVectorSearch() throws Exception {
Expand All @@ -530,7 +539,11 @@ public void testFlatBBQVectorSearch() throws Exception {
}
""";
// create index and index 10 random floating point vectors
createIndex(FLAT_BBQ_INDEX_NAME, Settings.EMPTY, mapping);
createIndex(
FLAT_BBQ_INDEX_NAME,
Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1).put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0).build(),
mapping
);
index64DimVectors(FLAT_BBQ_INDEX_NAME);
// force merge the index
client().performRequest(new Request("POST", "/" + FLAT_BBQ_INDEX_NAME + "/_forcemerge?max_num_segments=1"));
Expand Down Expand Up @@ -559,8 +572,8 @@ public void testFlatBBQVectorSearch() throws Exception {
Map<String, Object> response = search(searchRequest);
assertThat(extractValue(response, "hits.total.value"), equalTo(7));
List<Map<String, Object>> hits = extractValue(response, "hits.hits");
assertThat(hits.get(0).get("_id"), equalTo("0"));
assertThat((double) hits.get(0).get("_score"), closeTo(1.9869276, 0.0001));
assertThat("hits: " + response, hits.get(0).get("_id"), equalTo("0"));
assertThat("hits: " + response, (double) hits.get(0).get("_score"), closeTo(1.9869276, 0.0001));

// search with knn
searchRequest = new Request("POST", "/" + FLAT_BBQ_INDEX_NAME + "/_search");
Expand All @@ -578,8 +591,12 @@ public void testFlatBBQVectorSearch() throws Exception {
response = search(searchRequest);
assertThat(extractValue(response, "hits.total.value"), equalTo(2));
hits = extractValue(response, "hits.hits");
assertThat(hits.get(0).get("_id"), equalTo("0"));
assertThat((double) hits.get(0).get("_score"), closeTo(0.9934857, 0.005));
assertThat("expected: 0 received" + hits.get(0).get("_id") + " hits: " + response, hits.get(0).get("_id"), equalTo("0"));
assertThat(
"expected_near: 0.99 received" + hits.get(0).get("_score") + "hits: " + response,
(double) hits.get(0).get("_score"),
closeTo(0.9934857, 0.005)
);
}

private void index64DimVectors(String indexName) throws Exception {
Expand All @@ -605,6 +622,7 @@ private void index64DimVectors(String indexName) throws Exception {
assertOK(client().performRequest(indexRequest));
}
// always refresh to ensure the data is visible
flush(indexName, true);
refresh(indexName);
}

Expand Down

0 comments on commit 44cee92

Please sign in to comment.