Skip to content

Commit

Permalink
chore(tests): Fix the time for optimize test (#6830)
Browse files Browse the repository at this point in the history
The initial OptimizeScheduler instance could be created on a day's
boundary. Fix the time so that the test always runs with the same
parameters everytime.

Resolves #6829.
  • Loading branch information
nikhars authored Jan 27, 2025
1 parent 41451b1 commit 307a24d
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions tests/clickhouse/optimize/test_optimize_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,15 @@ def test_get_next_schedule(


def test_get_next_schedule_raises_exception() -> None:
optimize_scheduler = OptimizeScheduler(default_parallel_threads=1)
with time_machine.travel(
last_midnight
+ timedelta(hours=settings.OPTIMIZE_JOB_CUTOFF_TIME)
+ timedelta(minutes=20),
tick=False,
):
with pytest.raises(OptimizedSchedulerTimeout):
optimize_scheduler.get_next_schedule(
["(90,'2022-03-28')", "(90,'2022-03-21')"]
)
with time_machine.travel(last_midnight, tick=False):
optimize_scheduler = OptimizeScheduler(default_parallel_threads=1)
with time_machine.travel(
last_midnight
+ timedelta(hours=settings.OPTIMIZE_JOB_CUTOFF_TIME)
+ timedelta(minutes=20),
tick=False,
):
with pytest.raises(OptimizedSchedulerTimeout):
optimize_scheduler.get_next_schedule(
["(90,'2022-03-28')", "(90,'2022-03-21')"]
)

0 comments on commit 307a24d

Please sign in to comment.