-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move end2end tests into temporal_e2e
- Loading branch information
Showing
3 changed files
with
87 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
from concurrent.futures import ThreadPoolExecutor | ||
import pytest | ||
|
||
from temporalio.testing import WorkflowEnvironment | ||
from temporalio.worker import Worker | ||
from temporalio import activity | ||
|
||
from oonipipeline.temporal.workflows import ( | ||
TASK_QUEUE_NAME, | ||
ObservationsWorkflow, | ||
ObservationsWorkflowParams, | ||
) | ||
from oonipipeline.temporal.workers import ACTIVTIES | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_observation_workflow(datadir, db): | ||
obs_params = ObservationsWorkflowParams( | ||
probe_cc=["BA"], | ||
test_name=["web_connectivity"], | ||
clickhouse=db.clickhouse_url, | ||
data_dir=str(datadir.absolute()), | ||
fast_fail=False, | ||
bucket_date="2022-10-21", | ||
) | ||
async with await WorkflowEnvironment.start_time_skipping() as env: | ||
async with Worker( | ||
env.client, | ||
task_queue=TASK_QUEUE_NAME, | ||
workflows=[ObservationsWorkflow], | ||
activities=ACTIVTIES, | ||
activity_executor=ThreadPoolExecutor(max_workers=4 + 2), | ||
): | ||
wf_res = await env.client.execute_workflow( | ||
ObservationsWorkflow.run, | ||
obs_params, | ||
id="obs-wf", | ||
task_queue=TASK_QUEUE_NAME, | ||
) | ||
db.execute("OPTIMIZE TABLE buffer_obs_web") | ||
assert wf_res["measurement_count"] == 613 | ||
assert wf_res["size"] == 11381440 | ||
assert wf_res["bucket_date"] == "2022-10-21" | ||
|
||
res = db.execute( | ||
""" | ||
SELECT bucket_date, | ||
COUNT(DISTINCT(measurement_uid)) | ||
FROM obs_web WHERE probe_cc = 'BA' | ||
GROUP BY bucket_date | ||
""" | ||
) | ||
bucket_dict = dict(res) | ||
assert bucket_dict[wf_res["bucket_date"]] == wf_res["measurement_count"] | ||
res = db.execute( | ||
""" | ||
SELECT bucket_date, | ||
COUNT() | ||
FROM obs_web WHERE probe_cc = 'BA' | ||
GROUP BY bucket_date | ||
""" | ||
) | ||
bucket_dict = dict(res) | ||
obs_count = bucket_dict[wf_res["bucket_date"]] | ||
assert obs_count == 2548 | ||
|
||
wf_res = await env.client.execute_workflow( | ||
ObservationsWorkflow.run, | ||
obs_params, | ||
id="obs-wf-2", | ||
task_queue=TASK_QUEUE_NAME, | ||
) | ||
db.execute("OPTIMIZE TABLE buffer_obs_web") | ||
db.execute("OPTIMIZE TABLE obs_web") | ||
res = db.execute( | ||
""" | ||
SELECT bucket_date, | ||
COUNT() | ||
FROM obs_web WHERE probe_cc = 'BA' | ||
GROUP BY bucket_date | ||
""" | ||
) | ||
bucket_dict = dict(res) | ||
obs_count_2 = bucket_dict[wf_res["bucket_date"]] | ||
|
||
assert obs_count == obs_count_2 |