Add uwsgi functional test check to .zuul.yaml

This adds a uwsgi functional test check to .zuul.yaml so that
deploying Deckhand via uwsgi (in a more standalone fashion,
sans containerization) works as intended.

Change-Id: I931ab4d11719daca7665d3a25b00e353c707237e
This commit is contained in:
Felipe Monteiro 2018-05-29 10:45:40 -04:00
parent 119080b597
commit 3d53d53712
9 changed files with 74 additions and 57 deletions

View File

@ -17,6 +17,7 @@
- airship-deckhand-ubuntu: - airship-deckhand-ubuntu:
voting: false voting: false
- airship-deckhand-functional-docker-py35 - airship-deckhand-functional-docker-py35
- airship-deckhand-functional-uwsgi-py35
gate: gate:
jobs: jobs:
- airship-deckhand-linter - airship-deckhand-linter
@ -27,6 +28,7 @@
# - ^doc/.*$ # - ^doc/.*$
# - ^releasenotes/.*$ # - ^releasenotes/.*$
- airship-deckhand-functional-docker-py35 - airship-deckhand-functional-docker-py35
- airship-deckhand-functional-uwsgi-py35
- job: - job:
name: airship-deckhand-linter name: airship-deckhand-linter
@ -80,6 +82,17 @@
- ^doc/.*$ - ^doc/.*$
- ^releasenotes/.*$ - ^releasenotes/.*$
- job:
name: airship-deckhand-functional-uwsgi-py35
description: |
Run tox-based functional tests for the Airship Deckhand project using a
minimalistic deployment consisting of uwsgi for Deckhand API and pifpaf
for ephemeral PostgreSQL DB, under cPython version 3.5.
run: tools/gate/playbooks/run-functional-tests-uwsgi.yaml
nodeset: openstack-helm-single-node
vars:
tox_envlist: functional-dev
- job: - job:
name: airship-deckhand-functional-docker-py35 name: airship-deckhand-functional-docker-py35
description: | description: |

View File

@ -15,5 +15,4 @@ testrepository>=0.0.20 # Apache-2.0/BSD
testtools>=2.3.0 # MIT testtools>=2.3.0 # MIT
bandit>=1.4.0 # Apache-2.0 bandit>=1.4.0 # Apache-2.0
gabbi==1.35.1 gabbi==1.35.1
pytest-html==1.16.1 pifpaf>=0.10.0 # Apache-2.0
pifpaf==2.0.5

View File

@ -9,47 +9,13 @@ function log_section {
} }
function deploy_postgre {
#######################################
# Deploy an ephemeral PostgreSQL DB.
# Globals:
# POSTGRES_ID
# POSTGRES_IP
# Arguments:
# None
# Returns:
# None
#######################################
set -xe
# TODO(felipemonteiro): Use OSH PostgreSQL chart.
POSTGRES_ID=$(
sudo docker run \
--detach \
--publish :5432 \
-e POSTGRES_DB=deckhand \
-e POSTGRES_USER=deckhand \
-e POSTGRES_PASSWORD=password \
postgres:9.5
)
POSTGRES_IP=$(
sudo docker inspect \
--format='{{ .NetworkSettings.Networks.bridge.IPAddress }}' \
$POSTGRES_ID
)
echo $POSTGRES_IP
}
function gen_config { function gen_config {
####################################### #######################################
# Generate sample configuration file # Generate sample configuration file
# Globals: # Globals:
# CONF_DIR # CONF_DIR
# DECKHAND_TEST_URL # DECKHAND_TEST_URL
# DATABASE_URL # AIRSHIP_DECKHAND_DATABASE_URL
# DECKHAND_CONFIG_DIR # DECKHAND_CONFIG_DIR
# Arguments: # Arguments:
# disable_keystone: true or false # disable_keystone: true or false
@ -57,7 +23,7 @@ function gen_config {
# Returns: # Returns:
# None # None
####################################### #######################################
set -xe set -xe;
log_section "Creating config directory and test deckhand.conf" log_section "Creating config directory and test deckhand.conf"
@ -66,14 +32,13 @@ function gen_config {
local disable_keystone=$1 local disable_keystone=$1
export DECKHAND_TEST_URL=$2 export DECKHAND_TEST_URL=$2
export DATABASE_URL=postgresql+psycopg2://deckhand:password@$POSTGRES_IP:5432/deckhand
# Used by Deckhand's initialization script to search for config files. # Used by Deckhand's initialization script to search for config files.
export DECKHAND_CONFIG_DIR=$CONF_DIR export DECKHAND_CONFIG_DIR=$CONF_DIR
local conf_file=${CONF_DIR}/deckhand.conf local conf_file=${CONF_DIR}/deckhand.conf
cp etc/deckhand/logging.conf.sample $CONF_DIR/logging.conf cp etc/deckhand/logging.conf.sample $CONF_DIR/logging.conf
envsubst '${DATABASE_URL}' < deckhand/tests/deckhand.conf.test > $conf_file envsubst '${AIRSHIP_DECKHAND_DATABASE_URL}' < deckhand/tests/deckhand.conf.test > $conf_file
# Only set up logging if running Deckhand via uwsgi. The container already has # Only set up logging if running Deckhand via uwsgi. The container already has
# values for logging. # values for logging.
@ -104,7 +69,7 @@ function gen_paste {
# Returns: # Returns:
# None # None
####################################### #######################################
set -xe set -xe;
local disable_keystone=$1 local disable_keystone=$1

View File

@ -2,6 +2,8 @@
# Script intended for running Deckhand functional tests via gabbi for # Script intended for running Deckhand functional tests via gabbi for
# developers. Dependencies include gabbi, pifpaf and uwsgi. # developers. Dependencies include gabbi, pifpaf and uwsgi.
#
# Usage: pifpaf run postgresql -- tools/functional-tests.sh
set -xe set -xe
@ -26,41 +28,38 @@ function cleanup_deckhand {
trap cleanup_deckhand EXIT trap cleanup_deckhand EXIT
function deploy_postgresql {
eval `pifpaf run postgresql`
export POSTGRES_IP=${PIFPAF_POSTGRESQL_URL}
}
function deploy_deckhand { function deploy_deckhand {
source ${CURRENT_DIR}/common-tests.sh
gen_config true "127.0.0.1:9000" gen_config true "127.0.0.1:9000"
gen_paste true gen_paste true
log_section "Running Deckhand via uwsgi." log_section "Running Deckhand via uwsgi."
alembic upgrade head source ${CURRENT_DIR}/entrypoint.sh alembic upgrade head &
source $ROOTDIR/../entrypoint.sh server & # Give time for migrations to complete.
sleep 5
source ${CURRENT_DIR}/entrypoint.sh server &
# Give the server a chance to come up. Better to poll a health check. # Give the server a chance to come up. Better to poll a health check.
sleep 5 sleep 5
} }
export AIRSHIP_DECKHAND_DATABASE_URL=${PIFPAF_POSTGRESQL_URL}
# Deploy Deckhand and PostgreSQL and run tests. # Deploy Deckhand and PostgreSQL and run tests.
deploy_postgresql source ${CURRENT_DIR}/tools/common-tests.sh
deploy_deckhand deploy_deckhand
log_section Running tests log_section "Running tests."
export DECKHAND_TEST_DIR=${CURRENT_DIR}/../deckhand/tests/functional/gabbits export DECKHAND_TEST_DIR=${CURRENT_DIR}/deckhand/tests/functional/gabbits
set +e set +e
posargs=$@ posargs=$@
if [ ${#posargs} -ge 1 ]; then if [ ${#posargs} -ge 1 ]; then
py.test -k $1 -svx ${CURRENT_DIR}/../deckhand/tests/common/test_gabbi.py py.test -k $1 -svx ${CURRENT_DIR}/deckhand/tests/common/test_gabbi.py
else else
py.test -svx ${CURRENT_DIR}/../deckhand/tests/common/test_gabbi.py py.test -svx ${CURRENT_DIR}/deckhand/tests/common/test_gabbi.py
fi fi
TEST_STATUS=$? TEST_STATUS=$?
set -e set -e

View File

@ -15,6 +15,8 @@
- hosts: all - hosts: all
gather_facts: False gather_facts: False
roles: roles:
- install-postgresql
- run-tests - run-tests
tags: tags:
- install-postgresql
- run-tests - run-tests

View File

@ -0,0 +1,23 @@
# 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: Install PostgreSQL
shell: |-
set -xe;
if [ -z $(which pg_config) ]; then
apt-get update -y
apt-get install postgresql postgresql-contrib -y
apt-get install libpq-dev -y
fi
become: yes

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: install-postgresql.yaml

View File

@ -206,7 +206,7 @@ source ${CURRENT_DIR}/tools/common-tests.sh
deploy_osh_keystone_barbican deploy_osh_keystone_barbican
# Deploy PostgreSQL and Deckhand. # Deploy PostgreSQL and Deckhand.
deploy_postgre deploy_postgresql
deploy_deckhand deploy_deckhand
run_tests "$@" run_tests "$@"

View File

@ -54,12 +54,13 @@ commands =
basepython=python3.5 basepython=python3.5
# Minimalistic functional test job for running Deckhand functional tests # Minimalistic functional test job for running Deckhand functional tests
# via uwsgi. Uses pifpaf for DB instantiation. Useful for developers. # via uwsgi. Uses pifpaf for DB instantiation. Useful for developers.
# Requires PostgreSQL be installed on host.
setenv = VIRTUAL_ENV={envdir} setenv = VIRTUAL_ENV={envdir}
deps = -r{toxinidir}/requirements.txt deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt -r{toxinidir}/test-requirements.txt
commands = commands =
find . -type f -name "*.pyc" -delete find . -type f -name "*.pyc" -delete
{toxinidir}/tools/functional-tests.sh '{posargs}' pifpaf run postgresql -- {toxinidir}/tools/functional-tests.sh "{posargs}"
[testenv:cover] [testenv:cover]
setenv = {[testenv]setenv} setenv = {[testenv]setenv}