summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChandan Kumar <chkumar@redhat.com>2018-10-11 14:29:02 +0530
committerChandan Kumar <chkumar@redhat.com>2018-11-06 15:41:48 +0530
commit2d255d14f809d4e46bb1b67040c48cd376f088ec (patch)
tree0db45d67fbbdee47a13e75a258ed55c5b11e94d1
parent81a1ac04ec9d22a13d02ae1c3db17181ea8b3047 (diff)
Add podman support to validate-tempest role
* https://review.openstack.org/#/c/600517 introduces undercloud_container_cli to choose docker/podman container runtime. This changes introduces to use both docker/podman for running tempest tests. * Tempest user does not have permission to create tempest workspace let's create the tempest workspace and own it with the tempest user. * Introducing tempest_data directory to keep tempest related data which can be used by tempestconf and tempest run to tests * Cleaned up stuff which is not necessary for tempest container. Depends-On: https://review.openstack.org/#/c/614664/ Change-Id: I1b19b2580d1d4c9844e9221f18b23655b36b5a23
Notes
Notes (review): Verified-1: RDO Third Party CI <dmsimard+rdothirdparty@redhat.com> Code-Review+2: Emilien Macchi <emilien@redhat.com> Code-Review+1: Arx Cruz <arxcruz@redhat.com> Code-Review+2: Alex Schultz <aschultz@redhat.com> Workflow+1: Alex Schultz <aschultz@redhat.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Thu, 08 Nov 2018 07:49:15 +0000 Reviewed-on: https://review.openstack.org/605356 Project: openstack/tripleo-quickstart-extras Branch: refs/heads/master
-rw-r--r--roles/validate-tempest/README.md1
-rw-r--r--roles/validate-tempest/defaults/main.yml13
-rw-r--r--roles/validate-tempest/tasks/pre-tempest.yml5
-rw-r--r--roles/validate-tempest/tasks/tempest-containers.yml4
-rw-r--r--roles/validate-tempest/templates/configure-tempest.sh.j215
-rw-r--r--roles/validate-tempest/templates/run-tempest.sh.j257
6 files changed, 56 insertions, 39 deletions
diff --git a/roles/validate-tempest/README.md b/roles/validate-tempest/README.md
index 82b8f9e..283181b 100644
--- a/roles/validate-tempest/README.md
+++ b/roles/validate-tempest/README.md
@@ -46,6 +46,7 @@ Role Variables
46* `tempest_container_namespace`: <string> The name of tempest container image to use (default: centos-binary-tempest) 46* `tempest_container_namespace`: <string> The name of tempest container image to use (default: centos-binary-tempest)
47* `tempest_container_tag`: <string> The tag of the tempest container image to use (default: current-tripleo) 47* `tempest_container_tag`: <string> The tag of the tempest container image to use (default: current-tripleo)
48* `tempest_dir`: <string> The path to tempest workspace directory (default: /home/stack/tempest) 48* `tempest_dir`: <string> The path to tempest workspace directory (default: /home/stack/tempest)
49* `tempest_data`: <string> The path to keep tempest related files used for running tempest (default: /home/stack)
49* `test_black_regex`: <list> A set of tempest tests to skip (default: []) 50* `test_black_regex`: <list> A set of tempest tests to skip (default: [])
50* `tempest_version_dict`: <dict> A dict with release name as key and tempest tag version for that release as value 51* `tempest_version_dict`: <dict> A dict with release name as key and tempest tag version for that release as value
51* `tempest_version`: <string> The tempest version to use for running tempest 52* `tempest_version`: <string> The tempest version to use for running tempest
diff --git a/roles/validate-tempest/defaults/main.yml b/roles/validate-tempest/defaults/main.yml
index ae5d600..1d3be96 100644
--- a/roles/validate-tempest/defaults/main.yml
+++ b/roles/validate-tempest/defaults/main.yml
@@ -36,7 +36,18 @@ tempest_container_tag: >-
36 {%- else -%} 36 {%- else -%}
37 {{ docker_image_tag }} 37 {{ docker_image_tag }}
38 {%- endif %} 38 {%- endif %}
39tempest_dir: "{{ working_dir }}/tempest" 39tempest_dir: >-
40 {% if tempest_format in ['container'] -%}
41 /var/lib/tempest/tempest
42 {%- else -%}
43 {{ working_dir }}/tempest
44 {%- endif %}
45tempest_data: >-
46 {% if tempest_format in ['container'] -%}
47 /var/lib/tempest
48 {%- else -%}
49 {{ working_dir }}
50 {%- endif %}
40tempest_whitelist_file_src: "whitelist_file.j2" 51tempest_whitelist_file_src: "whitelist_file.j2"
41tempest_whitelist_file: "whitelist_file.conf" 52tempest_whitelist_file: "whitelist_file.conf"
42tempest_whitelist: [] 53tempest_whitelist: []
diff --git a/roles/validate-tempest/tasks/pre-tempest.yml b/roles/validate-tempest/tasks/pre-tempest.yml
index 73f2c68..4a474a1 100644
--- a/roles/validate-tempest/tasks/pre-tempest.yml
+++ b/roles/validate-tempest/tasks/pre-tempest.yml
@@ -8,6 +8,11 @@
8 set_fact: 8 set_fact:
9 rc_file: "{{ working_dir }}/{% if tempest_undercloud %}stackrc{% else %}overcloudrc{% endif %}" 9 rc_file: "{{ working_dir }}/{% if tempest_undercloud %}stackrc{% else %}overcloudrc{% endif %}"
10 10
11- name: Set rc file to be sourced to run tempest with in container
12 set_fact:
13 rc_file_container: "{{ tempest_data }}/{% if tempest_undercloud %}stackrc{% else %}overcloudrc{% endif %}"
14 when: tempest_format == 'container'
15
11- name: Create overcloud tempest setup script 16- name: Create overcloud tempest setup script
12 template: 17 template:
13 src: tempest-setup.j2 18 src: tempest-setup.j2
diff --git a/roles/validate-tempest/tasks/tempest-containers.yml b/roles/validate-tempest/tasks/tempest-containers.yml
index 01574ea..355f878 100644
--- a/roles/validate-tempest/tasks/tempest-containers.yml
+++ b/roles/validate-tempest/tasks/tempest-containers.yml
@@ -1,8 +1,8 @@
1--- 1---
2- name: Set tempest init command 2- name: Set tempest init command
3 set_fact: 3 set_fact:
4 tempest_init: "{% if release == 'newton' %}/usr/share/openstack-tempest-*/tools/configure-tempest-directory{% else %}tempest init {{ tempest_dir }}{% endif %}" 4 tempest_init: "tempest init {{ tempest_dir }}"
5 5
6- name: Set tempestconf call 6- name: Set tempestconf call
7 set_fact: 7 set_fact:
8 tempestconf: "{% if release == 'newton' %}{{ working_dir }}/tools/config_tempest.py{% else %}/usr/bin/discover-tempest-config{% endif %}" 8 tempestconf: "/usr/bin/discover-tempest-config"
diff --git a/roles/validate-tempest/templates/configure-tempest.sh.j2 b/roles/validate-tempest/templates/configure-tempest.sh.j2
index a978f16..bf40621 100644
--- a/roles/validate-tempest/templates/configure-tempest.sh.j2
+++ b/roles/validate-tempest/templates/configure-tempest.sh.j2
@@ -10,10 +10,10 @@
10# to create tempest directory. 10# to create tempest directory.
11# We are doing this as sudo because tempest in containers create the files as 11# We are doing this as sudo because tempest in containers create the files as
12# root. 12# root.
13{% if tempest_format in ["venv", "packages"] %}
13sudo rm -rf {{ working_dir }}/.tempest 14sudo rm -rf {{ working_dir }}/.tempest
14sudo rm -rf {{ tempest_dir }} 15sudo rm -rf {{ tempest_dir }}
15# Remove tempest_data directory created before running tempest container 16{% endif %}
16sudo rm -rf {{ working_dir }}/tempest_data
17 17
18 18
19# Cloud Credentials 19# Cloud Credentials
@@ -75,12 +75,17 @@ set -e
75 75
76rpm -qa | grep tempest 76rpm -qa | grep tempest
77 77
78# Remove the existing tempest workspace
79if [ -d {{ tempest_dir }}/etc ]; then
80tempest workspace remove --name {{ tempest_dir | basename }} --rmdir
81fi
78{% endif %} 82{% endif %}
79 83
80## Create Tempest Workspace 84## Create Tempest Workspace
81## ------------------------ 85## ------------------------
82## :: 86## ::
83 87
88
84# Create Tempest directory 89# Create Tempest directory
85 90
86mkdir {{ tempest_dir }} 91mkdir {{ tempest_dir }}
@@ -95,7 +100,9 @@ popd
95## :: 100## ::
96export TEMPESTCONF="{{ tempestconf }}" 101export TEMPESTCONF="{{ tempestconf }}"
97 102
98{% if tempest_os_cloud == '' %} 103{% if tempest_format == 'container' %}
104source {{ rc_file_container }}
105{% elif tempest_os_cloud == '' %}
99source {{ rc_file }} 106source {{ rc_file }}
100{% endif %} 107{% endif %}
101 108
@@ -128,7 +135,7 @@ export OS_AUTH_URL="$OS_AUTH_URL/v2.0"
128cd {{ tempest_dir }} 135cd {{ tempest_dir }}
129$TEMPESTCONF --out etc/tempest.conf \ 136$TEMPESTCONF --out etc/tempest.conf \
130 {% if tempest_overcloud|bool %} 137 {% if tempest_overcloud|bool %}
131 --deployer-input {{ working_dir }}/{{ tempest_deployer_input_file }} \ 138 --deployer-input {{ tempest_dir }}/{{ tempest_deployer_input_file }} \
132 --network-id $public_net_id \ 139 --network-id $public_net_id \
133 {% endif %} 140 {% endif %}
134 {% if tempest_os_cloud != '' %} 141 {% if tempest_os_cloud != '' %}
diff --git a/roles/validate-tempest/templates/run-tempest.sh.j2 b/roles/validate-tempest/templates/run-tempest.sh.j2
index 973bcde..e993150 100644
--- a/roles/validate-tempest/templates/run-tempest.sh.j2
+++ b/roles/validate-tempest/templates/run-tempest.sh.j2
@@ -10,6 +10,7 @@ export OSTESTR='{{ working_dir }}/tempest_git/tools/with_venv.sh ostestr'
10export OSTESTR='ostestr' 10export OSTESTR='ostestr'
11export TEMPESTCLI='/usr/bin/tempest' 11export TEMPESTCLI='/usr/bin/tempest'
12{% endif %} 12{% endif %}
13export TEMPESTDATA={{ tempest_data }}
13 14
14## List tempest plugins 15## List tempest plugins
15 16
@@ -26,9 +27,9 @@ $TEMPESTCLI cleanup --init-saved-state
26{% endif %} 27{% endif %}
27 28
28{% if release in ["newton", "ocata", "pike"] %} $OSTESTR {% else %} $TEMPESTCLI run {% endif %}{% if test_white_regex != '' %} --regex '({{ test_white_regex }})' {% endif %} 29{% if release in ["newton", "ocata", "pike"] %} $OSTESTR {% else %} $TEMPESTCLI run {% endif %}{% if test_white_regex != '' %} --regex '({{ test_white_regex }})' {% endif %}
29{% if tempest_whitelist|length > 0 %} --whitelist_file={{ working_dir }}/{{ tempest_whitelist_file }} {% endif %} 30{% if tempest_whitelist|length > 0 %} --whitelist_file=$TEMPESTDATA/{{ tempest_whitelist_file }} {% endif %}
30{% if release not in ["newton", "ocata", "pike"] %} {% if test_black_regex|length > 0 %} --black-regex='{{ test_black_regex|join('|') }}' {% endif %} {% endif %} 31{% if release not in ["newton", "ocata", "pike"] %} {% if test_black_regex|length > 0 %} --black-regex='{{ test_black_regex|join('|') }}'{% endif %} {% endif %}
31{% if skip_file_src != '' %} --blacklist_file={{ working_dir }}/{{ skip_file }} {% endif %} 32{% if skip_file_src != '' %} --blacklist_file=$TEMPESTDATA/{{ skip_file }} {% endif %}
32{% if tempest_workers is defined %} --concurrency {{ tempest_workers }} {% endif %} 33{% if tempest_workers is defined %} --concurrency {{ tempest_workers }} {% endif %}
33{% if tempest_until_failure|bool %} --until-failure {% endif %} 34{% if tempest_until_failure|bool %} --until-failure {% endif %}
34 35
@@ -44,9 +45,14 @@ $TEMPESTCLI cleanup --dry-run
44EOF 45EOF
45chmod +x {{ working_dir }}/tempest_container.sh 46chmod +x {{ working_dir }}/tempest_container.sh
46# Copy all the required files in a temprory directory 47# Copy all the required files in a temprory directory
47mkdir {{ working_dir }}/tempest_data 48export TEMPEST_HOST_DATA='/var/lib/tempestdata'
48 49
49cp $RCFILE \ 50if [ ! -d $TEMPEST_HOST_DATA ]
51then
52 mkdir -p $TEMPEST_HOST_DATA
53fi
54
55sudo cp $RCFILE \
50 {% if skip_file_src != '' %} 56 {% if skip_file_src != '' %}
51 {{ working_dir }}/{{ skip_file }} \ 57 {{ working_dir }}/{{ skip_file }} \
52 {% endif %} 58 {% endif %}
@@ -57,46 +63,33 @@ cp $RCFILE \
57 {{ working_dir }}/{{ tempest_deployer_input_file }} \ 63 {{ working_dir }}/{{ tempest_deployer_input_file }} \
58 {% endif %} 64 {% endif %}
59 {{ working_dir }}/tempest_container.sh \ 65 {{ working_dir }}/tempest_container.sh \
60 {{ working_dir }}/tempest_data 66 $TEMPEST_HOST_DATA
61 67
62# TODO(chkumar246): https://review.openstack.org/#/c/583940/ added tempest user to 68{% if undercloud_container_cli is defined %}
63# tempest container, The file getting mounted from host to tempest container have 69export CONTAINER_BINARY={{ undercloud_container_cli }}
64# different permission as tempest user does not own those folders which will give 70{% else %}
65# permission denied So first check whether tempest user is there or not if present 71export CONTAINER_BINARY='docker'
66# run the docker command to change the dir permission and if not found the usual 72{% endif %}
67# command, Once new container image is available after promotion, we will the add 73
68# the volume in THT itself and fix other stuffs. Also pull docker image locally 74sudo $CONTAINER_BINARY pull {{ tempest_container_registry }}/{{ tempest_container_namespace }}:{{ tempest_container_tag }}
69# as docker inspect needs the image to exist.
70sudo docker pull {{ tempest_container_registry }}/{{ tempest_container_namespace }}:{{ tempest_container_tag }}
71if [ x$(sudo docker inspect --format "{{ '{{' }} .Config.User {{ '}}' }}" {{ tempest_container_registry }}/{{ tempest_container_namespace }}:{{ tempest_container_tag }}) == 'xtempest' ]; then
72 sudo docker run --net=host -u root -v {{ working_dir }}/tempest_data:{{ working_dir }} \
73 {% if not 'http' in tempest_test_image_path %}
74 -v {{ tempest_test_image_path }}:{{ tempest_test_image_path }} \
75 {% endif %}
76 {{ tempest_container_registry }}/{{ tempest_container_namespace }}:{{ tempest_container_tag }} \
77 chown -R tempest:tempest \
78 {% if not 'http' in tempest_test_image_path %}
79 {{ tempest_test_image_path }} \
80 {% endif %}
81 {{ working_dir }}
82fi
83 75
84# Run tempest container using docker mouting required files 76# Run tempest container using docker mouting required files
85sudo docker run --net=host -i -v {{ working_dir }}/tempest_data/:{{ working_dir }} \ 77sudo $CONTAINER_BINARY run --net=host -i -v $TEMPEST_HOST_DATA:{{ tempest_data }} \
86 -e PYTHONWARNINGS="${PYTHONWARNINGS:-}" \ 78 -e PYTHONWARNINGS="${PYTHONWARNINGS:-}" \
87 -e CURL_CA_BUNDLE="" \ 79 -e CURL_CA_BUNDLE="" \
80 --user=root \
88 -v /var/log/containers/tempest:{{ tempest_log_dir }} \ 81 -v /var/log/containers/tempest:{{ tempest_log_dir }} \
89 {% if not 'http' in tempest_test_image_path %} 82 {% if not 'http' in tempest_test_image_path %}
90 -v {{ tempest_test_image_path }}:{{ tempest_test_image_path }} \ 83 -v {{ tempest_test_image_path }}:{{ tempest_test_image_path }} \
91 {% endif %} 84 {% endif %}
92 {{ tempest_container_registry }}/{{ tempest_container_namespace }}:{{ tempest_container_tag }} \ 85 {{ tempest_container_registry }}/{{ tempest_container_namespace }}:{{ tempest_container_tag }} \
93 /usr/bin/bash -c 'set -e; {{ working_dir }}/tempest_container.sh' 86 /usr/bin/bash -c 'set -e; {{ tempest_data }}/tempest_container.sh'
94 87
95# Change permission of tempest workspace directory 88# Change permission of tempest workspace directory
96sudo chmod -R 777 {{ working_dir }}/tempest_data 89sudo chmod -R 777 $TEMPEST_HOST_DATA
97 90
98# Copy tempest related data to tempest folder so that stackviz can use it 91# Copy tempest related data to tempest folder so that stackviz can use it
99cp -R {{ working_dir }}/tempest_data/tempest {{ working_dir }} 92cp -R $TEMPEST_HOST_DATA/tempest {{ working_dir }}
100 93
101{% endif %} 94{% endif %}
102### --stop_docs 95### --stop_docs