Skip to content

Commit e4d867d

Browse files
committed
Wait for pipeline run in integration tests
A new step in integration step is added to wait for pipeline to finish. Previously this was handled by the tekton cmd which was not reliable and often got stuck. JIRA: ISV-5237 Signed-off-by: Ales Raszka <[email protected]>
1 parent 8370d2f commit e4d867d

File tree

3 files changed

+55
-9
lines changed

3 files changed

+55
-9
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
PIPELINE_RUN_NAME=$1
3+
NAMESPACE=$2
4+
5+
if [ -z "$PIPELINE_RUN_NAME" ] || [ -z "$NAMESPACE" ]; then
6+
echo "Usage: $0 <pipeline-run-name> <namespace>"
7+
exit 1
8+
fi
9+
10+
get_pipeline_status() {
11+
oc get pipelinerun "$PIPELINE_RUN_NAME" -n "$NAMESPACE" -o json | jq -r '.status.conditions[] | select(.type=="Succeeded") | .status'
12+
}
13+
14+
while true; do
15+
STATUS=$(get_pipeline_status)
16+
17+
if [ "$STATUS" == "True" ]; then
18+
echo "PipelineRun $PIPELINE_RUN_NAME succeeded."
19+
exit 0
20+
elif [ "$STATUS" == "False" ]; then
21+
echo "PipelineRun $PIPELINE_RUN_NAME failed."
22+
exit 1
23+
else
24+
echo "PipelineRun $PIPELINE_RUN_NAME is still running..."
25+
fi
26+
sleep 20
27+
done

ansible/roles/integration_tests/tasks/check_pipeline_run.yml

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,43 @@
1313
- "suffix={{ suffix }}"
1414
register: pipeline_run
1515
until: pipeline_run.resources | length > 0
16-
retries: 5
16+
retries: 10
1717
delay: 5
1818
failed_when: pipeline_run.resources | length == 0
1919

2020
- name: Pipelinerun
2121
ansible.builtin.debug:
2222
var: pipeline_run.resources[0].metadata.name
2323

24+
- name: "Wait for the run of {{ pipeline_name }}"
25+
ansible.builtin.shell: |
26+
./wait_for_pipelinerun.sh \
27+
{{ pipeline_run.resources[0].metadata.name }} \
28+
{{ oc_namespace }}
29+
args:
30+
executable: /bin/bash
31+
chdir: "{{ temp_tools_dir.path }}"
32+
register: pipeline_run_wait
33+
failed_when: false
34+
timeout: 5400 # 90 minutes
35+
changed_when: false
2436

25-
- name: "Follow the run logs of {{ pipeline_name }}"
37+
- name: "Get pipelinerun logs - {{ pipeline_name }}"
2638
ansible.builtin.shell: |
2739
./tkn pipeline logs \
2840
{{ pipeline_name }} \
2941
{{ pipeline_run.resources[0].metadata.name }} \
30-
--namespace {{ oc_namespace }} \
31-
--follow
42+
--namespace {{ oc_namespace }}
3243
args:
3344
executable: /bin/bash
3445
chdir: "{{ temp_tools_dir.path }}"
35-
register: pipeline_run_log
36-
retries: 5
37-
until: pipeline_run_log.rc == 0
46+
no_log: true
47+
register: pipeline_run_logs
3848
changed_when: false
3949

40-
- name: Output the run logs of {{ pipeline_name }}
50+
- name: "Print pipelinerun logs - {{ pipeline_name }}"
4151
ansible.builtin.debug:
42-
msg: "{{ pipeline_run_log.stdout_lines }}"
52+
var: pipeline_run_logs.stdout_lines
4353

4454
- name: Verify successful run of {{ pipeline_name }}
4555
kubernetes.core.k8s_info:

ansible/roles/integration_tests/tasks/tools.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,12 @@
2323
remote_src: true
2424
include:
2525
- opm
26+
27+
- name: Copy a local scripts to the host
28+
ansible.builtin.copy:
29+
src: "{{ item }}"
30+
dest: "{{ temp_tools_dir.path }}"
31+
mode: a+x
32+
33+
with_items:
34+
- "files/wait_for_pipelinerun.sh"

0 commit comments

Comments
 (0)