Skip to content

Commit f8c743b

Browse files
authored
[zuul] Update Autoscaling job to run the playbooks directly from the hook (#118)
Pass the config file and the autoscaling test playbook directly to the hook instead of using an intermediate playbook. This is made possible since the hooks were updated to pass in a config file to the playbooks.
1 parent 11dc0d0 commit f8c743b

File tree

10 files changed

+38
-78
lines changed

10 files changed

+38
-78
lines changed

.github/workflows/check_plugin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ jobs:
88
- uses: actions/checkout@v3
99
- run: python3 -m pip install ansible
1010
- name: Run the test_logger playbook.
11-
run: cd ci && rm -rf test_run_result.out && ${HOME}/.local/bin/ansible-playbook -v github/test_logger.yml && diff -s test_run_result.out github/test_logger_expected
11+
run: cd ci && rm -rf ~/test_run_result.out && ${HOME}/.local/bin/ansible-playbook -v github/test_logger.yml && diff -s ~/test_run_result.out github/test_logger_expected
1212

callback_plugins/custom_logger.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ class CallbackModule(CallbackBase):
3131

3232
def __init__(self):
3333
super(CallbackModule, self).__init__()
34-
self.output_dir = os.getcwd()
34+
self.output_dir = os.path.expanduser("~/")
3535
self.results = {}
3636

3737
def playbook_on_stats(self, stats):
38-
# Log results for each host
38+
#Log results for each host
3939
hosts= stats.processed
4040
for host in hosts:
4141
self.log_summary_results(host)

ci/osp18_functional_tests.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

ci/report_result.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,17 @@
22
- name: Move callback_plugin result to log dir
33
ansible.builtin.shell:
44
cmd: |
5-
cp {{ fvt_dir }}/test_run_result.out {{ logs_dir }}/test_run_result.log
6-
cp {{ fvt_dir }}/summary_results.log {{ logs_dir }}/summary_results.log
5+
cp ~/test_run_result.out {{ test_dir }}/test_run_result.log
6+
# cp ~/summary_results.log {{ autoscaling_logs_dir }}/summary_results.log
77
88
- name: Grep the number of failed tasks
99
ansible.builtin.shell:
1010
cmd: |
11-
grep "Tasks Failed:" {{ fvt_dir }}/summary_results.log | awk '{print $3}'
11+
grep -c "failed" ~/test_run_result.out
1212
register: tasks_failed
13+
ignore_errors: yes
1314

1415
- name: Determine success or failure based on the number of failed tasks
15-
ansible.builtin.assert:
16-
that:
17-
- tasks_failed.stdout == "0"
18-
fail_msg: "Tasks Failed: {{ tasks_failed.stdout }}. Check the logs in {{ logs_dir }}/summary_results.log."
19-
success_msg: "Tasks Failed: {{ tasks_failed.stdout }}. All tasks succeeded."
16+
ansible.builtin.fail:
17+
msg: "The log file contains failed task."
18+
when: tasks_failed.rc == 0
Lines changed: 22 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,25 @@
11
---
2-
- name: "Run functional test playbooks"
2+
- name: Run telemetry autoscaling tests on osp18
33
hosts: "{{ cifmw_target_hook_host | default('localhost') }}"
44
gather_facts: true
55
environment:
66
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
77
PATH: "{{ cifmw_path }}"
88
vars_files:
99
- vars/common.yml
10+
- vars/osp18_env.yml
1011
tasks:
11-
- name: "Create log dir"
12-
ansible.builtin.file:
13-
path: "{{ logs_dir }}"
14-
state: directory
15-
mode: "0755"
12+
- block:
13+
- name: "Create log dir"
14+
ansible.builtin.file:
15+
path: "{{ logs_dir }}/autoscaling"
16+
state: directory
17+
mode: "0755"
1618

17-
- name: "Set dynamic KUBECONFIG and PATH vars"
18-
copy:
19-
content: |
20-
cifmw_openshift_kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
21-
cifmw_path: "{{ cifmw_path }}"
22-
vars_dir: "{{ fvt_dir }}/ci/vars"
23-
dest: "{{ env_vars_file }}"
19+
- name: Include vars from the extra_vars files
20+
ansible.builtin.include_vars:
21+
dir: "{{ cifmw_basedir }}/artifacts/parameters"
2422

25-
- name: Include vars from the extra_vars files
26-
ansible.builtin.include_vars:
27-
dir: "{{ cifmw_basedir }}/artifacts/parameters"
28-
29-
# Prepare the env
30-
- name: Setup the required resources before running the autoscaling functional test
31-
block:
32-
# TODO: Look at replacing this with something NOT from install_yamls.
3323
- community.general.make:
3424
chdir: '{{ ansible_env.HOME }}/{{ zuul.projects["github.com/openstack-k8s-operators/install_yamls"].src_dir }}/devsetup'
3525
target: edpm_deploy_instance
@@ -39,7 +29,7 @@
3929
- name: Patch the openstackversions to use the master containers for aodh and heat
4030
ansible.builtin.shell:
4131
cmd: |
42-
oc patch openstackversions controlplane --type merge --patch-file ci/patch-openstack-versions.yaml
32+
oc patch openstackversions controlplane --type merge --patch-file ci/patch-openstack-versions.yaml
4333
chdir: "{{ fvt_dir }}"
4434
when: "{{ patch_openstackversions | bool }}"
4535
tags:
@@ -67,24 +57,19 @@
6757
tags:
6858
- setup
6959

70-
- name: "Run telemetry tests playbook locally on the target host"
71-
ansible.builtin.shell:
72-
cmd: |
73-
ANSIBLE_CONFIG=ci/ansible.cfg ansible-playbook -v -e @"{{ env_vars_file }}" ci/osp18_functional_tests.yml
74-
chdir: "{{ fvt_dir }}"
75-
register: output
76-
77-
- name: Save ansible output to a file
78-
ansible.builtin.copy:
79-
content: "{{ output.stdout }}"
80-
dest: "{{ logs_dir }}/ansible_run.log"
81-
always:
60+
- name: "Run Telemetry Autoscaling tests"
61+
ansible.builtin.import_role:
62+
name: telemetry_autoscaling
63+
64+
always:
8265
- name: Revert the version update
8366
ansible.builtin.shell:
8467
cmd: |
8568
oc patch openstackversions controlplane --type json -p='[{"op": "replace", "path": "/spec/customContainerImages", "value": {} }]'
8669
when: "{{ patch_openstackversions | bool }}"
8770

88-
- name: Include report result
89-
ansible.builtin.include_tasks:
90-
file: report_result.yml
71+
- name: Include report result
72+
ansible.builtin.include_tasks:
73+
file: report_result.yml
74+
vars:
75+
test_dir: "{{ logs_dir }}/autoscaling"

ci/vars-functional-test.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
# temp: skip os-net-setup
33
cifmw_os_net_setup_config: []
44
post_deploy_run_functional_test:
5-
source: "{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/run_playbooks.yml"
5+
source: "{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/run_autoscaling_osp18.yml"
66
type: playbook
7+
config_file: "{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/ansible.cfg"

ci/vars/common.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
---
22
fvt_dir: "{{ ansible_env.HOME }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}"
3-
logs_dir: "{{ ansible_env.HOME }}/ci-framework-data/logs/functional-tests"
4-
env_vars_file: "/tmp/env_vars.yml"
3+
logs_dir: "{{ ansible_env.HOME }}/ci-framework-data/logs/"

roles/telemetry_autoscaling/tasks/creating_stack.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@
3636
ansible.builtin.debug:
3737
var: result
3838

39-
#- name: Wait for 60 sec
40-
# ansible.builtin.pause:
41-
# minutes: 1
4239

4340
- name: RHOSO-12704 Verify that the stack was created successfully
4441
ansible.builtin.shell: |
@@ -49,6 +46,7 @@
4946
timeout: 30
5047
retries: 20
5148

49+
5250
- name: RHOSO-12650 Verify that the stack resources are created
5351
ansible.builtin.shell: |
5452
# source ~/overcloudrc;
@@ -58,7 +56,7 @@
5856
timeout: 30
5957
retries: 20
6058
until: '"CREATE_COMPLETE" in result.stdout'
61-
# failed_when: '"CREATE_COMPLETE" not in result.stdout'
59+
#failed_when: '"CREATE_COMPLETE" not in result.stdout'
6260

6361
- name: RHOSO-12707 Verify that ceilometer_cpu metric exist
6462
ansible.builtin.shell: |

roles/telemetry_autoscaling/tasks/main.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,6 @@
22
# tasks file for telemetry_autoscaling
33
# TODO: Update the pre-checks to include the resources that the stack expects to exist
44
# i.e. networks, flavor, image, security group
5-
- name: Gather list of vars files
6-
set_fact:
7-
vars_files: "{{ lookup('fileglob', vars_path + '/*.yml', wantlist=True) }}"
8-
9-
- name: Include multiple variable files
10-
include_vars: "{{ item }}"
11-
with_items: "{{ vars_files }}"
12-
135
- name: RHOSO-12666 Test services are enabled for autoscaling
146
when: metrics_backend == "prometheus"
157
ansible.builtin.include_tasks:

roles/telemetry_autoscaling/tasks/post_teardown.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@
2020
ignore_errors: true
2121
retries: 50
2222
timeout: 5
23-
23+

0 commit comments

Comments
 (0)