Replace nose with testr
- add .testr.conf (in base dir and nova_tests) - remove all references to nose - adjust paths: A couple of tests would assume the current directory was ./tests/ but it is now ./ - don't run the tests in parallel as the db tests have one connection per test class. nova_tests hackery: It seems testtools/testr imports everything and I just don't see a way of running things in tests/ and nova_tests/ seperately but in one .test.conf. So if you want to use testr directly you will need to: testr run cd nova_tests testr run part of bug 1177924 Change-Id: I41875dcf94463fa5f9c07a7840c37089226c59ad
This commit is contained in:
parent
6693c9fb04
commit
1a723a05c7
2
.gitignore
vendored
2
.gitignore
vendored
@ -6,6 +6,8 @@ build
|
||||
.coverage
|
||||
.tox
|
||||
cover
|
||||
.testrepository
|
||||
subunit.log
|
||||
AUTHORS
|
||||
ChangeLog
|
||||
*.deb
|
||||
|
4
.testr.conf
Normal file
4
.testr.conf
Normal file
@ -0,0 +1,4 @@
|
||||
[DEFAULT]
|
||||
test_command=${PYTHON:-python} -m subunit.run discover -t ./ ./tests $LISTOPT $IDOPTION
|
||||
test_id_option=--load-list $IDFILE
|
||||
test_list_option=--list
|
@ -29,12 +29,13 @@ from ceilometer import storage
|
||||
storage.register_opts(cfg.CONF)
|
||||
|
||||
|
||||
def make_app(conf, enable_acl=True, attach_storage=True):
|
||||
def make_app(conf, enable_acl=True, attach_storage=True,
|
||||
sources_file='sources.json'):
|
||||
app = flask.Flask('ceilometer.api')
|
||||
app.register_blueprint(v1_blueprint.blueprint, url_prefix='/v1')
|
||||
|
||||
try:
|
||||
with open("sources.json", "r") as f:
|
||||
with open(sources_file, "r") as f:
|
||||
sources = jsonutils.load(f)
|
||||
except IOError:
|
||||
sources = {}
|
||||
|
@ -41,9 +41,13 @@ class TestBase(db_test_base.TestBase):
|
||||
def setUp(self):
|
||||
super(TestBase, self).setUp()
|
||||
cfg.CONF.set_override("auth_version", "v2.0", group=acl.OPT_GROUP_NAME)
|
||||
cfg.CONF.set_override("policy_file",
|
||||
self.path_get('tests/policy.json'))
|
||||
sources_file = self.path_get('tests/sources.json')
|
||||
self.app = v1_app.make_app(cfg.CONF,
|
||||
enable_acl=False,
|
||||
attach_storage=False)
|
||||
attach_storage=False,
|
||||
sources_file=sources_file)
|
||||
self.app.register_blueprint(v1_blueprint.blueprint)
|
||||
self.test_app = self.app.test_client()
|
||||
|
||||
@ -86,11 +90,7 @@ class FunctionalTest(db_test_base.TestBase):
|
||||
|
||||
def _make_app(self, enable_acl=False):
|
||||
# Determine where we are so we can set up paths in the config
|
||||
root_dir = os.path.abspath(os.path.join(os.path.dirname(__file__),
|
||||
'..',
|
||||
'..',
|
||||
)
|
||||
)
|
||||
root_dir = self.path_get()
|
||||
|
||||
self.config = {
|
||||
|
||||
|
@ -42,9 +42,20 @@ class TestCase(testtools.TestCase):
|
||||
# the system.
|
||||
cfg.CONF.set_override(
|
||||
'pipeline_cfg_file',
|
||||
'../etc/ceilometer/pipeline.yaml',
|
||||
self.path_get('etc/ceilometer/pipeline.yaml'),
|
||||
)
|
||||
|
||||
def path_get(self, project_file=None):
|
||||
root = os.path.abspath(os.path.join(os.path.dirname(__file__),
|
||||
'..',
|
||||
'..',
|
||||
)
|
||||
)
|
||||
if project_file:
|
||||
return os.path.join(root, project_file)
|
||||
else:
|
||||
return root
|
||||
|
||||
def temp_config_file_path(self, name='ceilometer.conf'):
|
||||
return os.path.join(self.tempdir.path, name)
|
||||
|
||||
|
4
nova_tests/.testr.conf
Normal file
4
nova_tests/.testr.conf
Normal file
@ -0,0 +1,4 @@
|
||||
[DEFAULT]
|
||||
test_command=${PYTHON:-python} -m subunit.run discover -t ./nova_tests ./nova_tests $LISTOPT $IDOPTION
|
||||
test_id_option=--load-list $IDFILE
|
||||
test_list_option=--list
|
@ -85,15 +85,6 @@ ceilometer.publisher =
|
||||
meter_publisher = ceilometer.publisher.meter:MeterPublisher
|
||||
meter = ceilometer.publisher.meter:MeterPublisher
|
||||
|
||||
[nosetests]
|
||||
cover-package = ceilometer
|
||||
cover-html = true
|
||||
cover-erase = true
|
||||
cover-inclusive = true
|
||||
verbosity=2
|
||||
detailed-errors=1
|
||||
where=tests
|
||||
|
||||
[build_sphinx]
|
||||
all_files = 1
|
||||
build-dir = doc/build
|
||||
|
@ -40,7 +40,7 @@ class TestApp(base.TestCase):
|
||||
group=acl.OPT_GROUP_NAME)
|
||||
cfg.CONF.set_override("auth_version", "v2.0", group=acl.OPT_GROUP_NAME)
|
||||
cfg.CONF.set_override("pipeline_cfg_file",
|
||||
"../etc/ceilometer/pipeline.yaml")
|
||||
self.path_get("etc/ceilometer/pipeline.yaml"))
|
||||
api_app = app.setup_app()
|
||||
self.assertEqual(api_app.auth_protocol, 'foottp')
|
||||
|
||||
@ -48,7 +48,8 @@ class TestApp(base.TestCase):
|
||||
tmpfile = self.temp_config_file_path()
|
||||
with open(tmpfile, "w") as f:
|
||||
f.write("[DEFAULT]\n")
|
||||
f.write("pipeline_cfg_file = ../etc/ceilometer/pipeline.yaml\n")
|
||||
f.write("pipeline_cfg_file = %s\n" %
|
||||
self.path_get("etc/ceilometer/pipeline.yaml"))
|
||||
f.write("[%s]\n" % acl.OPT_GROUP_NAME)
|
||||
f.write("auth_protocol = barttp\n")
|
||||
f.write("auth_version = v2.0\n")
|
||||
|
@ -36,7 +36,7 @@ class BinDbsyncTestCase(base.TestCase):
|
||||
tmp.write("database_connection=log://localhost\n")
|
||||
|
||||
def test_dbsync_run(self):
|
||||
subp = subprocess.Popen(["../bin/ceilometer-dbsync",
|
||||
subp = subprocess.Popen([self.path_get('bin/ceilometer-dbsync'),
|
||||
"--config-file=%s" % self.tempfile])
|
||||
self.assertEqual(subp.wait(), 0)
|
||||
|
||||
@ -45,15 +45,16 @@ class BinSendCounterTestCase(base.TestCase):
|
||||
def setUp(self):
|
||||
super(BinSendCounterTestCase, self).setUp()
|
||||
self.tempfile = self.temp_config_file_path()
|
||||
pipeline_cfg_file = self.path_get('etc/ceilometer/pipeline.yaml')
|
||||
with open(self.tempfile, 'w') as tmp:
|
||||
tmp.write("[DEFAULT]\n")
|
||||
tmp.write(
|
||||
"rpc_backend=ceilometer.openstack.common.rpc.impl_fake\n")
|
||||
tmp.write(
|
||||
"pipeline_cfg_file=../etc/ceilometer/pipeline.yaml\n")
|
||||
"pipeline_cfg_file=%s\n" % pipeline_cfg_file)
|
||||
|
||||
def test_send_counter_run(self):
|
||||
subp = subprocess.Popen(["../bin/ceilometer-send-counter",
|
||||
subp = subprocess.Popen([self.path_get('bin/ceilometer-send-counter'),
|
||||
"--config-file=%s" % self.tempfile,
|
||||
"--counter-resource=someuuid",
|
||||
"--counter-name=mycounter"])
|
||||
@ -67,6 +68,8 @@ class BinApiTestCase(base.TestCase):
|
||||
self.api_port = random.randint(10000, 11000)
|
||||
self.http = httplib2.Http()
|
||||
self.tempfile = self.temp_config_file_path()
|
||||
pipeline_cfg_file = self.path_get('etc/ceilometer/pipeline.yaml')
|
||||
policy_file = self.path_get('tests/policy.json')
|
||||
with open(self.tempfile, 'w') as tmp:
|
||||
tmp.write("[DEFAULT]\n")
|
||||
tmp.write(
|
||||
@ -79,8 +82,10 @@ class BinApiTestCase(base.TestCase):
|
||||
tmp.write(
|
||||
"debug=true\n")
|
||||
tmp.write(
|
||||
"pipeline_cfg_file=../etc/ceilometer/pipeline.yaml\n")
|
||||
self.subp = subprocess.Popen(["../bin/ceilometer-api",
|
||||
"pipeline_cfg_file=%s\n" % pipeline_cfg_file)
|
||||
tmp.write(
|
||||
"policy_file=%s\n" % policy_file)
|
||||
self.subp = subprocess.Popen([self.path_get('bin/ceilometer-api'),
|
||||
"--config-file=%s" % self.tempfile])
|
||||
|
||||
def tearDown(self):
|
||||
|
8
tools/init_testr_if_needed.sh
Executable file
8
tools/init_testr_if_needed.sh
Executable file
@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
# this is rather stupid script is needed as testr init
|
||||
# complains if there is already a repo.
|
||||
if [ -d nova_tests/.testrepository ]
|
||||
then
|
||||
exit 0
|
||||
fi
|
||||
testr init -d nova_tests
|
@ -1,5 +1,6 @@
|
||||
nose
|
||||
distribute>=0.6.24
|
||||
coverage
|
||||
discover
|
||||
mock
|
||||
mox
|
||||
fixtures>=0.3.12
|
||||
@ -17,4 +18,6 @@ netifaces
|
||||
sphinx
|
||||
docutils==0.9.1 # for bug 1091333, remove after sphinx >1.1.3 is released.
|
||||
python-spidermonkey
|
||||
python-subunit
|
||||
testrepository>=0.0.13
|
||||
testtools>=0.9.29
|
||||
|
14
tox.ini
14
tox.ini
@ -5,18 +5,16 @@ envlist = py26,py27,pep8
|
||||
deps = -r{toxinidir}/tools/test-requires
|
||||
-r{toxinidir}/tools/pip-requires
|
||||
setenv = VIRTUAL_ENV={envdir}
|
||||
NOSE_WITH_OPENSTACK=1
|
||||
NOSE_OPENSTACK_COLOR=1
|
||||
NOSE_OPENSTACK_RED=0.05
|
||||
NOSE_OPENSTACK_YELLOW=0.025
|
||||
NOSE_OPENSTACK_SHOW_ELAPSED=1
|
||||
EVENTLET_NO_GREENDNS=yes
|
||||
commands =
|
||||
nosetests --no-path-adjustment --where=../nova_tests
|
||||
nosetests --no-path-adjustment {posargs}
|
||||
python setup.py testr --slowest --testr-args='--concurrency=1 {posargs}'
|
||||
bash tools/init_testr_if_needed.sh
|
||||
python setup.py testr --slowest --testr-args='--concurrency=1 --here=nova_tests {posargs}'
|
||||
sitepackages = False
|
||||
|
||||
[testenv:cover]
|
||||
commands = nosetests --no-path-adjustment --with-coverage --cover-erase --cover-package=ceilometer --cover-inclusive []
|
||||
setenv = VIRTUAL_ENV={envdir}
|
||||
commands = python setup.py testr --coverage
|
||||
|
||||
[testenv:pep8]
|
||||
# Install bounded pep8/pyflakes first, then let flake8 install
|
||||
|
Loading…
Reference in New Issue
Block a user