From 151a242dba409161366290eccf87daf62eacd191 Mon Sep 17 00:00:00 2001 From: Frode Nordahl Date: Wed, 6 Feb 2019 11:24:26 +0100 Subject: [PATCH] Add helper for creating rbd-mirror key tox: Remove cleanup of Python object files as this breaks in the upstream gate. tox: While at it migrate from os-testr to stestr. Change-Id: I1bad5311ed034188a78dc67b493c22bff7ce4f7d --- .stestr.conf | 3 +++ .testr.conf | 8 -------- ceph/utils.py | 9 +++++++++ test-requirements.txt | 2 +- tox.ini | 9 ++------- unit_tests/test_utils.py | 12 ++++++++++++ 6 files changed, 27 insertions(+), 16 deletions(-) create mode 100644 .stestr.conf delete mode 100644 .testr.conf diff --git a/.stestr.conf b/.stestr.conf new file mode 100644 index 0000000..5fcccac --- /dev/null +++ b/.stestr.conf @@ -0,0 +1,3 @@ +[DEFAULT] +test_path=./unit_tests +top_dir=./ diff --git a/.testr.conf b/.testr.conf deleted file mode 100644 index 801646b..0000000 --- a/.testr.conf +++ /dev/null @@ -1,8 +0,0 @@ -[DEFAULT] -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 ./ ./unit_tests $LISTOPT $IDOPTION - -test_id_option=--load-list $IDFILE -test_list_option=--list diff --git a/ceph/utils.py b/ceph/utils.py index 98320ac..2256c66 100644 --- a/ceph/utils.py +++ b/ceph/utils.py @@ -1132,6 +1132,15 @@ osd_upgrade_caps = collections.OrderedDict([ ]) ]) +rbd_mirror_caps = collections.OrderedDict([ + ('mon', ['profile rbd']), + ('osd', ['profile rbd']), +]) + + +def get_rbd_mirror_key(name): + return get_named_key(name=name, caps=rbd_mirror_caps) + def create_named_keyring(entity, name, caps=None): caps = caps or _default_caps diff --git a/test-requirements.txt b/test-requirements.txt index 167b477..7404bec 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -5,6 +5,6 @@ coverage>=3.6 nose mock>=1.2 flake8>=2.2.4,<=2.4.1 -os-testr>=0.4.1 +stestr requests==2.6.0 netifaces diff --git a/tox.ini b/tox.ini index e7fb963..cf38ce4 100644 --- a/tox.ini +++ b/tox.ini @@ -7,14 +7,9 @@ skip_missing_interpreters = True setenv = VIRTUAL_ENV={envdir} install_command = pip install {opts} {packages} -commands = find . -type f -name "*.py[c|o]" -delete - find . -type d -name "__pycache__" -delete - rm -f .testrepository/times.dbm - ostestr {posargs} +commands = + stestr run {posargs} sitepackages = False -whitelist_externals = - find - rm [testenv:py27] # ceph charms are Python3-only, but py27 unit test target diff --git a/unit_tests/test_utils.py b/unit_tests/test_utils.py index 838192c..6aec383 100644 --- a/unit_tests/test_utils.py +++ b/unit_tests/test_utils.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import collections import unittest from mock import ( @@ -804,6 +805,17 @@ class CephTestCase(unittest.TestCase): self.assertEqual(utils._partition_name('/dev/mmcblk0'), '/dev/mmcblk0p1') + @patch.object(utils, 'get_named_key') + def test_get_rbd_mirror_key(self, _get_named_key): + utils.get_rbd_mirror_key('someid') + _get_named_key.assert_called_once_with( + name='someid', + caps=collections.OrderedDict([ + ('mon', ['profile rbd']), + ('osd', ['profile rbd']), + ]) + ) + class CephVolumeSizeCalculatorTestCase(unittest.TestCase):