|
|
@@ -54,7 +54,7 @@ public class WatchAckTests extends AbstractWatcherIntegrationTestCase {
|
|
|
|
|
|
@Before
|
|
|
public void indexTestDocument() {
|
|
|
- IndexResponse eventIndexResponse = client().prepareIndex("events", "event", id)
|
|
|
+ IndexResponse eventIndexResponse = client().prepareIndex().setIndex("events").setId(id)
|
|
|
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
|
|
|
.setSource("level", "error")
|
|
|
.get();
|
|
|
@@ -69,8 +69,8 @@ public class WatchAckTests extends AbstractWatcherIntegrationTestCase {
|
|
|
.input(searchInput(templateRequest(searchSource(), "events")))
|
|
|
.condition(new CompareCondition("ctx.payload.hits.total", CompareCondition.Op.GT, 0L))
|
|
|
.transform(searchTransform(templateRequest(searchSource(), "events")))
|
|
|
- .addAction("_a1", indexAction("actions1", "doc"))
|
|
|
- .addAction("_a2", indexAction("actions2", "doc"))
|
|
|
+ .addAction("_a1", indexAction("actions1"))
|
|
|
+ .addAction("_a2", indexAction("actions2"))
|
|
|
.defaultThrottlePeriod(new TimeValue(0, TimeUnit.SECONDS)))
|
|
|
.get();
|
|
|
|
|
|
@@ -83,8 +83,8 @@ public class WatchAckTests extends AbstractWatcherIntegrationTestCase {
|
|
|
assertThat(ackResponse.getStatus().actionStatus("_a2").ackStatus().state(), is(ActionStatus.AckStatus.State.ACKABLE));
|
|
|
|
|
|
refresh();
|
|
|
- long a1CountAfterAck = docCount("actions1", "doc", matchAllQuery());
|
|
|
- long a2CountAfterAck = docCount("actions2", "doc", matchAllQuery());
|
|
|
+ long a1CountAfterAck = docCount("actions1", matchAllQuery());
|
|
|
+ long a2CountAfterAck = docCount("actions2", matchAllQuery());
|
|
|
assertThat(a1CountAfterAck, greaterThan(0L));
|
|
|
assertThat(a2CountAfterAck, greaterThan(0L));
|
|
|
|
|
|
@@ -93,15 +93,15 @@ public class WatchAckTests extends AbstractWatcherIntegrationTestCase {
|
|
|
refresh();
|
|
|
|
|
|
// There shouldn't be more a1 actions in the index after we ack the watch, even though the watch was triggered
|
|
|
- long a1CountAfterPostAckFires = docCount("actions1", "doc", matchAllQuery());
|
|
|
+ long a1CountAfterPostAckFires = docCount("actions1", matchAllQuery());
|
|
|
assertThat(a1CountAfterPostAckFires, equalTo(a1CountAfterAck));
|
|
|
|
|
|
// There should be more a2 actions in the index after we ack the watch
|
|
|
- long a2CountAfterPostAckFires = docCount("actions2", "doc", matchAllQuery());
|
|
|
+ long a2CountAfterPostAckFires = docCount("actions2", matchAllQuery());
|
|
|
assertThat(a2CountAfterPostAckFires, greaterThan(a2CountAfterAck));
|
|
|
|
|
|
// Now delete the event and the ack states should change to AWAITS_EXECUTION
|
|
|
- DeleteResponse response = client().prepareDelete("events", "event", id).get();
|
|
|
+ DeleteResponse response = client().prepareDelete().setIndex("events").setId(id).get();
|
|
|
assertEquals(DocWriteResponse.Result.DELETED, response.getResult());
|
|
|
refresh();
|
|
|
|
|
|
@@ -117,7 +117,7 @@ public class WatchAckTests extends AbstractWatcherIntegrationTestCase {
|
|
|
assertThat(parsedWatch.status().actionStatus("_a2").ackStatus().state(),
|
|
|
is(ActionStatus.AckStatus.State.AWAITS_SUCCESSFUL_EXECUTION));
|
|
|
|
|
|
- long throttledCount = docCount(HistoryStoreField.INDEX_PREFIX_WITH_TEMPLATE + "*", null,
|
|
|
+ long throttledCount = docCount(HistoryStoreField.INDEX_PREFIX_WITH_TEMPLATE + "*",
|
|
|
matchQuery(WatchRecord.STATE.getPreferredName(), ExecutionState.ACKNOWLEDGED.id()));
|
|
|
assertThat(throttledCount, greaterThan(0L));
|
|
|
}
|
|
|
@@ -130,8 +130,8 @@ public class WatchAckTests extends AbstractWatcherIntegrationTestCase {
|
|
|
.input(searchInput(templateRequest(searchSource(), "events")))
|
|
|
.condition(new CompareCondition("ctx.payload.hits.total", CompareCondition.Op.GT, 0L))
|
|
|
.transform(searchTransform(templateRequest(searchSource(), "events")))
|
|
|
- .addAction("_a1", indexAction("actions1", "doc"))
|
|
|
- .addAction("_a2", indexAction("actions2", "doc"))
|
|
|
+ .addAction("_a1", indexAction("actions1"))
|
|
|
+ .addAction("_a2", indexAction("actions2"))
|
|
|
.defaultThrottlePeriod(new TimeValue(0, TimeUnit.SECONDS)))
|
|
|
.get();
|
|
|
|
|
|
@@ -152,8 +152,8 @@ public class WatchAckTests extends AbstractWatcherIntegrationTestCase {
|
|
|
assertThat(ackResponse.getStatus().actionStatus("_a2").ackStatus().state(), is(ActionStatus.AckStatus.State.ACKED));
|
|
|
|
|
|
refresh();
|
|
|
- long a1CountAfterAck = docCount("actions1", "doc", matchAllQuery());
|
|
|
- long a2CountAfterAck = docCount("actions2", "doc", matchAllQuery());
|
|
|
+ long a1CountAfterAck = docCount("actions1", matchAllQuery());
|
|
|
+ long a2CountAfterAck = docCount("actions2", matchAllQuery());
|
|
|
assertThat(a1CountAfterAck, greaterThanOrEqualTo((long) 1));
|
|
|
assertThat(a2CountAfterAck, greaterThanOrEqualTo((long) 1));
|
|
|
|
|
|
@@ -162,15 +162,15 @@ public class WatchAckTests extends AbstractWatcherIntegrationTestCase {
|
|
|
refresh();
|
|
|
|
|
|
// There shouldn't be more a1 actions in the index after we ack the watch, even though the watch was triggered
|
|
|
- long a1CountAfterPostAckFires = docCount("actions1", "doc", matchAllQuery());
|
|
|
+ long a1CountAfterPostAckFires = docCount("actions1", matchAllQuery());
|
|
|
assertThat(a1CountAfterPostAckFires, equalTo(a1CountAfterAck));
|
|
|
|
|
|
// There shouldn't be more a2 actions in the index after we ack the watch, even though the watch was triggered
|
|
|
- long a2CountAfterPostAckFires = docCount("actions2", "doc", matchAllQuery());
|
|
|
+ long a2CountAfterPostAckFires = docCount("actions2", matchAllQuery());
|
|
|
assertThat(a2CountAfterPostAckFires, equalTo(a2CountAfterAck));
|
|
|
|
|
|
// Now delete the event and the ack states should change to AWAITS_EXECUTION
|
|
|
- DeleteResponse response = client().prepareDelete("events", "event", id).get();
|
|
|
+ DeleteResponse response = client().prepareDelete().setIndex("events").setId(id).get();
|
|
|
assertEquals(DocWriteResponse.Result.DELETED, response.getResult());
|
|
|
refresh();
|
|
|
|
|
|
@@ -186,7 +186,7 @@ public class WatchAckTests extends AbstractWatcherIntegrationTestCase {
|
|
|
assertThat(parsedWatch.status().actionStatus("_a2").ackStatus().state(),
|
|
|
is(ActionStatus.AckStatus.State.AWAITS_SUCCESSFUL_EXECUTION));
|
|
|
|
|
|
- long throttledCount = docCount(HistoryStoreField.INDEX_PREFIX_WITH_TEMPLATE + "*", null,
|
|
|
+ long throttledCount = docCount(HistoryStoreField.INDEX_PREFIX_WITH_TEMPLATE + "*",
|
|
|
matchQuery(WatchRecord.STATE.getPreferredName(), ExecutionState.ACKNOWLEDGED.id()));
|
|
|
assertThat(throttledCount, greaterThan(0L));
|
|
|
}
|
|
|
@@ -199,7 +199,7 @@ public class WatchAckTests extends AbstractWatcherIntegrationTestCase {
|
|
|
.input(searchInput(templateRequest(searchSource(), "events")))
|
|
|
.condition(new CompareCondition("ctx.payload.hits.total", CompareCondition.Op.GT, 0L))
|
|
|
.transform(searchTransform(templateRequest(searchSource(), "events")))
|
|
|
- .addAction("_id", indexAction("actions", "action")))
|
|
|
+ .addAction("_id", indexAction("actions")))
|
|
|
.get();
|
|
|
assertThat(putWatchResponse.isCreated(), is(true));
|
|
|
assertThat(watcherClient().prepareWatcherStats().get().getWatchesCount(), is(1L));
|
|
|
@@ -211,7 +211,7 @@ public class WatchAckTests extends AbstractWatcherIntegrationTestCase {
|
|
|
assertThat(ackResponse.getStatus().actionStatus("_id").ackStatus().state(), is(ActionStatus.AckStatus.State.ACKED));
|
|
|
|
|
|
refresh("actions");
|
|
|
- long countAfterAck = client().prepareSearch("actions").setTypes("action").setQuery(matchAllQuery()).get()
|
|
|
+ long countAfterAck = client().prepareSearch("actions").setQuery(matchAllQuery()).get()
|
|
|
.getHits().getTotalHits().value;
|
|
|
assertThat(countAfterAck, greaterThanOrEqualTo(1L));
|
|
|
|
|
|
@@ -221,7 +221,7 @@ public class WatchAckTests extends AbstractWatcherIntegrationTestCase {
|
|
|
assertThat(watchResponse.getStatus().actionStatus("_id").ackStatus().state(), Matchers.equalTo(ActionStatus.AckStatus.State.ACKED));
|
|
|
|
|
|
refresh();
|
|
|
- GetResponse getResponse = client().get(new GetRequest(Watch.INDEX, Watch.DOC_TYPE, "_name")).actionGet();
|
|
|
+ GetResponse getResponse = client().get(new GetRequest(Watch.INDEX, "_name")).actionGet();
|
|
|
Watch indexedWatch = watchParser().parse("_name", true, getResponse.getSourceAsBytesRef(), XContentType.JSON,
|
|
|
getResponse.getSeqNo(), getResponse.getPrimaryTerm());
|
|
|
assertThat(watchResponse.getStatus().actionStatus("_id").ackStatus().state(),
|
|
|
@@ -231,7 +231,7 @@ public class WatchAckTests extends AbstractWatcherIntegrationTestCase {
|
|
|
refresh("actions");
|
|
|
|
|
|
// There shouldn't be more actions in the index after we ack the watch, even though the watch was triggered
|
|
|
- long countAfterPostAckFires = docCount("actions", "action", matchAllQuery());
|
|
|
+ long countAfterPostAckFires = docCount("actions", matchAllQuery());
|
|
|
assertThat(countAfterPostAckFires, equalTo(countAfterAck));
|
|
|
}
|
|
|
|