Skip to content

Commit f2035a6

Browse files
committed
Split the yaml to test for basic and trial, cleanedup and acted on all the comments
1 parent 3c86416 commit f2035a6

File tree

5 files changed

+148
-72
lines changed

5 files changed

+148
-72
lines changed

x-pack/plugin/search-business-rules/src/test/java/org/elasticsearch/xpack/searchbusinessrules/retriever/PinnedRetrieverBuilderTests.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,10 @@ public void testValidateSort() {
199199
assertThat(
200200
e.getMessage(),
201201
equalTo(
202-
"[" + PinnedRetrieverBuilder.NAME + "] retriever only supports sorting by score, invalid sort criterion: {\n \"field1\" : {\n \"order\" : \"asc\"\n }\n}"
202+
"["
203+
+ PinnedRetrieverBuilder.NAME
204+
+ "] retriever only supports sorting by score, "
205+
+ "invalid sort criterion: {\n \"field1\" : {\n \"order\" : \"asc\"\n }\n}"
203206
)
204207
);
205208

@@ -211,7 +214,10 @@ public void testValidateSort() {
211214
assertThat(
212215
e.getMessage(),
213216
equalTo(
214-
"[" + PinnedRetrieverBuilder.NAME + "] retriever only supports sorting by score, invalid sort criterion: {\n \"field1\" : {\n \"order\" : \"asc\"\n }\n}"
217+
"["
218+
+ PinnedRetrieverBuilder.NAME
219+
+ "] retriever only supports sorting by score, "
220+
+ "invalid sort criterion: {\n \"field1\" : {\n \"order\" : \"asc\"\n }\n}"
215221
)
216222
);
217223
}

x-pack/plugin/search-business-rules/src/yamlRestTest/java/org/elasticsearch/xpack/searchbusinessrules/SearchBusinessRulesClientYamlTestSuiteIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class SearchBusinessRulesClientYamlTestSuiteIT extends ESClientYamlSuiteT
1919
@ClassRule
2020
public static ElasticsearchCluster cluster = ElasticsearchCluster.local()
2121
.distribution(DistributionType.DEFAULT)
22-
.setting("xpack.license.self_generated.type", "trial")
22+
.setting("xpack.license.self_generated.type", "basic")
2323
.setting("xpack.security.enabled", "false")
2424
.build();
2525

@@ -29,7 +29,7 @@ public SearchBusinessRulesClientYamlTestSuiteIT(final ClientYamlTestCandidate te
2929

3030
@ParametersFactory
3131
public static Iterable<Object[]> parameters() throws Exception {
32-
return ESClientYamlSuiteTestCase.createParameters();
32+
return ESClientYamlSuiteTestCase.createParameters(new String[] { "search-business-rules/10_pinned_retriever_basic" });
3333
}
3434

3535
@Override
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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+
package org.elasticsearch.xpack.searchbusinessrules;
8+
9+
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
10+
11+
import org.elasticsearch.test.cluster.ElasticsearchCluster;
12+
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
13+
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
14+
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
15+
import org.junit.ClassRule;
16+
17+
/**
18+
* Test suite for running YAML tests specific to Pinned Retriever + RRF combination,
19+
* requiring a trial license.
20+
*/
21+
public class SearchBusinessRulesRrfClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase {
22+
23+
@ClassRule
24+
public static ElasticsearchCluster cluster = ElasticsearchCluster.local()
25+
.distribution(DistributionType.DEFAULT)
26+
// RRF requires trial or platinum license
27+
.setting("xpack.license.self_generated.type", "trial")
28+
.setting("xpack.security.enabled", "false")
29+
.build();
30+
31+
public SearchBusinessRulesRrfClientYamlTestSuiteIT(final ClientYamlTestCandidate testCandidate) {
32+
super(testCandidate);
33+
}
34+
35+
@ParametersFactory
36+
public static Iterable<Object[]> parameters() throws Exception {
37+
return ESClientYamlSuiteTestCase.createParameters(new String[] { "search-business-rules/11_pinned_retriever_rrf" });
38+
}
39+
40+
@Override
41+
protected String getTestRestCluster() {
42+
return cluster.getHttpAddresses();
43+
}
44+
}
Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -144,47 +144,6 @@ setup:
144144
- match: { hits.hits.3._id: doc4 }
145145
- match: { hits.hits.4._id: doc5 }
146146

147-
---
148-
"pinned retriever combined with rrf":
149-
- skip:
150-
features: headers
151-
152-
- do:
153-
headers:
154-
Content-Type: application/json
155-
search:
156-
index: test-index1
157-
body:
158-
retriever:
159-
pinned:
160-
ids: ["doc1"]
161-
retriever:
162-
rrf:
163-
retrievers: [
164-
{
165-
standard: {
166-
query: {
167-
term: { text: "document" }
168-
}
169-
}
170-
},
171-
{
172-
standard: {
173-
query: {
174-
term: { text: "three" }
175-
}
176-
}
177-
}
178-
]
179-
rank_window_size: 10
180-
181-
- match: { hits.total.value: 5 }
182-
- match: { hits.hits.0._id: doc1 }
183-
- match: { hits.hits.0._score: 1.7014122E38 }
184-
- match: { hits.hits.1._id: doc3 }
185-
- match: { hits.hits.1._score < 100.0 }
186-
- match: { hits.hits.2._id: doc2 }
187-
188147
---
189148
"pinned retriever with pagination":
190149
- skip: { features: headers }
@@ -208,33 +167,6 @@ setup:
208167
- match: { hits.hits.0._id: doc2 }
209168
- match: { hits.hits.0._score: 1.7014122E38 }
210169

211-
---
212-
"pinned retriever as a sub-retriever":
213-
- skip: { features: headers }
214-
- do:
215-
headers: { Content-Type: application/json }
216-
search:
217-
index: test-index1
218-
body:
219-
retriever:
220-
rrf:
221-
retrievers:
222-
-
223-
standard:
224-
query:
225-
match: { text: "document" }
226-
-
227-
pinned:
228-
ids: ["doc1", "doc2"]
229-
retriever:
230-
standard:
231-
query:
232-
match: { text: "document" }
233-
234-
- match: { hits.total.value: 5 }
235-
- match: { hits.hits.0._id: doc1 }
236-
- lt: { hits.hits.0._score: 100.0 }
237-
238170
---
239171
"pinned retriever with explicit sort on score":
240172
- skip: { features: headers }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
setup:
2+
- do:
3+
indices.create:
4+
index: test-index1
5+
6+
- do:
7+
bulk:
8+
refresh: true
9+
index: test-index1
10+
body:
11+
- index:
12+
_id: doc1
13+
- { "text": "document one" }
14+
- index:
15+
_id: doc2
16+
- { "text": "document two" }
17+
- index:
18+
_id: doc3
19+
- { "text": "document three" }
20+
- index:
21+
_id: doc4
22+
- { "text": "document four" }
23+
- index:
24+
_id: doc5
25+
- { "text": "document five" }
26+
27+
---
28+
"pinned retriever combined with rrf":
29+
- skip:
30+
features: headers
31+
32+
- do:
33+
headers:
34+
Content-Type: application/json
35+
search:
36+
index: test-index1
37+
body:
38+
retriever:
39+
pinned:
40+
ids: ["doc1"]
41+
retriever:
42+
rrf:
43+
retrievers: [
44+
{
45+
standard: {
46+
query: {
47+
term: { text: "document" }
48+
}
49+
}
50+
},
51+
{
52+
standard: {
53+
query: {
54+
term: { text: "three" }
55+
}
56+
}
57+
}
58+
]
59+
rank_window_size: 10
60+
61+
- match: { hits.total.value: 5 }
62+
- match: { hits.hits.0._id: doc1 }
63+
- match: { hits.hits.0._score: 1.7014122E38 }
64+
- match: { hits.hits.1._id: doc3 }
65+
- match: { hits.hits.1._score < 100.0 }
66+
- match: { hits.hits.2._id: doc2 }
67+
68+
---
69+
"pinned retriever as a sub-retriever":
70+
- skip: { features: headers }
71+
- do:
72+
headers: { Content-Type: application/json }
73+
search:
74+
index: test-index1
75+
body:
76+
retriever:
77+
rrf:
78+
retrievers:
79+
-
80+
standard:
81+
query:
82+
match: { text: "document" }
83+
-
84+
pinned:
85+
ids: ["doc1", "doc2"]
86+
retriever:
87+
standard:
88+
query:
89+
match: { text: "document" }
90+
91+
- match: { hits.total.value: 5 }
92+
- match: { hits.hits.0._id: doc1 }
93+
- lt: { hits.hits.0._score: 100.0 }
94+

0 commit comments

Comments
 (0)