Use supported random methods instead of DateTime.now()

This commit is contained in:
Thiago Souza 2016-08-19 14:09:15 -03:00
parent 2ba508a761
commit 9ea3f4ace3
1 changed files with 4 additions and 2 deletions

View File

@ -67,6 +67,7 @@ public class BucketScriptIT extends ESIntegTestCase {
private static int numDocs;
private static int minNumber;
private static int maxNumber;
private static long date;
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
@ -129,6 +130,7 @@ public class BucketScriptIT extends ESIntegTestCase {
numDocs = randomIntBetween(10, 500);
minNumber = -200;
maxNumber = 200;
date = randomLong();
List<IndexRequestBuilder> builders = new ArrayList<>();
for (int docs = 0; docs < numDocs; docs++) {
@ -146,7 +148,7 @@ public class BucketScriptIT extends ESIntegTestCase {
jsonBuilder.field(FIELD_2_NAME, randomIntBetween(minNumber, maxNumber));
jsonBuilder.field(FIELD_3_NAME, randomIntBetween(minNumber, maxNumber));
jsonBuilder.field(FIELD_4_NAME, randomIntBetween(minNumber, maxNumber));
jsonBuilder.field(FIELD_5_NAME, DateTime.now());
jsonBuilder.field(FIELD_5_NAME, date);
jsonBuilder.endObject();
return jsonBuilder;
}
@ -249,7 +251,7 @@ public class BucketScriptIT extends ESIntegTestCase {
.addAggregation(
dateRange("range")
.field(FIELD_5_NAME)
.addRange("now-1d", "now")
.addUnboundedFrom(date)
.subAggregation(sum("field2Sum").field(FIELD_2_NAME))
.subAggregation(sum("field3Sum").field(FIELD_3_NAME))
.subAggregation(sum("field4Sum").field(FIELD_4_NAME))