Skip to content

Commit

Permalink
Trying to catch unstable test reason. Adding more observability by ma…
Browse files Browse the repository at this point in the history
…king workflow ids unique
  • Loading branch information
VladimirFilonov committed Sep 9, 2024
1 parent c4b819e commit b3d5a2e
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions tests/test_workflow_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def test_workflow_execution(


workflow_definition2 = """workflow:
id: alert-first-time
id: %s
description: send slack message only the first time an alert fires
triggers:
- type: alert
Expand All @@ -228,32 +228,37 @@ def test_workflow_execution(


@pytest.mark.parametrize(
"test_case, alert_statuses, expected_action",
"workflow_id, test_case, alert_statuses, expected_action",
[
("First firing", [[0, "firing"]], True),
("Second firing within 24h", [[0, "firing"], [1, "firing"]], False),
("alert-first-firing", "First firing", [[0, "firing"]], True),
("alert-second-firing", "Second firing within 24h", [[0, "firing"], [1, "firing"]], False),
(
"firing-resolved-firing-24",
"First firing, resolved, and fired again after 24h",
[[0, "firing"], [1, "resolved"], [25, "firing"]],
True,
),
(
"multiple-firings-24",
"Multiple firings within 24h",
[[0, "firing"], [1, "firing"], [2, "firing"], [3, "firing"]],
False,
),
(
"resolved-fired-24",
"Resolved and fired again within 24h",
[[0, "firing"], [1, "resolved"], [2, "firing"]],
False,
),
(
"first-firing-multiple-resolutions",
"First firing after multiple resolutions",
[[0, "resolved"], [1, "resolved"], [2, "firing"]],
True,
),
("Firing exactly at 24h boundary", [[0, "firing"], [24, "firing"]], True),
("firing-exactly-24", "Firing exactly at 24h boundary", [[0, "firing"], [24, "firing"]], True),
(
"complex-scenario",
"Complex scenario with multiple status changes",
[
[0, "firing"],
Expand All @@ -270,6 +275,7 @@ def test_workflow_execution_2(
db_session,
create_alert,
workflow_manager,
workflow_id,
test_case,
alert_statuses,
expected_action,
Expand All @@ -296,13 +302,13 @@ def test_workflow_execution_2(
- Firing of an alert after resolving and firing again after 24 hours
"""
workflow = Workflow(
id="alert-first-time",
name="alert-first-time",
id=workflow_id,
name=workflow_id,
tenant_id=SINGLE_TENANT_UUID,
description="Send slack message only the first time an alert fires",
created_by="[email protected]",
interval=0,
workflow_raw=workflow_definition2,
workflow_raw=workflow_definition2 % workflow_id,
)
db_session.add(workflow)
db_session.commit()
Expand Down Expand Up @@ -334,7 +340,7 @@ def test_workflow_execution_2(
status = None
while workflow_execution is None and count < 30 and status != "success":
workflow_execution = get_last_workflow_execution_by_workflow_id(
SINGLE_TENANT_UUID, "alert-first-time"
SINGLE_TENANT_UUID, workflow_id,
)
if workflow_execution is not None:
status = workflow_execution.status
Expand Down

0 comments on commit b3d5a2e

Please sign in to comment.