Zuul: Integration tests via uwsgi.

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

Change-Id: I933f4781cd72e2df309efcb0515441db7ab96895
This commit is contained in:
Felipe Monteiro 2018-05-31 04:37:24 +01:00
parent 3d53d53712
commit a552bf2a0f
10 changed files with 101 additions and 69 deletions

View File

@ -18,6 +18,7 @@
voting: false
- airship-deckhand-functional-docker-py35
- airship-deckhand-functional-uwsgi-py35
- airship-deckhand-integration-uwsgi-py35
gate:
jobs:
- airship-deckhand-linter
@ -29,6 +30,7 @@
# - ^releasenotes/.*$
- airship-deckhand-functional-docker-py35
- airship-deckhand-functional-uwsgi-py35
- airship-deckhand-integration-uwsgi-py35
- job:
name: airship-deckhand-linter
@ -103,3 +105,12 @@
vars:
tox_envlist: functional
disable_keystone: true
- job:
name: airship-deckhand-integration-uwsgi-py35
description: |
Run tox-based integration 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-integration-tests-uwsgi.yaml
nodeset: openstack-helm-single-node

View File

@ -36,11 +36,11 @@ function deploy_deckhand {
source ${CURRENT_DIR}/entrypoint.sh alembic upgrade head &
# Give time for migrations to complete.
sleep 5
sleep 10
source ${CURRENT_DIR}/entrypoint.sh server &
# Give the server a chance to come up. Better to poll a health check.
sleep 5
sleep 10
}

View File

@ -44,6 +44,6 @@
- hosts: all
gather_facts: False
roles:
- run-tests
- run-functional-tests
tags:
- run-tests
- run-functional-tests

View File

@ -16,7 +16,7 @@
gather_facts: False
roles:
- install-postgresql
- run-tests
- run-functional-tests
tags:
- install-postgresql
- run-tests
- run-functional-tests

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.
- hosts: all
gather_facts: False
roles:
- install-postgresql
- run-integration-tests
tags:
- install-postgresql
- run-integration-tests

View File

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Run Tox Tests
- name: Run Functional Tests
shell: |
set -xe;
tox -e "{{ tox_envlist }}"
@ -21,3 +21,5 @@
environment:
DECKHAND_TEST_URL: "127.0.0.1:9000"
DECKHAND_TEST_DIR: "{{ airship_deckhand_path.stdout }}/deckhand/tests/functional/gabbits"
register: result
failed_when: "'Done SUCCESS' not in result.stdout and 'PASSED' not in result.stdout"

View File

@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
- include: tox-tests.yaml
- include: functional-tests.yaml

View File

@ -0,0 +1,30 @@
# 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 Integration Tests
shell: |
set -xe;
# NOTE(felipemonteiro): We don't use a venv because they don't play nicely
# with OpenStack-Helm, which is used to orchestrate various OpenStack
# services in the integration script called below.
sudo -H -E pip install -e .
sudo -H -E pip install -r requirements.txt -r test-requirements.txt
pifpaf run postgresql -- ./tools/integration-tests.sh
args:
chdir: "{{ zuul.project.src_dir }}"
environment:
DECKHAND_TEST_URL: "127.0.0.1:9000"
DECKHAND_TEST_DIR: "{{ airship_deckhand_path.stdout }}/deckhand/tests/integration/gabbits"
register: result
failed_when: "'Done SUCCESS' not in result.stdout and 'PASSED' not in result.stdout"

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: integration-tests.yaml

View File

@ -12,47 +12,11 @@
set -xe
DECKHAND_IMAGE=${DECKHAND_IMAGE:-quay.io/attcomdev/deckhand:latest}
CURRENT_DIR="$(pwd)"
: ${OSH_INFRA_PATH:="../openstack-helm-infra"}
: ${OSH_PATH:="../openstack-helm"}
function cleanup_osh {
set -xe
if [ -n "command -v kubectl" ]; then
kubectl delete namespace openstack
kubectl delete namespace ucp
fi
sudo systemctl disable kubelet --now
sudo systemctl stop kubelet
if [ -n "command -v docker" ]; then
sudo docker ps -aq | xargs -L1 -P16 sudo docker rm -f
fi
sudo rm -rf /var/lib/openstack-helm
}
function cleanup_deckhand {
set +e
if [ -n "$POSTGRES_ID" ]; then
sudo docker stop $POSTGRES_ID
fi
if [ -n "$DECKHAND_ID" ]; then
sudo docker stop $DECKHAND_ID
fi
rm -rf $CONF_DIR
}
function deploy_barbican {
set -xe
@ -74,8 +38,6 @@ function deploy_barbican {
function deploy_osh_keystone_barbican {
set -xe
trap cleanup_osh EXIT
if [ ! -d "$OSH_INFRA_PATH" ]; then
git clone https://git.openstack.org/openstack/openstack-helm-infra.git ../openstack-helm-infra
fi
@ -116,8 +78,6 @@ function deploy_osh_keystone_barbican {
function deploy_deckhand {
set -xe
trap cleanup_deckhand EXIT
export OS_CLOUD=openstack_helm
cd ${CURRENT_DIR}
@ -144,6 +104,16 @@ function deploy_deckhand {
gen_config false $deckhand_endpoint
gen_paste false
log_section "Running Deckhand via uwsgi."
source ${CURRENT_DIR}/entrypoint.sh alembic upgrade head &
# Give time for migrations to complete.
sleep 10
source ${CURRENT_DIR}/entrypoint.sh server &
# Give the server a chance to come up. Better to poll a health check.
sleep 10
# NOTE(fmontei): Generate an admin token instead of hacking a policy
# file with no permissions to test authN as well as authZ.
export TEST_AUTH_TOKEN=$( openstack token issue --format value -c id )
@ -154,25 +124,6 @@ function deploy_deckhand {
fi
export TEST_BARBICAN_URL=$test_barbican_url
log_section "Running Deckhand via Docker"
sudo docker run \
--rm \
--net=host \
-v $CONF_DIR:/etc/deckhand \
$DECKHAND_IMAGE alembic upgrade head &
sudo docker run \
--rm \
--net=host \
-p 9000:9000 \
-v $CONF_DIR:/etc/deckhand \
$DECKHAND_IMAGE server &
# Give the server a chance to come up. Better to poll a health check.
sleep 5
DECKHAND_ID=$(sudo docker ps | grep deckhand | awk '{print $1}')
echo $DECKHAND_ID
}
@ -202,11 +153,12 @@ function run_tests {
source ${CURRENT_DIR}/tools/common-tests.sh
export AIRSHIP_DECKHAND_DATABASE_URL=${PIFPAF_POSTGRESQL_URL}
# Clone openstack-helm-infra and setup host and k8s.
deploy_osh_keystone_barbican
# Deploy PostgreSQL and Deckhand.
deploy_postgresql
# Deploy Deckhand.
deploy_deckhand
run_tests "$@"