Skip to content

Commit 74c8900

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 74c8900

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
- name: Store stestr timing data in internal repository
3+
hosts: localhost
4+
gather_facts: false
5+
vars:
6+
job_name: "{{ job }}"
7+
# TODO add token using secrets
8+
9+
repo_path: "/tmp/timing-data"
10+
timing_data_repo: "https://user:{{ git_token }}@gitlab.cee.redhat.com/ci-framework/timing-data"
11+
tasks:
12+
- name: Clone timing data repository
13+
ansible.builtin.git:
14+
repo: "{{ timing_data_repo }}"
15+
dest: "{{ repo_path }}"
16+
version: "main"
17+
18+
- name: Configure git settings
19+
community.general.git_config:
20+
repo: "{{ repo_path }}"
21+
scope: local
22+
name: "{{ item.name }}"
23+
value: "{{ item.value }}"
24+
loop:
25+
- {name: 'user.name', value: 'Zuul'}
26+
- {name: 'user.email', value: '[email protected]'}
27+
- {name: 'remote.origin.url', value: '{{ timing_data_repo }}'}
28+
29+
- name: Find all 'tempest' directories
30+
ansible.builtin.find:
31+
paths: "{{ ansible_user_dir }}/ci-framework-data/tests/test_operator/"
32+
file_type: directory
33+
patterns: "*-tempest-*"
34+
register: tempest_dirs
35+
36+
- name: Loop over 'tempest' directories
37+
ansible.builtin.debug:
38+
msg: "DIR: {{ item.path }}"
39+
loop: "{{ tempest_dirs.files }}"
40+
41+
- name: Store timing data for every tempest-test directory
42+
ansible.builtin.include_tasks: tempest_store_timing_data_each.yaml
43+
vars:
44+
timing_data_repo_dir: "{{ repo_path }}/{{ job_name }}/{{ tempest_tests_name.path | basename }}"
45+
stestr_tar_path: "ci-framework-data/tests/test_operator/{{ tempest_tests_name.path | basename }}/stestr.tar.gz"
46+
loop: "{{ tempest_dirs.files }}"
47+
loop_control:
48+
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: "{{ ansible_user_dir }}/{{ 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 for {{ job_name }}"
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)