Browse Source

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.
Jason Tedor 7 years ago
parent
commit
aa56892f2f

+ 22 - 2
x-pack/plugin/ccr/build.gradle

@@ -14,8 +14,6 @@ esplugin {
 }
 archivesBaseName = 'x-pack-ccr'
 
-integTest.enabled = false
-
 compileJava.options.compilerArgs << "-Xlint:-try"
 compileTestJava.options.compilerArgs << "-Xlint:-try"
 
@@ -29,9 +27,31 @@ task internalClusterTest(type: RandomizedTestingTask,
     classpath = project.test.classpath
     testClassesDirs = project.test.testClassesDirs
     include '**/*IT.class'
+    exclude '**/CcrRestIT.class'
     systemProperty 'es.set.netty.runtime.available.processors', 'false'
 }
 
+integTestCluster {
+    distribution 'zip'
+    setting 'xpack.ml.enabled', 'false'
+    setting 'xpack.monitoring.enabled', 'false'
+    setting 'xpack.security.enabled', 'true'
+    setting 'xpack.license.self_generated.type', 'trial'
+    // TODO: reduce the need for superuser here
+    setupCommand 'setup-ccr-user',
+            'bin/elasticsearch-users', 'useradd', 'ccr-user', '-p', 'ccr-user-password', '-r', 'superuser'
+    waitCondition = { node, ant ->
+        File tmpFile = new File(node.cwd, 'wait.success')
+        ant.get(src: "http://${node.httpUri()}/_cluster/health?wait_for_nodes=>=${numNodes}&wait_for_status=yellow",
+                dest: tmpFile.toString(),
+                username: 'ccr-user',
+                password: 'ccr-user-password',
+                ignoreerrors: true,
+                retries: 10)
+        return tmpFile.exists()
+    }
+}
+
 check.dependsOn internalClusterTest
 internalClusterTest.mustRunAfter test
 

+ 42 - 0
x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/CcrRestIT.java

@@ -0,0 +1,42 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+
+package org.elasticsearch.xpack.ccr;
+
+import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
+import org.elasticsearch.common.settings.SecureString;
+import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.common.util.concurrent.ThreadContext;
+import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
+import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
+import org.elasticsearch.xpack.test.rest.XPackRestTestHelper;
+import org.junit.After;
+
+import static org.elasticsearch.xpack.core.security.authc.support.UsernamePasswordToken.basicAuthHeaderValue;
+
+public class CcrRestIT extends ESClientYamlSuiteTestCase {
+
+    public CcrRestIT(final ClientYamlTestCandidate testCandidate) {
+        super(testCandidate);
+    }
+
+    @ParametersFactory
+    public static Iterable<Object[]> parameters() throws Exception {
+        return ESClientYamlSuiteTestCase.createParameters();
+    }
+
+    @Override
+    protected Settings restClientSettings() {
+        final String ccrUserAuthHeaderValue = basicAuthHeaderValue("ccr-user", new SecureString("ccr-user-password".toCharArray()));
+        return Settings.builder().put(ThreadContext.PREFIX + ".Authorization", ccrUserAuthHeaderValue).build();
+    }
+
+    @After
+    public void cleanup() throws Exception {
+        XPackRestTestHelper.waitForPendingTasks(adminClient());
+    }
+
+}

+ 0 - 0
x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.create_and_follow_index.json → x-pack/plugin/ccr/src/test/resources/rest-api-spec/api/ccr.create_and_follow_index.json


+ 0 - 0
x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.delete_auto_follow_pattern.json → x-pack/plugin/ccr/src/test/resources/rest-api-spec/api/ccr.delete_auto_follow_pattern.json


+ 0 - 0
x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.follow_index.json → x-pack/plugin/ccr/src/test/resources/rest-api-spec/api/ccr.follow_index.json


+ 0 - 0
x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.put_auto_follow_pattern.json → x-pack/plugin/ccr/src/test/resources/rest-api-spec/api/ccr.put_auto_follow_pattern.json


+ 0 - 0
x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.stats.json → x-pack/plugin/ccr/src/test/resources/rest-api-spec/api/ccr.stats.json


+ 0 - 0
x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.unfollow_index.json → x-pack/plugin/ccr/src/test/resources/rest-api-spec/api/ccr.unfollow_index.json


+ 0 - 0
x-pack/plugin/src/test/resources/rest-api-spec/test/ccr/auto_follow.yml → x-pack/plugin/ccr/src/test/resources/rest-api-spec/test/ccr/auto_follow.yml


+ 0 - 0
x-pack/plugin/src/test/resources/rest-api-spec/test/ccr/follow_and_unfollow.yml → x-pack/plugin/ccr/src/test/resources/rest-api-spec/test/ccr/follow_and_unfollow.yml


+ 0 - 0
x-pack/plugin/src/test/resources/rest-api-spec/test/ccr/stats.yml → x-pack/plugin/ccr/src/test/resources/rest-api-spec/test/ccr/stats.yml