Skip to content

Commit

Permalink
Changes to testr as the test runner
Browse files Browse the repository at this point in the history
run_tests.sh has also been deprecated.

Fixes-Bug: #1177924
Change-Id: I15c1707eb6a62c74a0021a48b89ae15f03fcfea8
  • Loading branch information
dstanek committed Oct 15, 2013
1 parent c481afd commit 59adb86
Show file tree
Hide file tree
Showing 13 changed files with 390 additions and 87 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -28,3 +28,4 @@ keystone/tests/tmp/
.project
.pydevproject
keystone/locale/*/LC_MESSAGES/*.mo
.testrepository/
12 changes: 12 additions & 0 deletions .testr.conf
@@ -0,0 +1,12 @@
[DEFAULT]
test_command=${PYTHON:-python} -m subunit.run discover \
-t ./ ./keystone/tests \
$LISTOPT $IDOPTION

test_id_option=--load-list $IDFILE
test_list_option=--list

# NOTE(dstanek): Ensures that Keystone test never run in parallel.
# Please remove once the issues have been worked out.
# Bug: #1240052
test_run_concurrency=echo 1
2 changes: 1 addition & 1 deletion keystone/tests/backend_sql_disk.conf
@@ -1,2 +1,2 @@
[sql]
connection = sqlite:///tmp/test.db
connection = sqlite:///keystone/tests/tmp/test.db
12 changes: 5 additions & 7 deletions keystone/tests/core.py
Expand Up @@ -25,7 +25,6 @@

from lxml import etree
import mox
import nose.exc
from paste import deploy
import stubout
import testtools
Expand Down Expand Up @@ -74,9 +73,9 @@


LOG = logging.getLogger(__name__)
ROOTDIR = os.path.dirname(os.path.abspath('..'))
TESTSDIR = os.path.dirname(os.path.abspath(__file__))
ROOTDIR = os.path.normpath(os.path.join(TESTSDIR, '..', '..'))
VENDOR = os.path.join(ROOTDIR, 'vendor')
TESTSDIR = os.path.join(ROOTDIR, 'keystone', 'tests')
ETCDIR = os.path.join(ROOTDIR, 'etc')
TMPDIR = os.path.join(TESTSDIR, 'tmp')

Expand Down Expand Up @@ -490,7 +489,7 @@ def safe_repr(obj, short=False):
def assertEqualXML(self, a, b):
"""Parses two XML documents from strings and compares the results.
This provides easy-to-read failures from nose.
This provides easy-to-read failures.
"""
parser = etree.XMLParser(remove_blank_text=True)
Expand All @@ -510,13 +509,12 @@ def canonical_xml(s):
b = canonical_xml(b)
self.assertEqual(a.split('\n'), b.split('\n'))

@staticmethod
def skip_if_no_ipv6():
def skip_if_no_ipv6(self):
try:
s = socket.socket(socket.AF_INET6)
except socket.error as e:
if e.errno == errno.EAFNOSUPPORT:
raise nose.exc.SkipTest("IPv6 is not enabled in the system")
raise self.skipTest("IPv6 is not enabled in the system")
else:
raise
else:
Expand Down
4 changes: 1 addition & 3 deletions keystone/tests/test_ipv6.py
Expand Up @@ -24,11 +24,9 @@


class IPv6TestCase(tests.TestCase):
@classmethod
def setUpClass(cls):
cls.skip_if_no_ipv6()

def setUp(self):
self.skip_if_no_ipv6()
super(IPv6TestCase, self).setUp()
self.load_backends()

Expand Down
6 changes: 3 additions & 3 deletions keystone/tests/test_overrides.conf
Expand Up @@ -21,6 +21,6 @@ debug_cache_backend = True
proxies = keystone.tests.test_cache.CacheIsolatingProxy

[signing]
certfile = ../../examples/pki/certs/signing_cert.pem
keyfile = ../../examples/pki/private/signing_key.pem
ca_certs = ../../examples/pki/certs/cacert.pem
certfile = examples/pki/certs/signing_cert.pem
keyfile = examples/pki/private/signing_key.pem
ca_certs = examples/pki/certs/cacert.pem
4 changes: 2 additions & 2 deletions keystone/tests/test_v3_auth.py
Expand Up @@ -1071,7 +1071,7 @@ def test_deleting_project_deletes_grants(self):
class TestAuthExternalDisabled(test_v3.RestfulTestCase):
def config_files(self):
list = self._config_file_list[:]
list.append('auth_plugin_external_disabled.conf')
list.append(tests.testsdir('auth_plugin_external_disabled.conf'))
return list

def test_remote_user_disabled(self):
Expand All @@ -1093,7 +1093,7 @@ class TestAuthExternalDomain(test_v3.RestfulTestCase):

def config_files(self):
list = self._config_file_list[:]
list.append('auth_plugin_external_domain.conf')
list.append(tests.testsdir('auth_plugin_external_domain.conf'))
return list

def test_remote_user_with_realm(self):
Expand Down
1 change: 1 addition & 0 deletions openstack-common.conf
Expand Up @@ -3,6 +3,7 @@
# The list of modules to copy from openstack-common
module=db
module=db.sqlalchemy
module=colorizer
module=crypto
module=importutils
module=install_venv_common
Expand Down
60 changes: 19 additions & 41 deletions run_tests.sh
Expand Up @@ -32,9 +32,6 @@ function usage {
echo " -P, --no-pep8 Don't run flake8"
echo " -c, --coverage Generate coverage report"
echo " -h, --help Print this usage message"
echo " -xintegration Ignore all keystoneclient test cases (integration tests)"
echo " --hide-elapsed Don't print the elapsed time for each test along with slow test list"
echo " --standard-threads Don't do the eventlet threading monkeypatch."
echo ""
echo "Note: with no options specified, the script will try to run the tests in a virtual environment,"
echo " If no virtualenv is found, the script will ask if you would like to create one. If you "
Expand All @@ -55,12 +52,8 @@ function process_option {
-8|--8) short_flake8=1;;
-P|--no-pep8) no_flake8=1;;
-c|--coverage) coverage=1;;
-xintegration) nokeystoneclient=1;;
--standard-threads)
export STANDARD_THREADS=1
;;
-*) noseopts="$noseopts $1";;
*) noseargs="$noseargs $1"
-*) testropts="$testropts $1";;
*) testrargs="$testrargs $1"
esac
}

Expand All @@ -69,29 +62,25 @@ with_venv=tools/with_venv.sh
always_venv=0
never_venv=0
force=0
noseargs=
noseopts="--with-openstack --openstack-color"
testrargs=
testropts=--subunit
wrapper=""
just_flake8=0
short_flake8=0
no_flake8=0
coverage=0
nokeystoneclient=0
recreate_db=1
update=0

for arg in "$@"; do
process_option $arg
done

TESTRTESTS="python setup.py testr"

# If enabled, tell nose to collect coverage data
if [ $coverage -eq 1 ]; then
noseopts="$noseopts --with-coverage --cover-package=keystone"
fi

if [ $nokeystoneclient -eq 1 ]; then
# disable the integration tests
noseopts="$noseopts -I test_keystoneclient* -I _test_import_auth_token.py"
TESTRTESTS="$TESTRTESTS --coverage"
fi

function cleanup_test_db {
Expand All @@ -103,19 +92,11 @@ function cleanup_test_db {
}

function run_tests {
# Just run the test suites in current environment
${wrapper} $NOSETESTS
# If we get some short import error right away, print the error log directly
RESULT=$?
if [ "$RESULT" -ne "0" ];
then
ERRSIZE=`wc -l run_tests.log | awk '{print \$1}'`
if [ "$ERRSIZE" -lt "40" ];
then
cat run_tests.log
fi
fi
return $RESULT
set -e
echo ${wrapper}
${wrapper} $TESTRTESTS --testr-args="$testropts $testrargs" | \
${wrapper} subunit-2to1 | \
${wrapper} tools/colorizer.py
}

function run_flake8 {
Expand All @@ -125,14 +106,16 @@ function run_flake8 {
FLAGS=''
fi


echo "Running flake8 ..."
# Just run flake8 in current environment
echo ${wrapper} flake8 $FLAGS | tee pep8.txt
${wrapper} flake8 $FLAGS | tee pep8.txt
}

NOSETESTS="nosetests $noseopts $noseargs"
echo "This script is now deprecated. Please use tox instead."
echo "Checkout http://tox.readthedocs.org/en/latest/ for information on tox."
echo "[press enter to continue]"
read

if [ $never_venv -eq 0 ]
then
Expand Down Expand Up @@ -188,15 +171,10 @@ run_tests

# NOTE(sirp): we only want to run flake8 when we're running the full-test
# suite, not when we're running tests individually. To handle this, we need to
# distinguish between options (noseopts), which begin with a '-', and arguments
# (noseargs).
if [ -z "$noseargs" ]; then
# distinguish between options (testropts), which begin with a '-', and arguments
# (testrargs).
if [ -z "$testrargs" ]; then
if [ $no_flake8 -eq 0 ]; then
run_flake8
fi
fi

if [ $coverage -eq 1 ]; then
echo "Generating coverage report in covhtml/"
${wrapper} coverage html -d covhtml -i
fi
12 changes: 0 additions & 12 deletions setup.cfg
Expand Up @@ -55,15 +55,3 @@ mapping_file = babel.cfg
output_file = keystone/locale/keystone.pot
copyright_holder = OpenStack Foundation
msgid_bugs_address = https://bugs.launchpad.net/keystone

[nosetests]
# NOTE(jkoelker) To run the test suite under nose install the following
# coverage http://pypi.python.org/pypi/coverage
# tissue http://pypi.python.org/pypi/tissue (pep8 checker)
# openstack-nose https://github.com/jkoelker/openstack-nose
verbosity=2
detailed-errors=1
cover-package = keystone
cover-html = true
cover-erase = true
where=keystone/tests
12 changes: 6 additions & 6 deletions test-requirements.txt
Expand Up @@ -15,17 +15,17 @@ python-ldap==2.3.13
coverage
# mock object framework
mox
# for test discovery and console feedback
nose
nosexcover
openstack.nose_plugin
nosehtmloutput
# required to build documentation
Sphinx>=1.1.2
testtools>=0.9.32
# test wsgi apps without starting an http server
webtest

extras
discover
python-subunit
testrepository>=0.0.17
testtools>=0.9.32

# for python-keystoneclient
# keystoneclient <0.2.1
httplib2
Expand Down

0 comments on commit 59adb86

Please sign in to comment.