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:
voting: false
- airship-deckhand-functional-docker-py35
- airship-deckhand-functional-uwsgi-py35
gate:
jobs:
- airship-deckhand-linter
@ -27,6 +28,7 @@
# - ^doc/.*$
# - ^releasenotes/.*$
- airship-deckhand-functional-docker-py35
- airship-deckhand-functional-uwsgi-py35
- job:
name: airship-deckhand-linter
@ -80,6 +82,17 @@
- ^doc/.*$
- ^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:
name: airship-deckhand-functional-docker-py35
description: |

View File

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

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 {
#######################################
# Generate sample configuration file
# Globals:
# CONF_DIR
# DECKHAND_TEST_URL
# DATABASE_URL
# AIRSHIP_DECKHAND_DATABASE_URL
# DECKHAND_CONFIG_DIR
# Arguments:
# disable_keystone: true or false
@ -57,7 +23,7 @@ function gen_config {
# Returns:
# None
#######################################
set -xe
set -xe;
log_section "Creating config directory and test deckhand.conf"
@ -66,14 +32,13 @@ function gen_config {
local disable_keystone=$1
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.
export DECKHAND_CONFIG_DIR=$CONF_DIR
local conf_file=${CONF_DIR}/deckhand.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
# values for logging.
@ -104,7 +69,7 @@ function gen_paste {
# Returns:
# None
#######################################
set -xe
set -xe;
local disable_keystone=$1

View File

@ -2,6 +2,8 @@
# Script intended for running Deckhand functional tests via gabbi for
# developers. Dependencies include gabbi, pifpaf and uwsgi.
#
# Usage: pifpaf run postgresql -- tools/functional-tests.sh
set -xe
@ -26,41 +28,38 @@ function cleanup_deckhand {
trap cleanup_deckhand EXIT
function deploy_postgresql {
eval `pifpaf run postgresql`
export POSTGRES_IP=${PIFPAF_POSTGRESQL_URL}
}
function deploy_deckhand {
source ${CURRENT_DIR}/common-tests.sh
gen_config true "127.0.0.1:9000"
gen_paste true
log_section "Running Deckhand via uwsgi."
alembic upgrade head
source $ROOTDIR/../entrypoint.sh server &
source ${CURRENT_DIR}/entrypoint.sh alembic upgrade head &
# 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.
sleep 5
}
export AIRSHIP_DECKHAND_DATABASE_URL=${PIFPAF_POSTGRESQL_URL}
# Deploy Deckhand and PostgreSQL and run tests.
deploy_postgresql
source ${CURRENT_DIR}/tools/common-tests.sh
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
posargs=$@
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
py.test -svx ${CURRENT_DIR}/../deckhand/tests/common/test_gabbi.py
py.test -svx ${CURRENT_DIR}/deckhand/tests/common/test_gabbi.py
fi
TEST_STATUS=$?
set -e

View File

@ -15,6 +15,8 @@
- hosts: all
gather_facts: False
roles:
- install-postgresql
- run-tests
tags:
- install-postgresql
- 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 PostgreSQL and Deckhand.
deploy_postgre
deploy_postgresql
deploy_deckhand
run_tests "$@"

View File

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