From bb82897cda3f5f08eedbc93763447a10aac6fdf4 Mon Sep 17 00:00:00 2001 From: Ryan Beisner Date: Tue, 2 Aug 2016 20:32:27 +0000 Subject: [PATCH] Add .gitreview and clean up repo Update tox.ini to lint unit_tests, clean lint. Add src/README.md placeholder to prevent inheritence of the lower layer readme file in the built charm. Add src/tox.ini and test-requirements for Amulet prep. Update metadata.yaml for series. Update tox.ini to minimize and clarify pep8 ignores. Resolve flake8/pbr test-requirements version range conflict. Mock apt in unit tests. Add required tags data in src/metadata.yaml for charm proof. Use openstack/charms.openstack proper in test-requirements instead of a user space fork. Update src/layer.yaml repo value to point to official location and remove unnecessary options. Change-Id: I5ca9e6cf9f8f91b3ce0ec3b48cf63535ca37c0f7 --- .gitignore | 1 + .gitreview | 4 ++ src/README.md | 1 + src/layer.yaml | 6 +-- src/metadata.yaml | 6 +++ src/test-requirements.txt | 20 +++++++++ src/tests/README.md | 1 + src/tox.ini | 54 +++++++++++++++++++++++++ test-requirements.txt | 5 ++- tox.ini | 7 ++-- unit_tests/__init__.py | 2 + unit_tests/test_lib_barbican_softhsm.py | 1 - 12 files changed, 98 insertions(+), 10 deletions(-) create mode 100644 .gitreview create mode 100644 src/README.md create mode 100644 src/test-requirements.txt create mode 100644 src/tests/README.md create mode 100644 src/tox.ini diff --git a/.gitignore b/.gitignore index 53bfadc..a68c28d 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ layers interfaces trusty .testrepository +__pycache__ diff --git a/.gitreview b/.gitreview new file mode 100644 index 0000000..41c33ec --- /dev/null +++ b/.gitreview @@ -0,0 +1,4 @@ +[gerrit] +host=review.openstack.org +port=29418 +project=openstack/charm-barbican-softhsm.git diff --git a/src/README.md b/src/README.md new file mode 100644 index 0000000..f77cfea --- /dev/null +++ b/src/README.md @@ -0,0 +1 @@ +# Write me diff --git a/src/layer.yaml b/src/layer.yaml index f43c119..ed5e90e 100644 --- a/src/layer.yaml +++ b/src/layer.yaml @@ -1,5 +1,3 @@ includes: ['layer:openstack', 'interface:barbican-hsm'] -options: - basic: - use_venv: True - include_system_packages: True +repo: https://github.com/openstack/charm-barbican-softhsm + diff --git a/src/metadata.yaml b/src/metadata.yaml index 79d6a5f..f96282b 100644 --- a/src/metadata.yaml +++ b/src/metadata.yaml @@ -1,6 +1,12 @@ name: barbican-softhsm summary: The softhsm security module for the barbican charm service maintainer: OpenStack Charmers +tags: + - openstack +series: +# Trusty disabled pending https://bugs.launchpad.net/bugs/1609498 +# - trusty + - xenial subordinate: true description: | Barbican provides a secure storage for keys and other secrets and diff --git a/src/test-requirements.txt b/src/test-requirements.txt new file mode 100644 index 0000000..3ffd9c2 --- /dev/null +++ b/src/test-requirements.txt @@ -0,0 +1,20 @@ +# charm-proof +charm-tools>=2.0.0 +# amulet deployment helpers +bzr+lp:charm-helpers#egg=charmhelpers +# BEGIN: Amulet OpenStack Charm Helper Requirements +# Liberty client lower constraints +amulet>=1.14.3,<2.0 +bundletester>=0.6.1,<1.0 +python-keystoneclient>=1.7.1,<2.0 +python-designateclient>=1.5,<2.0 +python-cinderclient>=1.4.0,<2.0 +python-glanceclient>=1.1.0,<2.0 +python-heatclient>=0.8.0,<1.0 +python-neutronclient>=3.1.0,<4.0 +python-novaclient>=2.30.1,<3.0 +python-openstackclient>=1.7.0,<2.0 +python-swiftclient>=2.6.0,<3.0 +pika>=0.10.0,<1.0 +distro-info +# END: Amulet OpenStack Charm Helper Requirements diff --git a/src/tests/README.md b/src/tests/README.md new file mode 100644 index 0000000..8a856d6 --- /dev/null +++ b/src/tests/README.md @@ -0,0 +1 @@ +TODO: write Amulet tests. diff --git a/src/tox.ini b/src/tox.ini new file mode 100644 index 0000000..4a6291e --- /dev/null +++ b/src/tox.ini @@ -0,0 +1,54 @@ +[tox] +envlist = pep8 +skipsdist = True + +[testenv] +envdir = .tox/py27 +setenv = VIRTUAL_ENV={envdir} + PYTHONHASHSEED=0 + AMULET_SETUP_TIMEOUT=2700 +passenv = HOME TERM AMULET_HTTP_PROXY AMULET_OS_VIP +deps = -r{toxinidir}/test-requirements.txt +install_command = + pip install --allow-unverified python-apt {opts} {packages} + +[testenv:pep8] +basepython = python2.7 +commands = charm-proof + +[testenv:func27-noop] +# DRY RUN - For Debug +basepython = python2.7 +commands = + bundletester -vl DEBUG -r json -o func-results.json --test-pattern "gate-*" -n --no-destroy + +[testenv:func27] +# Charm Functional Test +# Run all gate tests which are +x (expected to always pass) +basepython = python2.7 +commands = + bundletester -vl DEBUG -r json -o func-results.json --test-pattern "gate-*" --no-destroy + +[testenv:func27-smoke] +# Charm Functional Test +# Run a specific test as an Amulet smoke test (expected to always pass) +basepython = python2.7 +commands = + bundletester -vl DEBUG -r json -o func-results.json gate-basic-xenial-mitaka --no-destroy + +[testenv:func27-dfs] +# Charm Functional Test +# Run all deploy-from-source tests which are +x (may not always pass!) +basepython = python2.7 +commands = + bundletester -vl DEBUG -r json -o func-results.json --test-pattern "dfs-*" --no-destroy + +[testenv:func27-dev] +# Charm Functional Test +# Run all development test targets which are +x (may not always pass!) +basepython = python2.7 +commands = + bundletester -vl DEBUG -r json -o func-results.json --test-pattern "dev-*" --no-destroy + +[testenv:venv] +commands = {posargs} diff --git a/test-requirements.txt b/test-requirements.txt index 0017fb5..368dbf2 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,6 +1,7 @@ -flake8>=2.2.4,<=2.4.1 +# Lint and unit test requirements +flake8 os-testr>=0.4.1 charms.reactive mock>=1.2 coverage>=3.6 -git+https://github.com/ajkavanagh/charms.openstack.git#egg=charms-openstack +git+https://github.com/openstack/charms.openstack.git#egg=charms-openstack diff --git a/tox.ini b/tox.ini index d853cfe..df765e0 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] skipsdist = True -envlist = generate +envlist = pep8,py34,py35 skip_missing_interpreters = True [testenv] @@ -35,10 +35,11 @@ commands = ostestr {posargs} [testenv:pep8] basepython = python2.7 deps = -r{toxinidir}/test-requirements.txt -commands = flake8 {posargs} src +commands = flake8 {posargs} src unit_tests [testenv:venv] commands = {posargs} [flake8] -ignore = E402,E226 +# E402 ignore necessary for path append before sys module import in actions +ignore = E402 diff --git a/unit_tests/__init__.py b/unit_tests/__init__.py index 4d30f85..ad8caed 100644 --- a/unit_tests/__init__.py +++ b/unit_tests/__init__.py @@ -21,6 +21,8 @@ sys.path.append('src/lib') # Mock out charmhelpers so that we can test without it. # also stops sideeffects from occuring. charmhelpers = mock.MagicMock() +apt_pkg = mock.MagicMock() +sys.modules['apt_pkg'] = apt_pkg sys.modules['charmhelpers'] = charmhelpers sys.modules['charmhelpers.core'] = charmhelpers.core sys.modules['charmhelpers.core.hookenv'] = charmhelpers.core.hookenv diff --git a/unit_tests/test_lib_barbican_softhsm.py b/unit_tests/test_lib_barbican_softhsm.py index 9e21b67..8e6a37f 100644 --- a/unit_tests/test_lib_barbican_softhsm.py +++ b/unit_tests/test_lib_barbican_softhsm.py @@ -224,4 +224,3 @@ class TestBarbicanSoftHSMCharm(Helper): "login": 'abcd', "slot_id": '10' }) -