diff --git a/src/test-requirements.txt b/src/test-requirements.txt new file mode 100644 index 0000000..0f71329 --- /dev/null +++ b/src/test-requirements.txt @@ -0,0 +1,15 @@ +# 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-glanceclient>=1.1.0,<2.0 +python-openstackclient>=1.7.0,<2.0 +python-mistralclient +pika>=0.10.0,<1.0 +distro-info +# END: Amulet OpenStack Charm Helper Requirements diff --git a/src/tests/basic_deployment.py b/src/tests/basic_deployment.py index 4e3d967..ca6886c 100644 --- a/src/tests/basic_deployment.py +++ b/src/tests/basic_deployment.py @@ -26,13 +26,13 @@ import charmhelpers.contrib.openstack.amulet.utils as os_amulet_utils u = os_amulet_utils.OpenStackAmuletUtils(os_amulet_utils.DEBUG) -class SDNCharmDeployment(amulet_deployment.OpenStackAmuletDeployment): +class MistralBasicDeployment(amulet_deployment.OpenStackAmuletDeployment): """Amulet tests on a basic sdn_charm deployment.""" def __init__(self, series, openstack=None, source=None, stable=False): """Deploy the entire test environment.""" - super(SDNCharmDeployment, self).__init__(series, openstack, - source, stable) + super(MistralBasicDeployment, self).__init__(series, openstack, + source, stable) self._add_services() self._add_relations() self._configure_services() @@ -51,63 +51,35 @@ class SDNCharmDeployment(amulet_deployment.OpenStackAmuletDeployment): and the rest of the service are from lp branches that are compatible with the local charm (e.g. stable or next). """ - this_service = {'name': 'sdn_charm'} + this_service = {'name': 'mistral'} other_services = [ - { - 'name': 'nova-compute', - 'constraints': {'mem': '4G'}, - }, - { - 'name': 'neutron-api', - }, - { - 'name': 'neutron-gateway', - }, {'name': 'mysql'}, {'name': 'rabbitmq-server'}, {'name': 'keystone'}, - {'name': 'nova-cloud-controller'}, {'name': 'glance'}, ] - super(SDNCharmDeployment, self)._add_services(this_service, - other_services) + super(MistralBasicDeployment, self)._add_services(this_service, + other_services) def _add_relations(self): """Add all of the relations for the services.""" relations = { - 'nova-compute:neutron-plugin': 'sdn_charm:neutron-plugin', 'keystone:shared-db': 'mysql:shared-db', - 'nova-cloud-controller:shared-db': 'mysql:shared-db', - 'nova-cloud-controller:amqp': 'rabbitmq-server:amqp', - 'nova-cloud-controller:image-service': 'glance:image-service', - 'nova-cloud-controller:identity-service': - 'keystone:identity-service', - 'nova-compute:cloud-compute': - 'nova-cloud-controller:cloud-compute', - 'nova-compute:amqp': 'rabbitmq-server:amqp', - 'nova-compute:image-service': 'glance:image-service', 'glance:shared-db': 'mysql:shared-db', 'glance:identity-service': 'keystone:identity-service', 'glance:amqp': 'rabbitmq-server:amqp', - 'neutron-api:shared-db': 'mysql:shared-db', - 'neutron-api:amqp': 'rabbitmq-server:amqp', - 'neutron-api:neutron-api': 'nova-cloud-controller:neutron-api', - 'neutron-api:identity-service': 'keystone:identity-service', - 'neutron-gateway:amqp': 'rabbitmq-server:amqp', - 'neutron-gateway:neutron-plugin-api': - 'neutron-api:neutron-plugin-api', - 'neutron-gateway:quantum-network-service': - 'nova-cloud-controller:quantum-network-service', - 'neutron-gateway:juju-info': 'sdn_charm:container', + 'mistral:shared-db': 'mysql:shared-db', + 'mistral:identity-service': 'keystone:identity-service', + 'mistral:amqp': 'rabbitmq-server:amqp', } - super(SDNCharmDeployment, self)._add_relations(relations) + super(MistralBasicDeployment, self)._add_relations(relations) def _configure_services(self): """Configure all of the services.""" keystone_config = {'admin-password': 'openstack', 'admin-token': 'ubuntutesting'} configs = {'keystone': keystone_config} - super(SDNCharmDeployment, self)._configure_services(configs) + super(MistralBasicDeployment, self)._configure_services(configs) def _get_token(self): return self.keystone.service_catalog.catalog['token']['id'] @@ -115,11 +87,11 @@ class SDNCharmDeployment(amulet_deployment.OpenStackAmuletDeployment): def _initialize_tests(self): """Perform final initialization before tests get run.""" # Access the sentries for inspecting service units - self.sdn_charm_sentry = self.d.sentry['sdn_charm'][0] + self.mistral_charm_sentry = self.d.sentry['sdn_charm'][0] self.mysql_sentry = self.d.sentry['mysql'][0] self.keystone_sentry = self.d.sentry['keystone'][0] self.rabbitmq_sentry = self.d.sentry['rabbitmq-server'][0] - self.sdn_charm_svcs = [ + self.mistral_charm_svcs = [ 'sdn_charm-agent', 'sdn_charm-api'] # Authenticate admin with keystone endpoint @@ -178,4 +150,4 @@ class SDNCharmDeployment(amulet_deployment.OpenStackAmuletDeployment): if ret: amulet.raise_status(amulet.FAIL, msg=ret) - u.log.debug('OK') \ No newline at end of file + u.log.debug('OK') diff --git a/src/tests/gate-basic-trusty-icehouse b/src/tests/gate-basic-trusty-icehouse deleted file mode 100755 index bc30915..0000000 --- a/src/tests/gate-basic-trusty-icehouse +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env 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 SDN Charm deployment on trusty-icehouse.""" - -from basic_deployment import SDNCharmDeployment - -if __name__ == '__main__': - deployment = SDNCharmDeployment(series='trusty') - deployment.run_tests() \ No newline at end of file diff --git a/src/tests/gate-basic-trusty-liberty b/src/tests/gate-basic-trusty-liberty deleted file mode 100755 index f4fe1ff..0000000 --- a/src/tests/gate-basic-trusty-liberty +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env 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 SDN Charm deployment on trusty-liberty.""" - -from basic_deployment import SDNCharmDeployment - -if __name__ == '__main__': - deployment = SDNCharmDeployment(series='trusty', - openstack='cloud:trusty-liberty', - source='cloud:trusty-updates/liberty') - deployment.run_tests() \ No newline at end of file diff --git a/src/tests/gate-basic-xenial-mitaka b/src/tests/gate-basic-xenial-mitaka deleted file mode 100755 index 37725c2..0000000 --- a/src/tests/gate-basic-xenial-mitaka +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env 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 SDN Charm deployment on xenial-mitaka.""" - -from basic_deployment import SDNCharmDeployment - -if __name__ == '__main__': - deployment = SDNCharmDeployment(series='xenial') - deployment.run_tests() \ No newline at end of file diff --git a/src/tests/gate-basic-trusty-mitaka b/src/tests/gate-basic-xenial-newton similarity index 64% rename from src/tests/gate-basic-trusty-mitaka rename to src/tests/gate-basic-xenial-newton index 9142a10..4cc7f2a 100755 --- a/src/tests/gate-basic-trusty-mitaka +++ b/src/tests/gate-basic-xenial-newton @@ -14,12 +14,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -"""Amulet tests on a basic SDN Charm deployment on trusty-mitaka.""" +"""Amulet tests on a basic designate deployment on xenial-newton.""" -from basic_deployment import SDNCharmDeployment +from basic_deployment import MistralBasicDeployment if __name__ == '__main__': - deployment = SDNCharmDeployment(series='trusty', - openstack='cloud:trusty-mitaka', - source='cloud:trusty-updates/mitaka') - deployment.run_tests() \ No newline at end of file + deployment = MistralBasicDeployment(series='xenial', + openstack='cloud:xenial-newton', + source='cloud:xenial-updates/newton') + deployment.run_tests() diff --git a/src/tox.ini b/src/tox.ini index 8b9f734..f178591 100644 --- a/src/tox.ini +++ b/src/tox.ini @@ -1,47 +1,53 @@ -# Source charm: ./tox.ini +# Source charm: ./src/tox.ini # This file is managed centrally by release-tools and should not be modified # within individual charm repos. [tox] +envlist = pep8 skipsdist = True -envlist = pep8,py34,py35 -skip_missing_interpreters = True [testenv] setenv = VIRTUAL_ENV={envdir} PYTHONHASHSEED=0 - TERM=linux - LAYER_PATH={toxinidir}/layers - INTERFACE_PATH={toxinidir}/interfaces - JUJU_REPOSITORY={toxinidir}/build -passenv = http_proxy https_proxy + AMULET_SETUP_TIMEOUT=2700 +whitelist_externals = juju +passenv = HOME TERM AMULET_* +deps = -r{toxinidir}/test-requirements.txt install_command = - pip install {opts} {packages} -deps = - -r{toxinidir}/requirements.txt - -[testenv:build] -basepython = python2.7 -commands = - charm-build --log-level DEBUG -o {toxinidir}/build src {posargs} - -[testenv:py34] -basepython = python3.4 -deps = -r{toxinidir}/test-requirements.txt -commands = ostestr {posargs} - -[testenv:py35] -basepython = python3.5 -deps = -r{toxinidir}/test-requirements.txt -commands = ostestr {posargs} + pip install --allow-unverified python-apt {opts} {packages} [testenv:pep8] basepython = python2.7 -deps = -r{toxinidir}/test-requirements.txt -commands = flake8 {posargs} src unit_tests +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] +# 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] +# 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-newton --no-destroy + +[testenv:func27-dfs] +# 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] +# 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} - -[flake8] -# E402 ignore necessary for path append before sys module import in actions -ignore = E402 \ No newline at end of file