diff --git a/.zuul.yaml b/.zuul.yaml index 0b12c55c..8b1f78d3 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -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 diff --git a/tools/functional-tests.sh b/tools/functional-tests.sh index 10af5983..3d44577e 100755 --- a/tools/functional-tests.sh +++ b/tools/functional-tests.sh @@ -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 } diff --git a/tools/gate/playbooks/run-functional-tests-docker.yaml b/tools/gate/playbooks/run-functional-tests-docker.yaml index 534e44ae..5acbe1c5 100644 --- a/tools/gate/playbooks/run-functional-tests-docker.yaml +++ b/tools/gate/playbooks/run-functional-tests-docker.yaml @@ -44,6 +44,6 @@ - hosts: all gather_facts: False roles: - - run-tests + - run-functional-tests tags: - - run-tests + - run-functional-tests diff --git a/tools/gate/playbooks/run-functional-tests-uwsgi.yaml b/tools/gate/playbooks/run-functional-tests-uwsgi.yaml index 536cf645..7ba32e62 100644 --- a/tools/gate/playbooks/run-functional-tests-uwsgi.yaml +++ b/tools/gate/playbooks/run-functional-tests-uwsgi.yaml @@ -16,7 +16,7 @@ gather_facts: False roles: - install-postgresql - - run-tests + - run-functional-tests tags: - install-postgresql - - run-tests + - run-functional-tests diff --git a/tools/gate/playbooks/run-integration-tests-uwsgi.yaml b/tools/gate/playbooks/run-integration-tests-uwsgi.yaml new file mode 100644 index 00000000..9160c412 --- /dev/null +++ b/tools/gate/playbooks/run-integration-tests-uwsgi.yaml @@ -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 diff --git a/tools/gate/roles/run-tests/tasks/tox-tests.yaml b/tools/gate/roles/run-functional-tests/tasks/functional-tests.yaml similarity index 86% rename from tools/gate/roles/run-tests/tasks/tox-tests.yaml rename to tools/gate/roles/run-functional-tests/tasks/functional-tests.yaml index e16fed34..f7899774 100644 --- a/tools/gate/roles/run-tests/tasks/tox-tests.yaml +++ b/tools/gate/roles/run-functional-tests/tasks/functional-tests.yaml @@ -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" diff --git a/tools/gate/roles/run-tests/tasks/main.yaml b/tools/gate/roles/run-functional-tests/tasks/main.yaml similarity index 94% rename from tools/gate/roles/run-tests/tasks/main.yaml rename to tools/gate/roles/run-functional-tests/tasks/main.yaml index a1c8c122..38b08b4a 100644 --- a/tools/gate/roles/run-tests/tasks/main.yaml +++ b/tools/gate/roles/run-functional-tests/tasks/main.yaml @@ -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 diff --git a/tools/gate/roles/run-integration-tests/tasks/integration-tests.yaml b/tools/gate/roles/run-integration-tests/tasks/integration-tests.yaml new file mode 100644 index 00000000..b055667c --- /dev/null +++ b/tools/gate/roles/run-integration-tests/tasks/integration-tests.yaml @@ -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" diff --git a/tools/gate/roles/run-integration-tests/tasks/main.yaml b/tools/gate/roles/run-integration-tests/tasks/main.yaml new file mode 100644 index 00000000..00d591a0 --- /dev/null +++ b/tools/gate/roles/run-integration-tests/tasks/main.yaml @@ -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 diff --git a/tools/integration-tests.sh b/tools/integration-tests.sh index eccf7b9d..7218c93c 100755 --- a/tools/integration-tests.sh +++ b/tools/integration-tests.sh @@ -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 "$@"