Skip to content

Commit 53efbe0

Browse files
committed
Run search CCS tests in a different suite
1 parent ac2e0b0 commit 53efbe0

File tree

5 files changed

+110
-0
lines changed

5 files changed

+110
-0
lines changed

qa/ccs-common-rest/src/yamlRestTest/java/org/elasticsearch/test/rest/yaml/CcsCommonYamlTestSuiteIT.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@
6666
* defined in CCS_APIS against the "search" cluster, while all other operations like indexing are performed
6767
* using the client running against the "write" cluster.
6868
*
69+
* Running all the YAML tests in a single test suite can lead to the suite timing out.
70+
* To avoid timeouts subsets of the tests are executed in specific test suites according
71+
* to the logic in {@link TestSuiteApiCheck}. To further split the tests add another suite
72+
* by subclassing this class then add an entry to {@link TestSuiteApiCheck} mapping the API
73+
* name(s) to the new class.
6974
*/
7075
@TimeoutSuite(millis = 20 * TimeUnits.MINUTE) // to account for slow as hell VMs
7176
public class CcsCommonYamlTestSuiteIT extends ESClientYamlSuiteTestCase {
@@ -298,6 +303,17 @@ public static Iterable<Object[]> parameters() throws Exception {
298303
return createParameters();
299304
}
300305

306+
@Override
307+
public void test() throws IOException {
308+
boolean shouldBeExecutedByThisSuite = TestSuiteApiCheck.shouldExecuteTest(this, getTestCandidate().getApi());
309+
assumeTrue(
310+
"Skipping test as the API [" + getTestCandidate().getApi() + "] is not covered by this suite",
311+
shouldBeExecutedByThisSuite
312+
);
313+
314+
super.test();
315+
}
316+
301317
@Override
302318
protected ClientYamlTestExecutionContext createRestTestExecutionContext(
303319
ClientYamlTestCandidate clientYamlTestCandidate,
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
package org.elasticsearch.test.rest.yaml;
11+
12+
import java.io.IOException;
13+
14+
/**
15+
* Runs the search and msearch API tests only. See {@link TestSuiteApiCheck}
16+
*/
17+
public class CssSearchYamlTestSuiteIT extends CcsCommonYamlTestSuiteIT {
18+
public CssSearchYamlTestSuiteIT(ClientYamlTestCandidate testCandidate) throws IOException {
19+
super(testCandidate);
20+
}
21+
}

qa/ccs-common-rest/src/yamlRestTest/java/org/elasticsearch/test/rest/yaml/RcsCcsCommonYamlTestSuiteIT.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@
6262
* defined in CCS_APIS against the "search" cluster, while all other operations like indexing are performed
6363
* using the client running against the "write" cluster.
6464
*
65+
* Running all the YAML tests in a single test suite can lead to the suite timing out.
66+
* To avoid timeouts subsets of the tests are executed in specific test suites according
67+
* to the logic in {@link TestSuiteApiCheck}. To further split the tests add another suite
68+
* by subclassing this class then add an entry to {@link TestSuiteApiCheck} mapping the API
69+
* name(s) to the new class.
6570
*/
6671
@TimeoutSuite(millis = 25 * TimeUnits.MINUTE) // to account for slow as hell VMs
6772
public class RcsCcsCommonYamlTestSuiteIT extends ESClientYamlSuiteTestCase {
@@ -279,6 +284,17 @@ public static Iterable<Object[]> parameters() throws Exception {
279284
return createParameters();
280285
}
281286

287+
@Override
288+
public void test() throws IOException {
289+
boolean shouldBeExecutedByThisSuite = TestSuiteApiCheck.shouldExecuteTest(this, getTestCandidate().getApi());
290+
assumeTrue(
291+
"Skipping test as the API [" + getTestCandidate().getApi() + "] is not covered by this suite",
292+
shouldBeExecutedByThisSuite
293+
);
294+
295+
super.test();
296+
}
297+
282298
@Override
283299
protected ClientYamlTestExecutionContext createRestTestExecutionContext(
284300
ClientYamlTestCandidate clientYamlTestCandidate,
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
package org.elasticsearch.test.rest.yaml;
11+
12+
import java.io.IOException;
13+
14+
15+
public class RcsCcsSearchYamlTestSuiteIT extends RcsCcsCommonYamlTestSuiteIT {
16+
public RcsCcsSearchYamlTestSuiteIT(ClientYamlTestCandidate testCandidate) throws IOException {
17+
super(testCandidate);
18+
}
19+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
package org.elasticsearch.test.rest.yaml;
11+
12+
/**
13+
* Contains the logic for which test suites should execute which tests.
14+
* YAML tests are split between multiple suites to avoid the test suite timing out.
15+
*/
16+
class TestSuiteApiCheck {
17+
18+
/**
19+
* Returns true if the test suite should run the tests for the given API.
20+
* @param testSuite a concrete subclass of ESClientYamlSuiteTestCase
21+
* @param apiName The API name as described in the rest spec e.g. `search`
22+
* @return True if the test
23+
*/
24+
public static boolean shouldExecuteTest(ESClientYamlSuiteTestCase testSuite, String apiName) {
25+
return switch (testSuite) {
26+
case CssSearchYamlTestSuiteIT cssSearch -> isSearchApi(apiName);
27+
case RcsCcsSearchYamlTestSuiteIT rssSearch -> isSearchApi(apiName);
28+
default -> true;
29+
};
30+
}
31+
32+
private static boolean isSearchApi(String apiName) {
33+
return apiName.startsWith("search") || apiName.startsWith("msearch");
34+
}
35+
36+
private TestSuiteApiCheck() {
37+
}
38+
}

0 commit comments

Comments
 (0)