Merge ~lloydwaltersj/maas-ci/+git/system-tests:temporal-workflow-candidate-tester into ~maas-committers/maas-ci/+git/system-tests:master

Proposed by Jack Lloyd-Walters
Status: Merged
Approved by: Stamatis Katsaounis
Approved revision: 18a2e3a4ff82b7bcd90408788b4f33a881e295f5
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~lloydwaltersj/maas-ci/+git/system-tests:temporal-workflow-candidate-tester
Merge into: ~maas-committers/maas-ci/+git/system-tests:master
Diff against target: 92 lines (+80/-0)
2 files modified
temporal/candidate_tester_worker.py (+10/-0)
temporal/candidate_tester_workflow.py (+70/-0)
Reviewer Review Type Date Requested Status
MAAS Lander Approve
MAAS Committers Pending
Review via email: mp+456324@code.launchpad.net

Commit message

temporal workflow to check status of image tester job

To post a comment you must log in.
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b temporal-workflow-candidate-tester lp:~lloydwaltersj/maas-ci/+git/system-tests into -b master lp:~maas-committers/maas-ci/+git/system-tests

STATUS: SUCCESS
COMMIT: 18a2e3a4ff82b7bcd90408788b4f33a881e295f5

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/temporal/candidate_tester_worker.py b/temporal/candidate_tester_worker.py
2new file mode 100644
3index 0000000..808801f
4--- /dev/null
5+++ b/temporal/candidate_tester_worker.py
6@@ -0,0 +1,10 @@
7+from .candidate_tester_workflow import activities as candidate_tester_activites
8+from .candidate_tester_workflow import workflows as candidate_tester_workflows
9+from .common_tasks import start_worker
10+
11+if __name__ == "__main__":
12+ start_worker(
13+ task_queue="candidate_image_tester",
14+ workflows=candidate_tester_workflows,
15+ activities=candidate_tester_activites,
16+ )
17diff --git a/temporal/candidate_tester_workflow.py b/temporal/candidate_tester_workflow.py
18new file mode 100644
19index 0000000..4a60ccd
20--- /dev/null
21+++ b/temporal/candidate_tester_workflow.py
22@@ -0,0 +1,70 @@
23+""" Request an image test from candidate,
24+ returning the build number of the testing job."""
25+
26+from dataclasses import dataclass
27+
28+from temporalio import workflow
29+from temporalio.common import RetryPolicy
30+
31+from .common_tasks import (
32+ await_build_complete,
33+ await_build_exists,
34+ check_jenkins_reachable,
35+ fetch_build_status,
36+ workflow_parameters,
37+)
38+
39+
40+@dataclass
41+class candidate_tester_params(workflow_parameters):
42+ job_name: str = "maas-system-tests-executor"
43+ build_num: int | None = None
44+
45+
46+@workflow.defn
47+class candidate_tester_workflow:
48+ @workflow.run
49+ async def run(self, params: candidate_tester_params) -> bool:
50+ await workflow.execute_activity(
51+ check_jenkins_reachable,
52+ params,
53+ start_to_close_timeout=params.gettimeout("jenkins_login_timeout"),
54+ retry_policy=RetryPolicy(maximum_attempts=params.max_retry_attempts),
55+ )
56+ # XXX: This assumes the most recent executor job after the
57+ # config generator completes is the correct one. Ideally this
58+ # would fetch the downstream job directly from the config
59+ # generator, but that doesn't seem to be working at current.
60+ await workflow.execute_activity(
61+ await_build_exists,
62+ params,
63+ start_to_close_timeout=params.gettimeout("request_build_timeout"),
64+ retry_policy=RetryPolicy(maximum_attempts=params.max_retry_attempts),
65+ )
66+
67+ # wait for the job to complete
68+ await workflow.execute_activity(
69+ await_build_complete,
70+ params,
71+ start_to_close_timeout=params.gettimeout("build_complete_timeout"),
72+ retry_policy=RetryPolicy(maximum_attempts=params.max_retry_attempts),
73+ )
74+
75+ # return a default failure state if the build was aborted
76+ build_status = await workflow.execute_activity(
77+ fetch_build_status,
78+ params,
79+ start_to_close_timeout=params.gettimeout("return_status_timeout"),
80+ retry_policy=RetryPolicy(maximum_attempts=params.max_retry_attempts),
81+ )
82+
83+ return build_status.lower() == "success"
84+
85+
86+activities = [
87+ check_jenkins_reachable,
88+ await_build_exists,
89+ await_build_complete,
90+ fetch_build_status,
91+]
92+workflows = [candidate_tester_workflow]

Subscribers

People subscribed via source and target branches