Fix http request round trip tests

I broke this by adding more randomization to core's randomTimeValue
method. Now it produces valid time values that don't round trip
properly over the XContent API. This change causes the test to skip
trying to round trip time these sorts of time values.

Original commit: elastic/x-pack-elasticsearch@dcdd588bdb
This commit is contained in:
Nik Everett 2017-05-11 12:58:29 -04:00
parent 711ee1e8d4
commit 16aa600830
1 changed files with 8 additions and 2 deletions

View File

@ -105,10 +105,16 @@ public class HttpRequestTests extends ESTestCase {
builder.body(randomAlphaOfLength(200)); builder.body(randomAlphaOfLength(200));
} }
if (randomBoolean()) { if (randomBoolean()) {
builder.connectionTimeout(TimeValue.parseTimeValue(randomTimeValue(), "my.setting")); // micros and nanos don't round trip will full precision so exclude them from the test
String safeConnectionTimeout = randomValueOtherThanMany(s -> (s.endsWith("micros") || s.endsWith("nanos")),
() -> randomTimeValue());
builder.connectionTimeout(TimeValue.parseTimeValue(safeConnectionTimeout, "my.setting"));
} }
if (randomBoolean()) { if (randomBoolean()) {
builder.readTimeout(TimeValue.parseTimeValue(randomTimeValue(), "my.setting")); // micros and nanos don't round trip will full precision so exclude them from the test
String safeReadTimeout = randomValueOtherThanMany(s -> (s.endsWith("micros") || s.endsWith("nanos")),
() -> randomTimeValue());
builder.readTimeout(TimeValue.parseTimeValue(safeReadTimeout, "my.setting"));
} }
if (randomBoolean()) { if (randomBoolean()) {
builder.proxy(new HttpProxy(randomAlphaOfLength(10), randomIntBetween(1024, 65000))); builder.proxy(new HttpProxy(randomAlphaOfLength(10), randomIntBetween(1024, 65000)));