From aa7e58cefb67b28ec3c3fcc6f654b41d3ecc6c4a Mon Sep 17 00:00:00 2001 From: TerryHowe Date: Thu, 16 Apr 2015 12:56:40 -0600 Subject: [PATCH] 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 --- .testr.conf | 2 +- functional/harpoon.sh | 37 ----------------------- functional/harpoonrc | 14 --------- functional/tests/object/v1/test_object.py | 34 +++++---------------- post_test_hook.sh | 9 ++++-- tox.ini | 2 +- 6 files changed, 17 insertions(+), 81 deletions(-) delete mode 100755 functional/harpoon.sh delete mode 100644 functional/harpoonrc diff --git a/.testr.conf b/.testr.conf index b8676b4580..7388cc3c45 100644 --- a/.testr.conf +++ b/.testr.conf @@ -2,7 +2,7 @@ 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 ./ ./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_list_option=--list diff --git a/functional/harpoon.sh b/functional/harpoon.sh deleted file mode 100755 index 4e16391794..0000000000 --- a/functional/harpoon.sh +++ /dev/null @@ -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 diff --git a/functional/harpoonrc b/functional/harpoonrc deleted file mode 100644 index ed9201ca1e..0000000000 --- a/functional/harpoonrc +++ /dev/null @@ -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 diff --git a/functional/tests/object/v1/test_object.py b/functional/tests/object/v1/test_object.py index 4121524ace..5e9ac72c6d 100644 --- a/functional/tests/object/v1/test_object.py +++ b/functional/tests/object/v1/test_object.py @@ -32,63 +32,45 @@ class ObjectV1Tests(test.TestCase): with open(self.OBJECT_NAME, 'w') as f: f.write('test content') - def test_container_create(self): + def test_object(self): raw_output = self.openstack('container create ' + self.CONTAINER_NAME) items = self.parse_listing(raw_output) 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') items = self.parse_listing(raw_output) self.assert_table_structure(items, BASIC_LIST_HEADERS) - def test_container_show(self): self.openstack('container show ' + self.CONTAINER_NAME) # TODO(stevemar): Assert returned fields - def test_container_save(self): self.openstack('container save ' + self.CONTAINER_NAME) # TODO(stevemar): Assert returned fields - def test_object_create(self): raw_output = self.openstack('object create ' + self.CONTAINER_NAME + ' ' + self.OBJECT_NAME) items = self.parse_listing(raw_output) 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) items = self.parse_listing(raw_output) 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.OBJECT_NAME) # 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.OBJECT_NAME + ' --file tmp.txt') # 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.OBJECT_NAME) # 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)) diff --git a/post_test_hook.sh b/post_test_hook.sh index b82c1e62a9..4c35b52099 100755 --- a/post_test_hook.sh +++ b/post_test_hook.sh @@ -10,6 +10,11 @@ set -xe OPENSTACKCLIENT_DIR=$(cd $(dirname "$0") && pwd) -cd $OPENSTACKCLIENT_DIR echo "Running openstackclient functional test suite" -sudo -H -u stack tox -e functional +sudo -H -u stack -i <