diff --git a/requirements.txt b/requirements.txt index ed9c353..fa0e460 100644 --- a/requirements.txt +++ b/requirements.txt @@ -23,6 +23,7 @@ python-openstackclient>=3.14.0 aodhclient gnocchiclient>=7.0.5,<8.0.0 pika>=1.1.0,<2.0.0 +python-barbicanclient python-designateclient python-ceilometerclient python-cinderclient diff --git a/setup.py b/setup.py index 0184f72..6d08832 100644 --- a/setup.py +++ b/setup.py @@ -40,6 +40,7 @@ install_require = [ 'aodhclient<1.4.0', 'gnocchiclient>=7.0.5,<8.0.0', 'pika>=1.1.0,<2.0.0', + 'python-barbicanclient>=4.0.1,<5.0.0', 'python-designateclient>=1.5,<3.0.0', 'python-heatclient<2.0.0', 'python-glanceclient<3.0.0', diff --git a/zaza/openstack/charm_tests/barbican/__init__.py b/zaza/openstack/charm_tests/barbican/__init__.py new file mode 100644 index 0000000..eecbd79 --- /dev/null +++ b/zaza/openstack/charm_tests/barbican/__init__.py @@ -0,0 +1,15 @@ +# Copyright 2020 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. + +"""Collection of code for setting up and testing barbican.""" diff --git a/zaza/openstack/charm_tests/barbican/tests.py b/zaza/openstack/charm_tests/barbican/tests.py new file mode 100644 index 0000000..3d54917 --- /dev/null +++ b/zaza/openstack/charm_tests/barbican/tests.py @@ -0,0 +1,81 @@ +# Copyright 2020 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. + +"""Encapsulate barbican testing.""" + +import logging + +import barbicanclient.client as barbican_client +import zaza.openstack.charm_tests.test_utils as test_utils +import zaza.openstack.utilities.openstack as openstack_utils + + +class BarbicanTest(test_utils.OpenStackBaseTest): + """Run nova-compute specific tests.""" + + _SERVICES = ['apache2', 'barbican-worker'] + + def test_110_catalog_endpoints(self): + """Verify that the endpoints are present in the catalog.""" + overcloud_auth = openstack_utils.get_overcloud_auth() + keystone_client = openstack_utils.get_keystone_client( + overcloud_auth) + actual_endpoints = keystone_client.service_catalog.get_endpoints() + for service_type in ('key-manager', 'identity'): + actual_interfaces = [endpoint['interface'] for endpoint in + actual_endpoints[service_type]] + for expected_interface in ('internal', 'admin', 'public'): + assert(expected_interface in actual_interfaces) + + def test_400_api_connection(self): + """Simple api calls to check service is up and responding.""" + logging.info('Authenticating with the barbican endpoint') + overcloud_auth = openstack_utils.get_overcloud_auth() + keystone_client = openstack_utils.get_keystone_client( + overcloud_auth) + keystone_session = openstack_utils.get_overcloud_keystone_session() + barbican_endpoint = keystone_client.service_catalog.url_for( + service_type='key-manager', interface='publicURL') + barbican = barbican_client.Client(session=keystone_session, + endpoint=barbican_endpoint) + + logging.info('Creating a secret') + my_secret = barbican.secrets.create() + my_secret.name = u'Random plain text password' + my_secret.payload = u'password' + + logging.info('Storing the secret') + my_secret_ref = my_secret.store() + assert(my_secret_ref is not None) + + logging.info('Deleting the secret') + my_secret.delete() + + def test_900_restart_on_config_change(self): + """Checking restart happens on config change. + + Change debug mode and assert that change propagates to the correct + file and that services are restarted as a result + """ + self.restart_on_changed_debug_oslo_config_file( + '/etc/barbican/barbican.conf', self._SERVICES) + + def test_910_pause_resume(self): + """Run pause and resume tests. + + Pause service and check services are stopped then resume and check + they are started + """ + with self.pause_resume(self._SERVICES): + logging.info("Testing pause resume")