From 69a4f5345e3966d142b5c890730e76f14aeac54d Mon Sep 17 00:00:00 2001 From: Eli Qiao Date: Mon, 28 Dec 2015 13:16:14 +0800 Subject: [PATCH] Functional: Add mesos functional bay creation basic testing frame work This patch adds functional testing case for mesos bay creation testing. 1. Add gate_hook.sh to set MAGNUM_GUEST_IMAGE_URL to use ubuntu image 2. Modify post_test_hook to use ubuntu image when doing functional testing 3. Add new tox env entry to do mesos functional testing. Partially implements: blueprint mesos-functional-testing Change-Id: I8ee53de4d34aa79d037901e599fc6409a7de2e72 --- magnum/tests/contrib/gate_hook.sh | 24 +++++++++++++++ magnum/tests/contrib/post_test_hook.sh | 18 +++++++---- magnum/tests/functional/mesos/__init__.py | 0 .../mesos/test_mesos_python_client.py | 30 +++++++++++++++++++ tox.ini | 10 +++++++ 5 files changed, 77 insertions(+), 5 deletions(-) create mode 100755 magnum/tests/contrib/gate_hook.sh create mode 100644 magnum/tests/functional/mesos/__init__.py create mode 100644 magnum/tests/functional/mesos/test_mesos_python_client.py diff --git a/magnum/tests/contrib/gate_hook.sh b/magnum/tests/contrib/gate_hook.sh new file mode 100755 index 0000000000..2ee242418a --- /dev/null +++ b/magnum/tests/contrib/gate_hook.sh @@ -0,0 +1,24 @@ +#!/bin/bash -x +# +# 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. +# +# This script is executed inside gate_hook function in devstack gate. + + +coe=$1 + +if [ "$coe" = "mesos" ]; then + echo "MAGNUM_GUEST_IMAGE_URL="https://fedorapeople.org/groups/magnum/ubuntu-14.04.3-mesos-0.25.0.qcow2"" >> $BASE/new/devstack/localrc +fi + +$BASE/new/devstack-gate/devstack-vm-gate.sh diff --git a/magnum/tests/contrib/post_test_hook.sh b/magnum/tests/contrib/post_test_hook.sh index eca4c67b03..e6c6b73a5d 100755 --- a/magnum/tests/contrib/post_test_hook.sh +++ b/magnum/tests/contrib/post_test_hook.sh @@ -27,8 +27,13 @@ function create_test_data { # First we test Magnum's command line to see if we can stand up # a baymodel, bay and a pod + coe=$1 + local image_name="fedora-21-atomic" + if [ $coe == 'mesos' ]; then + image_name="ubuntu-14.04" + fi export NIC_ID=$(neutron net-show public | awk '/ id /{print $4}') - export IMAGE_ID=$(glance --os-image-api-version 1 image-show fedora-21-atomic-5 | awk '/ id /{print $4}') + export IMAGE_ID=$(glance --os-image-api-version 1 image-list | grep $image_name | awk '{print $2}') # pass the appropriate variables via a config file CREDS_FILE=$MAGNUM_DIR/functional_creds.conf @@ -113,7 +118,10 @@ sudo chown -R jenkins:stack $MAGNUM_DIR echo "Running magnum functional test suite for $1" # For api, we will run tempest tests -if [[ "api" == $1 ]]; then + +coe=$1 + +if [[ "api" == "$coe" ]]; then # Import devstack functions 'iniset', 'iniget' and 'trueorfalse' source $BASE/new/devstack/functions echo "TEMPEST_SERVICES+=,magnum" >> $localrc_path @@ -126,7 +134,7 @@ if [[ "api" == $1 ]]; then source $BASE/new/devstack/accrc/demo/demo unset OS_AUTH_TYPE - create_test_data + create_test_data $coe # Set up tempest config with magnum goodness iniset $BASE/new/tempest/etc/tempest.conf magnum image_id $IMAGE_ID @@ -158,9 +166,9 @@ else add_flavor - create_test_data + create_test_data $coe - sudo -E -H -u jenkins tox -e functional-$1 -- --concurrency=1 + sudo -E -H -u jenkins tox -e functional-"$coe" -- --concurrency=1 fi EXIT_CODE=$? diff --git a/magnum/tests/functional/mesos/__init__.py b/magnum/tests/functional/mesos/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/magnum/tests/functional/mesos/test_mesos_python_client.py b/magnum/tests/functional/mesos/test_mesos_python_client.py new file mode 100644 index 0000000000..f644690953 --- /dev/null +++ b/magnum/tests/functional/mesos/test_mesos_python_client.py @@ -0,0 +1,30 @@ +# 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. + +from magnum.tests.functional.python_client_base import BayTest + + +class TestBayModelResource(BayTest): + coe = 'mesos' + + def test_baymodel_create_and_delete(self): + self._test_baymodel_create_and_delete('test_mesos_baymodel') + + +class TestBayResource(BayTest): + coe = 'mesos' + + def test_bay_create_and_delete(self): + baymodel_uuid = self._test_baymodel_create_and_delete( + 'test_mesos_baymodel', delete=False, tls_disabled=True, + network_driver='docker') + self._test_bay_create_and_delete('test_mesos_bay', baymodel_uuid) diff --git a/tox.ini b/tox.ini index 8ebfa3d58d..2d4ee00fb2 100644 --- a/tox.ini +++ b/tox.ini @@ -52,6 +52,16 @@ commands = find . -type f -name "*.pyc" -delete bash tools/pretty_tox.sh '{posargs}' +[testenv:functional-mesos] +sitepackages = True +setenv = OS_TEST_PATH=./magnum/tests/functional/mesos + OS_TEST_TIMEOUT=7200 +deps = + {[testenv]deps} +commands = + find . -type f -name "*.pyc" -delete + bash tools/pretty_tox.sh '{posargs}' + [testenv:pep8] commands = doc8 -e .rst specs/ doc/source/ contrib/ CONTRIBUTING.rst HACKING.rst README.rst