Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@

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() {
}

Expand All @@ -37,7 +40,7 @@ public static MonitoringDoc.Node randomMonitoringNode(final Random random) {
final String host = fakeTransportAddress.address().getHostString();
final String transportAddress = fakeTransportAddress.toString();
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);
}
Expand Down Expand Up @@ -87,8 +90,7 @@ public static MonitoringBulkDoc randomMonitoringBulkDoc(final Random random,
final MonitoredSystem system,
final String type) throws IOException {
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, 253402300799000L);
final long timestamp = RandomNumbers.randomLongBetween(random, 0L, MAX_MILLIS_BEFORE_10000);
final long interval = RandomNumbers.randomLongBetween(random, 0L, Long.MAX_VALUE);
return new MonitoringBulkDoc(system, type, id, timestamp, interval, source, xContentType);
}
Expand Down