Fix exporter tests to have reasonable dates (#38436)
The java time formatter used in the exporter adds a plus sign to the year, if a year with more than five digits is used. This changes the creation of those timestamp to only have a date up to 9999. Closes #38378
This commit is contained in:
parent
6290d59ffa
commit
6ae7915b9d
|
@ -23,6 +23,9 @@ import static org.elasticsearch.test.ESTestCase.buildNewFakeTransportAddress;
|
||||||
|
|
||||||
public final class MonitoringTestUtils {
|
public final class MonitoringTestUtils {
|
||||||
|
|
||||||
|
// maximum number of milliseconds before a five digit year comes in, which could change formatting
|
||||||
|
private static final long MAX_MILLIS_BEFORE_10000 = 253402300799999L;
|
||||||
|
|
||||||
private MonitoringTestUtils() {
|
private MonitoringTestUtils() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +40,7 @@ public final class MonitoringTestUtils {
|
||||||
final String host = fakeTransportAddress.address().getHostString();
|
final String host = fakeTransportAddress.address().getHostString();
|
||||||
final String transportAddress = fakeTransportAddress.toString();
|
final String transportAddress = fakeTransportAddress.toString();
|
||||||
final String ip = fakeTransportAddress.getAddress();
|
final String ip = fakeTransportAddress.getAddress();
|
||||||
final long timestamp = RandomNumbers.randomLongBetween(random, 0, Long.MAX_VALUE);
|
final long timestamp = RandomNumbers.randomLongBetween(random, 0, MAX_MILLIS_BEFORE_10000);
|
||||||
|
|
||||||
return new MonitoringDoc.Node(id, host, transportAddress, ip, name, timestamp);
|
return new MonitoringDoc.Node(id, host, transportAddress, ip, name, timestamp);
|
||||||
}
|
}
|
||||||
|
@ -87,8 +90,7 @@ public final class MonitoringTestUtils {
|
||||||
final MonitoredSystem system,
|
final MonitoredSystem system,
|
||||||
final String type) throws IOException {
|
final String type) throws IOException {
|
||||||
final String id = random.nextBoolean() ? RandomStrings.randomAsciiLettersOfLength(random, 5) : null;
|
final String id = random.nextBoolean() ? RandomStrings.randomAsciiLettersOfLength(random, 5) : null;
|
||||||
// ending date is the last second of 9999, should be sufficient
|
final long timestamp = RandomNumbers.randomLongBetween(random, 0L, MAX_MILLIS_BEFORE_10000);
|
||||||
final long timestamp = RandomNumbers.randomLongBetween(random, 0L, 253402300799000L);
|
|
||||||
final long interval = RandomNumbers.randomLongBetween(random, 0L, Long.MAX_VALUE);
|
final long interval = RandomNumbers.randomLongBetween(random, 0L, Long.MAX_VALUE);
|
||||||
return new MonitoringBulkDoc(system, type, id, timestamp, interval, source, xContentType);
|
return new MonitoringBulkDoc(system, type, id, timestamp, interval, source, xContentType);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue