[cleanup] Reorganized the integration tests
Distributed them to the proper packages, such that they'll be easy to find Original commit: elastic/x-pack-elasticsearch@e6e6c15870
This commit is contained in:
parent
478d5ecc48
commit
babe40137f
|
@ -24,7 +24,7 @@ import static org.mockito.Mockito.*;
|
|||
|
||||
/**
|
||||
*/
|
||||
public class WatcherLifeCycleServiceTest extends ElasticsearchTestCase {
|
||||
public class WatcherLifeCycleServiceTests extends ElasticsearchTestCase {
|
||||
|
||||
private WatcherService watcherService;
|
||||
private WatcherLifeCycleService lifeCycleService;
|
|
@ -3,7 +3,7 @@
|
|||
* 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.watcher.test.integration;
|
||||
package org.elasticsearch.watcher.actions;
|
||||
|
||||
import com.carrotsearch.randomizedtesting.annotations.Repeat;
|
||||
import org.elasticsearch.action.index.IndexResponse;
|
||||
|
@ -35,7 +35,7 @@ import static org.hamcrest.Matchers.is;
|
|||
|
||||
/**
|
||||
*/
|
||||
public class WatchTimeThrottleTests extends AbstractWatcherIntegrationTests {
|
||||
public class TimeThrottleIntegrationTests extends AbstractWatcherIntegrationTests {
|
||||
|
||||
private IndexResponse indexTestDoc() {
|
||||
createIndex("actions", "events");
|
|
@ -3,7 +3,7 @@
|
|||
* 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.watcher.test.integration;
|
||||
package org.elasticsearch.watcher.actions.email;
|
||||
|
||||
import org.elasticsearch.action.search.SearchRequest;
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
|
@ -3,7 +3,7 @@
|
|||
* 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.watcher.test.integration;
|
||||
package org.elasticsearch.watcher.actions.email;
|
||||
|
||||
import org.elasticsearch.action.get.GetResponse;
|
||||
import org.elasticsearch.common.joda.time.DateTime;
|
|
@ -3,7 +3,7 @@
|
|||
* 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.watcher.test.integration;
|
||||
package org.elasticsearch.watcher.actions.webhook;
|
||||
|
||||
import com.squareup.okhttp.mockwebserver.MockResponse;
|
||||
import com.squareup.okhttp.mockwebserver.MockWebServer;
|
|
@ -3,7 +3,7 @@
|
|||
* 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.watcher.test.integration;
|
||||
package org.elasticsearch.watcher.actions.webhook;
|
||||
|
||||
import com.carrotsearch.randomizedtesting.annotations.Repeat;
|
||||
import com.squareup.okhttp.mockwebserver.MockResponse;
|
|
@ -23,7 +23,7 @@ import static org.hamcrest.Matchers.*;
|
|||
|
||||
/**
|
||||
*/
|
||||
public class TriggeredWatchStoreLifeCycleTest extends AbstractWatcherIntegrationTests {
|
||||
public class TriggeredWatchStoreLifeCycleTests extends AbstractWatcherIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void testPutLoadUpdate() throws Exception {
|
|
@ -3,7 +3,7 @@
|
|||
* 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.watcher.test.integration;
|
||||
package org.elasticsearch.watcher.history;
|
||||
|
||||
import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse;
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
|
@ -20,7 +20,7 @@ import static org.hamcrest.core.Is.is;
|
|||
/**
|
||||
*/
|
||||
@ElasticsearchIntegrationTest.ClusterScope(scope = TEST, numClientNodes = 0, transportClientRatio = 0, randomDynamicTemplates = false, numDataNodes = 1)
|
||||
public class HistoryStoreSettingsTest extends AbstractWatcherIntegrationTests {
|
||||
public class HistoryStoreSettingsTests extends AbstractWatcherIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void testChangeSettings() throws Exception {
|
|
@ -3,7 +3,7 @@
|
|||
* 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.watcher.test.integration;
|
||||
package org.elasticsearch.watcher.history;
|
||||
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
|
@ -3,7 +3,7 @@
|
|||
* 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.watcher.test.integration;
|
||||
package org.elasticsearch.watcher.history;
|
||||
|
||||
import com.squareup.okhttp.mockwebserver.MockResponse;
|
||||
import com.squareup.okhttp.mockwebserver.MockWebServer;
|
|
@ -3,7 +3,7 @@
|
|||
* 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.watcher.test.integration;
|
||||
package org.elasticsearch.watcher.history;
|
||||
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.search.aggregations.Aggregations;
|
|
@ -3,7 +3,7 @@
|
|||
* 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.watcher.test.integration;
|
||||
package org.elasticsearch.watcher.history;
|
||||
|
||||
import org.elasticsearch.action.search.SearchRequest;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
|
@ -3,7 +3,7 @@
|
|||
* 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.watcher.test.integration;
|
||||
package org.elasticsearch.watcher.history;
|
||||
|
||||
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse;
|
||||
import org.elasticsearch.cluster.metadata.MappingMetaData;
|
|
@ -3,7 +3,7 @@
|
|||
* 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.watcher.test.integration;
|
||||
package org.elasticsearch.watcher.history;
|
||||
|
||||
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse;
|
||||
import org.elasticsearch.cluster.metadata.MappingMetaData;
|
|
@ -3,7 +3,7 @@
|
|||
* 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.watcher.test.integration;
|
||||
package org.elasticsearch.watcher.input.http;
|
||||
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.action.support.IndicesOptions;
|
||||
|
@ -36,7 +36,7 @@ import static org.elasticsearch.watcher.trigger.TriggerBuilders.schedule;
|
|||
import static org.elasticsearch.watcher.trigger.schedule.Schedules.interval;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
public class HttpInputIntegrationTest extends AbstractWatcherIntegrationTests {
|
||||
public class HttpInputIntegrationTests extends AbstractWatcherIntegrationTests {
|
||||
|
||||
@Override
|
||||
protected Settings nodeSettings(int nodeOrdinal) {
|
|
@ -3,7 +3,7 @@
|
|||
* 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.watcher.test.integration;
|
||||
package org.elasticsearch.watcher.shield;
|
||||
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.common.joda.time.DateTime;
|
|
@ -1,166 +0,0 @@
|
|||
/*
|
||||
* 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.watcher.test.integration;
|
||||
|
||||
import com.carrotsearch.randomizedtesting.annotations.Repeat;
|
||||
import org.elasticsearch.action.ActionRequestValidationException;
|
||||
import org.elasticsearch.watcher.WatcherException;
|
||||
import org.elasticsearch.watcher.client.WatchSourceBuilder;
|
||||
import org.elasticsearch.watcher.support.xcontent.XContentSource;
|
||||
import org.elasticsearch.watcher.test.AbstractWatcherIntegrationTests;
|
||||
import org.elasticsearch.watcher.transport.actions.delete.DeleteWatchRequest;
|
||||
import org.elasticsearch.watcher.transport.actions.delete.DeleteWatchResponse;
|
||||
import org.elasticsearch.watcher.transport.actions.get.GetWatchRequest;
|
||||
import org.elasticsearch.watcher.transport.actions.get.GetWatchResponse;
|
||||
import org.elasticsearch.watcher.transport.actions.put.PutWatchResponse;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.elasticsearch.watcher.actions.ActionBuilders.loggingAction;
|
||||
import static org.elasticsearch.watcher.client.WatchSourceBuilders.watchBuilder;
|
||||
import static org.elasticsearch.watcher.condition.ConditionBuilders.alwaysCondition;
|
||||
import static org.elasticsearch.watcher.input.InputBuilders.simpleInput;
|
||||
import static org.elasticsearch.watcher.trigger.TriggerBuilders.schedule;
|
||||
import static org.elasticsearch.watcher.trigger.schedule.Schedules.interval;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class WatchCrudTests extends AbstractWatcherIntegrationTests {
|
||||
|
||||
@Test @Repeat(iterations = 10)
|
||||
public void testPut() throws Exception {
|
||||
ensureWatcherStarted();
|
||||
|
||||
WatchSourceBuilder source = watchBuilder()
|
||||
.trigger(schedule(interval("5m")));
|
||||
|
||||
if (randomBoolean()) {
|
||||
source.input(simpleInput());
|
||||
}
|
||||
if (randomBoolean()) {
|
||||
source.condition(alwaysCondition());
|
||||
}
|
||||
if (randomBoolean()) {
|
||||
source.addAction("_action1", loggingAction("{{ctx.watch_id}}"));
|
||||
}
|
||||
|
||||
PutWatchResponse response = watcherClient().preparePutWatch("_name").setSource(source).get();
|
||||
|
||||
assertThat(response, notNullValue());
|
||||
assertThat(response.isCreated(), is(true));
|
||||
assertThat(response.getVersion(), is(1L));
|
||||
}
|
||||
|
||||
@Test(expected = WatchSourceBuilder.BuilderException.class)
|
||||
public void testPut_NoTrigger() throws Exception {
|
||||
ensureWatcherStarted();
|
||||
watcherClient().preparePutWatch("_name").setSource(watchBuilder()
|
||||
.input(simpleInput())
|
||||
.condition(alwaysCondition())
|
||||
.addAction("_action1", loggingAction("{{ctx.watch_id}}")))
|
||||
.get();
|
||||
}
|
||||
|
||||
@Test(expected = ActionRequestValidationException.class)
|
||||
public void testPut_InvalidWatchId() throws Exception {
|
||||
ensureWatcherStarted();
|
||||
watcherClient().preparePutWatch("id with whitespaces").setSource(watchBuilder()
|
||||
.trigger(schedule(interval("5m"))))
|
||||
.get();
|
||||
}
|
||||
|
||||
@Test(expected = WatcherException.class)
|
||||
public void testPut_InvalidActionId() throws Exception {
|
||||
ensureWatcherStarted();
|
||||
watcherClient().preparePutWatch("_name").setSource(watchBuilder()
|
||||
.trigger(schedule(interval("5m")))
|
||||
.addAction("id with whitespaces", loggingAction("{{ctx.watch_id}}")))
|
||||
.get();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGet() throws Exception {
|
||||
ensureWatcherStarted();
|
||||
PutWatchResponse putResponse = watcherClient().preparePutWatch("_name").setSource(watchBuilder()
|
||||
.trigger(schedule(interval("5m")))
|
||||
.input(simpleInput())
|
||||
.condition(alwaysCondition())
|
||||
.addAction("_action1", loggingAction("{{ctx.watch_id}}")))
|
||||
.get();
|
||||
|
||||
assertThat(putResponse, notNullValue());
|
||||
assertThat(putResponse.isCreated(), is(true));
|
||||
|
||||
GetWatchResponse getResponse = watcherClient().getWatch(new GetWatchRequest("_name")).get();
|
||||
assertThat(getResponse, notNullValue());
|
||||
assertThat(getResponse.isFound(), is(true));
|
||||
assertThat(getResponse.getId(), is("_name"));
|
||||
assertThat(getResponse.getVersion(), is(putResponse.getVersion()));
|
||||
Map<String, Object> source = getResponse.getSource().getAsMap();
|
||||
assertThat(source, notNullValue());
|
||||
assertThat(source, hasKey("trigger"));
|
||||
assertThat(source, hasKey("input"));
|
||||
assertThat(source, hasKey("condition"));
|
||||
assertThat(source, hasKey("actions"));
|
||||
assertThat(source, hasKey("status"));
|
||||
}
|
||||
|
||||
@Test(expected = ActionRequestValidationException.class)
|
||||
public void testGet_InvalidWatchId() throws Exception {
|
||||
watcherClient().prepareGetWatch("id with whitespaces").get();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGet_NotFound() throws Exception {
|
||||
ensureWatcherStarted();
|
||||
|
||||
GetWatchResponse getResponse = watcherClient().getWatch(new GetWatchRequest("_name")).get();
|
||||
assertThat(getResponse, notNullValue());
|
||||
assertThat(getResponse.getId(), is("_name"));
|
||||
assertThat(getResponse.getVersion(), is(-1L));
|
||||
assertThat(getResponse.isFound(), is(false));
|
||||
assertThat(getResponse.getSource(), nullValue());
|
||||
XContentSource source = getResponse.getSource();
|
||||
assertThat(source, nullValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDelete() throws Exception {
|
||||
ensureWatcherStarted();
|
||||
PutWatchResponse putResponse = watcherClient().preparePutWatch("_name").setSource(watchBuilder()
|
||||
.trigger(schedule(interval("5m")))
|
||||
.input(simpleInput())
|
||||
.condition(alwaysCondition())
|
||||
.addAction("_action1", loggingAction("{{ctx.watch_id}}")))
|
||||
.get();
|
||||
|
||||
assertThat(putResponse, notNullValue());
|
||||
assertThat(putResponse.isCreated(), is(true));
|
||||
|
||||
DeleteWatchResponse deleteResponse = watcherClient().deleteWatch(new DeleteWatchRequest("_name")).get();
|
||||
assertThat(deleteResponse, notNullValue());
|
||||
assertThat(deleteResponse.getId(), is("_name"));
|
||||
assertThat(deleteResponse.getVersion(), is(putResponse.getVersion() + 1));
|
||||
assertThat(deleteResponse.isFound(), is(true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDelete_NotFound() throws Exception {
|
||||
DeleteWatchResponse response = watcherClient().deleteWatch(new DeleteWatchRequest("_name")).get();
|
||||
assertThat(response, notNullValue());
|
||||
assertThat(response.getId(), is("_name"));
|
||||
assertThat(response.getVersion(), is(1L));
|
||||
assertThat(response.isFound(), is(false));
|
||||
}
|
||||
|
||||
@Test(expected = ActionRequestValidationException.class)
|
||||
public void testDelete_InvalidWatchId() throws Exception {
|
||||
watcherClient().deleteWatch(new DeleteWatchRequest("id with whitespaces")).actionGet();
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
* 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.watcher.test.integration;
|
||||
package org.elasticsearch.watcher.transform;
|
||||
|
||||
import org.elasticsearch.action.search.SearchRequest;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
|
@ -16,7 +16,6 @@ import org.elasticsearch.watcher.transport.actions.put.PutWatchResponse;
|
|||
import org.junit.Test;
|
||||
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
|
||||
|
@ -34,14 +33,14 @@ import static org.hamcrest.Matchers.*;
|
|||
|
||||
/**
|
||||
*/
|
||||
public class TransformSearchTests extends AbstractWatcherIntegrationTests {
|
||||
public class TransformIntegrationTests extends AbstractWatcherIntegrationTests {
|
||||
|
||||
@Override
|
||||
public Settings nodeSettings(int nodeOrdinal) {
|
||||
//Set path so ScriptService will pick up the test scripts
|
||||
try {
|
||||
return settingsBuilder().put(super.nodeSettings(nodeOrdinal))
|
||||
.put("path.conf", TransformSearchTests.class.getResource("/config").toURI().getPath()).build();
|
||||
.put("path.conf", TransformIntegrationTests.class.getResource("/config").toURI().getPath()).build();
|
||||
} catch (URISyntaxException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* 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.watcher.transport.action.delete;
|
||||
|
||||
import org.elasticsearch.action.ActionRequestValidationException;
|
||||
import org.elasticsearch.watcher.test.AbstractWatcherIntegrationTests;
|
||||
import org.elasticsearch.watcher.transport.actions.delete.DeleteWatchRequest;
|
||||
import org.elasticsearch.watcher.transport.actions.delete.DeleteWatchResponse;
|
||||
import org.elasticsearch.watcher.transport.actions.put.PutWatchResponse;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.elasticsearch.watcher.actions.ActionBuilders.loggingAction;
|
||||
import static org.elasticsearch.watcher.client.WatchSourceBuilders.watchBuilder;
|
||||
import static org.elasticsearch.watcher.condition.ConditionBuilders.alwaysCondition;
|
||||
import static org.elasticsearch.watcher.input.InputBuilders.simpleInput;
|
||||
import static org.elasticsearch.watcher.trigger.TriggerBuilders.schedule;
|
||||
import static org.elasticsearch.watcher.trigger.schedule.Schedules.interval;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class DeleteWatchTests extends AbstractWatcherIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void testDelete() throws Exception {
|
||||
ensureWatcherStarted();
|
||||
PutWatchResponse putResponse = watcherClient().preparePutWatch("_name").setSource(watchBuilder()
|
||||
.trigger(schedule(interval("5m")))
|
||||
.input(simpleInput())
|
||||
.condition(alwaysCondition())
|
||||
.addAction("_action1", loggingAction("{{ctx.watch_id}}")))
|
||||
.get();
|
||||
|
||||
assertThat(putResponse, notNullValue());
|
||||
assertThat(putResponse.isCreated(), is(true));
|
||||
|
||||
DeleteWatchResponse deleteResponse = watcherClient().deleteWatch(new DeleteWatchRequest("_name")).get();
|
||||
assertThat(deleteResponse, notNullValue());
|
||||
assertThat(deleteResponse.getId(), is("_name"));
|
||||
assertThat(deleteResponse.getVersion(), is(putResponse.getVersion() + 1));
|
||||
assertThat(deleteResponse.isFound(), is(true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDelete_NotFound() throws Exception {
|
||||
DeleteWatchResponse response = watcherClient().deleteWatch(new DeleteWatchRequest("_name")).get();
|
||||
assertThat(response, notNullValue());
|
||||
assertThat(response.getId(), is("_name"));
|
||||
assertThat(response.getVersion(), is(1L));
|
||||
assertThat(response.isFound(), is(false));
|
||||
}
|
||||
|
||||
@Test(expected = ActionRequestValidationException.class)
|
||||
public void testDelete_InvalidWatchId() throws Exception {
|
||||
watcherClient().deleteWatch(new DeleteWatchRequest("id with whitespaces")).actionGet();
|
||||
}
|
||||
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
* 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.watcher.test.integration;
|
||||
package org.elasticsearch.watcher.transport.action.delete;
|
||||
|
||||
import org.apache.lucene.util.LuceneTestCase.Slow;
|
||||
import org.elasticsearch.test.junit.annotations.TestLogging;
|
||||
|
@ -24,10 +24,11 @@ import static org.hamcrest.Matchers.is;
|
|||
|
||||
/**
|
||||
*/
|
||||
public class WatchForceDeleteTests extends AbstractWatcherIntegrationTests {
|
||||
public class ForceDeleteWatchTests extends AbstractWatcherIntegrationTests {
|
||||
|
||||
//Disable time warping for the force delete long running watch test
|
||||
protected boolean timeWarped() {
|
||||
return false; //Disable time warping for the force delete long running watch test
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
|
@ -45,7 +45,7 @@ import static org.hamcrest.Matchers.notNullValue;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
public class WatchExecuteTests extends AbstractWatcherIntegrationTests {
|
||||
public class ExecuteWatchTests extends AbstractWatcherIntegrationTests {
|
||||
|
||||
|
||||
@Test(expected = ActionRequestValidationException.class)
|
|
@ -28,7 +28,7 @@ import static org.hamcrest.Matchers.notNullValue;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
public class WatchExecuteWithDateMathTests extends AbstractWatcherIntegrationTests {
|
||||
public class ExecuteWatchWithDateMathTests extends AbstractWatcherIntegrationTests {
|
||||
|
||||
@Override
|
||||
protected boolean timeWarped() {
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* 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.watcher.transport.action.get;
|
||||
|
||||
import org.elasticsearch.action.ActionRequestValidationException;
|
||||
import org.elasticsearch.watcher.support.xcontent.XContentSource;
|
||||
import org.elasticsearch.watcher.test.AbstractWatcherIntegrationTests;
|
||||
import org.elasticsearch.watcher.transport.actions.get.GetWatchRequest;
|
||||
import org.elasticsearch.watcher.transport.actions.get.GetWatchResponse;
|
||||
import org.elasticsearch.watcher.transport.actions.put.PutWatchResponse;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.elasticsearch.watcher.actions.ActionBuilders.loggingAction;
|
||||
import static org.elasticsearch.watcher.client.WatchSourceBuilders.watchBuilder;
|
||||
import static org.elasticsearch.watcher.condition.ConditionBuilders.alwaysCondition;
|
||||
import static org.elasticsearch.watcher.input.InputBuilders.simpleInput;
|
||||
import static org.elasticsearch.watcher.trigger.TriggerBuilders.schedule;
|
||||
import static org.elasticsearch.watcher.trigger.schedule.Schedules.interval;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class GetWatchTests extends AbstractWatcherIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void testGet() throws Exception {
|
||||
ensureWatcherStarted();
|
||||
PutWatchResponse putResponse = watcherClient().preparePutWatch("_name").setSource(watchBuilder()
|
||||
.trigger(schedule(interval("5m")))
|
||||
.input(simpleInput())
|
||||
.condition(alwaysCondition())
|
||||
.addAction("_action1", loggingAction("{{ctx.watch_id}}")))
|
||||
.get();
|
||||
|
||||
assertThat(putResponse, notNullValue());
|
||||
assertThat(putResponse.isCreated(), is(true));
|
||||
|
||||
GetWatchResponse getResponse = watcherClient().getWatch(new GetWatchRequest("_name")).get();
|
||||
assertThat(getResponse, notNullValue());
|
||||
assertThat(getResponse.isFound(), is(true));
|
||||
assertThat(getResponse.getId(), is("_name"));
|
||||
assertThat(getResponse.getVersion(), is(putResponse.getVersion()));
|
||||
Map<String, Object> source = getResponse.getSource().getAsMap();
|
||||
assertThat(source, notNullValue());
|
||||
assertThat(source, hasKey("trigger"));
|
||||
assertThat(source, hasKey("input"));
|
||||
assertThat(source, hasKey("condition"));
|
||||
assertThat(source, hasKey("actions"));
|
||||
assertThat(source, hasKey("status"));
|
||||
}
|
||||
|
||||
@Test(expected = ActionRequestValidationException.class)
|
||||
public void testGet_InvalidWatchId() throws Exception {
|
||||
watcherClient().prepareGetWatch("id with whitespaces").get();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGet_NotFound() throws Exception {
|
||||
ensureWatcherStarted();
|
||||
|
||||
GetWatchResponse getResponse = watcherClient().getWatch(new GetWatchRequest("_name")).get();
|
||||
assertThat(getResponse, notNullValue());
|
||||
assertThat(getResponse.getId(), is("_name"));
|
||||
assertThat(getResponse.getVersion(), is(-1L));
|
||||
assertThat(getResponse.isFound(), is(false));
|
||||
assertThat(getResponse.getSource(), nullValue());
|
||||
XContentSource source = getResponse.getSource();
|
||||
assertThat(source, nullValue());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* 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.watcher.transport.action.put;
|
||||
|
||||
import com.carrotsearch.randomizedtesting.annotations.Repeat;
|
||||
import org.elasticsearch.action.ActionRequestValidationException;
|
||||
import org.elasticsearch.watcher.WatcherException;
|
||||
import org.elasticsearch.watcher.client.WatchSourceBuilder;
|
||||
import org.elasticsearch.watcher.test.AbstractWatcherIntegrationTests;
|
||||
import org.elasticsearch.watcher.transport.actions.put.PutWatchResponse;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.elasticsearch.watcher.actions.ActionBuilders.loggingAction;
|
||||
import static org.elasticsearch.watcher.client.WatchSourceBuilders.watchBuilder;
|
||||
import static org.elasticsearch.watcher.condition.ConditionBuilders.alwaysCondition;
|
||||
import static org.elasticsearch.watcher.input.InputBuilders.simpleInput;
|
||||
import static org.elasticsearch.watcher.trigger.TriggerBuilders.schedule;
|
||||
import static org.elasticsearch.watcher.trigger.schedule.Schedules.interval;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class PutWatchTests extends AbstractWatcherIntegrationTests {
|
||||
|
||||
@Test
|
||||
@Repeat(iterations = 10)
|
||||
public void testPut() throws Exception {
|
||||
ensureWatcherStarted();
|
||||
|
||||
WatchSourceBuilder source = watchBuilder()
|
||||
.trigger(schedule(interval("5m")));
|
||||
|
||||
if (randomBoolean()) {
|
||||
source.input(simpleInput());
|
||||
}
|
||||
if (randomBoolean()) {
|
||||
source.condition(alwaysCondition());
|
||||
}
|
||||
if (randomBoolean()) {
|
||||
source.addAction("_action1", loggingAction("{{ctx.watch_id}}"));
|
||||
}
|
||||
|
||||
PutWatchResponse response = watcherClient().preparePutWatch("_name").setSource(source).get();
|
||||
|
||||
assertThat(response, notNullValue());
|
||||
assertThat(response.isCreated(), is(true));
|
||||
assertThat(response.getVersion(), is(1L));
|
||||
}
|
||||
|
||||
@Test(expected = WatchSourceBuilder.BuilderException.class)
|
||||
public void testPut_NoTrigger() throws Exception {
|
||||
ensureWatcherStarted();
|
||||
watcherClient().preparePutWatch("_name").setSource(watchBuilder()
|
||||
.input(simpleInput())
|
||||
.condition(alwaysCondition())
|
||||
.addAction("_action1", loggingAction("{{ctx.watch_id}}")))
|
||||
.get();
|
||||
}
|
||||
|
||||
@Test(expected = ActionRequestValidationException.class)
|
||||
public void testPut_InvalidWatchId() throws Exception {
|
||||
ensureWatcherStarted();
|
||||
watcherClient().preparePutWatch("id with whitespaces").setSource(watchBuilder()
|
||||
.trigger(schedule(interval("5m"))))
|
||||
.get();
|
||||
}
|
||||
|
||||
@Test(expected = WatcherException.class)
|
||||
public void testPut_InvalidActionId() throws Exception {
|
||||
ensureWatcherStarted();
|
||||
watcherClient().preparePutWatch("_name").setSource(watchBuilder()
|
||||
.trigger(schedule(interval("5m")))
|
||||
.addAction("id with whitespaces", loggingAction("{{ctx.watch_id}}")))
|
||||
.get();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
* 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.watcher.test.integration;
|
||||
package org.elasticsearch.watcher.transport.action.stats;
|
||||
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.elasticsearch.common.joda.time.DateTime;
|
|
@ -3,7 +3,7 @@
|
|||
* 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.watcher.test.integration;
|
||||
package org.elasticsearch.watcher.transport.action.stats;
|
||||
|
||||
import org.elasticsearch.action.search.SearchRequest;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
|
@ -36,7 +36,7 @@ import static org.hamcrest.core.IsEqual.equalTo;
|
|||
/**
|
||||
*/
|
||||
@ClusterScope(scope = TEST, numClientNodes = 0, transportClientRatio = 0, randomDynamicTemplates = false)
|
||||
public class WatchStatsTests extends AbstractWatcherIntegrationTests {
|
||||
public class WatcherStatsTests extends AbstractWatcherIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void testStartedStats() throws Exception {
|
Loading…
Reference in New Issue