Add fullstack test to smaug
Change-Id: I75024a7d838882495f4b16ac46ca423fac5df3fe Closes-Bug: #1571474
This commit is contained in:
parent
4a19ec75a9
commit
cffccfa890
@ -2,6 +2,6 @@
|
||||
test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
|
||||
OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
|
||||
OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \
|
||||
${PYTHON:-python} -m subunit.run discover -t ./ . $LISTOPT $IDOPTION
|
||||
${PYTHON:-python} -m subunit.run discover -t ./ ${OS_TEST_PATH:-./smaug/tests/unit} $LISTOPT $IDOPTION
|
||||
test_id_option=--load-list $IDFILE
|
||||
test_list_option=--list
|
||||
|
10
smaug/tests/contrib/gate_hook.sh
Normal file
10
smaug/tests/contrib/gate_hook.sh
Normal file
@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -ex
|
||||
|
||||
VENV=${1:-"fullstack"}
|
||||
|
||||
GATE_DEST=$BASE/new
|
||||
DEVSTACK_PATH=$GATE_DEST/devstack
|
||||
|
||||
$BASE/new/devstack-gate/devstack-vm-gate.sh
|
61
smaug/tests/contrib/post_test_hook.sh
Normal file
61
smaug/tests/contrib/post_test_hook.sh
Normal file
@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -xe
|
||||
|
||||
SMAUG_DIR="$BASE/new/smaug"
|
||||
TEMPEST_DIR="$BASE/new/tempest"
|
||||
SCRIPTS_DIR="/usr/os-testr-env/bin/"
|
||||
|
||||
venv=${1:-"fullstack"}
|
||||
|
||||
function generate_test_logs {
|
||||
local path="$1"
|
||||
# Compress all $path/*.txt files and move the directories holding those
|
||||
# files to /opt/stack/logs. Files with .log suffix have their
|
||||
# suffix changed to .txt (so browsers will know to open the compressed
|
||||
# files and not download them).
|
||||
if [[ -d "$path" ]] ; then
|
||||
sudo find "$path" -iname "*.log" -type f -exec mv {} {}.txt \; -exec gzip -9 {}.txt \;
|
||||
sudo mv "$path/*" /opt/stack/logs/
|
||||
fi
|
||||
}
|
||||
|
||||
function generate_testr_results {
|
||||
# Give job user rights to access tox logs
|
||||
sudo -H -u "$owner" chmod o+rw .
|
||||
sudo -H -u "$owner" chmod o+rw -R .testrepository
|
||||
if [[ -f ".testrepository/0" ]] ; then
|
||||
".tox/$venv/bin/subunit-1to2" < .testrepository/0 > ./testrepository.subunit
|
||||
$SCRIPTS_DIR/subunit2html ./testrepository.subunit testr_results.html
|
||||
gzip -9 ./testrepository.subunit
|
||||
gzip -9 ./testr_results.html
|
||||
sudo mv ./*.gz /opt/stack/logs/
|
||||
fi
|
||||
|
||||
if [[ "$venv" == fullstack* ]] ; then
|
||||
generate_test_logs "/tmp/${venv}-logs"
|
||||
fi
|
||||
}
|
||||
|
||||
owner=stack
|
||||
sudo_env=
|
||||
|
||||
# virtuelenv 14.0.6 gives a strange error which appears solved in version 15.
|
||||
# Therefore, we force the newer version.
|
||||
sudo pip uninstall -y virtualenv
|
||||
sudo pip install "virtualenv>=15.0.1"
|
||||
|
||||
# Set owner permissions according to job's requirements.
|
||||
cd "$SMAUG_DIR"
|
||||
sudo chown -R $owner:stack "$SMAUG_DIR"
|
||||
|
||||
# Run tests
|
||||
echo "Running smaug $venv tests"
|
||||
set +e
|
||||
sudo -n -H -u "$owner" tox -e "$venv"
|
||||
testr_exit_code=$?
|
||||
set -e
|
||||
|
||||
# Collect and parse results
|
||||
generate_testr_results
|
||||
exit $testr_exit_code
|
0
smaug/tests/fullstack/__init__.py
Normal file
0
smaug/tests/fullstack/__init__.py
Normal file
73
smaug/tests/fullstack/smaug_base.py
Normal file
73
smaug/tests/fullstack/smaug_base.py
Normal file
@ -0,0 +1,73 @@
|
||||
# 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.
|
||||
|
||||
import os_client_config
|
||||
|
||||
from oslotest import base
|
||||
|
||||
from smaugclient.v1 import client as smaug_client
|
||||
|
||||
|
||||
def _get_cloud_config(cloud='devstack-admin'):
|
||||
return os_client_config.OpenStackConfig().get_one_cloud(cloud=cloud)
|
||||
|
||||
|
||||
def _credentials(cloud='devstack-admin'):
|
||||
"""Retrieves credentials to run functional tests
|
||||
|
||||
Credentials are either read via os-client-config from the environment
|
||||
or from a config file ('clouds.yaml'). Environment variables override
|
||||
those from the config file.
|
||||
|
||||
devstack produces a clouds.yaml with two named clouds - one named
|
||||
'devstack' which has user privs and one named 'devstack-admin' which
|
||||
has admin privs. This function will default to getting the devstack-admin
|
||||
cloud as that is the current expected behavior.
|
||||
"""
|
||||
return _get_cloud_config(cloud=cloud).get_auth_args()
|
||||
|
||||
|
||||
def _get_smaug_client_from_creds():
|
||||
api_version = ""
|
||||
cloud_config = _get_cloud_config()
|
||||
keystone_session = cloud_config.get_session_client("data-protect")
|
||||
keystone_auth = cloud_config.get_auth()
|
||||
region_name = cloud_config.get_region_name()
|
||||
service_type = "data-protect"
|
||||
endpoint_type = "publicURL"
|
||||
endpoint = keystone_auth.get_endpoint(
|
||||
keystone_session,
|
||||
service_type=service_type,
|
||||
region_name=region_name)
|
||||
|
||||
kwargs = {
|
||||
'session': keystone_session,
|
||||
'auth': keystone_auth,
|
||||
'service_type': service_type,
|
||||
'endpoint_type': endpoint_type,
|
||||
'region_name': region_name,
|
||||
}
|
||||
|
||||
client = smaug_client.Client(api_version, endpoint, **kwargs)
|
||||
return client
|
||||
|
||||
|
||||
class SmaugBaseTest(base.BaseTestCase):
|
||||
"""Basic class for Smaug fullstack testing
|
||||
|
||||
This class has common code shared for Smaug fullstack testing
|
||||
including the various clients (smaug) and common
|
||||
setup/cleanup code.
|
||||
"""
|
||||
def setUp(self):
|
||||
super(SmaugBaseTest, self).setUp()
|
||||
self.smaug_client = _get_smaug_client_from_creds()
|
33
smaug/tests/fullstack/test_smaug.py
Normal file
33
smaug/tests/fullstack/test_smaug.py
Normal file
@ -0,0 +1,33 @@
|
||||
# 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 smaug.tests.fullstack import smaug_base
|
||||
|
||||
|
||||
class SmaugTest(smaug_base.SmaugBaseTest):
|
||||
"""Test Smaug operation
|
||||
|
||||
"""
|
||||
def test_smaug(self):
|
||||
pass
|
||||
|
||||
def test_plan_list(self):
|
||||
plan = self.smaug_client.plans.create(
|
||||
"My 3 tier application",
|
||||
"2220f8b1-975d-4621-a872-fa9afb43cb6c",
|
||||
[{"type": "OS::Cinder::Volume",
|
||||
"id": "5fad94de-2926-486b-ae73-ff5d3477f80d"}])
|
||||
plan_id = plan.get("id")
|
||||
plan_item = self.smaug_client.plans.get(plan_id)
|
||||
plan_item_id = plan_item.id
|
||||
self.assertEqual(plan_id, plan_item_id)
|
@ -14,3 +14,4 @@ testrepository>=0.0.18 # Apache-2.0/BSD
|
||||
testscenarios>=0.4 # Apache-2.0/BSD
|
||||
testtools>=1.4.0 # MIT
|
||||
python-swiftclient>=2.2.0 # Apache-2.0
|
||||
http://tarballs.openstack.org/python-smaugclient/python-smaugclient-master.tar.gz#egg=python-smaugclient
|
||||
|
5
tox.ini
5
tox.ini
@ -8,9 +8,14 @@ usedevelop = True
|
||||
install_command = pip install -U {opts} {packages}
|
||||
setenv =
|
||||
VIRTUAL_ENV={envdir}
|
||||
OS_TEST_PATH=./smaug/tests/unit
|
||||
deps = -r{toxinidir}/test-requirements.txt
|
||||
commands = python setup.py test --slowest --testr-args='{posargs}'
|
||||
|
||||
[testenv:fullstack]
|
||||
basepython = python2.7
|
||||
setenv = OS_TEST_PATH=./smaug/tests/fullstack
|
||||
|
||||
[testenv:pep8]
|
||||
commands = flake8
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user