Add functional tests to .zuul.yaml

This patchset adds functional tests to .zuul.yaml. Additionally
it adds a functional-py35 job as well which will also be kicked
off via Zuul.

Change-Id: Ic2d1db4d3cd65c4d93c3a6f04e6efeeba9755f07
This commit is contained in:
Felipe Monteiro 2018-05-17 22:57:51 +01:00
parent d75977d6c0
commit 1cbe993b6b
11 changed files with 212 additions and 14 deletions

3
.gitignore vendored
View File

@ -109,6 +109,9 @@ ENV/
#pycharm-ide
.idea/
# osx
.DS_Store
# makefile build/lint artifacts
/charts/deckhand/*.tgz
/charts/deckhand/*.lock

View File

@ -16,10 +16,8 @@
- airship-deckhand-linter
- airship-deckhand-ubuntu:
voting: false
irrelevant-files:
- ^.*\.rst$
- ^doc/.*$
- ^releasenotes/.*$
- airship-deckhand-tox-functional
- airship-deckhand-tox-functional-py35
gate:
jobs:
- airship-deckhand-linter
@ -29,19 +27,23 @@
# - ^.*\.rst$
# - ^doc/.*$
# - ^releasenotes/.*$
- airship-deckhand-tox-functional
- airship-deckhand-tox-functional-py35
- job:
name: airship-deckhand-linter
description: |
Lints all files by checking them for whitespace.
run: tools/gate/playbooks/zuul-linter.yaml
nodeset: openstack-helm-single-node
- job:
name: airship-deckhand
name: airship-deckhand-base
roles:
- zuul: openstack/openstack-helm-infra
vars:
zuul_osh_infra_relative_path: ../openstack-helm-infra/
timeout: 7200
timeout: 3600
pre-run:
- tools/gate/playbooks/osh-infra-upgrade-host.yaml
- tools/gate/playbooks/osh-infra-deploy-docker.yaml
@ -54,5 +56,48 @@
- job:
name: airship-deckhand-ubuntu
parent: airship-deckhand
parent: airship-deckhand-base
nodeset: openstack-helm-single-node
irrelevant-files:
- ^.*\.rst$
- ^doc/.*$
- ^releasenotes/.*$
- job:
name: airship-deckhand-tox-functional-base
description: |
Base job for running airship-deckhand functional tests. Runs tests
against Docker image generated from source code.
roles:
- zuul: openstack/openstack-helm-infra
timeout: 3600
pre-run:
- tools/gate/playbooks/osh-infra-upgrade-host.yaml
- tools/gate/playbooks/osh-infra-deploy-docker.yaml
run: tools/gate/playbooks/run-functional-tests.yaml
required-projects:
- openstack/openstack-helm-infra
irrelevant-files:
- ^.*\.rst$
- ^doc/.*$
- ^releasenotes/.*$
- job:
name: airship-deckhand-tox-functional
description: |
Run tox-based functional tests for the Airship Deckhand project under
cPython version 2.7. Uses tox with the ``functional`` environment.
parent: airship-deckhand-tox-functional-base
nodeset: openstack-helm-single-node
vars:
tox_envlist: functional
- job:
name: airship-deckhand-tox-functional-py35
description: |
Run tox-based functional tests for the Airship Deckhand project under
cPython version 3.5. Uses tox with the ``functional-py35`` environment.
parent: airship-deckhand-tox-functional-base
nodeset: openstack-helm-single-node
vars:
tox_envlist: functional-py35

View File

@ -22,6 +22,7 @@ function deploy_postgre {
#######################################
set -xe
# TODO(felipemonteiro): Use OSH PostgreSQL chart.
POSTGRES_ID=$(
sudo docker run \
--detach \

View File

@ -33,11 +33,13 @@ function cleanup_deckhand {
rm -rf $CONF_DIR
# Kill all processes and child processes (for example, if workers > 1)
# if using uwsgi only.
PGID=$(ps -o comm -o pgid | grep uwsgi | grep -o [0-9]* | head -n 1)
if [ -n "$PGID" ]; then
setsid kill -- -$PGID
if [ -z "$DECKHAND_IMAGE" ]; then
# Kill uwsgi service if it is still running.
PID=$( sudo netstat -tulpn | grep ":9000" | head -n 1 | awk '{print $NF}' )
if [ -n $PID ]; then
PID=${PID%/*}
sudo kill -9 $PID
fi
fi
}

1
tools/gate/playbooks/roles Symbolic link
View File

@ -0,0 +1 @@
../roles/

View File

@ -0,0 +1,28 @@
# Copyright 2018 AT&T Intellectual Property. All other rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
- hosts: all
gather_facts: False
become: yes
roles:
- build-images
tags:
- build-images
- hosts: all
gather_facts: False
roles:
- run-tests
tags:
- run-tests

View File

@ -0,0 +1,56 @@
# Copyright 2018 AT&T Intellectual Property. All other rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
- name: set zuul_site_mirror_fqdn from env var if not defined
when: zuul_site_mirror_fqdn is not defined
set_fact:
zuul_site_mirror_fqdn: "{{ lookup('env','zuul_site_mirror_fqdn') }}"
# NOTE(portdirect): Untill https://github.com/ansible/ansible/issues/21433 is
# resolved, we build with a shell script to make use of the host network.
- name: Build Airship-Deckhand Image
block:
# NOTE(portdirect): We do this to ensure we are feeding the docker build
# a clean path to work with.
- name: Airship-Deckhand image build path
shell: cd "{{ work_dir }}"; pwd
register: airship_deckhand_path
vars:
zuul_airship_deckhand_relative_path: ../airship-deckhand
work_dir: "{{ zuul.project.src_dir }}/{{ zuul_airship_deckhand_relative_path | default('') }}"
- name: Airship-Deckhand image build path
shell: |-
set -ex;
docker build \
--network host \
--force-rm \
--label zuul \
--file images/deckhand/Dockerfile \
{% if zuul_site_mirror_fqdn is defined and zuul_site_mirror_fqdn %}
--build-arg UBUNTU_URL="http://{{ zuul_site_mirror_fqdn }}/ubuntu/" \
--build-arg ALLOW_UNAUTHENTICATED="true" \
--build-arg PIP_INDEX_URL="http://{{ zuul_site_mirror_fqdn }}/pypi/simple" \
--build-arg PIP_TRUSTED_HOST="{{ zuul_site_mirror_fqdn }}" \
{% endif %}
.
args:
chdir: "{{ airship_deckhand_path.stdout }}"
executable: /bin/bash
- name: Register Deckhand Image ID
shell: |-
set -e;
echo $( docker images --filter label=zuul | awk '{print $3}' | head -2 | tail -1 )
register: deckhand_image_id

View File

@ -0,0 +1,15 @@
# Copyright 2018 AT&T Intellectual Property. All other rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
- include: airship-deckhand.yaml

View File

@ -0,0 +1,15 @@
# Copyright 2018 AT&T Intellectual Property. All other rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
- include: tox-tests.yaml

View File

@ -0,0 +1,22 @@
# Copyright 2018 AT&T Intellectual Property. All other rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Run Tox Tests
shell: |
set -xe;
tox -e {{ tox_envlist }}
args:
chdir: "{{ zuul.project.src_dir }}"
environment:
DECKHAND_IMAGE: "{{ deckhand_image_id.stdout }}"

14
tox.ini
View File

@ -1,5 +1,5 @@
[tox]
envlist = py{35,27},py{35,27}-{postgresql},cover,pep8,bandit,docs
envlist = py{35,27},py{35,27}-{postgresql},functional,cover,pep8,bandit,docs
[testenv]
usedevelop = True
@ -41,7 +41,17 @@ commands =
{toxinidir}/tools/run_pifpaf.sh '{posargs}'
[testenv:functional]
# Always run functional tests using Python 3.
basepython = python2.7
setenv = VIRTUAL_ENV={envdir}
OS_TEST_PATH=./deckhand/tests/functional
LANGUAGE=en_US
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
commands =
find . -type f -name "*.pyc" -delete
{toxinidir}/tools/functional-tests.sh '{posargs}'
[testenv:functional-py35]
basepython=python3.5
setenv = VIRTUAL_ENV={envdir}
OS_TEST_PATH=./deckhand/tests/functional