diff mbox series

[4/9] ltp: add last-run directory and last-kernel.txt to the results

Message ID 20250305005755.697599-6-smayhew@redhat.com (mailing list archive)
State New
Headers show
Series tweak results organization and reporting | expand

Commit Message

Scott Mayhew March 5, 2025, 12:57 a.m. UTC
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 <smayhew@redhat.com>
---
 playbooks/roles/ltp/tasks/main.yml | 60 ++++++++++++++++++++++++++++--
 1 file changed, 56 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/playbooks/roles/ltp/tasks/main.yml b/playbooks/roles/ltp/tasks/main.yml
index 34cae23..71e1541 100644
--- a/playbooks/roles/ltp/tasks/main.yml
+++ b/playbooks/roles/ltp/tasks/main.yml
@@ -20,17 +20,52 @@ 
   tags: ['vars']
   ansible.builtin.set_fact:
     ltp_test_group: "{{ ansible_host | regex_replace(kdevops_host_prefix + '-') | regex_replace('-dev') }}"
-    ltp_results_dir: "../workflows/ltp/results/{{ ansible_kernel }}"
+    ltp_results_full_path: "{{ topdir_path }}/workflows/ltp/results"
+    ltp_results_target: "../workflows/ltp/results/last-run"
 
 - name: Create the local results directory
   tags: ['first_run']
   ansible.builtin.file:
-    path: "{{ ltp_results_dir }}"
+    path: "{{ ltp_results_full_path }}"
     state: directory
     mode: "u=rwx,g=rx,o=rx"
   delegate_to: localhost
   run_once: true
 
+- name: Clean up our localhost results/last-run directory
+  local_action: file path="{{ ltp_results_target }}/" state=absent
+  run_once: true
+  tags: [ 'run_tests', 'copy_results', 'clean_local_results' ]
+
+- name: Create empty last-run directory
+  local_action: file path="{{ ltp_results_target }}/" state=directory
+  run_once: true
+  tags: [ 'run_tests', 'copy_results', 'clean_local_results' ]
+
+- name: Get used target kernel version
+  tags: [ 'copy_results' ]
+  command: "uname -r"
+  register: uname_cmd
+
+- name: Store last kernel variable
+  tags: [ 'copy_results' ]
+  set_fact:
+    last_kernel: "{{ uname_cmd.stdout_lines | regex_replace('\\]') | regex_replace('\\[') | replace(\"'\",'') }}"
+  run_once: true
+
+- name: Document used target kernel version
+  local_action: "shell echo {{ last_kernel }} > {{ ltp_results_target }}/../last-kernel.txt"
+  tags: [ 'run_tests', 'copy_results', 'print_results' ]
+  run_once: true
+
+- name: Ensure the local results directory exists
+  tags: copy_results
+  ansible.builtin.file:
+    path: "{{ ltp_results_full_path }}/last-run/{{ last_kernel }}/{{ ltp_test_group }}"
+    state: directory
+    mode: "u=rwx,g=rx,o=rx"
+  delegate_to: localhost
+
 - name: Set OS-specific variables
   ansible.builtin.include_vars: "{{ lookup('ansible.builtin.first_found', params) }}"
   vars:
@@ -194,7 +229,7 @@ 
   tags: ['copy_results']
   ansible.builtin.fetch:
     src: "{{ item.path }}"
-    dest: "{{ ltp_results_dir }}/{{ ltp_test_group }}/"
+    dest: "{{ ltp_results_full_path }}/last-run/{{ last_kernel }}/{{ ltp_test_group }}/"
     flat: true
     validate_checksum: false
   with_items: "{{ results_files.files }}"
@@ -216,7 +251,7 @@ 
   tags: ['copy_results']
   ansible.builtin.fetch:
     src: "{{ item.path }}"
-    dest: "{{ ltp_results_dir }}/{{ ltp_test_group }}/"
+    dest: "{{ ltp_results_full_path }}/last-run/{{ last_kernel }}/{{ ltp_test_group }}/"
     flat: true
     validate_checksum: false
   with_items: "{{ output_files.files }}"
@@ -224,3 +259,20 @@ 
     - output_files.matched > 0
   loop_control:
     label: "Copying {{ item.path | basename }} ..."
+
+- name: Verify last-run kernel directory exists
+  tags: [ 'copy_results' ]
+  delegate_to: localhost
+  stat:
+    path: "{{ ltp_results_full_path }}/last-run/{{ last_kernel }}"
+  register: last_run_kernel_dir
+
+- name: Copy over the last-run into the results directory for archiving into kdevops
+  copy:
+    src: "{{ ltp_results_full_path }}/last-run/{{ last_kernel }}"
+    dest: "{{ ltp_results_full_path }}/"
+  run_once: true
+  tags: [ 'copy_results' ]
+  delegate_to: localhost
+  when:
+    - last_run_kernel_dir.stat.exists