From fbde2aab1f5f56a1bb88c3184f0aaae2cf1944b7 Mon Sep 17 00:00:00 2001 From: James Page Date: Fri, 30 Oct 2015 11:15:38 +0900 Subject: [PATCH] Add tox configurations and requirements definitions --- .testr.conf | 8 ++++++ hooks/ceph_hooks.py | 4 +-- requirements/requirements-precise.txt | 6 +++++ requirements/requirements-trusty.txt | 7 ++++++ requirements/test-requirements.txt | 7 ++++++ tox.ini | 35 +++++++++++++++++++++++++++ 6 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 .testr.conf create mode 100644 requirements/requirements-precise.txt create mode 100644 requirements/requirements-trusty.txt create mode 100644 requirements/test-requirements.txt create mode 100644 tox.ini diff --git a/.testr.conf b/.testr.conf new file mode 100644 index 0000000..801646b --- /dev/null +++ b/.testr.conf @@ -0,0 +1,8 @@ +[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/hooks/ceph_hooks.py b/hooks/ceph_hooks.py index ccd575a..9d73363 100755 --- a/hooks/ceph_hooks.py +++ b/hooks/ceph_hooks.py @@ -146,8 +146,8 @@ def config_changed(): umount(e_mountpoint) osd_journal = config('osd-journal') - if (osd_journal and not os.path.exists(JOURNAL_ZAPPED) - and os.path.exists(osd_journal)): + if (osd_journal and not os.path.exists(JOURNAL_ZAPPED) and + os.path.exists(osd_journal)): ceph.zap_disk(osd_journal) with open(JOURNAL_ZAPPED, 'w') as zapped: zapped.write('DONE') diff --git a/requirements/requirements-precise.txt b/requirements/requirements-precise.txt new file mode 100644 index 0000000..21ee7d1 --- /dev/null +++ b/requirements/requirements-precise.txt @@ -0,0 +1,6 @@ +PyYAML==3.10 +simplejson==2.3.2 +netifaces==0.8 +netaddr==0.7.10 +Jinja2==2.6 +six==1.1.0 diff --git a/requirements/requirements-trusty.txt b/requirements/requirements-trusty.txt new file mode 100644 index 0000000..b73a7e4 --- /dev/null +++ b/requirements/requirements-trusty.txt @@ -0,0 +1,7 @@ +PyYAML>=3.10 +simplejson>=3.3.1 +netifaces>=0.8 +netaddr>=0.7.10 +Jinja2>=2.7.2 +six>=1.5.2 +dnspython diff --git a/requirements/test-requirements.txt b/requirements/test-requirements.txt new file mode 100644 index 0000000..ff4fb63 --- /dev/null +++ b/requirements/test-requirements.txt @@ -0,0 +1,7 @@ +testtools +coverage +mock +flake8==2.1.0 +# No version required +charm-tools +os-testr diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..e9cf1d5 --- /dev/null +++ b/tox.ini @@ -0,0 +1,35 @@ +[tox] +# Default to current LTS +envlist = lint,py27-trusty +skipsdist = True + +[testenv] +setenv = VIRTUAL_ENV={envdir} + PYTHONHASHSEED=0 +install_command = + pip install --allow-unverified python-apt {opts} {packages} +commands = ostestr {posargs} + +[testenv:py27-precise] +basepython = python2.7 +deps = -r{toxinidir}/requirements/requirements-precise.txt + -r{toxinidir}/requirements/test-requirements.txt + +[testenv:py27-trusty] +basepython = python2.7 +deps = -r{toxinidir}/requirements/requirements-trusty.txt + -r{toxinidir}/requirements/test-requirements.txt + +[testenv:lint] +basepython = python2.7 +deps = -r{toxinidir}/requirements/requirements-trusty.txt + -r{toxinidir}/requirements/test-requirements.txt +commands = flake8 {posargs} hooks unit_tests tests + charm proof + +[testenv:venv] +commands = {posargs} + +[flake8] +ignore = E402,E226 +exclude = hooks/charmhelpers