Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ private static ListMultimap<Class<?>, String> createLegacyRestTestBasePluginUsag
map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:multi-cluster-search-security:legacy-with-basic-license");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:multi-cluster-search-security:legacy-with-full-license");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:multi-cluster-search-security:legacy-with-restricted-trust");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:third-party:jira");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:third-party:pagerduty");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:third-party:slack");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:ent-search:qa:rest");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:eql:qa:ccs-rolling-upgrade");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:eql:qa:correctness");
Expand Down
8 changes: 8 additions & 0 deletions x-pack/qa/third-party/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apply plugin: 'elasticsearch.java'

dependencies {
api project(':test:framework')
api project(':test:yaml-rest-runner')
api project(':test:test-clusters')
api project(xpackModule('core'))
}
25 changes: 7 additions & 18 deletions x-pack/qa/third-party/jira/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@ import groovy.json.JsonSlurper
import javax.net.ssl.HttpsURLConnection
import java.nio.charset.StandardCharsets

apply plugin: 'elasticsearch.legacy-yaml-rest-test'
apply plugin: 'elasticsearch.internal-yaml-rest-test'

dependencies {
yamlRestTestImplementation project(':x-pack:plugin:core')
yamlRestTestImplementation project(path: xpackModule('watcher'))
yamlRestTestImplementation project(':x-pack:qa:third-party')

clusterModules project(xpackModule('watcher'))
clusterModules project(xpackModule('ilm'))
}

restResources {
restApi {
include 'watcher'
include '_common', 'cluster', 'indices', 'search', 'watcher'
}
}

Expand All @@ -44,20 +46,7 @@ tasks.register("cleanJira", DefaultTask) {
if (!jiraUrl && !jiraUser && !jiraPassword && !jiraProject) {
tasks.named("yamlRestTest").configure { enabled = false }
} else {
testClusters.matching { it.name == "yamlRestTest" }.configureEach {
testDistribution = 'DEFAULT'
setting 'xpack.security.enabled', 'false'
setting 'xpack.ml.enabled', 'false'
setting 'xpack.license.self_generated.type', 'trial'
setting 'logger.org.elasticsearch.xpack.watcher', 'DEBUG'
setting 'xpack.notification.jira.account.test.issue_defaults.issuetype.name', 'Bug'
setting 'xpack.notification.jira.account.test.issue_defaults.labels.0', 'integration-tests'
setting 'xpack.notification.jira.account.test.issue_defaults.project.key', jiraProject
keystore 'xpack.notification.jira.account.test.secure_url', jiraUrl
keystore 'xpack.notification.jira.account.test.secure_user', jiraUser
keystore 'xpack.notification.jira.account.test.secure_password', jiraPassword
}
tasks.named("yamlRestTest")configure { finalizedBy "cleanJira" }
tasks.named("yamlRestTest").configure { finalizedBy "cleanJira" }
}

if (buildParams.inFipsJvm){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,69 +9,36 @@
import com.carrotsearch.randomizedtesting.annotations.Name;
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;

import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
import org.elasticsearch.test.rest.yaml.ClientYamlTestResponse;
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
import org.elasticsearch.xpack.core.watcher.support.WatcherIndexTemplateRegistryField;
import org.junit.After;
import org.junit.Before;

import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;

import static org.hamcrest.Matchers.is;
import org.junit.ClassRule;

/** Runs rest tests against external cluster */
public class WatcherJiraYamlTestSuiteIT extends ESClientYamlSuiteTestCase {
public class WatcherJiraYamlTestSuiteIT extends AbstractWatcherThirdPartyYamlTestSuiteIT {

@ClassRule
public static ElasticsearchCluster cluster = baseClusterBuilder().setting(
"xpack.notification.jira.account.test.issue_defaults.issuetype.name",
"Bug"
)
.setting("xpack.notification.jira.account.test.issue_defaults.labels.0", "integration-tests")
.setting("xpack.notification.jira.account.test.issue_defaults.project.key", System.getenv("jira_project"))
.keystore("xpack.notification.jira.account.test.secure_url", System.getenv("jira_url"))
.keystore("xpack.notification.jira.account.test.secure_user", System.getenv("jira_user"))
.keystore("xpack.notification.jira.account.test.secure_password", System.getenv("jira_password"))
.build();

@Override
protected ElasticsearchCluster getCluster() {
return cluster;
}

public WatcherJiraYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) {
super(testCandidate);
}

@ParametersFactory
public static Iterable<Object[]> parameters() throws Exception {
return ESClientYamlSuiteTestCase.createParameters();
}

@Before
public void startWatcher() throws Exception {
final List<String> watcherTemplates = List.of(WatcherIndexTemplateRegistryField.TEMPLATE_NAMES_NO_ILM);
assertBusy(() -> {
try {
getAdminExecutionContext().callApi("watcher.start", Map.of(), List.of(), Map.of());

for (String template : watcherTemplates) {
ClientYamlTestResponse templateExistsResponse = getAdminExecutionContext().callApi(
"indices.exists_template",
Map.of("name", template),
List.of(),
Map.of()
);
assertThat(templateExistsResponse.getStatusCode(), is(200));
}

ClientYamlTestResponse response = getAdminExecutionContext().callApi("watcher.stats", Map.of(), List.of(), Map.of());
String state = response.evaluate("stats.0.watcher_state");
assertThat(state, is("started"));
} catch (IOException e) {
throw new AssertionError(e);
}
});
}

@After
public void stopWatcher() throws Exception {
assertBusy(() -> {
try {
getAdminExecutionContext().callApi("watcher.stop", Map.of(), List.of(), Map.of());
ClientYamlTestResponse response = getAdminExecutionContext().callApi("watcher.stats", Map.of(), List.of(), Map.of());
String state = response.evaluate("stats.0.watcher_state");
assertThat(state, is("stopped"));
} catch (IOException e) {
throw new AssertionError(e);
}
}, 60, TimeUnit.SECONDS);
return createParameters();
}
}
23 changes: 8 additions & 15 deletions x-pack/qa/third-party/pagerduty/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,25 @@
* 2.0.
*/

apply plugin: 'elasticsearch.legacy-yaml-rest-test'
apply plugin: 'elasticsearch.internal-yaml-rest-test'

dependencies {
yamlRestTestImplementation project(':x-pack:plugin:core')
yamlRestTestImplementation project(path: xpackModule('watcher'))
}
yamlRestTestImplementation project(':x-pack:qa:third-party')

String pagerDutyServiceKey = System.getenv('pagerduty_service_api_key')
clusterModules project(xpackModule('watcher'))
clusterModules project(xpackModule('ilm'))
}

restResources {
restApi {
include 'watcher'
include '_common', 'watcher', 'indices', 'cluster', 'search'
}
}

String pagerDutyServiceKey = System.getenv('pagerduty_service_api_key')

if (!pagerDutyServiceKey) {
tasks.named("yamlRestTest").configure { enabled = false }
} else {
testClusters.matching { it.name == "yamlRestTest" }.configureEach {
testDistribution = 'DEFAULT'
setting 'xpack.security.enabled', 'false'
setting 'xpack.ml.enabled', 'false'
setting 'xpack.license.self_generated.type', 'trial'
setting 'logger.org.elasticsearch.xpack.watcher', 'DEBUG'
keystore 'xpack.notification.pagerduty.account.test_account.secure_service_api_key', pagerDutyServiceKey
}
}

if (buildParams.inFipsJvm){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,69 +9,29 @@
import com.carrotsearch.randomizedtesting.annotations.Name;
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;

import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
import org.elasticsearch.test.rest.yaml.ClientYamlTestResponse;
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
import org.elasticsearch.xpack.core.watcher.support.WatcherIndexTemplateRegistryField;
import org.junit.After;
import org.junit.Before;
import org.junit.ClassRule;

import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
public class WatcherPagerDutyYamlTestSuiteIT extends AbstractWatcherThirdPartyYamlTestSuiteIT {

import static org.hamcrest.Matchers.is;
@ClassRule
public static ElasticsearchCluster cluster = baseClusterBuilder().keystore(
"xpack.notification.pagerduty.account.test_account.secure_service_api_key",
System.getenv("pagerduty_service_api_key")
).build();

/** Runs rest tests against external cluster */
public class WatcherPagerDutyYamlTestSuiteIT extends ESClientYamlSuiteTestCase {
@Override
protected ElasticsearchCluster getCluster() {
return cluster;
}

public WatcherPagerDutyYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) {
super(testCandidate);
}

@ParametersFactory
public static Iterable<Object[]> parameters() throws Exception {
return ESClientYamlSuiteTestCase.createParameters();
}

@Before
public void startWatcher() throws Exception {
final List<String> watcherTemplates = List.of(WatcherIndexTemplateRegistryField.TEMPLATE_NAMES_NO_ILM);
assertBusy(() -> {
try {
getAdminExecutionContext().callApi("watcher.start", Map.of(), List.of(), Map.of());

for (String template : watcherTemplates) {
ClientYamlTestResponse templateExistsResponse = getAdminExecutionContext().callApi(
"indices.exists_template",
Map.of("name", template),
List.of(),
Map.of()
);
assertThat(templateExistsResponse.getStatusCode(), is(200));
}

ClientYamlTestResponse response = getAdminExecutionContext().callApi("watcher.stats", Map.of(), List.of(), Map.of());
String state = response.evaluate("stats.0.watcher_state");
assertThat(state, is("started"));
} catch (IOException e) {
throw new AssertionError(e);
}
});
}

@After
public void stopWatcher() throws Exception {
assertBusy(() -> {
try {
getAdminExecutionContext().callApi("watcher.stop", Map.of(), List.of(), Map.of());
ClientYamlTestResponse response = getAdminExecutionContext().callApi("watcher.stats", Map.of(), List.of(), Map.of());
String state = response.evaluate("stats.0.watcher_state");
assertThat(state, is("stopped"));
} catch (IOException e) {
throw new AssertionError(e);
}
}, 60, TimeUnit.SECONDS);
return createParameters();
}
}
19 changes: 6 additions & 13 deletions x-pack/qa/third-party/slack/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,25 @@
* 2.0.
*/

apply plugin: 'elasticsearch.legacy-yaml-rest-test'
apply plugin: 'elasticsearch.internal-yaml-rest-test'

dependencies {
yamlRestTestImplementation project(':x-pack:plugin:core')
yamlRestTestImplementation project(path: xpackModule('watcher'))
yamlRestTestImplementation project(':x-pack:qa:third-party')

clusterModules project(xpackModule('watcher'))
clusterModules project(xpackModule('ilm'))
}

restResources {
restApi {
include 'watcher'
include '_common', 'cluster', 'indices', 'search', 'watcher'
}
}

String slackUrl = System.getenv('slack_url')

if (!slackUrl) {
tasks.named("yamlRestTest").configure { enabled = false }
} else {
testClusters.matching { it.name == "yamlRestTest" }.configureEach {
testDistribution = 'DEFAULT'
setting 'xpack.security.enabled', 'false'
setting 'xpack.ml.enabled', 'false'
setting 'xpack.license.self_generated.type', 'trial'
setting 'logger.org.elasticsearch.xpack.watcher', 'DEBUG'
keystore 'xpack.notification.slack.account.test_account.secure_url', slackUrl
}
}

if (buildParams.inFipsJvm){
Expand Down
Loading