Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
fix bad LEQ and add assert messages (#476)
Browse files Browse the repository at this point in the history
  • Loading branch information
colbyguan authored and GitHub Enterprise committed Jun 10, 2019
1 parent 0382ba8 commit b993700
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,15 @@ public void testNumHoursUntilNextClearBloomFilter() {
int hour = calendar.get(Calendar.HOUR_OF_DAY);
// Will wait 24 hours before next flush if at same hour boundary
int secondsUntil = _esSchemaService.getNumSecondsUntilNthHourOfDay(hour, calendar);
assertTrue(secondsUntil >= 23 * 60 * 60 && secondsUntil <= 24 * 60 * 60);
assertTrue("secondsUntil should be between 23 hours and 24 hours but was " + secondsUntil,secondsUntil >= 23 * 60 * 60 && secondsUntil <= 24 * 60 * 60);

calendar.set(Calendar.HOUR_OF_DAY, Math.floorMod(hour - 2, 24));
secondsUntil = _esSchemaService.getNumSecondsUntilNthHourOfDay(hour, calendar);
assertTrue(secondsUntil >= 1 * 60 * 60 && secondsUntil <= 2 * 60 * 60);
assertTrue("secondsUntil should be between 1 hours and 2 hours but was " + secondsUntil,secondsUntil >= 1 * 60 * 60 && secondsUntil <= 2 * 60 * 60);

calendar.set(Calendar.HOUR_OF_DAY, Math.floorMod(hour + 2, 24));
secondsUntil = _esSchemaService.getNumSecondsUntilNthHourOfDay(hour, calendar);
assertTrue(secondsUntil >= 21 * 60 * 60 && secondsUntil < 22 * 60 * 60);
assertTrue("secondsUntil should be between 21 hours and 22 hours but was " + secondsUntil, secondsUntil >= 21 * 60 * 60 && secondsUntil <= 22 * 60 * 60);
}

@Test
Expand All @@ -254,15 +254,15 @@ public void testNumHoursUntilNextFlushBloomFilter() {
int secondsUntil = _esSchemaService.getNumSecondsUntilNthHourOfWeek(nthHour, wedAtSix);
int floorHoursUntil = secondsUntil / 60 / 60;
int expectedHours = (4 + dayIndex) * 24 - 2;
assertTrue(expectedHours - 1 <= floorHoursUntil && floorHoursUntil <= expectedHours);
assertTrue("hoursUntil should be between " + (expectedHours - 1) + " and " + expectedHours, expectedHours - 1 <= floorHoursUntil && floorHoursUntil <= expectedHours);
}
// Test Wednesday Thursday, Fri, Sat of this week @ 8 AM
for (int dayIndex = 3; dayIndex < 7; dayIndex++) {
int nthHour = dayIndex * 24 + 8;
int secondsUntil = _esSchemaService.getNumSecondsUntilNthHourOfWeek(nthHour, wedAtSix);
int floorHoursUntil = secondsUntil / 60 / 60;
int expectedHours = (dayIndex - 3) * 24 + 2;
assertTrue(expectedHours - 1 <= floorHoursUntil && floorHoursUntil <= expectedHours);
assertTrue("hoursUntil should be between " + (expectedHours - 1) + " and " + expectedHours, expectedHours - 1 <= floorHoursUntil && floorHoursUntil <= expectedHours);
}
}
}

0 comments on commit b993700

Please sign in to comment.