summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--.testr.conf4
-rw-r--r--ceilometer/api/v1/app.py5
-rw-r--r--ceilometer/tests/api.py12
-rw-r--r--ceilometer/tests/base.py13
-rw-r--r--nova_tests/.testr.conf4
-rw-r--r--setup.cfg9
-rw-r--r--tests/api/v2/test_app.py5
-rw-r--r--tests/test_bin.py15
-rwxr-xr-xtools/init_testr_if_needed.sh8
-rw-r--r--tools/test-requires5
-rw-r--r--tox.ini14
12 files changed, 62 insertions, 34 deletions
diff --git a/.gitignore b/.gitignore
index dc42fe29..0c3eb0c3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,6 +6,8 @@ build
.coverage
.tox
cover
+.testrepository
+subunit.log
AUTHORS
ChangeLog
*.deb
diff --git a/.testr.conf b/.testr.conf
new file mode 100644
index 00000000..081907d5
--- /dev/null
+++ b/.testr.conf
@@ -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
diff --git a/ceilometer/api/v1/app.py b/ceilometer/api/v1/app.py
index cb4db001..05bc505e 100644
--- a/ceilometer/api/v1/app.py
+++ b/ceilometer/api/v1/app.py
@@ -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 = {}
diff --git a/ceilometer/tests/api.py b/ceilometer/tests/api.py
index 0d831c48..0f667ec6 100644
--- a/ceilometer/tests/api.py
+++ b/ceilometer/tests/api.py
@@ -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 = {
diff --git a/ceilometer/tests/base.py b/ceilometer/tests/base.py
index befe9b43..3b15178b 100644
--- a/ceilometer/tests/base.py
+++ b/ceilometer/tests/base.py
@@ -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)
diff --git a/nova_tests/.testr.conf b/nova_tests/.testr.conf
new file mode 100644
index 00000000..d3284395
--- /dev/null
+++ b/nova_tests/.testr.conf
@@ -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
diff --git a/setup.cfg b/setup.cfg
index 6eb458ba..603f62d0 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -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
diff --git a/tests/api/v2/test_app.py b/tests/api/v2/test_app.py
index ede22be9..f98dd6ef 100644
--- a/tests/api/v2/test_app.py
+++ b/tests/api/v2/test_app.py
@@ -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")
diff --git a/tests/test_bin.py b/tests/test_bin.py
index 396b3973..0352a2e7 100644
--- a/tests/test_bin.py
+++ b/tests/test_bin.py
@@ -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):
diff --git a/tools/init_testr_if_needed.sh b/tools/init_testr_if_needed.sh
new file mode 100755
index 00000000..9d1e22f9
--- /dev/null
+++ b/tools/init_testr_if_needed.sh
@@ -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
diff --git a/tools/test-requires b/tools/test-requires
index 47dfc659..4709eb77 100644
--- a/tools/test-requires
+++ b/tools/test-requires
@@ -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
diff --git a/tox.ini b/tox.ini
index d9556a70..3c5bf146 100644
--- a/tox.ini
+++ b/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