Skip to content

Commit 3e559b3

Browse files
committed
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.
1 parent a54ba1a commit 3e559b3

File tree

2 files changed

+88
-0
lines changed

2 files changed

+88
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
- name: Store stestr timing data in internal repository
3+
hosts: localhost
4+
gather_facts: false
5+
vars:
6+
repo_path: "/tmp/timing-data"
7+
tests_log_dir: "{{ ansible_user_dir }}/ci-framework-data/tests/test_operator"
8+
timing_data_repo: "https://user:{{ git_token }}@gitlab.cee.redhat.com/ci-framework/timing-data"
9+
tasks:
10+
- name: All tasks required for storing timing data
11+
# Note(kstrenko): This playbook introduces an additional feature
12+
# and should not interfere with existing jobs.
13+
failed_when: false
14+
block:
15+
- name: Clone timing data repository
16+
ansible.builtin.git:
17+
repo: "{{ timing_data_repo }}"
18+
dest: "{{ repo_path }}"
19+
version: "main"
20+
21+
- name: Configure git settings
22+
community.general.git_config:
23+
repo: "{{ repo_path }}"
24+
scope: local
25+
name: "{{ item.name }}"
26+
value: "{{ item.value }}"
27+
loop:
28+
- {name: 'user.name', value: 'Zuul'}
29+
- {name: 'user.email', value: '[email protected]'}
30+
- {name: 'remote.origin.url', value: '{{ timing_data_repo }}'}
31+
32+
- name: Find all 'tempest' directories
33+
ansible.builtin.find:
34+
paths: "{{ tests_log_dir }}"
35+
file_type: directory
36+
patterns: "*-tempest*"
37+
register: tempest_dirs
38+
39+
- name: Store timing data for every tempest-test directory
40+
ansible.builtin.include_tasks: ../tasks/tempest_store_timing_data_each.yaml
41+
vars:
42+
stestr_tar_path: "{{ tests_log_dir }}/{{ tempest_tests_name.path | basename }}/stestr.tar.gz"
43+
timing_data_repo_dir: "{{ repo_path }}/{{ job_name }}/{{ tempest_tests_name.path | basename }}"
44+
loop: "{{ tempest_dirs.files }}"
45+
loop_control:
46+
loop_var: tempest_tests_name
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
#
3+
# Included by tempest_store_timing_data.yaml playbook
4+
#
5+
# There are two variables passed by the loop
6+
# - stestr_tar_path - a path to the data which will be copied
7+
# - timing_data_repo_dir - a path to a directory to be created
8+
#
9+
- name: Ensure the defined directory exists
10+
ansible.builtin.file:
11+
path: "{{ timing_data_repo_dir }}"
12+
state: directory
13+
mode: '0755'
14+
15+
- name: Copy timing data to commit
16+
ansible.builtin.copy:
17+
src: "{{ stestr_tar_path }}"
18+
dest: "{{ timing_data_repo_dir }}"
19+
mode: '0644'
20+
21+
- name: Add all changes
22+
ansible.builtin.command:
23+
cmd: git add .
24+
chdir: "{{ repo_path }}"
25+
changed_when: false
26+
# noqa command-instead-of-module
27+
28+
- name: Commit changes
29+
ansible.builtin.command:
30+
cmd: git commit -m "Automatic update"
31+
chdir: "{{ repo_path }}"
32+
register: commit_result
33+
changed_when: commit_result.rc == 0
34+
# noqa command-instead-of-module
35+
36+
- name: Push changes to the repository
37+
ansible.builtin.command:
38+
cmd: git push origin main
39+
chdir: "{{ repo_path }}"
40+
when: commit_result.rc == 0
41+
changed_when: false
42+
# noqa command-instead-of-module

0 commit comments

Comments
 (0)