Skip to content

Commit

Permalink
Fix for the case where the millis difference is exact (#779)
Browse files Browse the repository at this point in the history
  • Loading branch information
leandro-godon committed Apr 19, 2024
1 parent fe20265 commit 15f3376
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ internal class LogOrchestratorImpl(
sink.completedLogs().size >= MAX_LOGS_PER_BATCH

private fun isMaxInactivityTimeReached(now: Long): Boolean =
now - lastLogTime.get() > MAX_INACTIVITY_TIME
now - lastLogTime.get() >= MAX_INACTIVITY_TIME

private fun isMaxBatchTimeReached(now: Long): Boolean {
val firstLogInBatchTime = firstLogInBatchTime.get()
return firstLogInBatchTime != 0L && now - firstLogInBatchTime > MAX_BATCH_TIME
return firstLogInBatchTime != 0L && now - firstLogInBatchTime >= MAX_BATCH_TIME
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ internal class LogOrchestratorTest {
fun `logs are sent after inactivity time has passed`() {
logSink.storeLogs(listOf(FakeLogRecordData()))

moveTimeAhead(2500L)
moveTimeAhead(2000L)

// Verify the logs are sent
assertTrue(logSink.completedLogs().isEmpty())
Expand All @@ -87,9 +87,9 @@ internal class LogOrchestratorTest {

@Test
fun `logs are sent after batch time has passed`() {
val timeStep = 1100L
val timeStep = 500L

repeat(4) {
repeat(9) {
logSink.storeLogs(listOf(FakeLogRecordData()))
moveTimeAhead(timeStep)
}
Expand All @@ -98,11 +98,11 @@ internal class LogOrchestratorTest {
assertFalse(logSink.completedLogs().isEmpty())
verifyPayloadNotSent()

moveTimeAhead(700)
moveTimeAhead(500)

// Verify the logs are sent
assertTrue(logSink.completedLogs().isEmpty())
verifyPayload(4)
verifyPayload(9)
}

@Test
Expand Down

0 comments on commit 15f3376

Please sign in to comment.