@@ -577,15 +577,15 @@ class RollupRunnerIT : RollupRestTestCase() {
577577 // Define rollup
578578 var rollup = randomRollup().copy(
579579 enabled = true ,
580- jobSchedule = IntervalSchedule (Instant .now(), 1 , ChronoUnit .MINUTES , 0 ),
580+ jobSchedule = IntervalSchedule (Instant .now(), 1 , ChronoUnit .MINUTES ),
581581 jobEnabledTime = Instant .now(),
582582 sourceIndex = indexName,
583583 metadataID = null ,
584584 continuous = true ,
585585 delay = delay,
586586 dimensions = listOf (
587587 randomCalendarDateHistogram().copy(
588- calendarInterval = " 1s "
588+ calendarInterval = " 5s "
589589 )
590590 )
591591 )
@@ -598,7 +598,7 @@ class RollupRunnerIT : RollupRestTestCase() {
598598 // Create rollup job
599599 rollup = createRollup(rollup = rollup, rollupId = rollup.id)
600600
601- val nextExecutionTime = rollup.schedule.getNextExecutionTime(null ).toEpochMilli()
601+ var nextExecutionTime = rollup.schedule.getNextExecutionTime(null ).toEpochMilli()
602602 val expectedExecutionTime = rollup.jobEnabledTime!! .plusMillis(delay).toEpochMilli()
603603 val delayIsCorrect = ((expectedExecutionTime - nextExecutionTime) > - 500 ) && ((expectedExecutionTime - nextExecutionTime) < 500 )
604604 assertTrue(" Delay was not correctly applied" , delayIsCorrect)
@@ -609,20 +609,29 @@ class RollupRunnerIT : RollupRestTestCase() {
609609 // Still should not have run at this point
610610 assertFalse(" Target rollup index was created before the delay should allow" , indexExists(rollup.targetIndex))
611611 }
612-
613- waitFor {
612+ val rollupMetadata = waitFor {
614613 assertTrue(" Target rollup index was not created" , indexExists(rollup.targetIndex))
615614 val rollupJob = getRollup(rollupId = rollup.id)
616615 assertNotNull(" Rollup job doesn't have metadata set" , rollupJob.metadataID)
617616 val rollupMetadata = getRollupMetadata(rollupJob.metadataID!! )
618617 assertNotNull(" Rollup metadata not found" , rollupMetadata)
619- val nextWindowStartTime: Instant = rollupMetadata.continuous!! .nextWindowStartTime
620- assertTrue(" Rollup window not excluding the delay" , nextWindowStartTime < Instant .now().minusMillis(delay))
621- assertTrue(" Rollup window not updating" , nextWindowStartTime > Instant .now().minusMillis(delay + 2000 ))
618+ rollupMetadata
622619 }
620+ nextExecutionTime = rollup.schedule.getNextExecutionTime(null ).toEpochMilli()
621+ val nextExecutionOffset = (nextExecutionTime - Instant .now().toEpochMilli()) - 60000
622+ val nextExecutionIsCorrect = nextExecutionOffset < 5000 && nextExecutionOffset > - 5000
623+ assertTrue(" Next execution time not updated correctly" , nextExecutionIsCorrect)
624+ val nextWindowStartTime: Instant = rollupMetadata.continuous!! .nextWindowStartTime
625+ val nextWindowEndTime: Instant = rollupMetadata.continuous!! .nextWindowEndTime
626+ // Assert that after the window was updated, it falls approximately around 'now'
627+ assertTrue(" Rollup window start time is incorrect" , nextWindowStartTime.plusMillis(delay).minusMillis(1000 ) < Instant .now())
628+ assertTrue(" Rollup window end time is incorrect" , nextWindowEndTime.plusMillis(delay).plusMillis(1000 ) > Instant .now())
629+
630+ // window length should be 5 seconds
631+ val expectedWindowEnd = nextWindowStartTime.plusMillis(5000 )
632+ assertEquals(" Rollup window length applied incorrectly" , expectedWindowEnd, nextWindowEndTime)
623633 }
624634
625- // Tests that the non continuous delay does nothing
626635 fun `test non continuous delay does nothing` () {
627636 generateNYCTaxiData(" source_runner_ninth" )
628637
0 commit comments