Uppercase ells ('L') in long literals
This commit removes all lowercase ells ('l') in long literals because they are often hard to distinguish from the digit representing one ('1'). Closes elastic/elasticsearch#1414 Original commit: elastic/x-pack-elasticsearch@98b38705fb
This commit is contained in:
parent
9f886665fa
commit
e13a5e695a
|
@ -43,7 +43,7 @@ public class LicenseVerificationTests extends ESTestCase {
|
||||||
|
|
||||||
final License tamperedLicense = License.builder()
|
final License tamperedLicense = License.builder()
|
||||||
.fromLicenseSpec(license, license.signature())
|
.fromLicenseSpec(license, license.signature())
|
||||||
.expiryDate(license.expiryDate() + 10 * 24 * 60 * 60 * 1000l)
|
.expiryDate(license.expiryDate() + 10 * 24 * 60 * 60 * 1000L)
|
||||||
.validate()
|
.validate()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
|
@ -96,8 +96,8 @@ public class ScriptConditionSearchTests extends AbstractWatcherIntegrationTestCa
|
||||||
hit.score(1f);
|
hit.score(1f);
|
||||||
hit.shard(new SearchShardTarget("a", new Index("a", "testUUID"), 0));
|
hit.shard(new SearchShardTarget("a", new Index("a", "testUUID"), 0));
|
||||||
|
|
||||||
InternalSearchResponse internalSearchResponse = new InternalSearchResponse(new InternalSearchHits(new InternalSearchHit[]{hit}, 1l, 1f), null, null, null, false, false);
|
InternalSearchResponse internalSearchResponse = new InternalSearchResponse(new InternalSearchHits(new InternalSearchHit[]{hit}, 1L, 1f), null, null, null, false, false);
|
||||||
SearchResponse response = new SearchResponse(internalSearchResponse, "", 3, 3, 500l, new ShardSearchFailure[0]);
|
SearchResponse response = new SearchResponse(internalSearchResponse, "", 3, 3, 500L, new ShardSearchFailure[0]);
|
||||||
|
|
||||||
WatchExecutionContext ctx = mockExecutionContext("_watch_name", new Payload.XContent(response));
|
WatchExecutionContext ctx = mockExecutionContext("_watch_name", new Payload.XContent(response));
|
||||||
assertThat(condition.execute(ctx).met(), is(true));
|
assertThat(condition.execute(ctx).met(), is(true));
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class ScriptConditionTests extends ESTestCase {
|
||||||
public void testExecute() throws Exception {
|
public void testExecute() throws Exception {
|
||||||
ScriptServiceProxy scriptService = getScriptServiceProxy(tp);
|
ScriptServiceProxy scriptService = getScriptServiceProxy(tp);
|
||||||
ExecutableScriptCondition condition = new ExecutableScriptCondition(new ScriptCondition(Script.inline("ctx.payload.hits.total > 1").build()), logger, scriptService);
|
ExecutableScriptCondition condition = new ExecutableScriptCondition(new ScriptCondition(Script.inline("ctx.payload.hits.total > 1").build()), logger, scriptService);
|
||||||
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500l, new ShardSearchFailure[0]);
|
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500L, new ShardSearchFailure[0]);
|
||||||
WatchExecutionContext ctx = mockExecutionContext("_name", new Payload.XContent(response));
|
WatchExecutionContext ctx = mockExecutionContext("_name", new Payload.XContent(response));
|
||||||
assertFalse(condition.execute(ctx).met());
|
assertFalse(condition.execute(ctx).met());
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ public class ScriptConditionTests extends ESTestCase {
|
||||||
ScriptServiceProxy scriptService = getScriptServiceProxy(tp);
|
ScriptServiceProxy scriptService = getScriptServiceProxy(tp);
|
||||||
Script script = Script.inline("ctx.payload.hits.total > threshold").lang(Script.DEFAULT_LANG).params(singletonMap("threshold", 1)).build();
|
Script script = Script.inline("ctx.payload.hits.total > threshold").lang(Script.DEFAULT_LANG).params(singletonMap("threshold", 1)).build();
|
||||||
ExecutableScriptCondition executable = new ExecutableScriptCondition(new ScriptCondition(script), logger, scriptService);
|
ExecutableScriptCondition executable = new ExecutableScriptCondition(new ScriptCondition(script), logger, scriptService);
|
||||||
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500l, new ShardSearchFailure[0]);
|
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500L, new ShardSearchFailure[0]);
|
||||||
WatchExecutionContext ctx = mockExecutionContext("_name", new Payload.XContent(response));
|
WatchExecutionContext ctx = mockExecutionContext("_name", new Payload.XContent(response));
|
||||||
assertFalse(executable.execute(ctx).met());
|
assertFalse(executable.execute(ctx).met());
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ public class ScriptConditionTests extends ESTestCase {
|
||||||
ScriptCondition condition = factory.parseCondition("_watch", parser);
|
ScriptCondition condition = factory.parseCondition("_watch", parser);
|
||||||
ExecutableScriptCondition executable = factory.createExecutable(condition);
|
ExecutableScriptCondition executable = factory.createExecutable(condition);
|
||||||
|
|
||||||
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500l, new ShardSearchFailure[0]);
|
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500L, new ShardSearchFailure[0]);
|
||||||
WatchExecutionContext ctx = mockExecutionContext("_name", new Payload.XContent(response));
|
WatchExecutionContext ctx = mockExecutionContext("_name", new Payload.XContent(response));
|
||||||
|
|
||||||
assertFalse(executable.execute(ctx).met());
|
assertFalse(executable.execute(ctx).met());
|
||||||
|
@ -163,7 +163,7 @@ public class ScriptConditionTests extends ESTestCase {
|
||||||
public void testScriptConditionThrowException() throws Exception {
|
public void testScriptConditionThrowException() throws Exception {
|
||||||
ScriptServiceProxy scriptService = getScriptServiceProxy(tp);
|
ScriptServiceProxy scriptService = getScriptServiceProxy(tp);
|
||||||
ExecutableScriptCondition condition = new ExecutableScriptCondition(new ScriptCondition(Script.inline("assert false").build()), logger, scriptService);
|
ExecutableScriptCondition condition = new ExecutableScriptCondition(new ScriptCondition(Script.inline("assert false").build()), logger, scriptService);
|
||||||
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500l, new ShardSearchFailure[0]);
|
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500L, new ShardSearchFailure[0]);
|
||||||
WatchExecutionContext ctx = mockExecutionContext("_name", new Payload.XContent(response));
|
WatchExecutionContext ctx = mockExecutionContext("_name", new Payload.XContent(response));
|
||||||
ScriptCondition.Result result = condition.execute(ctx);
|
ScriptCondition.Result result = condition.execute(ctx);
|
||||||
assertThat(result, notNullValue());
|
assertThat(result, notNullValue());
|
||||||
|
@ -175,7 +175,7 @@ public class ScriptConditionTests extends ESTestCase {
|
||||||
public void testScriptConditionReturnObject() throws Exception {
|
public void testScriptConditionReturnObject() throws Exception {
|
||||||
ScriptServiceProxy scriptService = getScriptServiceProxy(tp);
|
ScriptServiceProxy scriptService = getScriptServiceProxy(tp);
|
||||||
ExecutableScriptCondition condition = new ExecutableScriptCondition(new ScriptCondition(Script.inline("return new Object()").build()), logger, scriptService);
|
ExecutableScriptCondition condition = new ExecutableScriptCondition(new ScriptCondition(Script.inline("return new Object()").build()), logger, scriptService);
|
||||||
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500l, new ShardSearchFailure[0]);
|
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500L, new ShardSearchFailure[0]);
|
||||||
WatchExecutionContext ctx = mockExecutionContext("_name", new Payload.XContent(response));
|
WatchExecutionContext ctx = mockExecutionContext("_name", new Payload.XContent(response));
|
||||||
ScriptCondition.Result result = condition.execute(ctx);
|
ScriptCondition.Result result = condition.execute(ctx);
|
||||||
assertThat(result, notNullValue());
|
assertThat(result, notNullValue());
|
||||||
|
@ -187,7 +187,7 @@ public class ScriptConditionTests extends ESTestCase {
|
||||||
public void testScriptConditionAccessCtx() throws Exception {
|
public void testScriptConditionAccessCtx() throws Exception {
|
||||||
ScriptServiceProxy scriptService = getScriptServiceProxy(tp);
|
ScriptServiceProxy scriptService = getScriptServiceProxy(tp);
|
||||||
ExecutableScriptCondition condition = new ExecutableScriptCondition(new ScriptCondition(Script.inline("ctx.trigger.scheduled_time.getMillis() < new Date().time ").build()), logger, scriptService);
|
ExecutableScriptCondition condition = new ExecutableScriptCondition(new ScriptCondition(Script.inline("ctx.trigger.scheduled_time.getMillis() < new Date().time ").build()), logger, scriptService);
|
||||||
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500l, new ShardSearchFailure[0]);
|
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500L, new ShardSearchFailure[0]);
|
||||||
WatchExecutionContext ctx = mockExecutionContext("_name", new DateTime(DateTimeZone.UTC), new Payload.XContent(response));
|
WatchExecutionContext ctx = mockExecutionContext("_name", new DateTime(DateTimeZone.UTC), new Payload.XContent(response));
|
||||||
Thread.sleep(10);
|
Thread.sleep(10);
|
||||||
assertThat(condition.execute(ctx).met(), is(true));
|
assertThat(condition.execute(ctx).met(), is(true));
|
||||||
|
|
|
@ -119,13 +119,13 @@ public class TransformIntegrationTests extends AbstractWatcherIntegrationTestCas
|
||||||
|
|
||||||
SearchResponse response = client().prepareSearch("output1").get();
|
SearchResponse response = client().prepareSearch("output1").get();
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1l));
|
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1L));
|
||||||
assertThat(response.getHits().getAt(0).sourceAsMap().size(), equalTo(1));
|
assertThat(response.getHits().getAt(0).sourceAsMap().size(), equalTo(1));
|
||||||
assertThat(response.getHits().getAt(0).sourceAsMap().get("key3").toString(), equalTo("20"));
|
assertThat(response.getHits().getAt(0).sourceAsMap().get("key3").toString(), equalTo("20"));
|
||||||
|
|
||||||
response = client().prepareSearch("output2").get();
|
response = client().prepareSearch("output2").get();
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1l));
|
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1L));
|
||||||
assertThat(response.getHits().getAt(0).sourceAsMap().size(), equalTo(1));
|
assertThat(response.getHits().getAt(0).sourceAsMap().size(), equalTo(1));
|
||||||
assertThat(response.getHits().getAt(0).sourceAsMap().get("key3").toString(), equalTo("20"));
|
assertThat(response.getHits().getAt(0).sourceAsMap().get("key3").toString(), equalTo("20"));
|
||||||
}
|
}
|
||||||
|
@ -168,12 +168,12 @@ public class TransformIntegrationTests extends AbstractWatcherIntegrationTestCas
|
||||||
|
|
||||||
SearchResponse response = client().prepareSearch("output1").get();
|
SearchResponse response = client().prepareSearch("output1").get();
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1l));
|
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1L));
|
||||||
assertThat(response.getHits().getAt(0).sourceAsString(), containsString("mytestresult"));
|
assertThat(response.getHits().getAt(0).sourceAsString(), containsString("mytestresult"));
|
||||||
|
|
||||||
response = client().prepareSearch("output2").get();
|
response = client().prepareSearch("output2").get();
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1l));
|
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1L));
|
||||||
assertThat(response.getHits().getAt(0).sourceAsString(), containsString("mytestresult"));
|
assertThat(response.getHits().getAt(0).sourceAsString(), containsString("mytestresult"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,13 +212,13 @@ public class TransformIntegrationTests extends AbstractWatcherIntegrationTestCas
|
||||||
|
|
||||||
SearchResponse response = client().prepareSearch("output1").get();
|
SearchResponse response = client().prepareSearch("output1").get();
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1l));
|
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1L));
|
||||||
assertThat(response.getHits().getAt(0).sourceAsMap().size(), equalTo(1));
|
assertThat(response.getHits().getAt(0).sourceAsMap().size(), equalTo(1));
|
||||||
assertThat(response.getHits().getAt(0).sourceAsMap().get("key4").toString(), equalTo("30"));
|
assertThat(response.getHits().getAt(0).sourceAsMap().get("key4").toString(), equalTo("30"));
|
||||||
|
|
||||||
response = client().prepareSearch("output2").get();
|
response = client().prepareSearch("output2").get();
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1l));
|
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1L));
|
||||||
assertThat(response.getHits().getAt(0).sourceAsMap().size(), equalTo(1));
|
assertThat(response.getHits().getAt(0).sourceAsMap().size(), equalTo(1));
|
||||||
assertThat(response.getHits().getAt(0).sourceAsMap().get("key4").toString(), equalTo("30"));
|
assertThat(response.getHits().getAt(0).sourceAsMap().get("key4").toString(), equalTo("30"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,7 @@ public class BasicWatcherTests extends AbstractWatcherIntegrationTestCase {
|
||||||
.setSource(watchBuilder()
|
.setSource(watchBuilder()
|
||||||
.trigger(schedule(interval(5, IntervalSchedule.Interval.Unit.SECONDS)))
|
.trigger(schedule(interval(5, IntervalSchedule.Interval.Unit.SECONDS)))
|
||||||
.input(searchInput(searchRequest))
|
.input(searchInput(searchRequest))
|
||||||
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1l))
|
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1L))
|
||||||
.addAction("_logger", loggingAction("\n\n************\n" +
|
.addAction("_logger", loggingAction("\n\n************\n" +
|
||||||
"total hits: {{ctx.payload.hits.total}}\n" +
|
"total hits: {{ctx.payload.hits.total}}\n" +
|
||||||
"************\n")
|
"************\n")
|
||||||
|
@ -114,7 +114,7 @@ public class BasicWatcherTests extends AbstractWatcherIntegrationTestCase {
|
||||||
.setSource(watchBuilder()
|
.setSource(watchBuilder()
|
||||||
.trigger(schedule(interval(5, IntervalSchedule.Interval.Unit.SECONDS)))
|
.trigger(schedule(interval(5, IntervalSchedule.Interval.Unit.SECONDS)))
|
||||||
.input(searchInput(searchRequest))
|
.input(searchInput(searchRequest))
|
||||||
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1l)))
|
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1L)))
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
if (timeWarped()) {
|
if (timeWarped()) {
|
||||||
|
@ -145,7 +145,7 @@ public class BasicWatcherTests extends AbstractWatcherIntegrationTestCase {
|
||||||
.setSource(watchBuilder()
|
.setSource(watchBuilder()
|
||||||
.trigger(schedule(interval(5, IntervalSchedule.Interval.Unit.SECONDS)))
|
.trigger(schedule(interval(5, IntervalSchedule.Interval.Unit.SECONDS)))
|
||||||
.input(searchInput(searchRequest))
|
.input(searchInput(searchRequest))
|
||||||
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1l)))
|
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1L)))
|
||||||
.get();
|
.get();
|
||||||
assertThat(indexResponse.isCreated(), is(true));
|
assertThat(indexResponse.isCreated(), is(true));
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ public class BasicWatcherTests extends AbstractWatcherIntegrationTestCase {
|
||||||
assertThat(deleteWatchResponse.isFound(), is(true));
|
assertThat(deleteWatchResponse.isFound(), is(true));
|
||||||
|
|
||||||
refresh();
|
refresh();
|
||||||
assertHitCount(client().prepareSearch(WatchStore.INDEX).setSize(0).get(), 0l);
|
assertHitCount(client().prepareSearch(WatchStore.INDEX).setSize(0).get(), 0L);
|
||||||
|
|
||||||
// Deleting the same watch for the second time
|
// Deleting the same watch for the second time
|
||||||
deleteWatchResponse = watcherClient.prepareDeleteWatch("_name").get();
|
deleteWatchResponse = watcherClient.prepareDeleteWatch("_name").get();
|
||||||
|
@ -214,7 +214,7 @@ public class BasicWatcherTests extends AbstractWatcherIntegrationTestCase {
|
||||||
.addAction("_id", indexAction("idx", "action"));
|
.addAction("_id", indexAction("idx", "action"));
|
||||||
|
|
||||||
watcherClient().preparePutWatch("_name")
|
watcherClient().preparePutWatch("_name")
|
||||||
.setSource(source.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1l)))
|
.setSource(source.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1L)))
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
if (timeWarped()) {
|
if (timeWarped()) {
|
||||||
|
@ -225,7 +225,7 @@ public class BasicWatcherTests extends AbstractWatcherIntegrationTestCase {
|
||||||
assertWatchWithMinimumPerformedActionsCount("_name", 0, false);
|
assertWatchWithMinimumPerformedActionsCount("_name", 0, false);
|
||||||
|
|
||||||
watcherClient().preparePutWatch("_name")
|
watcherClient().preparePutWatch("_name")
|
||||||
.setSource(source.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 0l)))
|
.setSource(source.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 0L)))
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
if (timeWarped()) {
|
if (timeWarped()) {
|
||||||
|
@ -238,7 +238,7 @@ public class BasicWatcherTests extends AbstractWatcherIntegrationTestCase {
|
||||||
watcherClient().preparePutWatch("_name")
|
watcherClient().preparePutWatch("_name")
|
||||||
.setSource(source
|
.setSource(source
|
||||||
.trigger(schedule(Schedules.cron("0/1 * * * * ? 2020")))
|
.trigger(schedule(Schedules.cron("0/1 * * * * ? 2020")))
|
||||||
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 0l)))
|
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 0L)))
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
if (timeWarped()) {
|
if (timeWarped()) {
|
||||||
|
@ -340,14 +340,14 @@ public class BasicWatcherTests extends AbstractWatcherIntegrationTestCase {
|
||||||
.setSource(watchBuilder()
|
.setSource(watchBuilder()
|
||||||
.trigger(schedule(interval(5, IntervalSchedule.Interval.Unit.SECONDS)))
|
.trigger(schedule(interval(5, IntervalSchedule.Interval.Unit.SECONDS)))
|
||||||
.input(searchInput(searchRequest).extractKeys("hits.total"))
|
.input(searchInput(searchRequest).extractKeys("hits.total"))
|
||||||
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1l)))
|
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1L)))
|
||||||
.get();
|
.get();
|
||||||
// in this watcher the condition will fail, because max_score isn't extracted, only total:
|
// in this watcher the condition will fail, because max_score isn't extracted, only total:
|
||||||
watcherClient.preparePutWatch("_name2")
|
watcherClient.preparePutWatch("_name2")
|
||||||
.setSource(watchBuilder()
|
.setSource(watchBuilder()
|
||||||
.trigger(schedule(interval(5, IntervalSchedule.Interval.Unit.SECONDS)))
|
.trigger(schedule(interval(5, IntervalSchedule.Interval.Unit.SECONDS)))
|
||||||
.input(searchInput(searchRequest).extractKeys("hits.total"))
|
.input(searchInput(searchRequest).extractKeys("hits.total"))
|
||||||
.condition(compareCondition("ctx.payload.hits.max_score", CompareCondition.Op.GTE, 0l)))
|
.condition(compareCondition("ctx.payload.hits.max_score", CompareCondition.Op.GTE, 0L)))
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
if (timeWarped()) {
|
if (timeWarped()) {
|
||||||
|
@ -454,7 +454,7 @@ public class BasicWatcherTests extends AbstractWatcherIntegrationTestCase {
|
||||||
.setSource(watchBuilder()
|
.setSource(watchBuilder()
|
||||||
.trigger(schedule(interval("5s")))
|
.trigger(schedule(interval("5s")))
|
||||||
.input(searchInput(request))
|
.input(searchInput(request))
|
||||||
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.GTE, 3l)))
|
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.GTE, 3L)))
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
logger.info("created watch [{}] at [{}]", watchName, SystemClock.INSTANCE.nowUTC());
|
logger.info("created watch [{}] at [{}]", watchName, SystemClock.INSTANCE.nowUTC());
|
||||||
|
|
|
@ -94,7 +94,7 @@ public class EmailActionIntegrationTests extends AbstractWatcherIntegrationTestC
|
||||||
.setSource(watchBuilder()
|
.setSource(watchBuilder()
|
||||||
.trigger(schedule(interval(5, IntervalSchedule.Interval.Unit.SECONDS)))
|
.trigger(schedule(interval(5, IntervalSchedule.Interval.Unit.SECONDS)))
|
||||||
.input(searchInput(searchRequest))
|
.input(searchInput(searchRequest))
|
||||||
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.GT, 0l))
|
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.GT, 0L))
|
||||||
.addAction("_email", emailAction(EmailTemplate.builder().from("_from").to("_to")
|
.addAction("_email", emailAction(EmailTemplate.builder().from("_from").to("_to")
|
||||||
.subject("{{ctx.payload.hits.hits.0._source.field}}")).setAuthentication(USERNAME, PASSWORD.toCharArray())))
|
.subject("{{ctx.payload.hits.hits.0._source.field}}")).setAuthentication(USERNAME, PASSWORD.toCharArray())))
|
||||||
.get();
|
.get();
|
||||||
|
|
|
@ -194,7 +194,7 @@ public class EmailAttachmentTests extends AbstractWatcherIntegrationTestCase {
|
||||||
WatchSourceBuilder watchSourceBuilder = watchBuilder()
|
WatchSourceBuilder watchSourceBuilder = watchBuilder()
|
||||||
.trigger(schedule(interval(5, IntervalSchedule.Interval.Unit.SECONDS)))
|
.trigger(schedule(interval(5, IntervalSchedule.Interval.Unit.SECONDS)))
|
||||||
.input(searchInput(searchRequest))
|
.input(searchInput(searchRequest))
|
||||||
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.GT, 0l))
|
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.GT, 0L))
|
||||||
.addAction("_email", emailAction(emailBuilder).setAuthentication(USERNAME, PASSWORD.toCharArray())
|
.addAction("_email", emailAction(emailBuilder).setAuthentication(USERNAME, PASSWORD.toCharArray())
|
||||||
.setAttachments(emailAttachments));
|
.setAttachments(emailAttachments));
|
||||||
logger.info("TMP WATCHSOURCE {}", watchSourceBuilder.build().getBytes().toUtf8());
|
logger.info("TMP WATCHSOURCE {}", watchSourceBuilder.build().getBytes().toUtf8());
|
||||||
|
|
|
@ -75,7 +75,7 @@ public class TimeThrottleIntegrationTests extends AbstractWatcherIntegrationTest
|
||||||
.setSource(watchBuilder()
|
.setSource(watchBuilder()
|
||||||
.trigger(schedule(interval("5s")))
|
.trigger(schedule(interval("5s")))
|
||||||
.input(searchInput(matchAllRequest().indices("events")))
|
.input(searchInput(matchAllRequest().indices("events")))
|
||||||
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.GT, 0l))
|
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.GT, 0L))
|
||||||
.transform(searchTransform(matchAllRequest().indices("events")))
|
.transform(searchTransform(matchAllRequest().indices("events")))
|
||||||
.addAction("_id", indexAction("actions", "action"))
|
.addAction("_id", indexAction("actions", "action"))
|
||||||
.defaultThrottlePeriod(TimeValue.timeValueSeconds(30)))
|
.defaultThrottlePeriod(TimeValue.timeValueSeconds(30)))
|
||||||
|
@ -149,7 +149,7 @@ public class TimeThrottleIntegrationTests extends AbstractWatcherIntegrationTest
|
||||||
.setSource(watchBuilder()
|
.setSource(watchBuilder()
|
||||||
.trigger(schedule(interval("1s")))
|
.trigger(schedule(interval("1s")))
|
||||||
.input(searchInput(matchAllRequest().indices("events")))
|
.input(searchInput(matchAllRequest().indices("events")))
|
||||||
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.GT, 0l))
|
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.GT, 0L))
|
||||||
.transform(searchTransform(matchAllRequest().indices("events")))
|
.transform(searchTransform(matchAllRequest().indices("events")))
|
||||||
.addAction("_id", indexAction("actions", "action")))
|
.addAction("_id", indexAction("actions", "action")))
|
||||||
.get();
|
.get();
|
||||||
|
|
|
@ -643,7 +643,7 @@ public class LicensesService extends AbstractLifecycleComponent<LicensesService>
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(long expirationDate, long now) {
|
public boolean matches(long expirationDate, long now) {
|
||||||
long expiryDuration = expirationDate - now;
|
long expiryDuration = expirationDate - now;
|
||||||
if (expiryDuration > 0l) {
|
if (expiryDuration > 0L) {
|
||||||
if (expiryDuration <= max.getMillis()) {
|
if (expiryDuration <= max.getMillis()) {
|
||||||
return expiryDuration >= min.getMillis();
|
return expiryDuration >= min.getMillis();
|
||||||
}
|
}
|
||||||
|
@ -673,7 +673,7 @@ public class LicensesService extends AbstractLifecycleComponent<LicensesService>
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(long expirationDate, long now) {
|
public boolean matches(long expirationDate, long now) {
|
||||||
long postExpiryDuration = now - expirationDate;
|
long postExpiryDuration = now - expirationDate;
|
||||||
if (postExpiryDuration > 0l) {
|
if (postExpiryDuration > 0L) {
|
||||||
if (postExpiryDuration <= max.getMillis()) {
|
if (postExpiryDuration <= max.getMillis()) {
|
||||||
return postExpiryDuration >= min.getMillis();
|
return postExpiryDuration >= min.getMillis();
|
||||||
}
|
}
|
||||||
|
@ -684,12 +684,12 @@ public class LicensesService extends AbstractLifecycleComponent<LicensesService>
|
||||||
@Override
|
@Override
|
||||||
public TimeValue delay(long expiryDuration) {
|
public TimeValue delay(long expiryDuration) {
|
||||||
final long delay;
|
final long delay;
|
||||||
if (expiryDuration >= 0l) {
|
if (expiryDuration >= 0L) {
|
||||||
delay = expiryDuration + min.getMillis();
|
delay = expiryDuration + min.getMillis();
|
||||||
} else {
|
} else {
|
||||||
delay = (-1l * expiryDuration) - min.getMillis();
|
delay = (-1L * expiryDuration) - min.getMillis();
|
||||||
}
|
}
|
||||||
if (delay > 0l) {
|
if (delay > 0L) {
|
||||||
return TimeValue.timeValueMillis(delay);
|
return TimeValue.timeValueMillis(delay);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -126,7 +126,7 @@ public abstract class AbstractLicensesConsumerPluginIntegrationTestCase extends
|
||||||
assertLicenseeState(consumerPlugin.id(), LicenseState.ENABLED);
|
assertLicenseeState(consumerPlugin.id(), LicenseState.ENABLED);
|
||||||
|
|
||||||
logger.info(" --> sleep for rest of trailLicense duration");
|
logger.info(" --> sleep for rest of trailLicense duration");
|
||||||
Thread.sleep(trialLicenseDurationInSeconds * 1000l);
|
Thread.sleep(trialLicenseDurationInSeconds * 1000L);
|
||||||
|
|
||||||
logger.info(" --> check consumer is still enabled [signed license]");
|
logger.info(" --> check consumer is still enabled [signed license]");
|
||||||
// consumer plugin should notify onEnabled on all data nodes (signed license)
|
// consumer plugin should notify onEnabled on all data nodes (signed license)
|
||||||
|
|
|
@ -121,7 +121,7 @@ public class LicensesPluginIntegrationTests extends AbstractLicensesIntegrationT
|
||||||
assertLicenseeState(getCurrentFeatureName(), LicenseState.ENABLED);
|
assertLicenseeState(getCurrentFeatureName(), LicenseState.ENABLED);
|
||||||
|
|
||||||
logger.info(" --> sleep for rest of trailLicense duration");
|
logger.info(" --> sleep for rest of trailLicense duration");
|
||||||
Thread.sleep(trialLicenseDurationInSeconds * 1000l);
|
Thread.sleep(trialLicenseDurationInSeconds * 1000L);
|
||||||
|
|
||||||
logger.info(" --> check consumer is still enabled [signed license]");
|
logger.info(" --> check consumer is still enabled [signed license]");
|
||||||
// consumer plugin should notify onEnabled on all data nodes (signed license)
|
// consumer plugin should notify onEnabled on all data nodes (signed license)
|
||||||
|
|
|
@ -78,7 +78,7 @@ public class LicensesTransportTests extends AbstractLicensesIntegrationTestCase
|
||||||
// modify content of signed license
|
// modify content of signed license
|
||||||
License tamperedLicense = License.builder()
|
License tamperedLicense = License.builder()
|
||||||
.fromLicenseSpec(signedLicense, signedLicense.signature())
|
.fromLicenseSpec(signedLicense, signedLicense.signature())
|
||||||
.expiryDate(signedLicense.expiryDate() + 10 * 24 * 60 * 60 * 1000l)
|
.expiryDate(signedLicense.expiryDate() + 10 * 24 * 60 * 60 * 1000L)
|
||||||
.validate()
|
.validate()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
|
@ -117,7 +117,7 @@ public class TestUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static License generateSignedLicense(String type, long issueDate, TimeValue expiryDuration) throws Exception {
|
public static License generateSignedLicense(String type, long issueDate, TimeValue expiryDuration) throws Exception {
|
||||||
long issue = (issueDate != -1l) ? issueDate : System.currentTimeMillis();
|
long issue = (issueDate != -1L) ? issueDate : System.currentTimeMillis();
|
||||||
int version = randomIntBetween(License.VERSION_START, License.VERSION_CURRENT);
|
int version = randomIntBetween(License.VERSION_START, License.VERSION_CURRENT);
|
||||||
final String licenseType;
|
final String licenseType;
|
||||||
if (version < License.VERSION_NO_FEATURE_TYPE) {
|
if (version < License.VERSION_NO_FEATURE_TYPE) {
|
||||||
|
|
|
@ -79,7 +79,7 @@ public class LicensesManagerServiceTests extends ESSingleNodeTestCase {
|
||||||
// modify content of signed license
|
// modify content of signed license
|
||||||
License tamperedLicense = License.builder()
|
License tamperedLicense = License.builder()
|
||||||
.fromLicenseSpec(signedLicense, signedLicense.signature())
|
.fromLicenseSpec(signedLicense, signedLicense.signature())
|
||||||
.expiryDate(signedLicense.expiryDate() + 10 * 24 * 60 * 60 * 1000l)
|
.expiryDate(signedLicense.expiryDate() + 10 * 24 * 60 * 60 * 1000L)
|
||||||
.validate()
|
.validate()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
|
@ -306,10 +306,10 @@ public class DocumentLevelSecurityTests extends ShieldIntegTestCase {
|
||||||
assertSearchHits(response, "1", "2");
|
assertSearchHits(response, "1", "2");
|
||||||
|
|
||||||
Global globalAgg = response.getAggregations().get("global");
|
Global globalAgg = response.getAggregations().get("global");
|
||||||
assertThat(globalAgg.getDocCount(), equalTo(2l));
|
assertThat(globalAgg.getDocCount(), equalTo(2L));
|
||||||
Terms termsAgg = globalAgg.getAggregations().get("field2");
|
Terms termsAgg = globalAgg.getAggregations().get("field2");
|
||||||
assertThat(termsAgg.getBuckets().get(0).getKeyAsString(), equalTo("value2"));
|
assertThat(termsAgg.getBuckets().get(0).getKeyAsString(), equalTo("value2"));
|
||||||
assertThat(termsAgg.getBuckets().get(0).getDocCount(), equalTo(1l));
|
assertThat(termsAgg.getBuckets().get(0).getDocCount(), equalTo(1L));
|
||||||
|
|
||||||
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user1", USERS_PASSWD)))
|
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user1", USERS_PASSWD)))
|
||||||
.prepareSearch("test")
|
.prepareSearch("test")
|
||||||
|
@ -319,7 +319,7 @@ public class DocumentLevelSecurityTests extends ShieldIntegTestCase {
|
||||||
assertSearchHits(response, "1");
|
assertSearchHits(response, "1");
|
||||||
|
|
||||||
globalAgg = response.getAggregations().get("global");
|
globalAgg = response.getAggregations().get("global");
|
||||||
assertThat(globalAgg.getDocCount(), equalTo(1l));
|
assertThat(globalAgg.getDocCount(), equalTo(1L));
|
||||||
termsAgg = globalAgg.getAggregations().get("field2");
|
termsAgg = globalAgg.getAggregations().get("field2");
|
||||||
assertThat(termsAgg.getBuckets().size(), equalTo(0));
|
assertThat(termsAgg.getBuckets().size(), equalTo(0));
|
||||||
}
|
}
|
||||||
|
@ -346,10 +346,10 @@ public class DocumentLevelSecurityTests extends ShieldIntegTestCase {
|
||||||
assertSearchHits(response, "1");
|
assertSearchHits(response, "1");
|
||||||
|
|
||||||
Children children = response.getAggregations().get("children");
|
Children children = response.getAggregations().get("children");
|
||||||
assertThat(children.getDocCount(), equalTo(1l));
|
assertThat(children.getDocCount(), equalTo(1L));
|
||||||
Terms termsAgg = children.getAggregations().get("field3");
|
Terms termsAgg = children.getAggregations().get("field3");
|
||||||
assertThat(termsAgg.getBuckets().get(0).getKeyAsString(), equalTo("value3"));
|
assertThat(termsAgg.getBuckets().get(0).getKeyAsString(), equalTo("value3"));
|
||||||
assertThat(termsAgg.getBuckets().get(0).getDocCount(), equalTo(1l));
|
assertThat(termsAgg.getBuckets().get(0).getDocCount(), equalTo(1L));
|
||||||
|
|
||||||
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user1", USERS_PASSWD)))
|
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user1", USERS_PASSWD)))
|
||||||
.prepareSearch("test")
|
.prepareSearch("test")
|
||||||
|
@ -361,7 +361,7 @@ public class DocumentLevelSecurityTests extends ShieldIntegTestCase {
|
||||||
assertSearchHits(response, "1");
|
assertSearchHits(response, "1");
|
||||||
|
|
||||||
children = response.getAggregations().get("children");
|
children = response.getAggregations().get("children");
|
||||||
assertThat(children.getDocCount(), equalTo(0l));
|
assertThat(children.getDocCount(), equalTo(0L));
|
||||||
termsAgg = children.getAggregations().get("field3");
|
termsAgg = children.getAggregations().get("field3");
|
||||||
assertThat(termsAgg.getBuckets().size(), equalTo(0));
|
assertThat(termsAgg.getBuckets().size(), equalTo(0));
|
||||||
}
|
}
|
||||||
|
@ -381,15 +381,15 @@ public class DocumentLevelSecurityTests extends ShieldIntegTestCase {
|
||||||
SearchResponse searchResponse = client().prepareSearch("test")
|
SearchResponse searchResponse = client().prepareSearch("test")
|
||||||
.setQuery(hasChildQuery("child", matchAllQuery()))
|
.setQuery(hasChildQuery("child", matchAllQuery()))
|
||||||
.get();
|
.get();
|
||||||
assertHitCount(searchResponse, 1l);
|
assertHitCount(searchResponse, 1L);
|
||||||
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
|
assertThat(searchResponse.getHits().totalHits(), equalTo(1L));
|
||||||
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p1"));
|
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p1"));
|
||||||
|
|
||||||
searchResponse = client().prepareSearch("test")
|
searchResponse = client().prepareSearch("test")
|
||||||
.setQuery(hasParentQuery("parent", matchAllQuery()))
|
.setQuery(hasParentQuery("parent", matchAllQuery()))
|
||||||
.addSort("_id", SortOrder.ASC)
|
.addSort("_id", SortOrder.ASC)
|
||||||
.get();
|
.get();
|
||||||
assertHitCount(searchResponse, 2l);
|
assertHitCount(searchResponse, 2L);
|
||||||
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("c1"));
|
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("c1"));
|
||||||
assertThat(searchResponse.getHits().getAt(1).id(), equalTo("c2"));
|
assertThat(searchResponse.getHits().getAt(1).id(), equalTo("c2"));
|
||||||
|
|
||||||
|
@ -398,25 +398,25 @@ public class DocumentLevelSecurityTests extends ShieldIntegTestCase {
|
||||||
.prepareSearch("test")
|
.prepareSearch("test")
|
||||||
.setQuery(hasChildQuery("child", matchAllQuery()))
|
.setQuery(hasChildQuery("child", matchAllQuery()))
|
||||||
.get();
|
.get();
|
||||||
assertHitCount(searchResponse, 0l);
|
assertHitCount(searchResponse, 0L);
|
||||||
|
|
||||||
searchResponse = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD)))
|
searchResponse = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD)))
|
||||||
.prepareSearch("test")
|
.prepareSearch("test")
|
||||||
.setQuery(hasChildQuery("child", matchAllQuery()))
|
.setQuery(hasChildQuery("child", matchAllQuery()))
|
||||||
.get();
|
.get();
|
||||||
assertHitCount(searchResponse, 0l);
|
assertHitCount(searchResponse, 0L);
|
||||||
|
|
||||||
searchResponse = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user1", USERS_PASSWD)))
|
searchResponse = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user1", USERS_PASSWD)))
|
||||||
.prepareSearch("test")
|
.prepareSearch("test")
|
||||||
.setQuery(hasParentQuery("parent", matchAllQuery()))
|
.setQuery(hasParentQuery("parent", matchAllQuery()))
|
||||||
.get();
|
.get();
|
||||||
assertHitCount(searchResponse, 0l);
|
assertHitCount(searchResponse, 0L);
|
||||||
|
|
||||||
searchResponse = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD)))
|
searchResponse = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD)))
|
||||||
.prepareSearch("test")
|
.prepareSearch("test")
|
||||||
.setQuery(hasParentQuery("parent", matchAllQuery()))
|
.setQuery(hasParentQuery("parent", matchAllQuery()))
|
||||||
.get();
|
.get();
|
||||||
assertHitCount(searchResponse, 0l);
|
assertHitCount(searchResponse, 0L);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPercolateApi() {
|
public void testPercolateApi() {
|
||||||
|
@ -434,7 +434,7 @@ public class DocumentLevelSecurityTests extends ShieldIntegTestCase {
|
||||||
.setDocumentType("type")
|
.setDocumentType("type")
|
||||||
.setPercolateDoc(new PercolateSourceBuilder.DocBuilder().setDoc("{}"))
|
.setPercolateDoc(new PercolateSourceBuilder.DocBuilder().setDoc("{}"))
|
||||||
.get();
|
.get();
|
||||||
assertThat(response.getCount(), equalTo(1l));
|
assertThat(response.getCount(), equalTo(1L));
|
||||||
assertThat(response.getMatches()[0].getId().string(), equalTo("1"));
|
assertThat(response.getMatches()[0].getId().string(), equalTo("1"));
|
||||||
|
|
||||||
// Percolator with a query on a document that the current user can see. Percolator will have one query to evaluate, so there is a match:
|
// Percolator with a query on a document that the current user can see. Percolator will have one query to evaluate, so there is a match:
|
||||||
|
@ -444,7 +444,7 @@ public class DocumentLevelSecurityTests extends ShieldIntegTestCase {
|
||||||
.setPercolateQuery(termQuery("field1", "value1"))
|
.setPercolateQuery(termQuery("field1", "value1"))
|
||||||
.setPercolateDoc(new PercolateSourceBuilder.DocBuilder().setDoc("{}"))
|
.setPercolateDoc(new PercolateSourceBuilder.DocBuilder().setDoc("{}"))
|
||||||
.get();
|
.get();
|
||||||
assertThat(response.getCount(), equalTo(1l));
|
assertThat(response.getCount(), equalTo(1L));
|
||||||
assertThat(response.getMatches()[0].getId().string(), equalTo("1"));
|
assertThat(response.getMatches()[0].getId().string(), equalTo("1"));
|
||||||
|
|
||||||
// Percolator with a query on a document that the current user can't see. Percolator will not have queries to evaluate, so there is no match:
|
// Percolator with a query on a document that the current user can't see. Percolator will not have queries to evaluate, so there is no match:
|
||||||
|
@ -454,7 +454,7 @@ public class DocumentLevelSecurityTests extends ShieldIntegTestCase {
|
||||||
.setPercolateQuery(termQuery("field1", "value1"))
|
.setPercolateQuery(termQuery("field1", "value1"))
|
||||||
.setPercolateDoc(new PercolateSourceBuilder.DocBuilder().setDoc("{}"))
|
.setPercolateDoc(new PercolateSourceBuilder.DocBuilder().setDoc("{}"))
|
||||||
.get();
|
.get();
|
||||||
assertThat(response.getCount(), equalTo(0l));
|
assertThat(response.getCount(), equalTo(0L));
|
||||||
|
|
||||||
assertAcked(client().admin().indices().prepareClose("test"));
|
assertAcked(client().admin().indices().prepareClose("test"));
|
||||||
assertAcked(client().admin().indices().prepareOpen("test"));
|
assertAcked(client().admin().indices().prepareOpen("test"));
|
||||||
|
@ -466,7 +466,7 @@ public class DocumentLevelSecurityTests extends ShieldIntegTestCase {
|
||||||
.setDocumentType("type")
|
.setDocumentType("type")
|
||||||
.setPercolateDoc(new PercolateSourceBuilder.DocBuilder().setDoc("{}"))
|
.setPercolateDoc(new PercolateSourceBuilder.DocBuilder().setDoc("{}"))
|
||||||
.get();
|
.get();
|
||||||
assertThat(response.getCount(), equalTo(1l));
|
assertThat(response.getCount(), equalTo(1L));
|
||||||
assertThat(response.getMatches()[0].getId().string(), equalTo("1"));
|
assertThat(response.getMatches()[0].getId().string(), equalTo("1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -336,7 +336,7 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
|
||||||
.setFields("field1", "field2")
|
.setFields("field1", "field2")
|
||||||
.get();
|
.get();
|
||||||
assertThat(response.getAllFieldStats().size(), equalTo(1));
|
assertThat(response.getAllFieldStats().size(), equalTo(1));
|
||||||
assertThat(response.getAllFieldStats().get("field1").getDocCount(), equalTo(1l));
|
assertThat(response.getAllFieldStats().get("field1").getDocCount(), equalTo(1L));
|
||||||
|
|
||||||
// user2 is granted access to field2 only:
|
// user2 is granted access to field2 only:
|
||||||
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD)))
|
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD)))
|
||||||
|
@ -344,7 +344,7 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
|
||||||
.setFields("field1", "field2")
|
.setFields("field1", "field2")
|
||||||
.get();
|
.get();
|
||||||
assertThat(response.getAllFieldStats().size(), equalTo(1));
|
assertThat(response.getAllFieldStats().size(), equalTo(1));
|
||||||
assertThat(response.getAllFieldStats().get("field2").getDocCount(), equalTo(1l));
|
assertThat(response.getAllFieldStats().get("field2").getDocCount(), equalTo(1L));
|
||||||
|
|
||||||
// user3 is granted access to field1 and field2:
|
// user3 is granted access to field1 and field2:
|
||||||
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user3", USERS_PASSWD)))
|
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user3", USERS_PASSWD)))
|
||||||
|
@ -352,8 +352,8 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
|
||||||
.setFields("field1", "field2")
|
.setFields("field1", "field2")
|
||||||
.get();
|
.get();
|
||||||
assertThat(response.getAllFieldStats().size(), equalTo(2));
|
assertThat(response.getAllFieldStats().size(), equalTo(2));
|
||||||
assertThat(response.getAllFieldStats().get("field1").getDocCount(), equalTo(1l));
|
assertThat(response.getAllFieldStats().get("field1").getDocCount(), equalTo(1L));
|
||||||
assertThat(response.getAllFieldStats().get("field2").getDocCount(), equalTo(1l));
|
assertThat(response.getAllFieldStats().get("field2").getDocCount(), equalTo(1L));
|
||||||
|
|
||||||
// user4 is granted access to no fields:
|
// user4 is granted access to no fields:
|
||||||
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user4", USERS_PASSWD)))
|
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user4", USERS_PASSWD)))
|
||||||
|
@ -368,8 +368,8 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
|
||||||
.setFields("field1", "field2")
|
.setFields("field1", "field2")
|
||||||
.get();
|
.get();
|
||||||
assertThat(response.getAllFieldStats().size(), equalTo(2));
|
assertThat(response.getAllFieldStats().size(), equalTo(2));
|
||||||
assertThat(response.getAllFieldStats().get("field1").getDocCount(), equalTo(1l));
|
assertThat(response.getAllFieldStats().get("field1").getDocCount(), equalTo(1L));
|
||||||
assertThat(response.getAllFieldStats().get("field2").getDocCount(), equalTo(1l));
|
assertThat(response.getAllFieldStats().get("field2").getDocCount(), equalTo(1L));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testQueryCache() throws Exception {
|
public void testQueryCache() throws Exception {
|
||||||
|
@ -541,7 +541,7 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
|
||||||
.prepareSearch("test")
|
.prepareSearch("test")
|
||||||
.addSort("field1", SortOrder.ASC)
|
.addSort("field1", SortOrder.ASC)
|
||||||
.get();
|
.get();
|
||||||
assertThat((Long) response.getHits().getAt(0).sortValues()[0], equalTo(1l));
|
assertThat((Long) response.getHits().getAt(0).sortValues()[0], equalTo(1L));
|
||||||
|
|
||||||
// user2 is not granted to use field1, so the default missing sort value is included
|
// user2 is not granted to use field1, so the default missing sort value is included
|
||||||
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD)))
|
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD)))
|
||||||
|
@ -562,7 +562,7 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
|
||||||
.prepareSearch("test")
|
.prepareSearch("test")
|
||||||
.addSort("field2", SortOrder.ASC)
|
.addSort("field2", SortOrder.ASC)
|
||||||
.get();
|
.get();
|
||||||
assertThat((Long) response.getHits().getAt(0).sortValues()[0], equalTo(2l));
|
assertThat((Long) response.getHits().getAt(0).sortValues()[0], equalTo(2L));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAggs() throws Exception {
|
public void testAggs() throws Exception {
|
||||||
|
@ -578,7 +578,7 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
|
||||||
.prepareSearch("test")
|
.prepareSearch("test")
|
||||||
.addAggregation(AggregationBuilders.terms("_name").field("field1"))
|
.addAggregation(AggregationBuilders.terms("_name").field("field1"))
|
||||||
.get();
|
.get();
|
||||||
assertThat(((Terms) response.getAggregations().get("_name")).getBucketByKey("value1").getDocCount(), equalTo(1l));
|
assertThat(((Terms) response.getAggregations().get("_name")).getBucketByKey("value1").getDocCount(), equalTo(1L));
|
||||||
|
|
||||||
// user2 is not authorized to use field1, so no buckets are include for a term agg on field1
|
// user2 is not authorized to use field1, so no buckets are include for a term agg on field1
|
||||||
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD)))
|
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD)))
|
||||||
|
@ -599,7 +599,7 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
|
||||||
.prepareSearch("test")
|
.prepareSearch("test")
|
||||||
.addAggregation(AggregationBuilders.terms("_name").field("field2"))
|
.addAggregation(AggregationBuilders.terms("_name").field("field2"))
|
||||||
.get();
|
.get();
|
||||||
assertThat(((Terms) response.getAggregations().get("_name")).getBucketByKey("value2").getDocCount(), equalTo(1l));
|
assertThat(((Terms) response.getAggregations().get("_name")).getBucketByKey("value2").getDocCount(), equalTo(1L));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testTVApi() throws Exception {
|
public void testTVApi() throws Exception {
|
||||||
|
@ -617,7 +617,7 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
|
||||||
.get();
|
.get();
|
||||||
assertThat(response.isExists(), is(true));
|
assertThat(response.isExists(), is(true));
|
||||||
assertThat(response.getFields().size(), equalTo(1));
|
assertThat(response.getFields().size(), equalTo(1));
|
||||||
assertThat(response.getFields().terms("field1").size(), equalTo(1l));
|
assertThat(response.getFields().terms("field1").size(), equalTo(1L));
|
||||||
|
|
||||||
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD)))
|
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD)))
|
||||||
.prepareTermVectors("test", "type1", "1")
|
.prepareTermVectors("test", "type1", "1")
|
||||||
|
@ -625,7 +625,7 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
|
||||||
.get();
|
.get();
|
||||||
assertThat(response.isExists(), is(true));
|
assertThat(response.isExists(), is(true));
|
||||||
assertThat(response.getFields().size(), equalTo(1));
|
assertThat(response.getFields().size(), equalTo(1));
|
||||||
assertThat(response.getFields().terms("field2").size(), equalTo(1l));
|
assertThat(response.getFields().terms("field2").size(), equalTo(1L));
|
||||||
|
|
||||||
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user3", USERS_PASSWD)))
|
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user3", USERS_PASSWD)))
|
||||||
.prepareTermVectors("test", "type1", "1")
|
.prepareTermVectors("test", "type1", "1")
|
||||||
|
@ -633,8 +633,8 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
|
||||||
.get();
|
.get();
|
||||||
assertThat(response.isExists(), is(true));
|
assertThat(response.isExists(), is(true));
|
||||||
assertThat(response.getFields().size(), equalTo(2));
|
assertThat(response.getFields().size(), equalTo(2));
|
||||||
assertThat(response.getFields().terms("field1").size(), equalTo(1l));
|
assertThat(response.getFields().terms("field1").size(), equalTo(1L));
|
||||||
assertThat(response.getFields().terms("field2").size(), equalTo(1l));
|
assertThat(response.getFields().terms("field2").size(), equalTo(1L));
|
||||||
|
|
||||||
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user4", USERS_PASSWD)))
|
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user4", USERS_PASSWD)))
|
||||||
.prepareTermVectors("test", "type1", "1")
|
.prepareTermVectors("test", "type1", "1")
|
||||||
|
@ -660,7 +660,7 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
|
||||||
assertThat(response.getResponses().length, equalTo(1));
|
assertThat(response.getResponses().length, equalTo(1));
|
||||||
assertThat(response.getResponses()[0].getResponse().isExists(), is(true));
|
assertThat(response.getResponses()[0].getResponse().isExists(), is(true));
|
||||||
assertThat(response.getResponses()[0].getResponse().getFields().size(), equalTo(1));
|
assertThat(response.getResponses()[0].getResponse().getFields().size(), equalTo(1));
|
||||||
assertThat(response.getResponses()[0].getResponse().getFields().terms("field1").size(), equalTo(1l));
|
assertThat(response.getResponses()[0].getResponse().getFields().terms("field1").size(), equalTo(1L));
|
||||||
|
|
||||||
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD)))
|
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD)))
|
||||||
.prepareMultiTermVectors()
|
.prepareMultiTermVectors()
|
||||||
|
@ -669,7 +669,7 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
|
||||||
assertThat(response.getResponses().length, equalTo(1));
|
assertThat(response.getResponses().length, equalTo(1));
|
||||||
assertThat(response.getResponses()[0].getResponse().isExists(), is(true));
|
assertThat(response.getResponses()[0].getResponse().isExists(), is(true));
|
||||||
assertThat(response.getResponses()[0].getResponse().getFields().size(), equalTo(1));
|
assertThat(response.getResponses()[0].getResponse().getFields().size(), equalTo(1));
|
||||||
assertThat(response.getResponses()[0].getResponse().getFields().terms("field2").size(), equalTo(1l));
|
assertThat(response.getResponses()[0].getResponse().getFields().terms("field2").size(), equalTo(1L));
|
||||||
|
|
||||||
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user3", USERS_PASSWD)))
|
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user3", USERS_PASSWD)))
|
||||||
.prepareMultiTermVectors()
|
.prepareMultiTermVectors()
|
||||||
|
@ -678,8 +678,8 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
|
||||||
assertThat(response.getResponses().length, equalTo(1));
|
assertThat(response.getResponses().length, equalTo(1));
|
||||||
assertThat(response.getResponses()[0].getResponse().isExists(), is(true));
|
assertThat(response.getResponses()[0].getResponse().isExists(), is(true));
|
||||||
assertThat(response.getResponses()[0].getResponse().getFields().size(), equalTo(2));
|
assertThat(response.getResponses()[0].getResponse().getFields().size(), equalTo(2));
|
||||||
assertThat(response.getResponses()[0].getResponse().getFields().terms("field1").size(), equalTo(1l));
|
assertThat(response.getResponses()[0].getResponse().getFields().terms("field1").size(), equalTo(1L));
|
||||||
assertThat(response.getResponses()[0].getResponse().getFields().terms("field2").size(), equalTo(1l));
|
assertThat(response.getResponses()[0].getResponse().getFields().terms("field2").size(), equalTo(1L));
|
||||||
|
|
||||||
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user4", USERS_PASSWD)))
|
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user4", USERS_PASSWD)))
|
||||||
.prepareMultiTermVectors()
|
.prepareMultiTermVectors()
|
||||||
|
@ -705,7 +705,7 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
|
||||||
.setDocumentType("type")
|
.setDocumentType("type")
|
||||||
.setPercolateDoc(new PercolateSourceBuilder.DocBuilder().setDoc("{}"))
|
.setPercolateDoc(new PercolateSourceBuilder.DocBuilder().setDoc("{}"))
|
||||||
.get();
|
.get();
|
||||||
assertThat(response.getCount(), equalTo(1l));
|
assertThat(response.getCount(), equalTo(1L));
|
||||||
assertThat(response.getMatches()[0].getId().string(), equalTo("1"));
|
assertThat(response.getMatches()[0].getId().string(), equalTo("1"));
|
||||||
|
|
||||||
// Percolator with a query on a field that the current user can't see. Percolator will not have queries to evaluate, so there is no match:
|
// Percolator with a query on a field that the current user can't see. Percolator will not have queries to evaluate, so there is no match:
|
||||||
|
@ -715,7 +715,7 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
|
||||||
.setPercolateQuery(termQuery("field1", "value1"))
|
.setPercolateQuery(termQuery("field1", "value1"))
|
||||||
.setPercolateDoc(new PercolateSourceBuilder.DocBuilder().setDoc("{}"))
|
.setPercolateDoc(new PercolateSourceBuilder.DocBuilder().setDoc("{}"))
|
||||||
.get();
|
.get();
|
||||||
assertThat(response.getCount(), equalTo(0l));
|
assertThat(response.getCount(), equalTo(0L));
|
||||||
|
|
||||||
assertAcked(client().admin().indices().prepareClose("test"));
|
assertAcked(client().admin().indices().prepareClose("test"));
|
||||||
assertAcked(client().admin().indices().prepareOpen("test"));
|
assertAcked(client().admin().indices().prepareOpen("test"));
|
||||||
|
@ -727,7 +727,7 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
|
||||||
.setDocumentType("type")
|
.setDocumentType("type")
|
||||||
.setPercolateDoc(new PercolateSourceBuilder.DocBuilder().setDoc("{}"))
|
.setPercolateDoc(new PercolateSourceBuilder.DocBuilder().setDoc("{}"))
|
||||||
.get();
|
.get();
|
||||||
assertThat(response.getCount(), equalTo(1l));
|
assertThat(response.getCount(), equalTo(1L));
|
||||||
assertThat(response.getMatches()[0].getId().string(), equalTo("1"));
|
assertThat(response.getMatches()[0].getId().string(), equalTo("1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -747,15 +747,15 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
|
||||||
.prepareSearch("test")
|
.prepareSearch("test")
|
||||||
.setQuery(hasChildQuery("child", termQuery("field1", "yellow")))
|
.setQuery(hasChildQuery("child", termQuery("field1", "yellow")))
|
||||||
.get();
|
.get();
|
||||||
assertHitCount(searchResponse, 1l);
|
assertHitCount(searchResponse, 1L);
|
||||||
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
|
assertThat(searchResponse.getHits().totalHits(), equalTo(1L));
|
||||||
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p1"));
|
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p1"));
|
||||||
|
|
||||||
searchResponse = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD)))
|
searchResponse = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD)))
|
||||||
.prepareSearch("test")
|
.prepareSearch("test")
|
||||||
.setQuery(hasChildQuery("child", termQuery("field1", "yellow")))
|
.setQuery(hasChildQuery("child", termQuery("field1", "yellow")))
|
||||||
.get();
|
.get();
|
||||||
assertHitCount(searchResponse, 0l);
|
assertHitCount(searchResponse, 0L);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testUpdateApiIsBlocked() throws Exception {
|
public void testUpdateApiIsBlocked() throws Exception {
|
||||||
|
|
|
@ -99,20 +99,20 @@ public class FieldDataCacheWithFieldSubsetReaderTests extends ESTestCase {
|
||||||
DirectoryReader ir = FieldSubsetReader.wrap(this.ir, Collections.<String>emptySet());
|
DirectoryReader ir = FieldSubsetReader.wrap(this.ir, Collections.<String>emptySet());
|
||||||
global = sortedSetDVOrdinalsIndexFieldData.loadGlobal(ir);
|
global = sortedSetDVOrdinalsIndexFieldData.loadGlobal(ir);
|
||||||
atomic = global.load(ir.leaves().get(0));
|
atomic = global.load(ir.leaves().get(0));
|
||||||
assertThat(atomic.getOrdinalsValues().getValueCount(), equalTo(0l));
|
assertThat(atomic.getOrdinalsValues().getValueCount(), equalTo(0L));
|
||||||
assertThat(indexFieldDataCache.topLevelBuilds, equalTo(1));
|
assertThat(indexFieldDataCache.topLevelBuilds, equalTo(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSortedSetDVOrdinalsIndexFieldData_segment() throws Exception {
|
public void testSortedSetDVOrdinalsIndexFieldData_segment() throws Exception {
|
||||||
for (LeafReaderContext context : ir.leaves()) {
|
for (LeafReaderContext context : ir.leaves()) {
|
||||||
AtomicOrdinalsFieldData atomic = sortedSetDVOrdinalsIndexFieldData.load(context);
|
AtomicOrdinalsFieldData atomic = sortedSetDVOrdinalsIndexFieldData.load(context);
|
||||||
assertThat(atomic.getOrdinalsValues().getValueCount(), greaterThanOrEqualTo(1l));
|
assertThat(atomic.getOrdinalsValues().getValueCount(), greaterThanOrEqualTo(1L));
|
||||||
}
|
}
|
||||||
|
|
||||||
DirectoryReader ir = FieldSubsetReader.wrap(this.ir, Collections.<String>emptySet());
|
DirectoryReader ir = FieldSubsetReader.wrap(this.ir, Collections.<String>emptySet());
|
||||||
for (LeafReaderContext context : ir.leaves()) {
|
for (LeafReaderContext context : ir.leaves()) {
|
||||||
AtomicOrdinalsFieldData atomic = sortedSetDVOrdinalsIndexFieldData.load(context);
|
AtomicOrdinalsFieldData atomic = sortedSetDVOrdinalsIndexFieldData.load(context);
|
||||||
assertThat(atomic.getOrdinalsValues().getValueCount(), equalTo(0l));
|
assertThat(atomic.getOrdinalsValues().getValueCount(), equalTo(0L));
|
||||||
}
|
}
|
||||||
// dv based field data doesn't use index field data cache, so in the end noting should have been added
|
// dv based field data doesn't use index field data cache, so in the end noting should have been added
|
||||||
assertThat(indexFieldDataCache.leafLevelBuilds, equalTo(0));
|
assertThat(indexFieldDataCache.leafLevelBuilds, equalTo(0));
|
||||||
|
@ -128,7 +128,7 @@ public class FieldDataCacheWithFieldSubsetReaderTests extends ESTestCase {
|
||||||
DirectoryReader ir = FieldSubsetReader.wrap(this.ir, Collections.<String>emptySet());
|
DirectoryReader ir = FieldSubsetReader.wrap(this.ir, Collections.<String>emptySet());
|
||||||
global = pagedBytesIndexFieldData.loadGlobal(ir);
|
global = pagedBytesIndexFieldData.loadGlobal(ir);
|
||||||
atomic = global.load(ir.leaves().get(0));
|
atomic = global.load(ir.leaves().get(0));
|
||||||
assertThat(atomic.getOrdinalsValues().getValueCount(), equalTo(0l));
|
assertThat(atomic.getOrdinalsValues().getValueCount(), equalTo(0L));
|
||||||
assertThat(indexFieldDataCache.topLevelBuilds, equalTo(1));
|
assertThat(indexFieldDataCache.topLevelBuilds, equalTo(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,14 +136,14 @@ public class FieldDataCacheWithFieldSubsetReaderTests extends ESTestCase {
|
||||||
assertThat(indexFieldDataCache.leafLevelBuilds, equalTo(0));
|
assertThat(indexFieldDataCache.leafLevelBuilds, equalTo(0));
|
||||||
for (LeafReaderContext context : ir.leaves()) {
|
for (LeafReaderContext context : ir.leaves()) {
|
||||||
AtomicOrdinalsFieldData atomic = pagedBytesIndexFieldData.load(context);
|
AtomicOrdinalsFieldData atomic = pagedBytesIndexFieldData.load(context);
|
||||||
assertThat(atomic.getOrdinalsValues().getValueCount(), greaterThanOrEqualTo(1l));
|
assertThat(atomic.getOrdinalsValues().getValueCount(), greaterThanOrEqualTo(1L));
|
||||||
}
|
}
|
||||||
assertThat(indexFieldDataCache.leafLevelBuilds, equalTo(ir.leaves().size()));
|
assertThat(indexFieldDataCache.leafLevelBuilds, equalTo(ir.leaves().size()));
|
||||||
|
|
||||||
DirectoryReader ir = FieldSubsetReader.wrap(this.ir, Collections.<String>emptySet());
|
DirectoryReader ir = FieldSubsetReader.wrap(this.ir, Collections.<String>emptySet());
|
||||||
for (LeafReaderContext context : ir.leaves()) {
|
for (LeafReaderContext context : ir.leaves()) {
|
||||||
AtomicOrdinalsFieldData atomic = pagedBytesIndexFieldData.load(context);
|
AtomicOrdinalsFieldData atomic = pagedBytesIndexFieldData.load(context);
|
||||||
assertThat(atomic.getOrdinalsValues().getValueCount(), equalTo(0l));
|
assertThat(atomic.getOrdinalsValues().getValueCount(), equalTo(0L));
|
||||||
}
|
}
|
||||||
assertThat(indexFieldDataCache.leafLevelBuilds, equalTo(ir.leaves().size()));
|
assertThat(indexFieldDataCache.leafLevelBuilds, equalTo(ir.leaves().size()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,8 +84,8 @@ public class CompareConditionSearchTests extends AbstractWatcherIntegrationTestC
|
||||||
hit.score(1f);
|
hit.score(1f);
|
||||||
hit.shard(new SearchShardTarget("a", new Index("a", "indexUUID"), 0));
|
hit.shard(new SearchShardTarget("a", new Index("a", "indexUUID"), 0));
|
||||||
|
|
||||||
InternalSearchResponse internalSearchResponse = new InternalSearchResponse(new InternalSearchHits(new InternalSearchHit[]{hit}, 1l, 1f), null, null, null, false, false);
|
InternalSearchResponse internalSearchResponse = new InternalSearchResponse(new InternalSearchHits(new InternalSearchHit[]{hit}, 1L, 1f), null, null, null, false, false);
|
||||||
SearchResponse response = new SearchResponse(internalSearchResponse, "", 3, 3, 500l, new ShardSearchFailure[0]);
|
SearchResponse response = new SearchResponse(internalSearchResponse, "", 3, 3, 500L, new ShardSearchFailure[0]);
|
||||||
|
|
||||||
WatchExecutionContext ctx = mockExecutionContext("_watch_name", new Payload.XContent(response));
|
WatchExecutionContext ctx = mockExecutionContext("_watch_name", new Payload.XContent(response));
|
||||||
assertThat(condition.execute(ctx).met(), is(true));
|
assertThat(condition.execute(ctx).met(), is(true));
|
||||||
|
|
|
@ -86,8 +86,8 @@ public class ScriptConditionSearchTests extends AbstractWatcherIntegrationTestCa
|
||||||
hit.score(1f);
|
hit.score(1f);
|
||||||
hit.shard(new SearchShardTarget("a", new Index("a", "testUUID"), 0));
|
hit.shard(new SearchShardTarget("a", new Index("a", "testUUID"), 0));
|
||||||
|
|
||||||
InternalSearchResponse internalSearchResponse = new InternalSearchResponse(new InternalSearchHits(new InternalSearchHit[]{hit}, 1l, 1f), null, null, null, false, false);
|
InternalSearchResponse internalSearchResponse = new InternalSearchResponse(new InternalSearchHits(new InternalSearchHit[]{hit}, 1L, 1f), null, null, null, false, false);
|
||||||
SearchResponse response = new SearchResponse(internalSearchResponse, "", 3, 3, 500l, new ShardSearchFailure[0]);
|
SearchResponse response = new SearchResponse(internalSearchResponse, "", 3, 3, 500L, new ShardSearchFailure[0]);
|
||||||
|
|
||||||
WatchExecutionContext ctx = mockExecutionContext("_watch_name", new Payload.XContent(response));
|
WatchExecutionContext ctx = mockExecutionContext("_watch_name", new Payload.XContent(response));
|
||||||
assertThat(condition.execute(ctx).met(), is(true));
|
assertThat(condition.execute(ctx).met(), is(true));
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class ScriptConditionTests extends ESTestCase {
|
||||||
public void testExecute() throws Exception {
|
public void testExecute() throws Exception {
|
||||||
ScriptServiceProxy scriptService = getScriptServiceProxy(tp);
|
ScriptServiceProxy scriptService = getScriptServiceProxy(tp);
|
||||||
ExecutableScriptCondition condition = new ExecutableScriptCondition(new ScriptCondition(Script.inline("ctx.payload.hits.total > 1").build()), logger, scriptService);
|
ExecutableScriptCondition condition = new ExecutableScriptCondition(new ScriptCondition(Script.inline("ctx.payload.hits.total > 1").build()), logger, scriptService);
|
||||||
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500l, new ShardSearchFailure[0]);
|
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500L, new ShardSearchFailure[0]);
|
||||||
WatchExecutionContext ctx = mockExecutionContext("_name", new Payload.XContent(response));
|
WatchExecutionContext ctx = mockExecutionContext("_name", new Payload.XContent(response));
|
||||||
assertFalse(condition.execute(ctx).met());
|
assertFalse(condition.execute(ctx).met());
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ public class ScriptConditionTests extends ESTestCase {
|
||||||
ScriptServiceProxy scriptService = getScriptServiceProxy(tp);
|
ScriptServiceProxy scriptService = getScriptServiceProxy(tp);
|
||||||
Script script = Script.inline("ctx.payload.hits.total > threshold").lang(Script.DEFAULT_LANG).params(singletonMap("threshold", 1)).build();
|
Script script = Script.inline("ctx.payload.hits.total > threshold").lang(Script.DEFAULT_LANG).params(singletonMap("threshold", 1)).build();
|
||||||
ExecutableScriptCondition executable = new ExecutableScriptCondition(new ScriptCondition(script), logger, scriptService);
|
ExecutableScriptCondition executable = new ExecutableScriptCondition(new ScriptCondition(script), logger, scriptService);
|
||||||
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500l, new ShardSearchFailure[0]);
|
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500L, new ShardSearchFailure[0]);
|
||||||
WatchExecutionContext ctx = mockExecutionContext("_name", new Payload.XContent(response));
|
WatchExecutionContext ctx = mockExecutionContext("_name", new Payload.XContent(response));
|
||||||
assertFalse(executable.execute(ctx).met());
|
assertFalse(executable.execute(ctx).met());
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ public class ScriptConditionTests extends ESTestCase {
|
||||||
ScriptCondition condition = factory.parseCondition("_watch", parser);
|
ScriptCondition condition = factory.parseCondition("_watch", parser);
|
||||||
ExecutableScriptCondition executable = factory.createExecutable(condition);
|
ExecutableScriptCondition executable = factory.createExecutable(condition);
|
||||||
|
|
||||||
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500l, new ShardSearchFailure[0]);
|
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500L, new ShardSearchFailure[0]);
|
||||||
WatchExecutionContext ctx = mockExecutionContext("_name", new Payload.XContent(response));
|
WatchExecutionContext ctx = mockExecutionContext("_name", new Payload.XContent(response));
|
||||||
|
|
||||||
assertFalse(executable.execute(ctx).met());
|
assertFalse(executable.execute(ctx).met());
|
||||||
|
@ -162,7 +162,7 @@ public class ScriptConditionTests extends ESTestCase {
|
||||||
public void testScriptConditionThrowException() throws Exception {
|
public void testScriptConditionThrowException() throws Exception {
|
||||||
ScriptServiceProxy scriptService = getScriptServiceProxy(tp);
|
ScriptServiceProxy scriptService = getScriptServiceProxy(tp);
|
||||||
ExecutableScriptCondition condition = new ExecutableScriptCondition(new ScriptCondition(Script.inline("assert false").build()), logger, scriptService);
|
ExecutableScriptCondition condition = new ExecutableScriptCondition(new ScriptCondition(Script.inline("assert false").build()), logger, scriptService);
|
||||||
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500l, new ShardSearchFailure[0]);
|
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500L, new ShardSearchFailure[0]);
|
||||||
WatchExecutionContext ctx = mockExecutionContext("_name", new Payload.XContent(response));
|
WatchExecutionContext ctx = mockExecutionContext("_name", new Payload.XContent(response));
|
||||||
ScriptCondition.Result result = condition.execute(ctx);
|
ScriptCondition.Result result = condition.execute(ctx);
|
||||||
assertThat(result, notNullValue());
|
assertThat(result, notNullValue());
|
||||||
|
@ -174,7 +174,7 @@ public class ScriptConditionTests extends ESTestCase {
|
||||||
public void testScriptConditionReturnObject() throws Exception {
|
public void testScriptConditionReturnObject() throws Exception {
|
||||||
ScriptServiceProxy scriptService = getScriptServiceProxy(tp);
|
ScriptServiceProxy scriptService = getScriptServiceProxy(tp);
|
||||||
ExecutableScriptCondition condition = new ExecutableScriptCondition(new ScriptCondition(Script.inline("return new Object()").build()), logger, scriptService);
|
ExecutableScriptCondition condition = new ExecutableScriptCondition(new ScriptCondition(Script.inline("return new Object()").build()), logger, scriptService);
|
||||||
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500l, new ShardSearchFailure[0]);
|
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500L, new ShardSearchFailure[0]);
|
||||||
WatchExecutionContext ctx = mockExecutionContext("_name", new Payload.XContent(response));
|
WatchExecutionContext ctx = mockExecutionContext("_name", new Payload.XContent(response));
|
||||||
ScriptCondition.Result result = condition.execute(ctx);
|
ScriptCondition.Result result = condition.execute(ctx);
|
||||||
assertThat(result, notNullValue());
|
assertThat(result, notNullValue());
|
||||||
|
@ -186,7 +186,7 @@ public class ScriptConditionTests extends ESTestCase {
|
||||||
public void testScriptConditionAccessCtx() throws Exception {
|
public void testScriptConditionAccessCtx() throws Exception {
|
||||||
ScriptServiceProxy scriptService = getScriptServiceProxy(tp);
|
ScriptServiceProxy scriptService = getScriptServiceProxy(tp);
|
||||||
ExecutableScriptCondition condition = new ExecutableScriptCondition(new ScriptCondition(Script.inline("ctx.trigger.scheduled_time.getMillis() < System.currentTimeMillis() ").build()), logger, scriptService);
|
ExecutableScriptCondition condition = new ExecutableScriptCondition(new ScriptCondition(Script.inline("ctx.trigger.scheduled_time.getMillis() < System.currentTimeMillis() ").build()), logger, scriptService);
|
||||||
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500l, new ShardSearchFailure[0]);
|
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500L, new ShardSearchFailure[0]);
|
||||||
WatchExecutionContext ctx = mockExecutionContext("_name", new DateTime(DateTimeZone.UTC), new Payload.XContent(response));
|
WatchExecutionContext ctx = mockExecutionContext("_name", new DateTime(DateTimeZone.UTC), new Payload.XContent(response));
|
||||||
Thread.sleep(10);
|
Thread.sleep(10);
|
||||||
assertThat(condition.execute(ctx).met(), is(true));
|
assertThat(condition.execute(ctx).met(), is(true));
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class TriggeredWatchStoreLifeCycleTests extends AbstractWatcherIntegratio
|
||||||
assertThat(loadedTriggeredWatches.contains(triggeredWatch), is(true));
|
assertThat(loadedTriggeredWatches.contains(triggeredWatch), is(true));
|
||||||
triggeredWatchStore.delete(triggeredWatch.id());
|
triggeredWatchStore.delete(triggeredWatch.id());
|
||||||
GetResponse getResponse = client().prepareGet(TriggeredWatchStore.INDEX_NAME, TriggeredWatchStore.DOC_TYPE, triggeredWatch.id().value())
|
GetResponse getResponse = client().prepareGet(TriggeredWatchStore.INDEX_NAME, TriggeredWatchStore.DOC_TYPE, triggeredWatch.id().value())
|
||||||
.setVersion(2l)
|
.setVersion(2L)
|
||||||
.get();
|
.get();
|
||||||
assertThat(getResponse.isExists(), equalTo(false));
|
assertThat(getResponse.isExists(), equalTo(false));
|
||||||
}
|
}
|
||||||
|
|
|
@ -269,7 +269,7 @@ public class TriggeredWatchStoreTests extends ESTestCase {
|
||||||
when(searchResponse1.getSuccessfulShards()).thenReturn(1);
|
when(searchResponse1.getSuccessfulShards()).thenReturn(1);
|
||||||
when(searchResponse1.getTotalShards()).thenReturn(1);
|
when(searchResponse1.getTotalShards()).thenReturn(1);
|
||||||
InternalSearchHit hit = new InternalSearchHit(0, "_id", new Text("_type"), null);
|
InternalSearchHit hit = new InternalSearchHit(0, "_id", new Text("_type"), null);
|
||||||
hit.version(1l);
|
hit.version(1L);
|
||||||
hit.shard(new SearchShardTarget("_node_id", index, 0));
|
hit.shard(new SearchShardTarget("_node_id", index, 0));
|
||||||
hit.sourceRef(new BytesArray("{}"));
|
hit.sourceRef(new BytesArray("{}"));
|
||||||
InternalSearchHits hits = new InternalSearchHits(new InternalSearchHit[]{hit}, 1, 1.0f);
|
InternalSearchHits hits = new InternalSearchHits(new InternalSearchHit[]{hit}, 1, 1.0f);
|
||||||
|
@ -279,7 +279,7 @@ public class TriggeredWatchStoreTests extends ESTestCase {
|
||||||
|
|
||||||
// First return a scroll response with a single hit and then with no hits
|
// First return a scroll response with a single hit and then with no hits
|
||||||
hit = new InternalSearchHit(0, "_id", new Text("_type"), null);
|
hit = new InternalSearchHit(0, "_id", new Text("_type"), null);
|
||||||
hit.version(1l);
|
hit.version(1L);
|
||||||
hit.shard(new SearchShardTarget("_node_id", index, 0));
|
hit.shard(new SearchShardTarget("_node_id", index, 0));
|
||||||
hit.sourceRef(new BytesArray("{}"));
|
hit.sourceRef(new BytesArray("{}"));
|
||||||
hits = new InternalSearchHits(new InternalSearchHit[]{hit}, 1, 1.0f);
|
hits = new InternalSearchHits(new InternalSearchHit[]{hit}, 1, 1.0f);
|
||||||
|
@ -289,7 +289,7 @@ public class TriggeredWatchStoreTests extends ESTestCase {
|
||||||
|
|
||||||
|
|
||||||
TriggeredWatch triggeredWatch = mock(TriggeredWatch.class);
|
TriggeredWatch triggeredWatch = mock(TriggeredWatch.class);
|
||||||
when(parser.parse(eq("_id"), eq(1l), any(BytesReference.class))).thenReturn(triggeredWatch);
|
when(parser.parse(eq("_id"), eq(1L), any(BytesReference.class))).thenReturn(triggeredWatch);
|
||||||
|
|
||||||
when(clientProxy.clearScroll(anyString())).thenReturn(new ClearScrollResponse(true, 1));
|
when(clientProxy.clearScroll(anyString())).thenReturn(new ClearScrollResponse(true, 1));
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class HttpInputIntegrationTests extends AbstractWatcherIntegrationTestCas
|
||||||
.path("/index/_search")
|
.path("/index/_search")
|
||||||
.body(jsonBuilder().startObject().field("size", 1).endObject())
|
.body(jsonBuilder().startObject().field("size", 1).endObject())
|
||||||
.auth(shieldEnabled() ? new BasicAuth("test", "changeme".toCharArray()) : null)))
|
.auth(shieldEnabled() ? new BasicAuth("test", "changeme".toCharArray()) : null)))
|
||||||
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1l))
|
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1L))
|
||||||
.addAction("_id", loggingAction("watch [{{ctx.watch_id}}] matched")))
|
.addAction("_id", loggingAction("watch [{{ctx.watch_id}}] matched")))
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ public class HttpInputIntegrationTests extends AbstractWatcherIntegrationTestCas
|
||||||
.input(httpInput(HttpRequestTemplate.builder(address.getHostString(), address.getPort())
|
.input(httpInput(HttpRequestTemplate.builder(address.getHostString(), address.getPort())
|
||||||
.path("/_cluster/stats")
|
.path("/_cluster/stats")
|
||||||
.auth(shieldEnabled() ? new BasicAuth("test", "changeme".toCharArray()) : null)))
|
.auth(shieldEnabled() ? new BasicAuth("test", "changeme".toCharArray()) : null)))
|
||||||
.condition(compareCondition("ctx.payload.nodes.count.total", CompareCondition.Op.GTE, 1l))
|
.condition(compareCondition("ctx.payload.nodes.count.total", CompareCondition.Op.GTE, 1L))
|
||||||
.addAction("_id", loggingAction("watch [{{ctx.watch_id}}] matched")))
|
.addAction("_id", loggingAction("watch [{{ctx.watch_id}}] matched")))
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ public class HttpInputIntegrationTests extends AbstractWatcherIntegrationTestCas
|
||||||
.setSource(watchBuilder()
|
.setSource(watchBuilder()
|
||||||
.trigger(schedule(interval(10, IntervalSchedule.Interval.Unit.SECONDS)))
|
.trigger(schedule(interval(10, IntervalSchedule.Interval.Unit.SECONDS)))
|
||||||
.input(httpInput(requestBuilder).extractKeys("hits.total"))
|
.input(httpInput(requestBuilder).extractKeys("hits.total"))
|
||||||
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1l)))
|
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1L)))
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
// in this watcher the condition will fail, because max_score isn't extracted, only total:
|
// in this watcher the condition will fail, because max_score isn't extracted, only total:
|
||||||
|
@ -122,7 +122,7 @@ public class HttpInputIntegrationTests extends AbstractWatcherIntegrationTestCas
|
||||||
.setSource(watchBuilder()
|
.setSource(watchBuilder()
|
||||||
.trigger(schedule(interval(10, IntervalSchedule.Interval.Unit.SECONDS)))
|
.trigger(schedule(interval(10, IntervalSchedule.Interval.Unit.SECONDS)))
|
||||||
.input(httpInput(requestBuilder).extractKeys("hits.total"))
|
.input(httpInput(requestBuilder).extractKeys("hits.total"))
|
||||||
.condition(compareCondition("ctx.payload.hits.max_score", CompareCondition.Op.GTE, 0l)))
|
.condition(compareCondition("ctx.payload.hits.max_score", CompareCondition.Op.GTE, 0L)))
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
if (timeWarped()) {
|
if (timeWarped()) {
|
||||||
|
|
|
@ -129,7 +129,7 @@ public class BasicShieldTests extends AbstractWatcherIntegrationTestCase {
|
||||||
.preparePutWatch("_id")
|
.preparePutWatch("_id")
|
||||||
.setSource(watchBuilder().trigger(schedule(interval(5, IntervalSchedule.Interval.Unit.SECONDS))))
|
.setSource(watchBuilder().trigger(schedule(interval(5, IntervalSchedule.Interval.Unit.SECONDS))))
|
||||||
.get();
|
.get();
|
||||||
assertThat(putWatchResponse.getVersion(), equalTo(1l));
|
assertThat(putWatchResponse.getVersion(), equalTo(1L));
|
||||||
ExecuteWatchResponse executeWatchResponse = watcherClient().filterWithHeader(Collections.singletonMap("Authorization", token))
|
ExecuteWatchResponse executeWatchResponse = watcherClient().filterWithHeader(Collections.singletonMap("Authorization", token))
|
||||||
.prepareExecuteWatch("_id")
|
.prepareExecuteWatch("_id")
|
||||||
.setTriggerEvent(triggerEvent)
|
.setTriggerEvent(triggerEvent)
|
||||||
|
@ -137,7 +137,7 @@ public class BasicShieldTests extends AbstractWatcherIntegrationTestCase {
|
||||||
DeleteWatchResponse deleteWatchResponse = watcherClient().filterWithHeader(Collections.singletonMap("Authorization", token))
|
DeleteWatchResponse deleteWatchResponse = watcherClient().filterWithHeader(Collections.singletonMap("Authorization", token))
|
||||||
.prepareDeleteWatch("_id")
|
.prepareDeleteWatch("_id")
|
||||||
.get();
|
.get();
|
||||||
assertThat(deleteWatchResponse.getVersion(), equalTo(2l));
|
assertThat(deleteWatchResponse.getVersion(), equalTo(2L));
|
||||||
assertThat(deleteWatchResponse.isFound(), is(true));
|
assertThat(deleteWatchResponse.isFound(), is(true));
|
||||||
|
|
||||||
// stats and get watch are also allowed by role monitor:
|
// stats and get watch are also allowed by role monitor:
|
||||||
|
|
|
@ -104,7 +104,7 @@ public class BootStrapTests extends AbstractWatcherIntegrationTestCase {
|
||||||
WatcherStatsResponse response = watcherClient().prepareWatcherStats().get();
|
WatcherStatsResponse response = watcherClient().prepareWatcherStats().get();
|
||||||
assertThat(response.getWatcherState(), equalTo(WatcherState.STARTED));
|
assertThat(response.getWatcherState(), equalTo(WatcherState.STARTED));
|
||||||
// Only the valid watch should been loaded
|
// Only the valid watch should been loaded
|
||||||
assertThat(response.getWatchesCount(), equalTo(1l));
|
assertThat(response.getWatchesCount(), equalTo(1L));
|
||||||
assertThat(watcherClient().prepareGetWatch("_id0").get().getId(), Matchers.equalTo("_id0"));
|
assertThat(watcherClient().prepareGetWatch("_id0").get().getId(), Matchers.equalTo("_id0"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,7 +184,7 @@ public class BootStrapTests extends AbstractWatcherIntegrationTestCase {
|
||||||
|
|
||||||
WatcherStatsResponse response = watcherClient().prepareWatcherStats().get();
|
WatcherStatsResponse response = watcherClient().prepareWatcherStats().get();
|
||||||
assertThat(response.getWatcherState(), equalTo(WatcherState.STARTED));
|
assertThat(response.getWatcherState(), equalTo(WatcherState.STARTED));
|
||||||
assertThat(response.getWatchesCount(), equalTo(1l));
|
assertThat(response.getWatchesCount(), equalTo(1L));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDeletedWhileQueued() throws Exception {
|
public void testDeletedWhileQueued() throws Exception {
|
||||||
|
@ -221,7 +221,7 @@ public class BootStrapTests extends AbstractWatcherIntegrationTestCase {
|
||||||
.setSource(watchBuilder()
|
.setSource(watchBuilder()
|
||||||
.trigger(schedule(cron("0 0/5 * * * ? 2050")))
|
.trigger(schedule(cron("0 0/5 * * * ? 2050")))
|
||||||
.input(searchInput(searchRequest))
|
.input(searchInput(searchRequest))
|
||||||
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1l))
|
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1L))
|
||||||
.buildAsBytes(XContentType.JSON)
|
.buildAsBytes(XContentType.JSON)
|
||||||
)
|
)
|
||||||
.setConsistencyLevel(WriteConsistencyLevel.ALL)
|
.setConsistencyLevel(WriteConsistencyLevel.ALL)
|
||||||
|
@ -282,7 +282,7 @@ public class BootStrapTests extends AbstractWatcherIntegrationTestCase {
|
||||||
// that numRecords watch records have been processed as part of starting up.
|
// that numRecords watch records have been processed as part of starting up.
|
||||||
WatcherStatsResponse response = watcherClient().prepareWatcherStats().get();
|
WatcherStatsResponse response = watcherClient().prepareWatcherStats().get();
|
||||||
assertThat(response.getWatcherState(), equalTo(WatcherState.STARTED));
|
assertThat(response.getWatcherState(), equalTo(WatcherState.STARTED));
|
||||||
assertThat(response.getThreadPoolQueueSize(), equalTo(0l));
|
assertThat(response.getThreadPoolQueueSize(), equalTo(0L));
|
||||||
|
|
||||||
// but even then since the execution of the watch record is async it may take a little bit before
|
// but even then since the execution of the watch record is async it may take a little bit before
|
||||||
// the actual documents are in the output index
|
// the actual documents are in the output index
|
||||||
|
@ -333,7 +333,7 @@ public class BootStrapTests extends AbstractWatcherIntegrationTestCase {
|
||||||
// that numRecords watch records have been processed as part of starting up.
|
// that numRecords watch records have been processed as part of starting up.
|
||||||
WatcherStatsResponse response = watcherClient().prepareWatcherStats().get();
|
WatcherStatsResponse response = watcherClient().prepareWatcherStats().get();
|
||||||
assertThat(response.getWatcherState(), equalTo(WatcherState.STARTED));
|
assertThat(response.getWatcherState(), equalTo(WatcherState.STARTED));
|
||||||
assertThat(response.getThreadPoolQueueSize(), equalTo(0l));
|
assertThat(response.getThreadPoolQueueSize(), equalTo(0L));
|
||||||
|
|
||||||
// but even then since the execution of the watch record is async it may take a little bit before
|
// but even then since the execution of the watch record is async it may take a little bit before
|
||||||
// the actual documents are in the output index
|
// the actual documents are in the output index
|
||||||
|
@ -390,7 +390,7 @@ public class BootStrapTests extends AbstractWatcherIntegrationTestCase {
|
||||||
// that numRecords watch records have been processed as part of starting up.
|
// that numRecords watch records have been processed as part of starting up.
|
||||||
WatcherStatsResponse response = watcherClient().prepareWatcherStats().get();
|
WatcherStatsResponse response = watcherClient().prepareWatcherStats().get();
|
||||||
assertThat(response.getWatcherState(), equalTo(WatcherState.STARTED));
|
assertThat(response.getWatcherState(), equalTo(WatcherState.STARTED));
|
||||||
assertThat(response.getThreadPoolQueueSize(), equalTo(0l));
|
assertThat(response.getThreadPoolQueueSize(), equalTo(0L));
|
||||||
|
|
||||||
// but even then since the execution of the watch record is async it may take a little bit before
|
// but even then since the execution of the watch record is async it may take a little bit before
|
||||||
// the actual documents are in the output index
|
// the actual documents are in the output index
|
||||||
|
|
|
@ -94,7 +94,7 @@ public class NoMasterNodeTests extends AbstractWatcherIntegrationTestCase {
|
||||||
WatchSourceBuilder watchSource = watchBuilder()
|
WatchSourceBuilder watchSource = watchBuilder()
|
||||||
.trigger(schedule(cron("0/5 * * * * ? *")))
|
.trigger(schedule(cron("0/5 * * * * ? *")))
|
||||||
.input(searchInput(searchRequest))
|
.input(searchInput(searchRequest))
|
||||||
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1l));
|
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1L));
|
||||||
|
|
||||||
// we first need to make sure the license is enabled, otherwise all APIs will be blocked
|
// we first need to make sure the license is enabled, otherwise all APIs will be blocked
|
||||||
ensureLicenseEnabled();
|
ensureLicenseEnabled();
|
||||||
|
@ -203,7 +203,7 @@ public class NoMasterNodeTests extends AbstractWatcherIntegrationTestCase {
|
||||||
WatchSourceBuilder watchSource = watchBuilder()
|
WatchSourceBuilder watchSource = watchBuilder()
|
||||||
.trigger(schedule(cron("0/5 * * * * ? *")))
|
.trigger(schedule(cron("0/5 * * * * ? *")))
|
||||||
.input(searchInput(searchRequest))
|
.input(searchInput(searchRequest))
|
||||||
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1l));
|
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1L));
|
||||||
watcherClient().preparePutWatch(watchName).setSource(watchSource).get();
|
watcherClient().preparePutWatch(watchName).setSource(watchSource).get();
|
||||||
}
|
}
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
|
@ -254,7 +254,7 @@ public class NoMasterNodeTests extends AbstractWatcherIntegrationTestCase {
|
||||||
assertThat(watcherService.state(), is(WatcherState.STOPPED));
|
assertThat(watcherService.state(), is(WatcherState.STOPPED));
|
||||||
}
|
}
|
||||||
for (ExecutionService executionService : internalCluster().getInstances(ExecutionService.class)) {
|
for (ExecutionService executionService : internalCluster().getInstances(ExecutionService.class)) {
|
||||||
assertThat(executionService.executionThreadPoolQueueSize(), equalTo(0l));
|
assertThat(executionService.executionThreadPoolQueueSize(), equalTo(0L));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class WatchMetadataTests extends AbstractWatcherIntegrationTestCase {
|
||||||
.setSource(watchBuilder()
|
.setSource(watchBuilder()
|
||||||
.trigger(schedule(cron("0/5 * * * * ? *")))
|
.trigger(schedule(cron("0/5 * * * * ? *")))
|
||||||
.input(searchInput(WatcherTestUtils.newInputSearchRequest("my-index").source(searchSource().query(matchAllQuery()))))
|
.input(searchInput(WatcherTestUtils.newInputSearchRequest("my-index").source(searchSource().query(matchAllQuery()))))
|
||||||
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1l))
|
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1L))
|
||||||
.metadata(metadata))
|
.metadata(metadata))
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
|
|
|
@ -108,13 +108,13 @@ public class TransformIntegrationTests extends AbstractWatcherIntegrationTestCas
|
||||||
|
|
||||||
SearchResponse response = client().prepareSearch("output1").get();
|
SearchResponse response = client().prepareSearch("output1").get();
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1l));
|
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1L));
|
||||||
assertThat(response.getHits().getAt(0).sourceAsMap().size(), equalTo(1));
|
assertThat(response.getHits().getAt(0).sourceAsMap().size(), equalTo(1));
|
||||||
assertThat(response.getHits().getAt(0).sourceAsMap().get("key3").toString(), equalTo("20"));
|
assertThat(response.getHits().getAt(0).sourceAsMap().get("key3").toString(), equalTo("20"));
|
||||||
|
|
||||||
response = client().prepareSearch("output2").get();
|
response = client().prepareSearch("output2").get();
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1l));
|
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1L));
|
||||||
assertThat(response.getHits().getAt(0).sourceAsMap().size(), equalTo(1));
|
assertThat(response.getHits().getAt(0).sourceAsMap().size(), equalTo(1));
|
||||||
assertThat(response.getHits().getAt(0).sourceAsMap().get("key3").toString(), equalTo("20"));
|
assertThat(response.getHits().getAt(0).sourceAsMap().get("key3").toString(), equalTo("20"));
|
||||||
}
|
}
|
||||||
|
@ -157,12 +157,12 @@ public class TransformIntegrationTests extends AbstractWatcherIntegrationTestCas
|
||||||
|
|
||||||
SearchResponse response = client().prepareSearch("output1").get();
|
SearchResponse response = client().prepareSearch("output1").get();
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1l));
|
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1L));
|
||||||
assertThat(response.getHits().getAt(0).sourceAsString(), containsString("mytestresult"));
|
assertThat(response.getHits().getAt(0).sourceAsString(), containsString("mytestresult"));
|
||||||
|
|
||||||
response = client().prepareSearch("output2").get();
|
response = client().prepareSearch("output2").get();
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1l));
|
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1L));
|
||||||
assertThat(response.getHits().getAt(0).sourceAsString(), containsString("mytestresult"));
|
assertThat(response.getHits().getAt(0).sourceAsString(), containsString("mytestresult"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,13 +201,13 @@ public class TransformIntegrationTests extends AbstractWatcherIntegrationTestCas
|
||||||
|
|
||||||
SearchResponse response = client().prepareSearch("output1").get();
|
SearchResponse response = client().prepareSearch("output1").get();
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1l));
|
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1L));
|
||||||
assertThat(response.getHits().getAt(0).sourceAsMap().size(), equalTo(1));
|
assertThat(response.getHits().getAt(0).sourceAsMap().size(), equalTo(1));
|
||||||
assertThat(response.getHits().getAt(0).sourceAsMap().get("key4").toString(), equalTo("30"));
|
assertThat(response.getHits().getAt(0).sourceAsMap().get("key4").toString(), equalTo("30"));
|
||||||
|
|
||||||
response = client().prepareSearch("output2").get();
|
response = client().prepareSearch("output2").get();
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1l));
|
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1L));
|
||||||
assertThat(response.getHits().getAt(0).sourceAsMap().size(), equalTo(1));
|
assertThat(response.getHits().getAt(0).sourceAsMap().size(), equalTo(1));
|
||||||
assertThat(response.getHits().getAt(0).sourceAsMap().get("key4").toString(), equalTo("30"));
|
assertThat(response.getHits().getAt(0).sourceAsMap().get("key4").toString(), equalTo("30"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ public class WatchAckTests extends AbstractWatcherIntegrationTestCase {
|
||||||
.setSource(watchBuilder()
|
.setSource(watchBuilder()
|
||||||
.trigger(schedule(cron("0/5 * * * * ? *")))
|
.trigger(schedule(cron("0/5 * * * * ? *")))
|
||||||
.input(searchInput(matchAllRequest().indices("events")))
|
.input(searchInput(matchAllRequest().indices("events")))
|
||||||
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.GT, 0l))
|
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.GT, 0L))
|
||||||
.transform(searchTransform(matchAllRequest().indices("events")))
|
.transform(searchTransform(matchAllRequest().indices("events")))
|
||||||
.addAction("_a1", indexAction("actions", "action1"))
|
.addAction("_a1", indexAction("actions", "action1"))
|
||||||
.addAction("_a2", indexAction("actions", "action2"))
|
.addAction("_a2", indexAction("actions", "action2"))
|
||||||
|
@ -145,7 +145,7 @@ public class WatchAckTests extends AbstractWatcherIntegrationTestCase {
|
||||||
.setSource(watchBuilder()
|
.setSource(watchBuilder()
|
||||||
.trigger(schedule(cron("0/5 * * * * ? *")))
|
.trigger(schedule(cron("0/5 * * * * ? *")))
|
||||||
.input(searchInput(matchAllRequest().indices("events")))
|
.input(searchInput(matchAllRequest().indices("events")))
|
||||||
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.GT, 0l))
|
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.GT, 0L))
|
||||||
.transform(searchTransform(matchAllRequest().indices("events")))
|
.transform(searchTransform(matchAllRequest().indices("events")))
|
||||||
.addAction("_a1", indexAction("actions", "action1"))
|
.addAction("_a1", indexAction("actions", "action1"))
|
||||||
.addAction("_a2", indexAction("actions", "action2"))
|
.addAction("_a2", indexAction("actions", "action2"))
|
||||||
|
@ -224,7 +224,7 @@ public class WatchAckTests extends AbstractWatcherIntegrationTestCase {
|
||||||
.setSource(watchBuilder()
|
.setSource(watchBuilder()
|
||||||
.trigger(schedule(cron("0/5 * * * * ? *")))
|
.trigger(schedule(cron("0/5 * * * * ? *")))
|
||||||
.input(searchInput(matchAllRequest().indices("events")))
|
.input(searchInput(matchAllRequest().indices("events")))
|
||||||
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.GT, 0l))
|
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.GT, 0L))
|
||||||
.transform(searchTransform(matchAllRequest().indices("events")))
|
.transform(searchTransform(matchAllRequest().indices("events")))
|
||||||
.addAction("_id", indexAction("actions", "action")))
|
.addAction("_id", indexAction("actions", "action")))
|
||||||
.get();
|
.get();
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class SlowWatchStatsTests extends AbstractWatcherIntegrationTestCase {
|
||||||
public void run() {
|
public void run() {
|
||||||
WatcherStatsResponse response = watcherClient().prepareWatcherStats().setIncludeCurrentWatches(true).get();
|
WatcherStatsResponse response = watcherClient().prepareWatcherStats().setIncludeCurrentWatches(true).get();
|
||||||
assertThat(response.getWatcherState(), equalTo(WatcherState.STARTED));
|
assertThat(response.getWatcherState(), equalTo(WatcherState.STARTED));
|
||||||
assertThat(response.getWatchesCount(), equalTo(1l));
|
assertThat(response.getWatchesCount(), equalTo(1L));
|
||||||
assertThat(response.getQueuedWatches(), nullValue());
|
assertThat(response.getQueuedWatches(), nullValue());
|
||||||
assertThat(response.getSnapshots(), notNullValue());
|
assertThat(response.getSnapshots(), notNullValue());
|
||||||
assertThat(response.getSnapshots().size(), equalTo(1));
|
assertThat(response.getSnapshots().size(), equalTo(1));
|
||||||
|
@ -98,7 +98,7 @@ public class SlowWatchStatsTests extends AbstractWatcherIntegrationTestCase {
|
||||||
public void run() {
|
public void run() {
|
||||||
WatcherStatsResponse response = watcherClient().prepareWatcherStats().setIncludeQueuedWatches(true).get();
|
WatcherStatsResponse response = watcherClient().prepareWatcherStats().setIncludeQueuedWatches(true).get();
|
||||||
assertThat(response.getWatcherState(), equalTo(WatcherState.STARTED));
|
assertThat(response.getWatcherState(), equalTo(WatcherState.STARTED));
|
||||||
assertThat(response.getWatchesCount(), equalTo(5l));
|
assertThat(response.getWatchesCount(), equalTo(5L));
|
||||||
assertThat(response.getSnapshots(), nullValue());
|
assertThat(response.getSnapshots(), nullValue());
|
||||||
assertThat(response.getQueuedWatches(), notNullValue());
|
assertThat(response.getQueuedWatches(), notNullValue());
|
||||||
assertThat(response.getQueuedWatches().size(), greaterThanOrEqualTo(5));
|
assertThat(response.getQueuedWatches().size(), greaterThanOrEqualTo(5));
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class WatcherStatsTests extends AbstractWatcherIntegrationTestCase {
|
||||||
.setSource(watchBuilder()
|
.setSource(watchBuilder()
|
||||||
.trigger(schedule(cron("* * * * * ? *")))
|
.trigger(schedule(cron("* * * * * ? *")))
|
||||||
.input(searchInput(searchRequest))
|
.input(searchInput(searchRequest))
|
||||||
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1l))
|
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1L))
|
||||||
)
|
)
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue