Skip to content

Commit fc7ac3c

Browse files
authored
Split the CCS YAML rest tests into a multiple tests (elastic#139107)
Running full test set in a single IT file can lead to suite timeouts on slow machines. This moves the search APIs tests into a different IT.
1 parent 1cdc01f commit fc7ac3c

File tree

5 files changed

+114
-0
lines changed

5 files changed

+114
-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 {
@@ -297,6 +302,17 @@ public static Iterable<Object[]> parameters() throws Exception {
297302
return createParameters();
298303
}
299304

305+
@Override
306+
public void test() throws IOException {
307+
boolean shouldBeExecutedByThisSuite = TestSuiteApiCheck.shouldExecuteTest(this, getTestCandidate().getApi());
308+
assumeTrue(
309+
"Skipping test as the API [" + getTestCandidate().getApi() + "] is not covered by this suite",
310+
shouldBeExecutedByThisSuite
311+
);
312+
313+
super.test();
314+
}
315+
300316
@Override
301317
protected ClientYamlTestExecutionContext createRestTestExecutionContext(
302318
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 {
@@ -278,6 +283,17 @@ public static Iterable<Object[]> parameters() throws Exception {
278283
return createParameters();
279284
}
280285

286+
@Override
287+
public void test() throws IOException {
288+
boolean shouldBeExecutedByThisSuite = TestSuiteApiCheck.shouldExecuteTest(this, getTestCandidate().getApi());
289+
assumeTrue(
290+
"Skipping test as the API [" + getTestCandidate().getApi() + "] is not covered by this suite",
291+
shouldBeExecutedByThisSuite
292+
);
293+
294+
super.test();
295+
}
296+
281297
@Override
282298
protected ClientYamlTestExecutionContext createRestTestExecutionContext(
283299
ClientYamlTestCandidate clientYamlTestCandidate,
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
public class RcsCcsSearchYamlTestSuiteIT extends RcsCcsCommonYamlTestSuiteIT {
15+
public RcsCcsSearchYamlTestSuiteIT(ClientYamlTestCandidate testCandidate) throws IOException {
16+
super(testCandidate);
17+
}
18+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
* IMPORTANT: This is a temporary solution to reduce the number of test failures
17+
* due to suite timeouts for this large test set which suffers the problem more
18+
* than most. It is not a pattern that should be copied or applied elsewhere.
19+
* A longer term solution would be the test runner automatically splitting the
20+
* tests.
21+
*/
22+
class TestSuiteApiCheck {
23+
24+
/**
25+
* Returns true if the test suite should run the tests for the given API.
26+
* @param testSuite a concrete subclass of ESClientYamlSuiteTestCase
27+
* @param apiName The API name as described in the rest spec e.g. `search`
28+
* @return True if the test
29+
*/
30+
public static boolean shouldExecuteTest(ESClientYamlSuiteTestCase testSuite, String apiName) {
31+
return switch (testSuite) {
32+
case CssSearchYamlTestSuiteIT cssSearch -> isSearchApi(apiName);
33+
case RcsCcsSearchYamlTestSuiteIT rssSearch -> isSearchApi(apiName);
34+
default -> true;
35+
};
36+
}
37+
38+
private static boolean isSearchApi(String apiName) {
39+
return apiName.startsWith("search") || apiName.startsWith("msearch");
40+
}
41+
42+
private TestSuiteApiCheck() {}
43+
}

0 commit comments

Comments
 (0)