Skip to content

Commit cce6d68

Browse files
committed
Clean up test process
If stestr failed, then no node info was logged. Logging node info is now handled in pre and post stages of Zuul. Additionally Zuul v3 migration recommendations were applied and some unused code removed improving general readability. Change-Id: Iae9d37cb76997ba8389e21c7e2a3bf5905abe029 Signed-off-by: Radosław Piliszek <[email protected]> (cherry picked from commit c7ac0f0)
1 parent d51c0f0 commit cce6d68

File tree

10 files changed

+62
-133
lines changed

10 files changed

+62
-133
lines changed

.zuul.d/base.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@
4646
run: tests/playbooks/run.yml
4747
post-run: tests/playbooks/post.yml
4848
attempts: 1
49-
required-projects:
50-
- openstack/kolla-ansible
51-
- openstack/requirements
5249
irrelevant-files:
5350
- ^.*\.rst$
5451
- ^doc/.*
@@ -59,3 +56,6 @@
5956
- ^test-requirements.txt$
6057
vars:
6158
publisher: false
59+
extra-vars:
60+
kolla_logs_dir: "{{ zuul_output_dir }}/logs/kolla"
61+
kolla_build_logs_dir: "{{ kolla_logs_dir }}/build"

tests/playbooks/post.yml

Lines changed: 40 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,88 @@
11
---
22
- hosts: all
33
tasks:
4-
- shell:
4+
- name: Dump host info to logs
5+
command: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/tools/dump_info.sh"
6+
args:
7+
chdir: "{{ kolla_logs_dir }}"
8+
9+
- name: Collect various info to logs
10+
shell:
511
cmd: |
612
set +o errexit
7-
mkdir -p logs
8-
# copy system log
13+
set -o xtrace
914
10-
sudo cp -r /var/log logs/system_log
15+
# copy system log
16+
sudo cp -r /var/log system_log
1117
1218
if which journalctl ; then
1319
# the journal gives us syslog() and kernel output, so is like
1420
# a concatenation of the above.
15-
sudo journalctl --no-pager | sudo tee logs/syslog.txt > /dev/null
16-
sudo journalctl --no-pager -u docker.service | sudo tee logs/docker.log > /dev/null
21+
sudo journalctl --no-pager > syslog.txt
22+
sudo journalctl --no-pager -u docker.service > docker.log
1723
else
1824
# assume rsyslog
19-
sudo cp /var/log/syslog logs/syslog.txt
20-
sudo cp /var/log/kern.log logs/kern_log.txt
21-
sudo cp /var/log/upstart/docker.log logs/docker.log
25+
sudo cp /var/log/syslog syslog.txt
26+
sudo cp /var/log/kern.log kern_log.txt
27+
sudo cp /var/log/upstart/docker.log docker.log
2228
fi
2329
2430
if sudo test -d /var/lib/docker/volumes/kolla_logs/_data; then
25-
sudo cp -r /var/lib/docker/volumes/kolla_logs/_data logs/kolla_logs
31+
sudo cp -r /var/lib/docker/volumes/kolla_logs/_data kolla_logs
2632
fi
2733
2834
# sudo config
29-
sudo cp -r /etc/sudoers.d logs/
30-
sudo cp /etc/sudoers logs/sudoers.txt
35+
sudo cp -r /etc/sudoers.d ./
36+
sudo cp /etc/sudoers sudoers.txt
3137
32-
df -h > logs/df.txt
33-
free > logs/free.txt
34-
sudo parted -l | sudo tee logs/parted-l.txt > /dev/null
35-
mount > logs/mount.txt
36-
env > logs/env.txt
38+
df -h > df.txt
39+
free > free.txt
40+
sudo parted -l > parted-l.txt
41+
mount > mount.txt
42+
env > env.txt
3743
3844
if [ `command -v dpkg` ]; then
39-
dpkg -l | sudo tee logs/dpkg-l.txt > /dev/null
45+
dpkg -l > dpkg-l.txt
4046
fi
4147
if [ `command -v rpm` ]; then
42-
rpm -qa | sudo tee logs/rpm-qa.txt > /dev/null
48+
rpm -qa > rpm-qa.txt
4349
fi
4450
4551
# final memory usage and process list
46-
ps -eo user,pid,ppid,lwp,%cpu,%mem,size,rss,cmd > logs/ps.txt
52+
ps -eo user,pid,ppid,lwp,%cpu,%mem,size,rss,cmd > ps.txt
4753
4854
# docker related information
49-
(docker info && docker system df && docker system df -v) > logs/docker-info.txt
55+
(docker info && docker system df && docker system df -v) > docker-info.txt
5056
51-
sudo cp -r /etc/kolla logs/kolla_configs
57+
sudo cp -r /etc/kolla kolla_configs
5258
53-
# fix the permissions for logs folder
54-
sudo chmod -R 777 logs
59+
# last sudo to own all files
60+
sudo chown -R {{ ansible_user_id }}: .
5561
5662
# Parse build logs and extract pkg install info
57-
tests/files/process_build_logs.py -l logs/build -b {{ base_distro }} > logs/packages-info.txt
63+
{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/tests/files/process_build_logs.py -l build -b {{ base_distro }} > packages-info.txt
5864
5965
# rename files to .txt; this is so that when displayed via
6066
# logs.openstack.org clicking results in the browser shows the
6167
# files, rather than trying to send it to another app or make you
6268
# download it, etc.
6369
6470
# firstly, rename all .log files to .txt files
65-
for f in $(find logs -name "*.log"); do
66-
sudo mv $f ${f/.log/.txt}
71+
for f in $(find . -name "*.log"); do
72+
mv $f ${f/.log/.txt}
6773
done
6874
6975
# Update symlinks to new file names
70-
for f in $(find logs -name "*FAILED*"); do
71-
sudo mv ${f} ${f}.gz
72-
sudo ln -sf ${f#*/000_FAILED_}.gz ${f}.gz
76+
for f in $(find . -name "*FAILED*"); do
77+
mv ${f} ${f}.gz
78+
ln -sf ${f#*/000_FAILED_}.gz ${f}.gz
7379
done
7480
7581
# append .txt to all kolla config file
76-
find logs/kolla_configs -type f -exec mv '{}' '{}'.txt \;
82+
find kolla_configs -type f -exec mv '{}' '{}'.txt \;
7783
7884
# Compress all text logs
79-
find logs -iname '*.txt' -execdir gzip -9 {} \+
80-
find logs -iname '*.json' -execdir gzip -9 {} \+
85+
find . -iname '*.txt' -execdir gzip -9 {} \+
86+
find . -iname '*.json' -execdir gzip -9 {} \+
8187
executable: /bin/bash
82-
chdir: "{{ zuul.project.src_dir }}"
83-
84-
- synchronize:
85-
src: '{{ zuul.project.src_dir }}/logs'
86-
dest: '{{ zuul.executor.log_root }}'
87-
mode: pull
88-
copy_links: true
89-
verify_host: true
90-
rsync_opts:
91-
- "--quiet"
88+
chdir: "{{ kolla_logs_dir }}"

tests/playbooks/pre.yml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
---
22
- hosts: all
3-
become: true
43
tasks:
5-
- name: Install dbus for debian system
6-
apt: name=dbus
7-
when: ansible_os_family == 'Debian'
4+
- name: Create dir for kolla logs
5+
file:
6+
path: "{{ kolla_logs_dir }}"
7+
state: directory
88

9-
- name: Install ansible
10-
pip:
11-
name: ansible
12-
when:
13-
- inventory_hostname == "primary"
9+
- name: Dump host info to logs
10+
command: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/tools/dump_info.sh"
11+
args:
12+
chdir: "{{ kolla_logs_dir }}"
13+
14+
- name: Create dir for kolla build logs
15+
file:
16+
path: "{{ kolla_build_logs_dir }}"
17+
state: directory

tests/playbooks/run.yml

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
- hosts: all
33
vars:
4-
kolla_inventory_path: "{{ zuul.project.src_dir }}/inventory"
54
nodepool_rdo_proxy: "{{ zuul_site_mirror_fqdn }}:8080/rdo"
65
nodepool_pypi_mirror: "http://{{ zuul_site_mirror_fqdn }}:8080/pypi/simple"
76
nodepool_mirror_host: "{{ zuul_site_mirror_fqdn }}"
@@ -12,23 +11,6 @@
1211
nodepool_oraclelinux_proxy: "http://{{ zuul_site_mirror_fqdn }}:8080/oraclelinux/"
1312
nodepool_percona_proxy: "http://{{ zuul_site_mirror_fqdn }}:8080/percona"
1413
tasks:
15-
- name: generate kolla inventory file
16-
copy:
17-
dest: "{{ kolla_inventory_path }}"
18-
content: |
19-
{% for host in hostvars %}
20-
{{ host }} ansible_host={{ hostvars[host]['ansible_host'] }} ansible_user={{ hostvars[host]['ansible_user'] }}
21-
{% endfor %}
22-
23-
- name: setup logging
24-
shell:
25-
cmd: |
26-
mkdir logs
27-
ln -s $(pwd)/logs /tmp/logs
28-
mkdir -p /tmp/logs/{ansible,build,kolla,kolla_configs}
29-
executable: /bin/bash
30-
chdir: "{{ zuul.project.src_dir }}"
31-
3214
- name: copy setup script
3315
copy:
3416
src: "{{ zuul.executor.work_root }}/{{ zuul.project.src_dir }}/tools/setup_{{ ansible_os_family }}.sh"
@@ -57,21 +39,12 @@
5739
src: "{{ zuul.executor.work_root }}/{{ zuul.project.src_dir }}/tests/templates/kolla-build.conf.j2"
5840
dest: /etc/kolla/kolla-build.conf
5941

60-
- name: Template override
42+
- name: Template template_overrides.j2
6143
template:
6244
src: "{{ zuul.executor.work_root }}/{{ zuul.project.src_dir }}/tests/templates/template_overrides.j2"
6345
dest: /etc/kolla/template_overrides.j2
6446

65-
- shell:
66-
cmd: |
67-
set -e
68-
set -x
69-
70-
export ACTION={{ action }}
71-
export BASE_DISTRO={{ base_distro }}
72-
export INSTALL_TYPE={{ install_type }}
73-
export IN_PROJECT_JOBS=1
74-
tools/gate_run.sh
75-
executable: /bin/bash
47+
- name: Run tox
48+
command: tox -e {{ action }}-{{ base_distro }}-{{ install_type }}
49+
args:
7650
chdir: "{{ zuul.project.src_dir }}"
77-
environment: '{{ zuul | zuul_legacy_vars }}'

tests/setup_gate.sh

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/templates/kolla-build.conf.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ namespace = kolla
55
tag = {{ zuul.tag if zuul.pipeline == "release" else zuul.branch | basename }}
66
{% endif %}
77
push = false
8-
logs_dir = /tmp/logs/build
8+
logs_dir = {{ kolla_build_logs_dir }}
99
template_override = /etc/kolla/template_overrides.j2

tools/dump_info.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ function dump_node_info {
2323
set -o errexit
2424
}
2525

26-
(dump_node_info 2>&1) > /tmp/logs/node_info_$(date +%s)
26+
(dump_node_info 2>&1) > node_info_$(date +%s)

tools/gate_run.sh

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

tools/setup_gate.sh

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

tox.ini

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,6 @@ commands =
7575
doc8 doc
7676
sphinx-build -W -b html doc/source doc/build/html
7777

78-
[testenv:setupenv]
79-
commands =
80-
{toxinidir}/tools/setup_gate.sh
81-
{toxinidir}/tools/dump_info.sh
82-
8378
[testenv:build-centos-binary]
8479
whitelist_externals = find
8580
bash
@@ -89,7 +84,6 @@ commands =
8984
find . -type f -name "*.py[c|o]" -delete -o -type l -name "*.py[c|o]" -delete
9085
bash -c "if [ ! -d .stestr ]; then stestr init; fi"
9186
stestr run test_build.BuildTestCentosBinary
92-
{toxinidir}/tools/dump_info.sh
9387

9488
[testenv:build-centos-source]
9589
whitelist_externals = find
@@ -100,7 +94,6 @@ commands =
10094
find . -type f -name "*.py[c|o]" -delete -o -type l -name "*.py[c|o]" -delete
10195
bash -c "if [ ! -d .stestr ]; then stestr init; fi"
10296
stestr run test_build.BuildTestCentosSource
103-
{toxinidir}/tools/dump_info.sh
10497

10598
[testenv:build-ubuntu-binary]
10699
whitelist_externals = find
@@ -111,7 +104,6 @@ commands =
111104
find . -type f -name "*.py[c|o]" -delete -o -type l -name "*.py[c|o]" -delete
112105
bash -c "if [ ! -d .stestr ]; then stestr init; fi"
113106
stestr run test_build.BuildTestUbuntuBinary
114-
{toxinidir}/tools/dump_info.sh
115107

116108
[testenv:build-ubuntu-source]
117109
whitelist_externals = find
@@ -122,7 +114,6 @@ commands =
122114
find . -type f -name "*.py[c|o]" -delete -o -type l -name "*.py[c|o]" -delete
123115
bash -c "if [ ! -d .stestr ]; then stestr init; fi"
124116
stestr run test_build.BuildTestUbuntuSource
125-
{toxinidir}/tools/dump_info.sh
126117

127118
[testenv:build-debian-binary]
128119
whitelist_externals = find
@@ -133,7 +124,6 @@ commands =
133124
find . -type f -name "*.py[c|o]" -delete -o -type l -name "*.py[c|o]" -delete
134125
bash -c "if [ ! -d .stestr ]; then stestr init; fi"
135126
stestr run test_build.BuildTestDebianBinary
136-
{toxinidir}/tools/dump_info.sh
137127

138128
[testenv:build-debian-source]
139129
whitelist_externals = find
@@ -144,7 +134,6 @@ commands =
144134
find . -type f -name "*.py[c|o]" -delete -o -type l -name "*.py[c|o]" -delete
145135
bash -c "if [ ! -d .stestr ]; then stestr init; fi"
146136
stestr run test_build.BuildTestDebianSource
147-
{toxinidir}/tools/dump_info.sh
148137

149138
[testenv:build-oraclelinux-binary]
150139
whitelist_externals = find
@@ -155,7 +144,6 @@ commands =
155144
find . -type f -name "*.py[c|o]" -delete -o -type l -name "*.py[c|o]" -delete
156145
bash -c "if [ ! -d .stestr ]; then stestr init; fi"
157146
stestr run test_build.BuildTestOracleLinuxBinary
158-
{toxinidir}/tools/dump_info.sh
159147

160148
[testenv:build-oraclelinux-source]
161149
whitelist_externals = find
@@ -166,7 +154,6 @@ commands =
166154
find . -type f -name "*.py[c|o]" -delete -o -type l -name "*.py[c|o]" -delete
167155
bash -c "if [ ! -d .stestr ]; then stestr init; fi"
168156
stestr run test_build.BuildTestOracleLinuxSource
169-
{toxinidir}/tools/dump_info.sh
170157

171158
[testenv:genconfig]
172159
whitelist_externals = which

0 commit comments

Comments
 (0)