Skip to content

Commit b3432fd

Browse files
committed
nfstest: add last-run directory and last-kernel.txt to the results
Create the last-run directory and last-kernel.txt file in a manner similar to the way the fstests workflow does it. This will make it easier to get at the most recent test results for reporting purposes. Signed-off-by: Scott Mayhew <[email protected]>
1 parent f0c8372 commit b3432fd

File tree

1 file changed

+52
-8
lines changed

1 file changed

+52
-8
lines changed

playbooks/roles/nfstest/tasks/main.yml

Lines changed: 52 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,23 +131,50 @@
131131
tags:
132132
- run_tests
133133

134+
- name: Set the pathname of the results directory
135+
ansible.builtin.set_fact:
136+
nfstest_results_full_path: "{{ topdir_path }}/workflows/nfstest/results"
137+
nfstest_results_target: "../workflows/nfstest/results/last-run"
138+
when:
139+
- kdevops_workflows_dedicated_workflow|bool
140+
tags: copy_results
141+
142+
- name: Clean up our localhost results/last-run directory
143+
local_action: file path="{{ nfstest_results_target }}/" state=absent
144+
run_once: true
145+
tags: [ 'run_tests', 'copy_results', 'clean_local_results' ]
146+
147+
- name: Create empty last-run directory
148+
local_action: file path="{{ nfstest_results_target }}/" state=directory
149+
run_once: true
150+
tags: [ 'run_tests', 'copy_results', 'clean_local_results' ]
151+
134152
- name: Run the test group script on the target node
135153
ansible.builtin.command:
136154
cmd: "/tmp/runtest.sh"
137155
when:
138156
- kdevops_workflows_dedicated_workflow|bool
139157
tags: run_tests
140158

141-
- name: Set the pathname of the results directory
142-
ansible.builtin.set_fact:
143-
nfstest_results_dir: "../workflows/nfstest/results/{{ ansible_kernel }}"
144-
when:
145-
- kdevops_workflows_dedicated_workflow|bool
146-
tags: copy_results
159+
- name: Get used target kernel version
160+
tags: [ 'copy_results' ]
161+
command: "uname -r"
162+
register: uname_cmd
163+
164+
- name: Store last kernel variable
165+
tags: [ 'copy_results' ]
166+
set_fact:
167+
last_kernel: "{{ uname_cmd.stdout_lines | regex_replace('\\]') | regex_replace('\\[') | replace(\"'\",'') }}"
168+
run_once: true
169+
170+
- name: Document used target kernel version
171+
local_action: "shell echo {{ last_kernel }} > {{ nfstest_results_target }}/../last-kernel.txt"
172+
tags: [ 'run_tests', 'copy_results', 'print_results' ]
173+
run_once: true
147174

148175
- name: Create the results directory on the control node
149176
ansible.builtin.file:
150-
path: "{{ nfstest_results_dir }}"
177+
path: "{{ nfstest_results_full_path }}/last-run/{{ last_kernel }}"
151178
state: directory
152179
mode: "u=rwx,g=rx,o=rx"
153180
delegate_to: localhost
@@ -168,7 +195,7 @@
168195
- name: Copy the output logs to the control node
169196
ansible.builtin.fetch:
170197
src: "{{ item.path }}"
171-
dest: "{{ nfstest_results_dir }}/{{ nfstest_test_group }}/"
198+
dest: "{{ nfstest_results_full_path }}/last-run/{{ last_kernel }}/{{ nfstest_test_group }}/"
172199
flat: true
173200
with_items: "{{ nfstest_logs.files }}"
174201
loop_control:
@@ -178,3 +205,20 @@
178205
- kdevops_workflows_dedicated_workflow|bool
179206
changed_when: false
180207
tags: copy_results
208+
209+
- name: Verify last-run kernel directory exists
210+
tags: [ 'copy_results' ]
211+
delegate_to: localhost
212+
stat:
213+
path: "{{ nfstest_results_full_path }}/last-run/{{ last_kernel }}"
214+
register: last_run_kernel_dir
215+
216+
- name: Copy over the last-run into the results directory for archiving into kdevops
217+
copy:
218+
src: "{{ nfstest_results_full_path }}/last-run/{{ last_kernel }}"
219+
dest: "{{ nfstest_results_full_path }}/"
220+
run_once: true
221+
tags: [ 'copy_results' ]
222+
delegate_to: localhost
223+
when:
224+
- last_run_kernel_dir.stat.exists

0 commit comments

Comments
 (0)