[TEST] Use at least 1ms for FunctionScoreQueryBuilderTests

Previously micros or nanoseconds could be used, which was reduced to 0
milliseconds and `scale` must be higher than 0.
This commit is contained in:
Lee Hinman 2017-05-11 10:09:14 -06:00
parent f7c50f5f71
commit 57fddce8c4
2 changed files with 7 additions and 3 deletions

View File

@ -218,7 +218,7 @@ public class FunctionScoreQueryBuilderTests extends AbstractQueryTestCase<Functi
break; break;
case DATE_FIELD_NAME: case DATE_FIELD_NAME:
origin = new DateTime(System.currentTimeMillis() - randomIntBetween(0, 1000000), DateTimeZone.UTC).toString(); origin = new DateTime(System.currentTimeMillis() - randomIntBetween(0, 1000000), DateTimeZone.UTC).toString();
scale = randomPositiveTimeValue(); scale = randomTimeValue(1, 1000, new String[]{"d", "h", "ms", "s", "m"});
offset = randomPositiveTimeValue(); offset = randomPositiveTimeValue();
break; break;
default: default:

View File

@ -631,8 +631,12 @@ public abstract class ESTestCase extends LuceneTestCase {
private static final String[] TIME_SUFFIXES = new String[]{"d", "h", "ms", "s", "m", "micros", "nanos"}; private static final String[] TIME_SUFFIXES = new String[]{"d", "h", "ms", "s", "m", "micros", "nanos"};
private static String randomTimeValue(int lower, int upper) { public static String randomTimeValue(int lower, int upper, String[] suffixes) {
return randomIntBetween(lower, upper) + randomFrom(TIME_SUFFIXES); return randomIntBetween(lower, upper) + randomFrom(suffixes);
}
public static String randomTimeValue(int lower, int upper) {
return randomTimeValue(lower, upper, TIME_SUFFIXES);
} }
public static String randomTimeValue() { public static String randomTimeValue() {