From 7a1d9eb3f853b7b32aa9b429285bd9ec512198e4 Mon Sep 17 00:00:00 2001 From: David Ames Date: Thu, 27 Apr 2017 11:19:14 -0700 Subject: [PATCH] Enable Zesty-Ocata Amulet Tests - Turn on Zesty-Ocata Amulet test definitions. - Standardize test-requirements.txt - Sync charm helpers for various fixes Change-Id: Id3cbb8944e559ddb57dd249274572d264183f56f --- src/test-requirements.txt | 30 ++++++++++++++++++++---------- src/tests/basic_deployment.py | 23 ++++++++++++++--------- src/tests/gate-basic-zesty-ocata | 0 src/tox.ini | 2 +- unit_tests/__init__.py | 31 +++++-------------------------- 5 files changed, 40 insertions(+), 46 deletions(-) mode change 100644 => 100755 src/tests/gate-basic-zesty-ocata diff --git a/src/test-requirements.txt b/src/test-requirements.txt index 613b081..3cb4ae7 100644 --- a/src/test-requirements.txt +++ b/src/test-requirements.txt @@ -1,5 +1,12 @@ -# charm-proof +# 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. +coverage>=3.6 +mock>=1.2 +flake8>=2.2.4,<=2.4.1 +os-testr>=0.4.1 charm-tools>=2.0.0 +requests==2.6.0 # amulet deployment helpers bzr+lp:charm-helpers#egg=charmhelpers # BEGIN: Amulet OpenStack Charm Helper Requirements @@ -7,15 +14,18 @@ bzr+lp:charm-helpers#egg=charmhelpers amulet>=1.14.3,<2.0 bundletester>=0.6.1,<1.0 aodhclient>=0.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-keystoneclient>=1.7.1,<2.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 +python-barbicanclient>=4.0.1 +python-ceilometerclient>=1.5.0 +python-cinderclient>=1.4.0 +python-designateclient>=1.5 +python-glanceclient>=1.1.0 +python-heatclient>=0.8.0 +python-keystoneclient>=1.7.1 +python-manilaclient>=1.8.1 +python-neutronclient>=3.1.0 +python-novaclient>=2.30.1 +python-openstackclient>=1.7.0 +python-swiftclient>=2.6.0 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 9c5466b..ebe535f 100644 --- a/src/tests/basic_deployment.py +++ b/src/tests/basic_deployment.py @@ -13,8 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os - import charmhelpers.contrib.openstack.amulet.deployment as amulet_deployment import charmhelpers.contrib.openstack.amulet.utils as os_amulet_utils @@ -31,8 +29,10 @@ class KeystoneLDAPCharmDeployment(amulet_deployment.OpenStackAmuletDeployment): source, stable) self._add_services() self._add_relations() - self._configure_services() self._deploy() + # Run the configure post-deploy to get the ldap-server's IP + # for use by keystone-ldap + self._configure_services() u.log.info('Waiting on extended status checks...') exclude_services = ['mysql', 'mongodb'] @@ -51,11 +51,13 @@ class KeystoneLDAPCharmDeployment(amulet_deployment.OpenStackAmuletDeployment): other_services = [ {'name': 'keystone'}, {'name': 'percona-cluster'}, + {'name': 'ldap-server', + 'location': 'cs:~openstack-charmers/ldap-test-fixture'}, ] super(KeystoneLDAPCharmDeployment, self)._add_services( this_service, other_services, - no_origin=['keystone-ldap'] + no_origin=['keystone-ldap', 'ldap-server'] ) def _add_relations(self): @@ -83,12 +85,14 @@ class KeystoneLDAPCharmDeployment(amulet_deployment.OpenStackAmuletDeployment): super(KeystoneLDAPCharmDeployment, self)._configure_services(configs) def _get_ldap_config(self): - # NOTE(jamespage): use amulet variables for CI specific config + self.ldap_server_sentry = self.d.sentry['ldap-server'][0] + self.ldap_server_ip = self.ldap_server_sentry.info['public-address'] + keystone_ldap_config = { - 'ldap-server': os.environ.get('AMULET_LDAP_SERVER'), - 'ldap-user': os.environ.get('AMULET_LDAP_USER'), - 'ldap-password': os.environ.get('AMULET_LDAP_PASSWORD'), - 'ldap-suffix': os.environ.get('AMULET_LDAP_SUFFIX'), + 'ldap-server': "ldap://{}".format(self.ldap_server_ip), + 'ldap-user': 'cn=admin,dc=test,dc=com', + 'ldap-password': 'crapper', + 'ldap-suffix': 'dc=test,dc=com', 'domain-name': 'userdomain', } if all(keystone_ldap_config.values()): @@ -135,6 +139,7 @@ class KeystoneLDAPCharmDeployment(amulet_deployment.OpenStackAmuletDeployment): return u.authenticate_keystone_admin(self.keystone_sentry, user='admin', password='openstack', + project_name='admin', api_version=api_version, keystone_ip=keystone_ip) diff --git a/src/tests/gate-basic-zesty-ocata b/src/tests/gate-basic-zesty-ocata old mode 100644 new mode 100755 diff --git a/src/tox.ini b/src/tox.ini index 3bc4d0b..276db2f 100644 --- a/src/tox.ini +++ b/src/tox.ini @@ -10,7 +10,7 @@ setenv = VIRTUAL_ENV={envdir} PYTHONHASHSEED=0 AMULET_SETUP_TIMEOUT=2700 whitelist_externals = juju -passenv = HOME TERM AMULET_* CS_API_URL +passenv = HOME TERM AMULET_* CS_API_* deps = -r{toxinidir}/test-requirements.txt install_command = pip install --allow-unverified python-apt {opts} {packages} diff --git a/unit_tests/__init__.py b/unit_tests/__init__.py index d537812..3a5e9a3 100644 --- a/unit_tests/__init__.py +++ b/unit_tests/__init__.py @@ -1,8 +1,11 @@ # 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. @@ -10,34 +13,10 @@ # limitations under the License. import sys -import mock sys.path.append('src') 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.decorators'] = charmhelpers.core.decorators -sys.modules['charmhelpers.core.hookenv'] = charmhelpers.core.hookenv -sys.modules['charmhelpers.core.host'] = charmhelpers.core.host -sys.modules['charmhelpers.core.unitdata'] = charmhelpers.core.unitdata -sys.modules['charmhelpers.core.templating'] = charmhelpers.core.templating -sys.modules['charmhelpers.contrib'] = charmhelpers.contrib -sys.modules['charmhelpers.contrib.openstack'] = charmhelpers.contrib.openstack -sys.modules['charmhelpers.contrib.openstack.utils'] = ( - charmhelpers.contrib.openstack.utils) -sys.modules['charmhelpers.contrib.openstack.templating'] = ( - charmhelpers.contrib.openstack.templating) -sys.modules['charmhelpers.contrib.network'] = charmhelpers.contrib.network -sys.modules['charmhelpers.contrib.network.ip'] = ( - charmhelpers.contrib.network.ip) -sys.modules['charmhelpers.fetch'] = charmhelpers.fetch -sys.modules['charmhelpers.cli'] = charmhelpers.cli -sys.modules['charmhelpers.contrib.hahelpers'] = charmhelpers.contrib.hahelpers -sys.modules['charmhelpers.contrib.hahelpers.cluster'] = ( - charmhelpers.contrib.hahelpers.cluster) +import charms_openstack.test_mocks # noqa +charms_openstack.test_mocks.mock_charmhelpers()