Skip to content

Commit aa56892

Browse files
authored
Move CCR REST tests to ccr sub-project (#33731)
This commit moves the CCR REST tests to the ccr sub-project as another step towards running :x-pack:plugin:ccr:check giving us full coverage on CCR.
1 parent f037edb commit aa56892

11 files changed

+64
-2
lines changed

x-pack/plugin/ccr/build.gradle

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ esplugin {
1414
}
1515
archivesBaseName = 'x-pack-ccr'
1616

17-
integTest.enabled = false
18-
1917
compileJava.options.compilerArgs << "-Xlint:-try"
2018
compileTestJava.options.compilerArgs << "-Xlint:-try"
2119

@@ -29,9 +27,31 @@ task internalClusterTest(type: RandomizedTestingTask,
2927
classpath = project.test.classpath
3028
testClassesDirs = project.test.testClassesDirs
3129
include '**/*IT.class'
30+
exclude '**/CcrRestIT.class'
3231
systemProperty 'es.set.netty.runtime.available.processors', 'false'
3332
}
3433

34+
integTestCluster {
35+
distribution 'zip'
36+
setting 'xpack.ml.enabled', 'false'
37+
setting 'xpack.monitoring.enabled', 'false'
38+
setting 'xpack.security.enabled', 'true'
39+
setting 'xpack.license.self_generated.type', 'trial'
40+
// TODO: reduce the need for superuser here
41+
setupCommand 'setup-ccr-user',
42+
'bin/elasticsearch-users', 'useradd', 'ccr-user', '-p', 'ccr-user-password', '-r', 'superuser'
43+
waitCondition = { node, ant ->
44+
File tmpFile = new File(node.cwd, 'wait.success')
45+
ant.get(src: "http://${node.httpUri()}/_cluster/health?wait_for_nodes=>=${numNodes}&wait_for_status=yellow",
46+
dest: tmpFile.toString(),
47+
username: 'ccr-user',
48+
password: 'ccr-user-password',
49+
ignoreerrors: true,
50+
retries: 10)
51+
return tmpFile.exists()
52+
}
53+
}
54+
3555
check.dependsOn internalClusterTest
3656
internalClusterTest.mustRunAfter test
3757

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
package org.elasticsearch.xpack.ccr;
8+
9+
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
10+
import org.elasticsearch.common.settings.SecureString;
11+
import org.elasticsearch.common.settings.Settings;
12+
import org.elasticsearch.common.util.concurrent.ThreadContext;
13+
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
14+
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
15+
import org.elasticsearch.xpack.test.rest.XPackRestTestHelper;
16+
import org.junit.After;
17+
18+
import static org.elasticsearch.xpack.core.security.authc.support.UsernamePasswordToken.basicAuthHeaderValue;
19+
20+
public class CcrRestIT extends ESClientYamlSuiteTestCase {
21+
22+
public CcrRestIT(final ClientYamlTestCandidate testCandidate) {
23+
super(testCandidate);
24+
}
25+
26+
@ParametersFactory
27+
public static Iterable<Object[]> parameters() throws Exception {
28+
return ESClientYamlSuiteTestCase.createParameters();
29+
}
30+
31+
@Override
32+
protected Settings restClientSettings() {
33+
final String ccrUserAuthHeaderValue = basicAuthHeaderValue("ccr-user", new SecureString("ccr-user-password".toCharArray()));
34+
return Settings.builder().put(ThreadContext.PREFIX + ".Authorization", ccrUserAuthHeaderValue).build();
35+
}
36+
37+
@After
38+
public void cleanup() throws Exception {
39+
XPackRestTestHelper.waitForPendingTasks(adminClient());
40+
}
41+
42+
}

0 commit comments

Comments
 (0)