From aa56892f2fb8416e32bbcea3366e0c4e0146601d Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Sat, 15 Sep 2018 09:18:15 -0400 Subject: [PATCH] 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. --- x-pack/plugin/ccr/build.gradle | 24 ++++++++++- .../elasticsearch/xpack/ccr/CcrRestIT.java | 42 +++++++++++++++++++ .../api/ccr.create_and_follow_index.json | 0 .../api/ccr.delete_auto_follow_pattern.json | 0 .../rest-api-spec/api/ccr.follow_index.json | 0 .../api/ccr.put_auto_follow_pattern.json | 0 .../rest-api-spec/api/ccr.stats.json | 0 .../rest-api-spec/api/ccr.unfollow_index.json | 0 .../rest-api-spec/test/ccr/auto_follow.yml | 0 .../test/ccr/follow_and_unfollow.yml | 0 .../rest-api-spec/test/ccr/stats.yml | 0 11 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/CcrRestIT.java rename x-pack/plugin/{ => ccr}/src/test/resources/rest-api-spec/api/ccr.create_and_follow_index.json (100%) rename x-pack/plugin/{ => ccr}/src/test/resources/rest-api-spec/api/ccr.delete_auto_follow_pattern.json (100%) rename x-pack/plugin/{ => ccr}/src/test/resources/rest-api-spec/api/ccr.follow_index.json (100%) rename x-pack/plugin/{ => ccr}/src/test/resources/rest-api-spec/api/ccr.put_auto_follow_pattern.json (100%) rename x-pack/plugin/{ => ccr}/src/test/resources/rest-api-spec/api/ccr.stats.json (100%) rename x-pack/plugin/{ => ccr}/src/test/resources/rest-api-spec/api/ccr.unfollow_index.json (100%) rename x-pack/plugin/{ => ccr}/src/test/resources/rest-api-spec/test/ccr/auto_follow.yml (100%) rename x-pack/plugin/{ => ccr}/src/test/resources/rest-api-spec/test/ccr/follow_and_unfollow.yml (100%) rename x-pack/plugin/{ => ccr}/src/test/resources/rest-api-spec/test/ccr/stats.yml (100%) diff --git a/x-pack/plugin/ccr/build.gradle b/x-pack/plugin/ccr/build.gradle index ea8aa897777..f4c7c09c19e 100644 --- a/x-pack/plugin/ccr/build.gradle +++ b/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 diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/CcrRestIT.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/CcrRestIT.java new file mode 100644 index 00000000000..45998433d33 --- /dev/null +++ b/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 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()); + } + +} diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.create_and_follow_index.json b/x-pack/plugin/ccr/src/test/resources/rest-api-spec/api/ccr.create_and_follow_index.json similarity index 100% rename from x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.create_and_follow_index.json rename to x-pack/plugin/ccr/src/test/resources/rest-api-spec/api/ccr.create_and_follow_index.json diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.delete_auto_follow_pattern.json b/x-pack/plugin/ccr/src/test/resources/rest-api-spec/api/ccr.delete_auto_follow_pattern.json similarity index 100% rename from x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.delete_auto_follow_pattern.json rename to x-pack/plugin/ccr/src/test/resources/rest-api-spec/api/ccr.delete_auto_follow_pattern.json diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.follow_index.json b/x-pack/plugin/ccr/src/test/resources/rest-api-spec/api/ccr.follow_index.json similarity index 100% rename from x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.follow_index.json rename to x-pack/plugin/ccr/src/test/resources/rest-api-spec/api/ccr.follow_index.json diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.put_auto_follow_pattern.json b/x-pack/plugin/ccr/src/test/resources/rest-api-spec/api/ccr.put_auto_follow_pattern.json similarity index 100% rename from x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.put_auto_follow_pattern.json rename to x-pack/plugin/ccr/src/test/resources/rest-api-spec/api/ccr.put_auto_follow_pattern.json diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.stats.json b/x-pack/plugin/ccr/src/test/resources/rest-api-spec/api/ccr.stats.json similarity index 100% rename from x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.stats.json rename to x-pack/plugin/ccr/src/test/resources/rest-api-spec/api/ccr.stats.json diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.unfollow_index.json b/x-pack/plugin/ccr/src/test/resources/rest-api-spec/api/ccr.unfollow_index.json similarity index 100% rename from x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.unfollow_index.json rename to x-pack/plugin/ccr/src/test/resources/rest-api-spec/api/ccr.unfollow_index.json diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/ccr/auto_follow.yml b/x-pack/plugin/ccr/src/test/resources/rest-api-spec/test/ccr/auto_follow.yml similarity index 100% rename from x-pack/plugin/src/test/resources/rest-api-spec/test/ccr/auto_follow.yml rename to x-pack/plugin/ccr/src/test/resources/rest-api-spec/test/ccr/auto_follow.yml diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/ccr/follow_and_unfollow.yml b/x-pack/plugin/ccr/src/test/resources/rest-api-spec/test/ccr/follow_and_unfollow.yml similarity index 100% rename from x-pack/plugin/src/test/resources/rest-api-spec/test/ccr/follow_and_unfollow.yml rename to x-pack/plugin/ccr/src/test/resources/rest-api-spec/test/ccr/follow_and_unfollow.yml diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/ccr/stats.yml b/x-pack/plugin/ccr/src/test/resources/rest-api-spec/test/ccr/stats.yml similarity index 100% rename from x-pack/plugin/src/test/resources/rest-api-spec/test/ccr/stats.yml rename to x-pack/plugin/ccr/src/test/resources/rest-api-spec/test/ccr/stats.yml