diff --git a/Makefile b/Makefile index fb9c8d1..0282e25 100644 --- a/Makefile +++ b/Makefile @@ -12,9 +12,7 @@ test: functional_test: @echo Starting Amulet tests... - @tests/setup/00-setup - @juju test -v -p AMULET_ODL_LOCATION,AMULET_ODL_HE_LOCATION,AMULET_ODL_LI_LOCATION,AMULET_ODL_BE_LOCATION,AMULET_HTTP_PROXY,AMULET_OS_VIP \ - --timeout 2700 + @tox -e func27 bin/charm_helpers_sync.py: @mkdir -p bin diff --git a/requirements.txt b/requirements.txt index e292ca2..6a3271b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,12 @@ -PyYAML>=3.10 -simplejson==3.3.1 -netifaces==0.8 -netaddr==0.7.10 -Jinja2==2.7.2 -six==1.5.2 +# The order of packages is significant, because pip processes them in the order +# of appearance. Changing the order has an impact on the overall integration +# process, which may cause wedges in the gate later. +pbr>=1.8.0,<1.9.0 +PyYAML>=3.1.0 +simplejson>=2.2.0 +netifaces>=0.10.4 +netaddr>=0.7.12,!=0.7.16 +Jinja2>=2.6 # BSD License (3 clause) +six>=1.9.0 +dnspython>=1.12.0 +psutil>=1.1.1,<2.0.0 diff --git a/test-requirements.txt b/test-requirements.txt index c0be415..313172d 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,3 +1,6 @@ +# The order of packages is significant, because pip processes them in the order +# of appearance. Changing the order has an impact on the overall integration +# process, which may cause wedges in the gate later. testtools coverage==3.7.1 mock==1.0.1 @@ -6,3 +9,17 @@ flake8==2.1.0 charm-tools>=2.0.0 os-testr requests==2.6.0 +# BEGIN: Amulet OpenStack Charm Helper Requirements +# Liberty client lower constraints +amulet>=1.14.3,<2.0 +bundletester>=0.6.1,<1.0 +python-ceilometerclient>=1.5.0,<2.0 +python-cinderclient>=1.4.0,<2.0 +python-glanceclient>=1.1.0,<2.0 +python-heatclient>=0.8.0,<1.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/tests/020-basic-wily-liberty b/tests/020-basic-wily-liberty deleted file mode 100755 index 8585beb..0000000 --- a/tests/020-basic-wily-liberty +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/python -# -# Copyright 2016 Canonical Ltd -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Amulet tests on a basic openvswitch ODL deployment on wily-liberty.""" - -from basic_deployment import OVSODLBasicDeployment - -if __name__ == '__main__': - deployment = OVSODLBasicDeployment(series='wily') - deployment.run_tests() diff --git a/tests/README b/tests/README deleted file mode 100644 index 79c5b06..0000000 --- a/tests/README +++ /dev/null @@ -1,113 +0,0 @@ -This directory provides Amulet tests to verify basic deployment functionality -from the perspective of this charm, its requirements and its features, as -exercised in a subset of the full OpenStack deployment test bundle topology. - -Reference: lp:openstack-charm-testing for full test bundles. - -A single topology and configuration is defined and deployed, once for each of -the defined Ubuntu:OpenStack release combos. The ongoing goal is for this -charm to always possess tests and combo definitions for all currently-supported -release combinations of U:OS. - -test_* methods are called in lexical sort order, as with most runners. However, -each individual test method should be idempotent and expected to pass regardless -of run order or Ubuntu:OpenStack combo. When writing or modifying tests, -ensure that every individual test is not dependent on another test_ method. - -Test naming convention, purely for code organization purposes: - 1xx service and endpoint checks - 2xx relation checks - 3xx config checks - 4xx functional checks - 9xx restarts, config changes, actions and other final checks - -In order to run tests, charm-tools and juju must be installed: - sudo add-apt-repository ppa:juju/stable - sudo apt-get update - sudo apt-get install charm-tools juju juju-deployer amulet - -Alternatively, tests may be exercised with proposed or development versions -of juju and related tools: - - # juju proposed version - sudo add-apt-repository ppa:juju/proposed - sudo apt-get update - sudo apt-get install charm-tools juju juju-deployer - - # juju development version - sudo add-apt-repository ppa:juju/devel - sudo apt-get update - sudo apt-get install charm-tools juju juju-deployer - -Some tests may need to download files. If a web proxy server is required in -the environment, the AMULET_HTTP_PROXY environment variable must be set and -passed into the juju test command. This is unrelated to juju's http proxy -settings or behavior. - -The following examples demonstrate different ways that tests can be executed. -All examples are run from the charm's root directory. - - * To run all +x tests in the tests directory: - - bzr branch lp:charms/trusty/foo - cd foo - make functional_test - - * To run the tests against a specific release combo as defined in tests/: - - bzr branch lp:charms/trusty/foo - cd foo - juju test -v -p AMULET_HTTP_PROXY 015-basic-trusty-icehouse - - * To run tests and keep the juju environment deployed after a failure: - - bzr branch lp:charms/trusty/foo - cd foo - juju test --set-e -v -p AMULET_HTTP_PROXY 015-basic-trusty-icehouse - - * To re-run a test module against an already deployed environment (one - that was deployed by a previous call to 'juju test --set-e'): - - ./tests/015-basic-trusty-icehouse - - * Even with --set-e, `juju test` will tear down the deployment when all - tests pass. The following work flow may be more effective when - iterating on test writing. - - bzr branch lp:charms/trusty/foo - cd foo - ./tests/setup/00-setup - juju bootstrap - ./tests/015-basic-trusty-icehouse - # make some changes, run tests again - ./tests/015-basic-trusty-icehouse - # make some changes, run tests again - ./tests/015-basic-trusty-icehouse - - * There may be test definitions in the tests/ dir which are not set +x - executable. This is generally true for deprecated releases, or for - upcoming releases which are not yet validated and enabled. To enable - and run these tests: - bzr branch lp:charms/trusty/foo - cd foo - ls tests - chmod +x tests/017-basic-trusty-kilo - ./tests/setup/00-setup - juju bootstrap - ./tests/017-basic-trusty-kilo - - -Additional notes: - - * Use DEBUG to turn on debug logging, use ERROR otherwise. - u = OpenStackAmuletUtils(ERROR) - u = OpenStackAmuletUtils(DEBUG) - - * To interact with the deployed environment: - export OS_USERNAME=admin - export OS_PASSWORD=openstack - export OS_TENANT_NAME=admin - export OS_REGION_NAME=RegionOne - export OS_AUTH_URL=${OS_AUTH_PROTOCOL:-http}://`juju-deployer -e trusty -f keystone`:5000/v2.0 - keystone user-list - glance image-list diff --git a/tests/README.md b/tests/README.md new file mode 100644 index 0000000..046be7f --- /dev/null +++ b/tests/README.md @@ -0,0 +1,9 @@ +# Overview + +This directory provides Amulet tests to verify basic deployment functionality +from the perspective of this charm, its requirements and its features, as +exercised in a subset of the full OpenStack deployment test bundle topology. + +For full details on functional testing of OpenStack charms please refer to +the [functional testing](http://docs.openstack.org/developer/charm-guide/testing.html#functional-testing) +section of the OpenStack Charm Guide. diff --git a/tests/basic_deployment.py b/tests/basic_deployment.py index f9da170..e058eee 100644 --- a/tests/basic_deployment.py +++ b/tests/basic_deployment.py @@ -178,17 +178,17 @@ class OVSODLBasicDeployment(OpenStackAmuletDeployment): def _initialize_tests(self): """Perform final initialization before tests get run.""" # Access the sentries for inspecting service units - self.compute_sentry = self.d.sentry.unit['nova-compute/0'] - self.neutron_api_sentry = self.d.sentry.unit['neutron-api/0'] - self.ovsodl_sentry = self.d.sentry.unit['openvswitch-odl/0'] - self.mysql_sentry = self.d.sentry.unit['mysql/0'] - self.rabbitmq_server_sentry = self.d.sentry.unit['rabbitmq-server/0'] - self.keystone_sentry = self.d.sentry.unit['keystone/0'] - self.glance_sentry = self.d.sentry.unit['glance/0'] - self.nova_cc_sentry = self.d.sentry.unit['nova-cloud-controller/0'] - self.neutron_api_odl_sentry = self.d.sentry.unit['neutron-api-odl/0'] - self.odl_controller_sentry = self.d.sentry.unit['odl-controller/0'] - self.gateway_sentry = self.d.sentry.unit['neutron-gateway/0'] + self.compute_sentry = self.d.sentry['nova-compute'][0] + self.neutron_api_sentry = self.d.sentry['neutron-api'][0] + self.ovsodl_sentry = self.d.sentry['openvswitch-odl'][0] + self.mysql_sentry = self.d.sentry['mysql'][0] + self.rabbitmq_server_sentry = self.d.sentry['rabbitmq-server'][0] + self.keystone_sentry = self.d.sentry['keystone'][0] + self.glance_sentry = self.d.sentry['glance'][0] + self.nova_cc_sentry = self.d.sentry['nova-cloud-controller'][0] + self.neutron_api_odl_sentry = self.d.sentry['neutron-api-odl'][0] + self.odl_controller_sentry = self.d.sentry['odl-controller'][0] + self.gateway_sentry = self.d.sentry['neutron-gateway'][0] self.keystone = u.authenticate_keystone_admin(self.keystone_sentry, user='admin', password='openstack', diff --git a/tests/015-basic-trusty-icehouse b/tests/gate-basic-trusty-icehouse similarity index 97% rename from tests/015-basic-trusty-icehouse rename to tests/gate-basic-trusty-icehouse index 91280d2..aa94421 100755 --- a/tests/015-basic-trusty-icehouse +++ b/tests/gate-basic-trusty-icehouse @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # # Copyright 2016 Canonical Ltd # diff --git a/tests/017-basic-trusty-kilo b/tests/gate-basic-trusty-kilo similarity index 97% rename from tests/017-basic-trusty-kilo rename to tests/gate-basic-trusty-kilo index 161ac07..dd5f0d2 100755 --- a/tests/017-basic-trusty-kilo +++ b/tests/gate-basic-trusty-kilo @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # # Copyright 2016 Canonical Ltd # diff --git a/tests/018-basic-trusty-liberty b/tests/gate-basic-trusty-liberty similarity index 97% rename from tests/018-basic-trusty-liberty rename to tests/gate-basic-trusty-liberty index aa57ca6..6d2f470 100755 --- a/tests/018-basic-trusty-liberty +++ b/tests/gate-basic-trusty-liberty @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # # Copyright 2016 Canonical Ltd # diff --git a/tests/019-basic-trusty-mitaka b/tests/gate-basic-trusty-mitaka similarity index 97% rename from tests/019-basic-trusty-mitaka rename to tests/gate-basic-trusty-mitaka index 4c98843..d10b822 100755 --- a/tests/019-basic-trusty-mitaka +++ b/tests/gate-basic-trusty-mitaka @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # # Copyright 2016 Canonical Ltd # diff --git a/tests/021-basic-xenial-mitaka b/tests/gate-basic-xenial-mitaka similarity index 97% rename from tests/021-basic-xenial-mitaka rename to tests/gate-basic-xenial-mitaka index 0bef7cd..d53c620 100755 --- a/tests/021-basic-xenial-mitaka +++ b/tests/gate-basic-xenial-mitaka @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # # Copyright 2016 Canonical Ltd # diff --git a/tests/setup/00-setup b/tests/setup/00-setup deleted file mode 100755 index 0158054..0000000 --- a/tests/setup/00-setup +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -set -ex - -sudo add-apt-repository --yes ppa:juju/stable -sudo apt-get update --yes -sudo apt-get install --yes python-amulet diff --git a/tests/tests.yaml b/tests/tests.yaml index 4d17631..e3185c6 100644 --- a/tests/tests.yaml +++ b/tests/tests.yaml @@ -1,21 +1,17 @@ -bootstrap: true -reset: false -virtualenv: true -makefile: - - lint - - test -sources: - - ppa:juju/stable -packages: - - amulet - - distro-info-data - - python-ceilometerclient - - python-cinderclient - - python-distro-info - - python-glanceclient - - python-heatclient - - python-keystoneclient - - python-neutronclient - - python-novaclient - - python-pika - - python-swiftclient +# Bootstrap the model if necessary. +bootstrap: True +# Re-use bootstrap node instead of destroying/re-bootstrapping. +reset: True +# Use tox/requirements to drive the venv instead of bundletester's venv feature. +virtualenv: False +# Leave makefile empty, otherwise unit/lint tests will rerun ahead of amulet. +makefile: [] +# Do not specify juju PPA sources. Juju is presumed to be pre-installed +# and configured in all test runner environments. +#sources: +# Do not specify or rely on system packages. +#packages: +# Do not specify python packages here. Use test-requirements.txt +# and tox instead. ie. The venv is constructed before bundletester +# is invoked. +#python-packages: diff --git a/tox.ini b/tox.ini index 03c24fd..9e2a4cc 100644 --- a/tox.ini +++ b/tox.ini @@ -7,6 +7,8 @@ skipsdist = True setenv = VIRTUAL_ENV={envdir} PYTHONHASHSEED=0 CHARM_DIR={envdir} + AMULET_SETUP_TIMEOUT=2700 +passenv = HOME TERM AMULET_* install_command = pip install --allow-unverified python-apt {opts} {packages} commands = ostestr {posargs} @@ -26,6 +28,50 @@ commands = flake8 {posargs} hooks unit_tests tests [testenv:venv] commands = {posargs} +[testenv:func27-noop] +# DRY RUN - For Debug +basepython = python2.7 +deps = -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt +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 +deps = -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt +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 +deps = -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt +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 +deps = -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt +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 +deps = -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt +commands = + bundletester -vl DEBUG -r json -o func-results.json --test-pattern "dev-*" --no-destroy + [flake8] ignore = E402,E226 exclude = hooks/charmhelpers