Functional tests run in many environments

Have the functional tests running with less customization and
less shell.  This change will allow the functional tests to be
run against any cloud set up in the environment.

Change-Id: I24f621fbace62273e5a0be24e7af9078c0fc8550
This commit is contained in:
TerryHowe 2015-04-16 12:56:40 -06:00
parent e288e0194c
commit aa7e58cefb
6 changed files with 17 additions and 81 deletions

View File

@ -2,7 +2,7 @@
test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \ test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \ OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \ OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \
${PYTHON:-python} -m subunit.run discover -t ./ ./openstackclient/tests $LISTOPT $IDOPTION ${PYTHON:-python} -m subunit.run discover -t ./ ${OS_TEST_PATH:-./openstackclient/tests} $LISTOPT $IDOPTION
test_id_option=--load-list $IDFILE test_id_option=--load-list $IDFILE
test_list_option=--list test_list_option=--list

View File

@ -1,37 +0,0 @@
#!/bin/bash
FUNCTIONAL_TEST_DIR=$(cd $(dirname "$0") && pwd)
source $FUNCTIONAL_TEST_DIR/harpoonrc
OPENSTACKCLIENT_DIR=$FUNCTIONAL_TEST_DIR/..
if [[ -z $DEVSTACK_DIR ]]; then
DEVSTACK_DIR=$OPENSTACKCLIENT_DIR/../devstack
if [[ ! -d $DEVSTACK_DIR ]]; then
DEVSTACK_DIR=$HOME/devstack
if [[ ! -d $DEVSTACK_DIR ]]; then
echo "Where did you hide DevStack? Set DEVSTACK_DIR and try again"
exit 1
fi
fi
echo "Using DevStack found at $DEVSTACK_DIR"
fi
function setup_credentials {
RC_FILE=$DEVSTACK_DIR/accrc/$HARPOON_USER/$HARPOON_TENANT
source $RC_FILE
echo 'sourcing' $RC_FILE
echo 'running tests with'
env | grep OS
}
function run_tests {
cd $FUNCTIONAL_TEST_DIR
python -m testtools.run discover
rvalue=$?
cd $OPENSTACKCLIENT_DIR
exit $rvalue
}
setup_credentials
run_tests

View File

@ -1,14 +0,0 @@
# Global options
#RECLONE=yes
# Devstack options
#ADMIN_PASSWORD=openstack
#MYSQL_PASSWORD=openstack
#RABBIT_PASSWORD=openstack
#SERVICE_TOKEN=openstack
#SERVICE_PASSWORD=openstack
# Harpoon options
HARPOON_USER=admin
HARPOON_TENANT=admin
#DEVSTACK_DIR=/opt/stack/devstack

View File

@ -32,63 +32,45 @@ class ObjectV1Tests(test.TestCase):
with open(self.OBJECT_NAME, 'w') as f: with open(self.OBJECT_NAME, 'w') as f:
f.write('test content') f.write('test content')
def test_container_create(self): def test_object(self):
raw_output = self.openstack('container create ' + self.CONTAINER_NAME) raw_output = self.openstack('container create ' + self.CONTAINER_NAME)
items = self.parse_listing(raw_output) items = self.parse_listing(raw_output)
self.assert_show_fields(items, CONTAINER_FIELDS) self.assert_show_fields(items, CONTAINER_FIELDS)
def test_container_delete(self):
container_tmp = uuid.uuid4().hex
self.openstack('container create ' + container_tmp)
raw_output = self.openstack('container delete ' + container_tmp)
self.assertEqual(0, len(raw_output))
def test_container_list(self):
raw_output = self.openstack('container list') raw_output = self.openstack('container list')
items = self.parse_listing(raw_output) items = self.parse_listing(raw_output)
self.assert_table_structure(items, BASIC_LIST_HEADERS) self.assert_table_structure(items, BASIC_LIST_HEADERS)
def test_container_show(self):
self.openstack('container show ' + self.CONTAINER_NAME) self.openstack('container show ' + self.CONTAINER_NAME)
# TODO(stevemar): Assert returned fields # TODO(stevemar): Assert returned fields
def test_container_save(self):
self.openstack('container save ' + self.CONTAINER_NAME) self.openstack('container save ' + self.CONTAINER_NAME)
# TODO(stevemar): Assert returned fields # TODO(stevemar): Assert returned fields
def test_object_create(self):
raw_output = self.openstack('object create ' + self.CONTAINER_NAME raw_output = self.openstack('object create ' + self.CONTAINER_NAME
+ ' ' + self.OBJECT_NAME) + ' ' + self.OBJECT_NAME)
items = self.parse_listing(raw_output) items = self.parse_listing(raw_output)
self.assert_show_fields(items, OBJECT_FIELDS) self.assert_show_fields(items, OBJECT_FIELDS)
def test_object_delete(self):
raw_output = self.openstack('object delete ' + self.CONTAINER_NAME
+ ' ' + self.OBJECT_NAME)
self.assertEqual(0, len(raw_output))
def test_object_list(self):
raw_output = self.openstack('object list ' + self.CONTAINER_NAME) raw_output = self.openstack('object list ' + self.CONTAINER_NAME)
items = self.parse_listing(raw_output) items = self.parse_listing(raw_output)
self.assert_table_structure(items, BASIC_LIST_HEADERS) self.assert_table_structure(items, BASIC_LIST_HEADERS)
def test_object_save(self):
self.openstack('object create ' + self.CONTAINER_NAME
+ ' ' + self.OBJECT_NAME)
self.openstack('object save ' + self.CONTAINER_NAME self.openstack('object save ' + self.CONTAINER_NAME
+ ' ' + self.OBJECT_NAME) + ' ' + self.OBJECT_NAME)
# TODO(stevemar): Assert returned fields # TODO(stevemar): Assert returned fields
def test_object_save_with_filename(self):
self.openstack('object create ' + self.CONTAINER_NAME
+ ' ' + self.OBJECT_NAME)
self.openstack('object save ' + self.CONTAINER_NAME self.openstack('object save ' + self.CONTAINER_NAME
+ ' ' + self.OBJECT_NAME + ' --file tmp.txt') + ' ' + self.OBJECT_NAME + ' --file tmp.txt')
# TODO(stevemar): Assert returned fields # TODO(stevemar): Assert returned fields
def test_object_show(self):
self.openstack('object create ' + self.CONTAINER_NAME
+ ' ' + self.OBJECT_NAME)
self.openstack('object show ' + self.CONTAINER_NAME self.openstack('object show ' + self.CONTAINER_NAME
+ ' ' + self.OBJECT_NAME) + ' ' + self.OBJECT_NAME)
# TODO(stevemar): Assert returned fields # TODO(stevemar): Assert returned fields
raw_output = self.openstack('object delete ' + self.CONTAINER_NAME
+ ' ' + self.OBJECT_NAME)
self.assertEqual(0, len(raw_output))
raw_output = self.openstack('container delete ' + self.CONTAINER_NAME)
self.assertEqual(0, len(raw_output))

View File

@ -10,6 +10,11 @@ set -xe
OPENSTACKCLIENT_DIR=$(cd $(dirname "$0") && pwd) OPENSTACKCLIENT_DIR=$(cd $(dirname "$0") && pwd)
cd $OPENSTACKCLIENT_DIR
echo "Running openstackclient functional test suite" echo "Running openstackclient functional test suite"
sudo -H -u stack tox -e functional sudo -H -u stack -i <<!
source ~stack/devstack/accrc/admin/admin
echo 'Running tests with:'
env | grep OS_
cd ${OPENSTACKCLIENT_DIR}
tox -e functional
!

View File

@ -16,7 +16,7 @@ whitelist_externals = bash
commands = flake8 commands = flake8
[testenv:functional] [testenv:functional]
commands = bash -x {toxinidir}/functional/harpoon.sh setenv = OS_TEST_PATH=./functional/tests
[testenv:venv] [testenv:venv]
commands = {posargs} commands = {posargs}