Skip to content

Commit

Permalink
Fix bug in reschedule command
Browse files Browse the repository at this point in the history
* Add tests for scheduling
  • Loading branch information
hellais committed Sep 6, 2024
1 parent 5e1d841 commit 38f61e1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
3 changes: 2 additions & 1 deletion oonipipeline/src/oonipipeline/temporal/schedules.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ async def list_existing_schedules(
async for sched in schedule_list:
if sched.id.startswith(f"{OBSERVATIONS_SCHED_PREFIX}-{filter_id}"):
schedule_id_map_list.observations.append(sched.id)
elif sched.id.startswith(f"{ANALYSIS_WF_PREFIX}-{filter_id}"):
elif sched.id.startswith(f"{ANALYSIS_SCHED_PREFIX}-{filter_id}"):
schedule_id_map_list.analysis.append(sched.id)

return schedule_id_map_list


Expand Down
33 changes: 31 additions & 2 deletions oonipipeline/tests/test_temporal_e2e.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import asyncio
from concurrent.futures import ThreadPoolExecutor
from oonipipeline.temporal.schedules import schedule_all, reschedule_all
import pytest

from temporalio.testing import WorkflowEnvironment
from temporalio.worker import Worker
from temporalio import activity

from oonipipeline.temporal.workflows.common import TASK_QUEUE_NAME

Expand All @@ -15,6 +16,34 @@

from .utils import wait_for_mutations


@pytest.mark.asyncio
async def test_scheduling(datadir, db):
async with await WorkflowEnvironment.start_local() as env:
sched_res = await schedule_all(
client=env.client,
probe_cc=[],
test_name=[],
clickhouse_url=db.clickhouse_url,
data_dir=str(datadir),
)
assert sched_res.analysis
assert sched_res.observations

# Wait 1 second for the ID to change
await asyncio.sleep(1)

reschedule_res = await reschedule_all(
client=env.client,
probe_cc=[],
test_name=[],
clickhouse_url=db.clickhouse_url,
data_dir=str(datadir),
)
assert reschedule_res.observations != sched_res.observations
assert reschedule_res.analysis != sched_res.analysis


@pytest.mark.asyncio
async def test_observation_workflow(datadir, db):
obs_params = ObservationsWorkflowParams(
Expand All @@ -25,7 +54,7 @@ async def test_observation_workflow(datadir, db):
fast_fail=False,
bucket_date="2022-10-21",
)
async with await WorkflowEnvironment.start_time_skipping() as env:
async with await WorkflowEnvironment.start_local() as env:
async with Worker(
env.client,
task_queue=TASK_QUEUE_NAME,
Expand Down

0 comments on commit 38f61e1

Please sign in to comment.