From c1c28ed61afba7d13817d17cb21e5e7e7c59a071 Mon Sep 17 00:00:00 2001 From: Katarina Strenkova Date: Wed, 24 Sep 2025 10:17:36 -0400 Subject: [PATCH] Add a new hook for storing Tempest timing data This new hook is enabling timing data to be stored into an internal repository. Later the timing data will be used to reduce test execution time. --- .../playbooks/tempest_store_timing_data.yaml | 46 +++++++++++++++++++ .../tasks/tempest_store_timing_data_each.yaml | 42 +++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 hooks/playbooks/tempest_store_timing_data.yaml create mode 100644 hooks/tasks/tempest_store_timing_data_each.yaml diff --git a/hooks/playbooks/tempest_store_timing_data.yaml b/hooks/playbooks/tempest_store_timing_data.yaml new file mode 100644 index 0000000000..c5c363b2ce --- /dev/null +++ b/hooks/playbooks/tempest_store_timing_data.yaml @@ -0,0 +1,46 @@ +--- +- name: Store stestr timing data in repository + hosts: localhost + gather_facts: false + vars: + repo_path: "/tmp/timing-data" + tests_log_dir: "{{ ansible_user_dir }}/ci-framework-data/tests/test_operator" + timing_data_repo: "https://repo.example.org/project/timing-data" + tasks: + - name: All tasks required for storing timing data + # Note(kstrenko): This playbook introduces an additional feature + # and should not interfere with existing jobs. + ignore_errors: true # noqa: ignore-errors + block: + - name: Clone timing data repository + ansible.builtin.git: + repo: "{{ timing_data_repo }}" + dest: "{{ repo_path }}" + version: "main" + + - name: Configure git settings + community.general.git_config: + repo: "{{ repo_path }}" + scope: local + name: "{{ item.name }}" + value: "{{ item.value }}" + loop: + - {name: 'user.name', value: 'Zuul'} + - {name: 'user.email', value: 'rhos-dfg-ciops@redhat.com'} + - {name: 'remote.origin.url', value: '{{ timing_data_repo }}'} + + - name: Find all 'tempest' directories + ansible.builtin.find: + paths: "{{ tests_log_dir }}" + file_type: directory + patterns: "*-tempest*" + register: tempest_dirs + + - name: Store timing data for every tempest-test directory + ansible.builtin.include_tasks: ../tasks/tempest_store_timing_data_each.yaml + vars: + stestr_tar_path: "{{ tests_log_dir }}/{{ tempest_tests_name.path | basename }}/stestr.tar.gz" + timing_data_repo_dir: "{{ repo_path }}/{{ job_name }}/{{ tempest_tests_name.path | basename }}" + loop: "{{ tempest_dirs.files }}" + loop_control: + loop_var: tempest_tests_name diff --git a/hooks/tasks/tempest_store_timing_data_each.yaml b/hooks/tasks/tempest_store_timing_data_each.yaml new file mode 100644 index 0000000000..82b6d3d69b --- /dev/null +++ b/hooks/tasks/tempest_store_timing_data_each.yaml @@ -0,0 +1,42 @@ +--- +# +# Included by tempest_store_timing_data.yaml playbook +# +# There are two variables passed by the loop +# - stestr_tar_path - a path to the data which will be copied +# - timing_data_repo_dir - a path to a directory to be created +# +- name: Ensure the defined directory exists + ansible.builtin.file: + path: "{{ timing_data_repo_dir }}" + state: directory + mode: '0755' + +- name: Copy timing data to commit + ansible.builtin.copy: + src: "{{ stestr_tar_path }}" + dest: "{{ timing_data_repo_dir }}" + mode: '0644' + +- name: Add all changes + ansible.builtin.command: + cmd: git add . + chdir: "{{ repo_path }}" + changed_when: false + # noqa command-instead-of-module + +- name: Commit changes + ansible.builtin.command: + cmd: git commit -m "Automatic update" + chdir: "{{ repo_path }}" + register: commit_result + changed_when: commit_result.rc == 0 + # noqa command-instead-of-module + +- name: Push changes to the repository + ansible.builtin.command: + cmd: git push origin main + chdir: "{{ repo_path }}" + when: commit_result.rc == 0 + changed_when: false + # noqa command-instead-of-module