Skip to content

Commit

Permalink
Fix flaky MetricsQueries test (#17097)
Browse files Browse the repository at this point in the history
* fix flaky test

* also add wiggle room for job age
  • Loading branch information
pmossman committed Sep 27, 2022
1 parent 0404203 commit 4d9c585
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,8 @@ void shouldReturnOnlyPendingSeconds() throws SQLException {
ctx -> ctx.insertInto(JOBS, JOBS.ID, JOBS.SCOPE, JOBS.STATUS).values(4L, "", JobStatus.failed).execute());

final var res = configDb.query(MetricQueries::oldestPendingJobAgeSecs);
assertEquals(1000, res);
// expected age is 1000 seconds, but allow for +/- 1 second to account for timing/rounding errors
assertTrue(List.of(999L, 1000L, 1001L).contains(res));
}

@Test
Expand Down Expand Up @@ -332,7 +333,8 @@ void shouldReturnOnlyRunningSeconds() throws SQLException {
ctx -> ctx.insertInto(JOBS, JOBS.ID, JOBS.SCOPE, JOBS.STATUS).values(4L, "", JobStatus.failed).execute());

final var res = configDb.query(MetricQueries::oldestRunningJobAgeSecs);
assertEquals(10000, res);
// expected age is 10000 seconds, but allow for +/- 1 second to account for timing/rounding errors
assertTrue(List.of(9999L, 10000L, 10001L).contains(res));
}

@Test
Expand Down

0 comments on commit 4d9c585

Please sign in to comment.