From f1ce44fab860073f33481c80d36a24b2b7365a0c Mon Sep 17 00:00:00 2001 From: Michal Srb Date: Jul 15 2022 12:16:58 +0000 Subject: Add "testing-farm-run-generic-test" role This role is just a copy of the existing testing-farm role, with some minor modifications. Testing changes in the existing role turned out to be tricky and therefore a separate role will allow us to develop and test changes without fear of breaking existing pipelines. The two roles could be merged together in future. Signed-off-by: Michal Srb --- diff --git a/roles/testing-farm-run-generic-test/defaults/main.yml b/roles/testing-farm-run-generic-test/defaults/main.yml new file mode 100644 index 0000000..1b59908 --- /dev/null +++ b/roles/testing-farm-run-generic-test/defaults/main.yml @@ -0,0 +1,3 @@ +--- +api_url: "https://api.dev.testing-farm.io/v0.1" +base_url: "https://src.fedoraproject.org" diff --git a/roles/testing-farm-run-generic-test/tasks/main.yml b/roles/testing-farm-run-generic-test/tasks/main.yml new file mode 100644 index 0000000..3540ddc --- /dev/null +++ b/roles/testing-farm-run-generic-test/tasks/main.yml @@ -0,0 +1,86 @@ +# This role is also used in Centos Stream Zuul CI +--- +- name: trigger a generic Testing Farm test + uri: + url: "{{ api_url }}/requests" + method: POST + body_format: json + body: | + { + "api_key": "{{ testing_farm_zuul_ci_key.apikey }}", + "test": { + "{{ test_type | default('fmf') }}": { + "url": "{{ tmt_repo }}", + "ref": "{{ tmt_ref }}" + } + }, + "environments": [{ + "tmt": { + "context": { + "trigger": "commit", + "arch": "x86_64", + "distro": "{{ distro }}" + } + }, + "arch": "x86_64", + "variables": [ + "REPO_URL": "{{ repo.url }}" + ], + {%- if compose -%} + "os": { + "compose": "{{ compose }}", + }, + {%- endif -%} + }] + } + status_code: 200, 201 + timeout: 30 + register: id + no_log: true + +- debug: + msg: "Request URL: {{ api_url }}/requests/{{ id.json.id }}" + +- name: wait until the state is complete or error + uri: + url: "{{ api_url }}/requests/{{ id.json.id }}" + method: GET + body_format: json + body: + api_key: "{{ testing_farm_zuul_ci_key.apikey }}" + status_code: 200 + timeout: 30 + register: response + until: response.json.state == "complete" or + response.json.state == "error" + retries: 720 + delay: 60 + ignore_errors: true + +- name: Testing Farm API request response + debug: var=response + +- name: Testing Farm artifacts + debug: msg="See http://artifacts.dev.testing-farm.io/{{ id.json.id }} for detailed results" + +- name: Check the result for timeout + fail: msg="Testing has timed out in 12 hours" + when: response.json.result.overall is undefined or response.json.state == "running" or response.json.state == "queued" + +- name: Return Testing Farm artifacts URL + zuul_return: + data: + zuul: + artifacts: + - name: Testing Farm Artifacts + url: "http://artifacts.dev.testing-farm.io/{{ id.json.id }}" + +- name: Check the result for error + fail: msg="Testing Farm failed to finish the test process" + when: response.json.state == "error" + +- name: Check the result for failure + fail: msg="Tests have failed" + when: response.json.result.overall == "failed" + +- debug: msg="Tests have passed"