mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-04-24 23:27:25 -04:00
Remove xpack dependencies from qa rest modules (#41134)
This commit removes xpack dependencies of many xpack qa modules. (for some qa modules this will require some more work) The reason behind this change is that qa rest modules should not depend on the x-pack plugins, because the plugins are an implementation detail and the tests should only know about the rest interface and qa cluster that is being tested. Also some qa modules rely on xpack plugins and hlrc (which is a valid dependency for rest qa tests) creates a cyclic dependency and this is something that we should avoid. Also Eclipse can't handle gradle cyclic dependencies (see #41064). * don't copy xpack-core's plugin property into the test resource of qa modules. Otherwise installing security manager fails, because it tries to find the XPackPlugin class.
This commit is contained in:
parent
f0fac9f56b
commit
7543478faf
34 changed files with 173 additions and 147 deletions
|
@ -3,7 +3,7 @@
|
||||||
* or more contributor license agreements. Licensed under the Elastic License;
|
* or more contributor license agreements. Licensed under the Elastic License;
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
* you may not use this file except in compliance with the Elastic License.
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.smoketest;
|
package org.elasticsearch.xpack.watcher.support;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.io.JsonStringEncoder;
|
import com.fasterxml.jackson.core.io.JsonStringEncoder;
|
||||||
import org.elasticsearch.common.Nullable;
|
import org.elasticsearch.common.Nullable;
|
|
@ -3,6 +3,13 @@
|
||||||
|
|
||||||
import org.elasticsearch.gradle.test.RestIntegTestTask
|
import org.elasticsearch.gradle.test.RestIntegTestTask
|
||||||
|
|
||||||
|
apply plugin: 'elasticsearch.build'
|
||||||
|
test.enabled = false
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile project(':test:framework')
|
||||||
|
}
|
||||||
|
|
||||||
subprojects {
|
subprojects {
|
||||||
// HACK: please fix this
|
// HACK: please fix this
|
||||||
// we want to add the rest api specs for xpack to qa tests, but we
|
// we want to add the rest api specs for xpack to qa tests, but we
|
||||||
|
|
|
@ -2,8 +2,7 @@ apply plugin: 'elasticsearch.standalone-rest-test'
|
||||||
apply plugin: 'elasticsearch.rest-test'
|
apply plugin: 'elasticsearch.rest-test'
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
testCompile project(path: xpackModule('core'), configuration: 'testArtifacts')
|
testCompile project(':x-pack:qa')
|
||||||
testCompile project(path: xpackModule('security'), configuration: 'testArtifacts')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
integTest {
|
integTest {
|
||||||
|
|
|
@ -18,7 +18,7 @@ import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import static org.elasticsearch.xpack.core.security.authc.support.UsernamePasswordToken.basicAuthHeaderValue;
|
import static org.elasticsearch.xpack.test.SecuritySettingsSourceField.basicAuthHeaderValue;
|
||||||
|
|
||||||
@TimeoutSuite(millis = 30 * TimeUnits.MINUTE) // as default timeout seems not enough on the jenkins VMs
|
@TimeoutSuite(millis = 30 * TimeUnits.MINUTE) // as default timeout seems not enough on the jenkins VMs
|
||||||
public class CoreWithSecurityClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase {
|
public class CoreWithSecurityClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase {
|
||||||
|
|
|
@ -10,22 +10,12 @@ apply plugin: 'elasticsearch.standalone-test'
|
||||||
test.enabled = false
|
test.enabled = false
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// "org.elasticsearch.plugin:x-pack-core:${version}" doesn't work with idea because the testArtifacts are also here
|
// TODO: Remove core dependency and change tests to not use builders that are part of xpack-core.
|
||||||
testCompile project(path: xpackModule('core'), configuration: 'default')
|
// Currently needed for ml tests are using the building for datafeed and job config)
|
||||||
testCompile (project(path: xpackModule('security'), configuration: 'runtime')) {
|
|
||||||
// Need to drop the guava dependency here or we get a conflict with watcher's guava dependency.
|
|
||||||
// This is total #$%, but the solution is to get the SAML realm (which uses guava) out of security proper
|
|
||||||
exclude group: "com.google.guava", module: "guava"
|
|
||||||
}
|
|
||||||
testCompile project(path: xpackModule('watcher'), configuration: 'runtime')
|
|
||||||
|
|
||||||
testCompile project(path: xpackModule('core'), configuration: 'testArtifacts')
|
testCompile project(path: xpackModule('core'), configuration: 'testArtifacts')
|
||||||
testCompile (project(path: xpackModule('security'), configuration: 'testArtifacts')) {
|
|
||||||
// Need to drop the guava dependency here or we get a conflict with watcher's guava dependency.
|
|
||||||
// This is total #$%, but the solution is to get the SAML realm (which uses guava) out of security proper
|
|
||||||
exclude group: "com.google.guava", module: "guava"
|
|
||||||
}
|
|
||||||
testCompile project(path: ':qa:full-cluster-restart', configuration: 'testArtifacts')
|
testCompile project(path: ':qa:full-cluster-restart', configuration: 'testArtifacts')
|
||||||
|
testCompile project(':x-pack:qa')
|
||||||
}
|
}
|
||||||
|
|
||||||
Closure waitWithAuth = { NodeInfo node, AntBuilder ant ->
|
Closure waitWithAuth = { NodeInfo node, AntBuilder ant ->
|
||||||
|
@ -225,11 +215,4 @@ task copyXPackRestSpec(type: Copy) {
|
||||||
include 'rest-api-spec/api/**'
|
include 'rest-api-spec/api/**'
|
||||||
into project.sourceSets.test.output.resourcesDir
|
into project.sourceSets.test.output.resourcesDir
|
||||||
}
|
}
|
||||||
|
project.sourceSets.test.output.dir(outputDir, builtBy: copyXPackRestSpec)
|
||||||
task copyXPackPluginProps(type: Copy) {
|
|
||||||
dependsOn(copyXPackRestSpec)
|
|
||||||
from project(xpackModule('core')).file('src/main/plugin-metadata')
|
|
||||||
from project(xpackModule('core')).tasks.pluginProperties
|
|
||||||
into outputDir
|
|
||||||
}
|
|
||||||
project.sourceSets.test.output.dir(outputDir, builtBy: copyXPackPluginProps)
|
|
||||||
|
|
|
@ -13,22 +13,12 @@ import org.elasticsearch.client.ResponseException;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.util.concurrent.ThreadContext;
|
import org.elasticsearch.common.util.concurrent.ThreadContext;
|
||||||
import org.elasticsearch.common.xcontent.ObjectPath;
|
import org.elasticsearch.common.xcontent.ObjectPath;
|
||||||
import org.elasticsearch.common.xcontent.XContentType;
|
|
||||||
import org.elasticsearch.common.xcontent.support.XContentMapValues;
|
import org.elasticsearch.common.xcontent.support.XContentMapValues;
|
||||||
import org.elasticsearch.rest.RestStatus;
|
import org.elasticsearch.rest.RestStatus;
|
||||||
import org.elasticsearch.rest.action.search.RestSearchAction;
|
import org.elasticsearch.rest.action.search.RestSearchAction;
|
||||||
import org.elasticsearch.test.StreamsUtils;
|
import org.elasticsearch.test.StreamsUtils;
|
||||||
import org.elasticsearch.test.rest.ESRestTestCase;
|
import org.elasticsearch.test.rest.ESRestTestCase;
|
||||||
import org.elasticsearch.upgrades.AbstractFullClusterRestartTestCase;
|
import org.elasticsearch.upgrades.AbstractFullClusterRestartTestCase;
|
||||||
import org.elasticsearch.xpack.core.upgrade.UpgradeField;
|
|
||||||
import org.elasticsearch.xpack.core.watcher.client.WatchSourceBuilder;
|
|
||||||
import org.elasticsearch.xpack.security.support.SecurityIndexManager;
|
|
||||||
import org.elasticsearch.xpack.watcher.actions.index.IndexAction;
|
|
||||||
import org.elasticsearch.xpack.watcher.actions.logging.LoggingAction;
|
|
||||||
import org.elasticsearch.xpack.watcher.common.text.TextTemplate;
|
|
||||||
import org.elasticsearch.xpack.watcher.condition.InternalAlwaysCondition;
|
|
||||||
import org.elasticsearch.xpack.watcher.trigger.schedule.IntervalSchedule;
|
|
||||||
import org.elasticsearch.xpack.watcher.trigger.schedule.ScheduleTrigger;
|
|
||||||
import org.hamcrest.Matcher;
|
import org.hamcrest.Matcher;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -54,6 +44,12 @@ import static org.hamcrest.Matchers.startsWith;
|
||||||
|
|
||||||
public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
||||||
|
|
||||||
|
public static final String INDEX_ACTION_TYPES_DEPRECATION_MESSAGE =
|
||||||
|
"[types removal] Specifying types in a watcher index action is deprecated.";
|
||||||
|
|
||||||
|
public static final int UPGRADE_FIELD_EXPECTED_INDEX_FORMAT_VERSION = 6;
|
||||||
|
public static final int SECURITY_EXPECTED_INDEX_FORMAT_VERSION = 6;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Settings restClientSettings() {
|
protected Settings restClientSettings() {
|
||||||
String token = "Basic " + Base64.getEncoder().encodeToString("test_user:x-pack-test-password".getBytes(StandardCharsets.UTF_8));
|
String token = "Basic " + Base64.getEncoder().encodeToString("test_user:x-pack-test-password".getBytes(StandardCharsets.UTF_8));
|
||||||
|
@ -106,7 +102,7 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
||||||
if (settingsMap.containsKey("index")) {
|
if (settingsMap.containsKey("index")) {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
int format = Integer.parseInt(String.valueOf(((Map<String, Object>)settingsMap.get("index")).get("format")));
|
int format = Integer.parseInt(String.valueOf(((Map<String, Object>)settingsMap.get("index")).get("format")));
|
||||||
assertEquals("The security index needs to be upgraded", SecurityIndexManager.INTERNAL_INDEX_FORMAT, format);
|
assertEquals("The security index needs to be upgraded", SECURITY_EXPECTED_INDEX_FORMAT_VERSION, format);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,8 +123,8 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
||||||
Request createBwcWatch = new Request("PUT", getWatcherEndpoint() + "/watch/bwc_watch");
|
Request createBwcWatch = new Request("PUT", getWatcherEndpoint() + "/watch/bwc_watch");
|
||||||
Request createBwcThrottlePeriod = new Request("PUT", getWatcherEndpoint() + "/watch/bwc_throttle_period");
|
Request createBwcThrottlePeriod = new Request("PUT", getWatcherEndpoint() + "/watch/bwc_throttle_period");
|
||||||
if (getOldClusterVersion().onOrAfter(Version.V_7_0_0)) {
|
if (getOldClusterVersion().onOrAfter(Version.V_7_0_0)) {
|
||||||
createBwcWatch.setOptions(expectWarnings(IndexAction.TYPES_DEPRECATION_MESSAGE));
|
createBwcWatch.setOptions(expectWarnings(INDEX_ACTION_TYPES_DEPRECATION_MESSAGE));
|
||||||
createBwcThrottlePeriod.setOptions(expectWarnings(IndexAction.TYPES_DEPRECATION_MESSAGE));
|
createBwcThrottlePeriod.setOptions(expectWarnings(INDEX_ACTION_TYPES_DEPRECATION_MESSAGE));
|
||||||
}
|
}
|
||||||
createBwcWatch.setJsonEntity(loadWatch("simple-watch.json"));
|
createBwcWatch.setJsonEntity(loadWatch("simple-watch.json"));
|
||||||
client().performRequest(createBwcWatch);
|
client().performRequest(createBwcWatch);
|
||||||
|
@ -166,7 +162,7 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
||||||
logger.info("settings map {}", settingsMap);
|
logger.info("settings map {}", settingsMap);
|
||||||
if (settingsMap.containsKey("index")) {
|
if (settingsMap.containsKey("index")) {
|
||||||
int format = Integer.parseInt(String.valueOf(((Map<String, Object>)settingsMap.get("index")).get("format")));
|
int format = Integer.parseInt(String.valueOf(((Map<String, Object>)settingsMap.get("index")).get("format")));
|
||||||
assertEquals("The watches index needs to be upgraded", UpgradeField.EXPECTED_INDEX_FORMAT_VERSION, format);
|
assertEquals("The watches index needs to be upgraded", UPGRADE_FIELD_EXPECTED_INDEX_FORMAT_VERSION, format);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,7 +285,7 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
||||||
Request getRequest = new Request("GET", "_watcher/watch/bwc_watch");
|
Request getRequest = new Request("GET", "_watcher/watch/bwc_watch");
|
||||||
getRequest.setOptions(
|
getRequest.setOptions(
|
||||||
expectWarnings(
|
expectWarnings(
|
||||||
IndexAction.TYPES_DEPRECATION_MESSAGE
|
INDEX_ACTION_TYPES_DEPRECATION_MESSAGE
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -310,7 +306,7 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
||||||
getRequest = new Request("GET", "_watcher/watch/bwc_throttle_period");
|
getRequest = new Request("GET", "_watcher/watch/bwc_throttle_period");
|
||||||
getRequest.setOptions(
|
getRequest.setOptions(
|
||||||
expectWarnings(
|
expectWarnings(
|
||||||
IndexAction.TYPES_DEPRECATION_MESSAGE
|
INDEX_ACTION_TYPES_DEPRECATION_MESSAGE
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -352,10 +348,9 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
||||||
|
|
||||||
private void assertBasicWatchInteractions() throws Exception {
|
private void assertBasicWatchInteractions() throws Exception {
|
||||||
|
|
||||||
String watch = new WatchSourceBuilder()
|
String watch = "{\"trigger\":{\"schedule\":{\"interval\":\"1s\"}},\"input\":{\"none\":{}}," +
|
||||||
.condition(InternalAlwaysCondition.INSTANCE)
|
"\"condition\":{\"always\":{}}," +
|
||||||
.trigger(ScheduleTrigger.builder(new IntervalSchedule(IntervalSchedule.Interval.seconds(1))))
|
"\"actions\":{\"awesome\":{\"logging\":{\"level\":\"info\",\"text\":\"test\"}}}}";
|
||||||
.addAction("awesome", LoggingAction.builder(new TextTemplate("test"))).buildAsBytes(XContentType.JSON).utf8ToString();
|
|
||||||
Request createWatchRequest = new Request("PUT", "_watcher/watch/new_watch");
|
Request createWatchRequest = new Request("PUT", "_watcher/watch/new_watch");
|
||||||
createWatchRequest.setJsonEntity(watch);
|
createWatchRequest.setJsonEntity(watch);
|
||||||
Map<String, Object> createWatch = entityAsMap(client().performRequest(createWatchRequest));
|
Map<String, Object> createWatch = entityAsMap(client().performRequest(createWatchRequest));
|
||||||
|
|
|
@ -24,6 +24,7 @@ import org.elasticsearch.xpack.core.ml.job.config.AnalysisConfig;
|
||||||
import org.elasticsearch.xpack.core.ml.job.config.DataDescription;
|
import org.elasticsearch.xpack.core.ml.job.config.DataDescription;
|
||||||
import org.elasticsearch.xpack.core.ml.job.config.Detector;
|
import org.elasticsearch.xpack.core.ml.job.config.Detector;
|
||||||
import org.elasticsearch.xpack.core.ml.job.config.Job;
|
import org.elasticsearch.xpack.core.ml.job.config.Job;
|
||||||
|
import org.elasticsearch.xpack.test.rest.XPackRestTestConstants;
|
||||||
import org.elasticsearch.xpack.test.rest.XPackRestTestHelper;
|
import org.elasticsearch.xpack.test.rest.XPackRestTestHelper;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
|
||||||
|
@ -56,7 +57,7 @@ public class MlMigrationFullClusterRestartIT extends AbstractFullClusterRestartT
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void waitForMlTemplates() throws Exception {
|
public void waitForMlTemplates() throws Exception {
|
||||||
List<String> templatesToWaitFor = XPackRestTestHelper.ML_POST_V660_TEMPLATES;
|
List<String> templatesToWaitFor = XPackRestTestConstants.ML_POST_V660_TEMPLATES;
|
||||||
XPackRestTestHelper.waitForTemplates(client(), templatesToWaitFor);
|
XPackRestTestHelper.waitForTemplates(client(), templatesToWaitFor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,7 @@ import org.elasticsearch.gradle.test.RestIntegTestTask
|
||||||
apply plugin: 'elasticsearch.standalone-test'
|
apply plugin: 'elasticsearch.standalone-test'
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// "org.elasticsearch.plugin:x-pack-core:${version}" doesn't work with idea because the testArtifacts are also here
|
testCompile project(':x-pack:qa')
|
||||||
testCompile project(path: xpackModule('core'), configuration: 'default')
|
|
||||||
testCompile project(path: xpackModule('core'), configuration: 'testArtifacts')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
task remoteClusterTest(type: RestIntegTestTask) {
|
task remoteClusterTest(type: RestIntegTestTask) {
|
||||||
|
|
|
@ -14,7 +14,7 @@ import org.elasticsearch.common.util.concurrent.ThreadContext;
|
||||||
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
|
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
|
||||||
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
|
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
|
||||||
|
|
||||||
import static org.elasticsearch.xpack.core.security.authc.support.UsernamePasswordToken.basicAuthHeaderValue;
|
import static org.elasticsearch.xpack.test.SecuritySettingsSourceField.basicAuthHeaderValue;
|
||||||
|
|
||||||
public class MultiClusterSearchWithSecurityYamlTestSuiteIT extends ESClientYamlSuiteTestCase {
|
public class MultiClusterSearchWithSecurityYamlTestSuiteIT extends ESClientYamlSuiteTestCase {
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ apply plugin: 'elasticsearch.standalone-rest-test'
|
||||||
apply plugin: 'elasticsearch.rest-test'
|
apply plugin: 'elasticsearch.rest-test'
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
testCompile "org.elasticsearch.plugin:x-pack-core:${version}"
|
testCompile project(':x-pack:qa')
|
||||||
}
|
}
|
||||||
|
|
||||||
integTestCluster {
|
integTestCluster {
|
||||||
|
|
|
@ -16,7 +16,7 @@ import org.elasticsearch.test.rest.ESRestTestCase;
|
||||||
import org.elasticsearch.test.rest.yaml.ObjectPath;
|
import org.elasticsearch.test.rest.yaml.ObjectPath;
|
||||||
|
|
||||||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
||||||
import static org.elasticsearch.xpack.core.security.authc.support.UsernamePasswordToken.basicAuthHeaderValue;
|
import static org.elasticsearch.xpack.test.SecuritySettingsSourceField.basicAuthHeaderValue;
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
|
|
||||||
public class GlobalCheckpointSyncActionIT extends ESRestTestCase {
|
public class GlobalCheckpointSyncActionIT extends ESRestTestCase {
|
||||||
|
|
|
@ -32,7 +32,7 @@ import java.util.Map;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
||||||
import static org.elasticsearch.xpack.core.security.authc.support.UsernamePasswordToken.basicAuthHeaderValue;
|
import static org.elasticsearch.xpack.test.SecuritySettingsSourceField.basicAuthHeaderValue;
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
import static org.hamcrest.Matchers.isOneOf;
|
import static org.hamcrest.Matchers.isOneOf;
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,7 @@ import org.elasticsearch.gradle.test.RestIntegTestTask
|
||||||
apply plugin: 'elasticsearch.standalone-test'
|
apply plugin: 'elasticsearch.standalone-test'
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// "org.elasticsearch.plugin:x-pack-core:${version}" doesn't work with idea because the testArtifacts are also here
|
testCompile project(':x-pack:qa')
|
||||||
testCompile project(path: xpackModule('core'), configuration: 'default')
|
|
||||||
testCompile project(path: xpackModule('core'), configuration: 'testArtifacts') // to be moved in a later commit
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is a top level task which we will add dependencies to below.
|
// This is a top level task which we will add dependencies to below.
|
||||||
|
@ -141,14 +139,7 @@ task copyXPackRestSpec(type: Copy) {
|
||||||
include 'rest-api-spec/api/**'
|
include 'rest-api-spec/api/**'
|
||||||
into project.sourceSets.test.output.resourcesDir
|
into project.sourceSets.test.output.resourcesDir
|
||||||
}
|
}
|
||||||
|
project.sourceSets.test.output.dir(outputDir, builtBy: copyXPackRestSpec)
|
||||||
task copyXPackPluginProps(type: Copy) {
|
|
||||||
dependsOn(copyXPackRestSpec)
|
|
||||||
from project(xpackModule('core')).file('src/main/plugin-metadata')
|
|
||||||
from project(xpackModule('core')).tasks.pluginProperties
|
|
||||||
into outputDir
|
|
||||||
}
|
|
||||||
project.sourceSets.test.output.dir(outputDir, builtBy: copyXPackPluginProps)
|
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven {
|
maven {
|
||||||
|
|
|
@ -4,9 +4,7 @@ import org.elasticsearch.gradle.test.RestIntegTestTask
|
||||||
apply plugin: 'elasticsearch.standalone-test'
|
apply plugin: 'elasticsearch.standalone-test'
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// "org.elasticsearch.plugin:x-pack-core:${version}" doesn't work with idea because the testArtifacts are also here
|
testCompile project(':x-pack:qa')
|
||||||
testCompile project(path: xpackModule('core'), configuration: 'default')
|
|
||||||
testCompile project(path: xpackModule('core'), configuration: 'testArtifacts') // to be moved in a later commit
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is a top level task which we will add dependencies to below.
|
// This is a top level task which we will add dependencies to below.
|
||||||
|
|
|
@ -10,10 +10,7 @@ apply plugin: 'elasticsearch.standalone-test'
|
||||||
test.enabled = false
|
test.enabled = false
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// "org.elasticsearch.plugin:x-pack-core:${version}" doesn't work with idea because the testArtifacts are also here
|
testCompile project(':x-pack:qa')
|
||||||
testCompile project(path: xpackModule('core'), configuration: 'default')
|
|
||||||
testCompile project(path: xpackModule('security'), configuration: 'runtime')
|
|
||||||
testCompile project(path: xpackModule('core'), configuration: 'testArtifacts') // to be moved in a later commit
|
|
||||||
testCompile ("org.elasticsearch.client:elasticsearch-rest-high-level-client:${version}")
|
testCompile ("org.elasticsearch.client:elasticsearch-rest-high-level-client:${version}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,11 +304,4 @@ task copyXPackRestSpec(type: Copy) {
|
||||||
include 'rest-api-spec/api/**'
|
include 'rest-api-spec/api/**'
|
||||||
into project.sourceSets.test.output.resourcesDir
|
into project.sourceSets.test.output.resourcesDir
|
||||||
}
|
}
|
||||||
|
project.sourceSets.test.output.dir(outputDir, builtBy: copyXPackRestSpec)
|
||||||
task copyXPackPluginProps(type: Copy) {
|
|
||||||
dependsOn(copyXPackRestSpec)
|
|
||||||
from project(xpackModule('core')).file('src/main/plugin-metadata')
|
|
||||||
from project(xpackModule('core')).tasks.pluginProperties
|
|
||||||
into outputDir
|
|
||||||
}
|
|
||||||
project.sourceSets.test.output.dir(outputDir, builtBy: copyXPackPluginProps)
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ package org.elasticsearch.upgrades;
|
||||||
import org.elasticsearch.client.Request;
|
import org.elasticsearch.client.Request;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.util.concurrent.ThreadContext;
|
import org.elasticsearch.common.util.concurrent.ThreadContext;
|
||||||
import org.elasticsearch.test.SecuritySettingsSourceField;
|
import org.elasticsearch.xpack.test.SecuritySettingsSourceField;
|
||||||
import org.elasticsearch.test.rest.ESRestTestCase;
|
import org.elasticsearch.test.rest.ESRestTestCase;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
|
||||||
|
@ -16,12 +16,12 @@ import java.io.IOException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
import static org.elasticsearch.xpack.core.security.authc.support.UsernamePasswordToken.basicAuthHeaderValue;
|
import static org.elasticsearch.xpack.test.SecuritySettingsSourceField.basicAuthHeaderValue;
|
||||||
|
|
||||||
public abstract class AbstractUpgradeTestCase extends ESRestTestCase {
|
public abstract class AbstractUpgradeTestCase extends ESRestTestCase {
|
||||||
|
|
||||||
private static final String BASIC_AUTH_VALUE =
|
private static final String BASIC_AUTH_VALUE =
|
||||||
basicAuthHeaderValue("test_user", SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING);
|
basicAuthHeaderValue("test_user", SecuritySettingsSourceField.TEST_PASSWORD);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean preserveIndicesUponCompletion() {
|
protected boolean preserveIndicesUponCompletion() {
|
||||||
|
|
|
@ -14,7 +14,7 @@ import org.elasticsearch.client.ml.job.config.Detector;
|
||||||
import org.elasticsearch.client.ml.job.config.Job;
|
import org.elasticsearch.client.ml.job.config.Job;
|
||||||
import org.elasticsearch.common.Strings;
|
import org.elasticsearch.common.Strings;
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.xpack.core.ml.job.persistence.AnomalyDetectorsIndex;
|
import org.elasticsearch.xpack.test.rest.XPackRestTestConstants;
|
||||||
import org.elasticsearch.xpack.test.rest.XPackRestTestHelper;
|
import org.elasticsearch.xpack.test.rest.XPackRestTestHelper;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -30,7 +30,7 @@ public class MlMappingsUpgradeIT extends AbstractUpgradeTestCase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Collection<String> templatesToWaitFor() {
|
protected Collection<String> templatesToWaitFor() {
|
||||||
return Stream.concat(XPackRestTestHelper.ML_POST_V660_TEMPLATES.stream(),
|
return Stream.concat(XPackRestTestConstants.ML_POST_V660_TEMPLATES.stream(),
|
||||||
super.templatesToWaitFor().stream()).collect(Collectors.toSet());
|
super.templatesToWaitFor().stream()).collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ public class MlMappingsUpgradeIT extends AbstractUpgradeTestCase {
|
||||||
private void assertUpgradedMappings() throws Exception {
|
private void assertUpgradedMappings() throws Exception {
|
||||||
|
|
||||||
assertBusy(() -> {
|
assertBusy(() -> {
|
||||||
Request getMappings = new Request("GET", AnomalyDetectorsIndex.resultsWriteAlias(JOB_ID) + "/_mappings");
|
Request getMappings = new Request("GET", XPackRestTestHelper.resultsWriteAlias(JOB_ID) + "/_mappings");
|
||||||
Response response = client().performRequest(getMappings);
|
Response response = client().performRequest(getMappings);
|
||||||
|
|
||||||
Map<String, Object> responseLevel = entityAsMap(response);
|
Map<String, Object> responseLevel = entityAsMap(response);
|
||||||
|
|
|
@ -13,6 +13,7 @@ import org.elasticsearch.common.util.concurrent.ThreadContext;
|
||||||
import org.elasticsearch.test.rest.ESRestTestCase;
|
import org.elasticsearch.test.rest.ESRestTestCase;
|
||||||
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
|
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
|
||||||
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
|
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
|
||||||
|
import org.elasticsearch.xpack.test.rest.XPackRestTestConstants;
|
||||||
import org.elasticsearch.xpack.test.rest.XPackRestTestHelper;
|
import org.elasticsearch.xpack.test.rest.XPackRestTestHelper;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
|
||||||
|
@ -28,7 +29,7 @@ public class UpgradeClusterClientYamlTestSuiteIT extends ESClientYamlSuiteTestCa
|
||||||
*/
|
*/
|
||||||
@Before
|
@Before
|
||||||
public void waitForTemplates() throws Exception {
|
public void waitForTemplates() throws Exception {
|
||||||
XPackRestTestHelper.waitForTemplates(client(), XPackRestTestHelper.ML_POST_V660_TEMPLATES);
|
XPackRestTestHelper.waitForTemplates(client(), XPackRestTestConstants.ML_POST_V660_TEMPLATES);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -6,10 +6,7 @@ apply plugin: 'elasticsearch.rest-test'
|
||||||
apply plugin: 'elasticsearch.test.fixtures'
|
apply plugin: 'elasticsearch.test.fixtures'
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// "org.elasticsearch.plugin:x-pack-core:${version}" doesn't work with idea because the testArtifacts are also here
|
|
||||||
testCompile project(path: xpackModule('core'), configuration: 'default')
|
|
||||||
testCompile project(path: xpackModule('core'), configuration: 'testArtifacts')
|
testCompile project(path: xpackModule('core'), configuration: 'testArtifacts')
|
||||||
testCompile project(path: xpackModule('security'), configuration: 'testArtifacts')
|
|
||||||
testCompile 'com.google.jimfs:jimfs:1.1'
|
testCompile 'com.google.jimfs:jimfs:1.1'
|
||||||
}
|
}
|
||||||
testFixtures.useFixture ":x-pack:test:idp-fixture"
|
testFixtures.useFixture ":x-pack:test:idp-fixture"
|
||||||
|
@ -103,9 +100,7 @@ thirdPartyAudit {
|
||||||
'com.google.common.cache.Striped64$1',
|
'com.google.common.cache.Striped64$1',
|
||||||
'com.google.common.cache.Striped64$Cell',
|
'com.google.common.cache.Striped64$Cell',
|
||||||
'com.google.common.primitives.UnsignedBytes$LexicographicalComparatorHolder$UnsafeComparator',
|
'com.google.common.primitives.UnsignedBytes$LexicographicalComparatorHolder$UnsafeComparator',
|
||||||
'com.google.common.primitives.UnsignedBytes$LexicographicalComparatorHolder$UnsafeComparator$1',
|
'com.google.common.primitives.UnsignedBytes$LexicographicalComparatorHolder$UnsafeComparator$1'
|
||||||
'com.google.common.util.concurrent.AbstractFuture$UnsafeAtomicHelper',
|
|
||||||
'com.google.common.util.concurrent.AbstractFuture$UnsafeAtomicHelper$1'
|
|
||||||
)
|
)
|
||||||
|
|
||||||
ignoreMissingClasses (
|
ignoreMissingClasses (
|
||||||
|
|
|
@ -2,9 +2,7 @@ apply plugin: 'elasticsearch.standalone-rest-test'
|
||||||
apply plugin: 'elasticsearch.rest-test'
|
apply plugin: 'elasticsearch.rest-test'
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
testCompile "org.elasticsearch.plugin:x-pack-core:${version}"
|
testCompile project(':x-pack:qa')
|
||||||
testCompile project(path: xpackModule('watcher'))
|
|
||||||
testCompile project(path: xpackModule('monitoring'))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
integTestCluster {
|
integTestCluster {
|
||||||
|
|
|
@ -9,28 +9,32 @@ import org.apache.lucene.util.LuceneTestCase.AwaitsFix;
|
||||||
import org.elasticsearch.client.Request;
|
import org.elasticsearch.client.Request;
|
||||||
import org.elasticsearch.client.Response;
|
import org.elasticsearch.client.Response;
|
||||||
import org.elasticsearch.common.Strings;
|
import org.elasticsearch.common.Strings;
|
||||||
import org.elasticsearch.common.xcontent.XContentType;
|
|
||||||
import org.elasticsearch.test.junit.annotations.TestLogging;
|
import org.elasticsearch.test.junit.annotations.TestLogging;
|
||||||
import org.elasticsearch.test.rest.ESRestTestCase;
|
import org.elasticsearch.test.rest.ESRestTestCase;
|
||||||
import org.elasticsearch.test.rest.yaml.ObjectPath;
|
import org.elasticsearch.test.rest.yaml.ObjectPath;
|
||||||
import org.elasticsearch.xpack.monitoring.exporter.ClusterAlertsUtil;
|
|
||||||
import org.elasticsearch.xpack.watcher.actions.ActionBuilders;
|
|
||||||
import org.elasticsearch.xpack.watcher.client.WatchSourceBuilders;
|
|
||||||
import org.elasticsearch.xpack.watcher.trigger.TriggerBuilders;
|
|
||||||
import org.elasticsearch.xpack.watcher.trigger.schedule.IntervalSchedule;
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
||||||
import static org.elasticsearch.xpack.watcher.input.InputBuilders.simpleInput;
|
|
||||||
import static org.elasticsearch.xpack.watcher.trigger.schedule.IntervalSchedule.Interval.Unit.MINUTES;
|
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
|
|
||||||
@TestLogging("org.elasticsearch.client:TRACE,tracer:TRACE")
|
@TestLogging("org.elasticsearch.client:TRACE,tracer:TRACE")
|
||||||
@AwaitsFix(bugUrl = "flaky tests")
|
@AwaitsFix(bugUrl = "flaky tests")
|
||||||
public class MonitoringWithWatcherRestIT extends ESRestTestCase {
|
public class MonitoringWithWatcherRestIT extends ESRestTestCase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An unsorted list of Watch IDs representing resource files for Monitoring Cluster Alerts.
|
||||||
|
*/
|
||||||
|
public static final String[] WATCH_IDS = {
|
||||||
|
"elasticsearch_cluster_status",
|
||||||
|
"elasticsearch_version_mismatch",
|
||||||
|
"kibana_version_mismatch",
|
||||||
|
"logstash_version_mismatch",
|
||||||
|
"xpack_license_expiration",
|
||||||
|
"elasticsearch_nodes",
|
||||||
|
};
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void cleanExporters() throws Exception {
|
public void cleanExporters() throws Exception {
|
||||||
Request request = new Request("PUT", "/_cluster/settings");
|
Request request = new Request("PUT", "/_cluster/settings");
|
||||||
|
@ -53,7 +57,7 @@ public class MonitoringWithWatcherRestIT extends ESRestTestCase {
|
||||||
.endObject().endObject()));
|
.endObject().endObject()));
|
||||||
adminClient().performRequest(request);
|
adminClient().performRequest(request);
|
||||||
|
|
||||||
assertTotalWatchCount(ClusterAlertsUtil.WATCH_IDS.length);
|
assertTotalWatchCount(WATCH_IDS.length);
|
||||||
|
|
||||||
assertMonitoringWatchHasBeenOverWritten(watchId);
|
assertMonitoringWatchHasBeenOverWritten(watchId);
|
||||||
}
|
}
|
||||||
|
@ -71,7 +75,7 @@ public class MonitoringWithWatcherRestIT extends ESRestTestCase {
|
||||||
.endObject().endObject()));
|
.endObject().endObject()));
|
||||||
adminClient().performRequest(request);
|
adminClient().performRequest(request);
|
||||||
|
|
||||||
assertTotalWatchCount(ClusterAlertsUtil.WATCH_IDS.length);
|
assertTotalWatchCount(WATCH_IDS.length);
|
||||||
|
|
||||||
assertMonitoringWatchHasBeenOverWritten(watchId);
|
assertMonitoringWatchHasBeenOverWritten(watchId);
|
||||||
}
|
}
|
||||||
|
@ -95,11 +99,10 @@ public class MonitoringWithWatcherRestIT extends ESRestTestCase {
|
||||||
String clusterUUID = getClusterUUID();
|
String clusterUUID = getClusterUUID();
|
||||||
String watchId = clusterUUID + "_kibana_version_mismatch";
|
String watchId = clusterUUID + "_kibana_version_mismatch";
|
||||||
Request request = new Request("PUT", "/_watcher/watch/" + watchId);
|
Request request = new Request("PUT", "/_watcher/watch/" + watchId);
|
||||||
request.setJsonEntity(WatchSourceBuilders.watchBuilder()
|
String watch = "{\"trigger\":{\"schedule\":{\"interval\":\"1000m\"}},\"input\":{\"simple\":{}}," +
|
||||||
.trigger(TriggerBuilders.schedule(new IntervalSchedule(new IntervalSchedule.Interval(1000, MINUTES))))
|
"\"condition\":{\"always\":{}}," +
|
||||||
.input(simpleInput())
|
"\"actions\":{\"logme\":{\"logging\":{\"level\":\"info\",\"text\":\"foo\"}}}}";
|
||||||
.addAction("logme", ActionBuilders.loggingAction("foo"))
|
request.setJsonEntity(watch);
|
||||||
.buildAsBytes(XContentType.JSON).utf8ToString());
|
|
||||||
client().performRequest(request);
|
client().performRequest(request);
|
||||||
return watchId;
|
return watchId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ apply plugin: 'elasticsearch.standalone-rest-test'
|
||||||
apply plugin: 'elasticsearch.rest-test'
|
apply plugin: 'elasticsearch.rest-test'
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
testCompile "org.elasticsearch.plugin:x-pack-core:${version}"
|
testCompile project(':x-pack:qa')
|
||||||
}
|
}
|
||||||
|
|
||||||
ext.pluginsCount = 0
|
ext.pluginsCount = 0
|
||||||
|
|
|
@ -14,7 +14,7 @@ import org.elasticsearch.common.util.concurrent.ThreadContext;
|
||||||
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
|
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
|
||||||
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
|
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
|
||||||
|
|
||||||
import static org.elasticsearch.xpack.core.security.authc.support.UsernamePasswordToken.basicAuthHeaderValue;
|
import static org.elasticsearch.xpack.test.SecuritySettingsSourceField.basicAuthHeaderValue;
|
||||||
|
|
||||||
public class XSmokeTestPluginsClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase {
|
public class XSmokeTestPluginsClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase {
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,7 @@ apply plugin: 'elasticsearch.standalone-rest-test'
|
||||||
apply plugin: 'elasticsearch.rest-test'
|
apply plugin: 'elasticsearch.rest-test'
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// "org.elasticsearch.plugin:x-pack-core:${version}" doesn't work with idea because the testArtifacts are also here
|
testCompile project(':x-pack:qa')
|
||||||
testCompile project(path: xpackModule('core'), configuration: 'default')
|
|
||||||
testCompile project(path: xpackModule('core'), configuration: 'testArtifacts')
|
|
||||||
testCompile project(path: ':modules:lang-mustache', configuration: 'runtime')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
integTestCluster {
|
integTestCluster {
|
||||||
|
|
|
@ -14,7 +14,7 @@ import org.elasticsearch.common.util.concurrent.ThreadContext;
|
||||||
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
|
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
|
||||||
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
|
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
|
||||||
|
|
||||||
import static org.elasticsearch.xpack.core.security.authc.support.UsernamePasswordToken.basicAuthHeaderValue;
|
import static org.elasticsearch.xpack.test.SecuritySettingsSourceField.basicAuthHeaderValue;
|
||||||
|
|
||||||
public class SmokeTestSecurityWithMustacheClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase {
|
public class SmokeTestSecurityWithMustacheClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase {
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ apply plugin: 'elasticsearch.standalone-rest-test'
|
||||||
apply plugin: 'elasticsearch.rest-test'
|
apply plugin: 'elasticsearch.rest-test'
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
testCompile "org.elasticsearch.plugin:x-pack-core:${version}"
|
testCompile project(':x-pack:qa')
|
||||||
}
|
}
|
||||||
|
|
||||||
// bring in watcher rest test suite
|
// bring in watcher rest test suite
|
||||||
|
|
|
@ -14,7 +14,7 @@ import org.elasticsearch.common.util.concurrent.ThreadContext;
|
||||||
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
|
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
|
||||||
import org.elasticsearch.test.rest.yaml.ClientYamlTestResponse;
|
import org.elasticsearch.test.rest.yaml.ClientYamlTestResponse;
|
||||||
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
|
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
|
||||||
import org.elasticsearch.xpack.core.watcher.support.WatcherIndexTemplateRegistryField;
|
import org.elasticsearch.xpack.test.rest.XPackRestTestConstants;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ import java.util.Collections;
|
||||||
import static java.util.Collections.emptyList;
|
import static java.util.Collections.emptyList;
|
||||||
import static java.util.Collections.emptyMap;
|
import static java.util.Collections.emptyMap;
|
||||||
import static java.util.Collections.singletonMap;
|
import static java.util.Collections.singletonMap;
|
||||||
import static org.elasticsearch.xpack.core.security.authc.support.UsernamePasswordToken.basicAuthHeaderValue;
|
import static org.elasticsearch.xpack.test.SecuritySettingsSourceField.basicAuthHeaderValue;
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
|
|
||||||
public class SmokeTestWatcherWithSecurityClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase {
|
public class SmokeTestWatcherWithSecurityClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase {
|
||||||
|
@ -76,7 +76,7 @@ public class SmokeTestWatcherWithSecurityClientYamlTestSuiteIT extends ESClientY
|
||||||
});
|
});
|
||||||
|
|
||||||
assertBusy(() -> {
|
assertBusy(() -> {
|
||||||
for (String template : WatcherIndexTemplateRegistryField.TEMPLATE_NAMES_NO_ILM) {
|
for (String template : XPackRestTestConstants.TEMPLATE_NAMES_NO_ILM) {
|
||||||
ClientYamlTestResponse templateExistsResponse = getAdminExecutionContext().callApi("indices.exists_template",
|
ClientYamlTestResponse templateExistsResponse = getAdminExecutionContext().callApi("indices.exists_template",
|
||||||
singletonMap("name", template), emptyList(), emptyMap());
|
singletonMap("name", template), emptyList(), emptyMap());
|
||||||
assertThat(templateExistsResponse.getStatusCode(), is(200));
|
assertThat(templateExistsResponse.getStatusCode(), is(200));
|
||||||
|
|
|
@ -16,7 +16,7 @@ import org.elasticsearch.common.util.concurrent.ThreadContext;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.test.rest.ESRestTestCase;
|
import org.elasticsearch.test.rest.ESRestTestCase;
|
||||||
import org.elasticsearch.test.rest.yaml.ObjectPath;
|
import org.elasticsearch.test.rest.yaml.ObjectPath;
|
||||||
import org.elasticsearch.xpack.core.watcher.support.WatcherIndexTemplateRegistryField;
|
import org.elasticsearch.xpack.test.rest.XPackRestTestConstants;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
||||||
import static org.elasticsearch.rest.action.search.RestSearchAction.TOTAL_HITS_AS_INT_PARAM;
|
import static org.elasticsearch.rest.action.search.RestSearchAction.TOTAL_HITS_AS_INT_PARAM;
|
||||||
import static org.elasticsearch.xpack.core.security.authc.support.UsernamePasswordToken.basicAuthHeaderValue;
|
import static org.elasticsearch.xpack.test.SecuritySettingsSourceField.basicAuthHeaderValue;
|
||||||
import static org.hamcrest.Matchers.containsString;
|
import static org.hamcrest.Matchers.containsString;
|
||||||
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||||
import static org.hamcrest.Matchers.hasEntry;
|
import static org.hamcrest.Matchers.hasEntry;
|
||||||
|
@ -83,7 +83,7 @@ public class SmokeTestWatcherWithSecurityIT extends ESRestTestCase {
|
||||||
});
|
});
|
||||||
|
|
||||||
assertBusy(() -> {
|
assertBusy(() -> {
|
||||||
for (String template : WatcherIndexTemplateRegistryField.TEMPLATE_NAMES) {
|
for (String template : XPackRestTestConstants.TEMPLATE_NAMES) {
|
||||||
assertOK(adminClient().performRequest(new Request("HEAD", "_template/" + template)));
|
assertOK(adminClient().performRequest(new Request("HEAD", "_template/" + template)));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,10 +2,7 @@ apply plugin: 'elasticsearch.standalone-rest-test'
|
||||||
apply plugin: 'elasticsearch.rest-test'
|
apply plugin: 'elasticsearch.rest-test'
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
testCompile "org.elasticsearch.plugin:x-pack-core:${version}"
|
testCompile project(':x-pack:qa')
|
||||||
testCompile project(path: xpackModule('watcher'), configuration: 'runtime')
|
|
||||||
testCompile project(path: ':modules:lang-mustache', configuration: 'runtime')
|
|
||||||
testCompile project(path: ':modules:lang-painless', configuration: 'runtime')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
integTestCluster {
|
integTestCluster {
|
||||||
|
|
|
@ -15,7 +15,7 @@ import org.elasticsearch.common.util.concurrent.ThreadContext;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.test.rest.ESRestTestCase;
|
import org.elasticsearch.test.rest.ESRestTestCase;
|
||||||
import org.elasticsearch.test.rest.yaml.ObjectPath;
|
import org.elasticsearch.test.rest.yaml.ObjectPath;
|
||||||
import org.elasticsearch.xpack.core.watcher.support.WatcherIndexTemplateRegistryField;
|
import org.elasticsearch.xpack.test.rest.XPackRestTestConstants;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
||||||
import static org.elasticsearch.rest.action.search.RestSearchAction.TOTAL_HITS_AS_INT_PARAM;
|
import static org.elasticsearch.rest.action.search.RestSearchAction.TOTAL_HITS_AS_INT_PARAM;
|
||||||
import static org.elasticsearch.xpack.core.security.authc.support.UsernamePasswordToken.basicAuthHeaderValue;
|
import static org.elasticsearch.xpack.test.SecuritySettingsSourceField.basicAuthHeaderValue;
|
||||||
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||||
import static org.hamcrest.Matchers.hasEntry;
|
import static org.hamcrest.Matchers.hasEntry;
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
|
@ -64,7 +64,7 @@ public class SmokeTestWatcherTestSuiteIT extends ESRestTestCase {
|
||||||
});
|
});
|
||||||
|
|
||||||
assertBusy(() -> {
|
assertBusy(() -> {
|
||||||
for (String template : WatcherIndexTemplateRegistryField.TEMPLATE_NAMES_NO_ILM) {
|
for (String template : XPackRestTestConstants.TEMPLATE_NAMES_NO_ILM) {
|
||||||
Response templateExistsResponse = adminClient().performRequest(new Request("HEAD", "/_template/" + template));
|
Response templateExistsResponse = adminClient().performRequest(new Request("HEAD", "/_template/" + template));
|
||||||
assertThat(templateExistsResponse.getStatusLine().getStatusCode(), is(200));
|
assertThat(templateExistsResponse.getStatusLine().getStatusCode(), is(200));
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
|
||||||
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
|
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
|
||||||
import org.elasticsearch.test.rest.yaml.ClientYamlTestResponse;
|
import org.elasticsearch.test.rest.yaml.ClientYamlTestResponse;
|
||||||
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
|
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
|
||||||
import org.elasticsearch.xpack.core.watcher.support.WatcherIndexTemplateRegistryField;
|
import org.elasticsearch.xpack.test.rest.XPackRestTestConstants;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ public class WatcherRestIT extends ESClientYamlSuiteTestCase {
|
||||||
});
|
});
|
||||||
|
|
||||||
assertBusy(() -> {
|
assertBusy(() -> {
|
||||||
for (String template : WatcherIndexTemplateRegistryField.TEMPLATE_NAMES_NO_ILM) {
|
for (String template : XPackRestTestConstants.TEMPLATE_NAMES_NO_ILM) {
|
||||||
ClientYamlTestResponse templateExistsResponse = getAdminExecutionContext().callApi("indices.exists_template",
|
ClientYamlTestResponse templateExistsResponse = getAdminExecutionContext().callApi("indices.exists_template",
|
||||||
singletonMap("name", template), emptyList(), emptyMap());
|
singletonMap("name", template), emptyList(), emptyMap());
|
||||||
assertThat(templateExistsResponse.getStatusCode(), is(200));
|
assertThat(templateExistsResponse.getStatusCode(), is(200));
|
||||||
|
|
|
@ -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.test;
|
||||||
|
|
||||||
|
import org.elasticsearch.common.CharArrays;
|
||||||
|
import org.elasticsearch.common.settings.SecureString;
|
||||||
|
|
||||||
|
import java.nio.CharBuffer;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Base64;
|
||||||
|
|
||||||
|
public final class SecuritySettingsSourceField {
|
||||||
|
public static final SecureString TEST_PASSWORD_SECURE_STRING = new SecureString("x-pack-test-password".toCharArray());
|
||||||
|
public static final String TEST_PASSWORD = "x-pack-test-password";
|
||||||
|
|
||||||
|
private SecuritySettingsSourceField() {}
|
||||||
|
|
||||||
|
public static String basicAuthHeaderValue(String username, String passwd) {
|
||||||
|
return basicAuthHeaderValue(username, new SecureString(passwd.toCharArray()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String basicAuthHeaderValue(String username, SecureString passwd) {
|
||||||
|
CharBuffer chars = CharBuffer.allocate(username.length() + passwd.length() + 1);
|
||||||
|
byte[] charBytes = null;
|
||||||
|
try {
|
||||||
|
chars.put(username).put(':').put(passwd.getChars());
|
||||||
|
charBytes = CharArrays.toUtf8Bytes(chars.array());
|
||||||
|
|
||||||
|
//TODO we still have passwords in Strings in headers. Maybe we can look into using a CharSequence?
|
||||||
|
String basicToken = Base64.getEncoder().encodeToString(charBytes);
|
||||||
|
return "Basic " + basicToken;
|
||||||
|
} finally {
|
||||||
|
Arrays.fill(chars.array(), (char) 0);
|
||||||
|
if (charBytes != null) {
|
||||||
|
Arrays.fill(charBytes, (byte) 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
/*
|
||||||
|
* 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.test.rest;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public final class XPackRestTestConstants {
|
||||||
|
|
||||||
|
// Watcher constants:
|
||||||
|
public static final String INDEX_TEMPLATE_VERSION = "9";
|
||||||
|
public static final String HISTORY_TEMPLATE_NAME = ".watch-history-" + INDEX_TEMPLATE_VERSION;
|
||||||
|
public static final String HISTORY_TEMPLATE_NAME_NO_ILM = ".watch-history-no-ilm-" + INDEX_TEMPLATE_VERSION;
|
||||||
|
public static final String TRIGGERED_TEMPLATE_NAME = ".triggered_watches";
|
||||||
|
public static final String WATCHES_TEMPLATE_NAME = ".watches";
|
||||||
|
public static final String[] TEMPLATE_NAMES = new String[] {
|
||||||
|
HISTORY_TEMPLATE_NAME, TRIGGERED_TEMPLATE_NAME, WATCHES_TEMPLATE_NAME
|
||||||
|
};
|
||||||
|
public static final String[] TEMPLATE_NAMES_NO_ILM = new String[] {
|
||||||
|
HISTORY_TEMPLATE_NAME_NO_ILM, TRIGGERED_TEMPLATE_NAME, WATCHES_TEMPLATE_NAME
|
||||||
|
};
|
||||||
|
|
||||||
|
// ML constants:
|
||||||
|
public static final String ML_META_INDEX_NAME = ".ml-meta";
|
||||||
|
public static final String AUDITOR_NOTIFICATIONS_INDEX = ".ml-notifications";
|
||||||
|
public static final String CONFIG_INDEX = ".ml-config";
|
||||||
|
public static final String RESULTS_INDEX_PREFIX = ".ml-anomalies-";
|
||||||
|
public static final String STATE_INDEX_PREFIX = ".ml-state";
|
||||||
|
public static final String RESULTS_INDEX_DEFAULT = "shared";
|
||||||
|
|
||||||
|
public static final List<String> ML_POST_V660_TEMPLATES =
|
||||||
|
List.of(AUDITOR_NOTIFICATIONS_INDEX, ML_META_INDEX_NAME, STATE_INDEX_PREFIX, RESULTS_INDEX_PREFIX, CONFIG_INDEX);
|
||||||
|
|
||||||
|
private XPackRestTestConstants() {
|
||||||
|
}
|
||||||
|
}
|
|
@ -14,14 +14,8 @@ import org.elasticsearch.client.RestClient;
|
||||||
import org.elasticsearch.common.xcontent.XContentHelper;
|
import org.elasticsearch.common.xcontent.XContentHelper;
|
||||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
import org.elasticsearch.xpack.core.ml.MlMetaIndex;
|
|
||||||
import org.elasticsearch.xpack.core.ml.job.persistence.AnomalyDetectorsIndex;
|
|
||||||
import org.elasticsearch.xpack.core.ml.job.persistence.AnomalyDetectorsIndexFields;
|
|
||||||
import org.elasticsearch.xpack.core.ml.notifications.AuditorField;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
@ -30,13 +24,6 @@ import static org.elasticsearch.test.rest.ESRestTestCase.allowTypesRemovalWarnin
|
||||||
|
|
||||||
public final class XPackRestTestHelper {
|
public final class XPackRestTestHelper {
|
||||||
|
|
||||||
public static final List<String> ML_POST_V660_TEMPLATES = Collections.unmodifiableList(
|
|
||||||
Arrays.asList(AuditorField.NOTIFICATIONS_INDEX,
|
|
||||||
MlMetaIndex.INDEX_NAME,
|
|
||||||
AnomalyDetectorsIndexFields.STATE_INDEX_PREFIX,
|
|
||||||
AnomalyDetectorsIndex.jobResultsIndexPrefix(),
|
|
||||||
AnomalyDetectorsIndex.configIndexName()));
|
|
||||||
|
|
||||||
private XPackRestTestHelper() {
|
private XPackRestTestHelper() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,4 +76,10 @@ public final class XPackRestTestHelper {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String resultsWriteAlias(String jobId) {
|
||||||
|
// ".write" rather than simply "write" to avoid the danger of clashing
|
||||||
|
// with the read alias of a job whose name begins with "write-"
|
||||||
|
return XPackRestTestConstants.RESULTS_INDEX_PREFIX + ".write-" + jobId;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue