From a5b95bb12c3529ea45d90cacf3a03d2f5155f099 Mon Sep 17 00:00:00 2001 From: James Page Date: Mon, 28 Jan 2019 14:51:04 +0000 Subject: [PATCH 1/8] ceph: Add tests for radosgw Basic ones to start with. --- zaza/charm_tests/ceph/tests.py | 56 +++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/zaza/charm_tests/ceph/tests.py b/zaza/charm_tests/ceph/tests.py index 54a9117..e019bf1 100644 --- a/zaza/charm_tests/ceph/tests.py +++ b/zaza/charm_tests/ceph/tests.py @@ -292,7 +292,8 @@ class CephTest(test_utils.OpenStackBaseTest): file_mtime = None folder_name = '/etc/ceph/dmcrypt-keys/' - with self.config_change(set_default, set_alternate): + with self.config_change(set_default, set_alternate, + application_name=juju_service): with tempfile.TemporaryDirectory() as tempdir: # Creating a temp dir to copy keys temp_folder = '/tmp/dmcrypt-keys' @@ -501,3 +502,56 @@ class CephTest(test_utils.OpenStackBaseTest): 'active' ) logging.debug('OK') + + +class CephRGWDaemonTest(test_utils.OpenStackBaseTest): + """Ceph RADOS Gateway Daemons Test Class.""" + + @classmethod + def setUpClass(cls): + """Run class setup for running ceph low level tests.""" + super(CephRGWDaemonTest, cls).setUpClass() + + def test_processes(self): + """Verify Ceph processes. + + Verify that the expected service processes are running + on each ceph unit. + """ + logging.info('Checking radosgw processes...') + # Process name and quantity of processes to expect on each unit + ceph_radosgw_processes = { + 'radosgw': 1, + } + + # Units with process names and PID quantities expected + expected_processes = { + 'ceph-radosgw/0': ceph_radosgw_processes, + } + + actual_pids = zaza_utils.get_unit_process_ids(expected_processes) + ret = zaza_utils.validate_unit_process_ids(expected_processes, + actual_pids) + self.assertTrue(ret) + + def test_services(self): + """Verify the ceph services. + + Verify the expected services are running on the service units. + """ + logging.info('Checking radosgw services...') + current_release = zaza_openstack.get_os_release() + xenial_mitaka = zaza_openstack.get_os_release('xenial_mitaka') + for unit in zaza_model.get_units('ceph-radosgw'): + if current_release >= xenial_mitaka: + result = zaza_model.run_on_unit(unit.entity_id, 'hostname') + hostname = result['Stdout'].rstrip() + services = ['ceph-radosgw@rgw.{hostname}'.format(hostname), + 'haproxy'] + else: + services = ['radosgw', 'haproxy'] + zaza_model.block_until_service_status( + unit_name=unit.entity_id, + services=services, + target_status='running' + ) From 733fe2e6005108dfc23ea2836b2cb3cd20c00909 Mon Sep 17 00:00:00 2001 From: James Page Date: Mon, 28 Jan 2019 16:40:48 +0000 Subject: [PATCH 2/8] Fixup hostname string formatting --- zaza/charm_tests/ceph/tests.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/zaza/charm_tests/ceph/tests.py b/zaza/charm_tests/ceph/tests.py index e019bf1..2df469d 100644 --- a/zaza/charm_tests/ceph/tests.py +++ b/zaza/charm_tests/ceph/tests.py @@ -546,8 +546,10 @@ class CephRGWDaemonTest(test_utils.OpenStackBaseTest): if current_release >= xenial_mitaka: result = zaza_model.run_on_unit(unit.entity_id, 'hostname') hostname = result['Stdout'].rstrip() - services = ['ceph-radosgw@rgw.{hostname}'.format(hostname), - 'haproxy'] + services = [ + 'ceph-radosgw@rgw.{hostname}'.format(hostname=hostname), + 'haproxy' + ] else: services = ['radosgw', 'haproxy'] zaza_model.block_until_service_status( From 579e58878729e1e080665f27eb6c21bd5b0a4506 Mon Sep 17 00:00:00 2001 From: James Page Date: Thu, 31 Jan 2019 11:54:17 +0000 Subject: [PATCH 3/8] Rework rgw service checks --- zaza/charm_tests/ceph/tests.py | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/zaza/charm_tests/ceph/tests.py b/zaza/charm_tests/ceph/tests.py index 2df469d..c3af5b2 100644 --- a/zaza/charm_tests/ceph/tests.py +++ b/zaza/charm_tests/ceph/tests.py @@ -540,18 +540,8 @@ class CephRGWDaemonTest(test_utils.OpenStackBaseTest): Verify the expected services are running on the service units. """ logging.info('Checking radosgw services...') - current_release = zaza_openstack.get_os_release() - xenial_mitaka = zaza_openstack.get_os_release('xenial_mitaka') + services = ['radosgw', 'haproxy'] for unit in zaza_model.get_units('ceph-radosgw'): - if current_release >= xenial_mitaka: - result = zaza_model.run_on_unit(unit.entity_id, 'hostname') - hostname = result['Stdout'].rstrip() - services = [ - 'ceph-radosgw@rgw.{hostname}'.format(hostname=hostname), - 'haproxy' - ] - else: - services = ['radosgw', 'haproxy'] zaza_model.block_until_service_status( unit_name=unit.entity_id, services=services, From 273d2910e98576a2c56d1d846ccec9f70a69806b Mon Sep 17 00:00:00 2001 From: James Page Date: Mon, 4 Feb 2019 10:40:01 +0000 Subject: [PATCH 4/8] Add basic Swift check --- zaza/charm_tests/ceph/tests.py | 22 ++++++++++++++++++++-- zaza/utilities/openstack.py | 12 ++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/zaza/charm_tests/ceph/tests.py b/zaza/charm_tests/ceph/tests.py index c3af5b2..d52ff3b 100644 --- a/zaza/charm_tests/ceph/tests.py +++ b/zaza/charm_tests/ceph/tests.py @@ -504,13 +504,13 @@ class CephTest(test_utils.OpenStackBaseTest): logging.debug('OK') -class CephRGWDaemonTest(test_utils.OpenStackBaseTest): +class CephRGWTest(test_utils.OpenStackBaseTest): """Ceph RADOS Gateway Daemons Test Class.""" @classmethod def setUpClass(cls): """Run class setup for running ceph low level tests.""" - super(CephRGWDaemonTest, cls).setUpClass() + super(CephRGWTest, cls).setUpClass() def test_processes(self): """Verify Ceph processes. @@ -547,3 +547,21 @@ class CephRGWDaemonTest(test_utils.OpenStackBaseTest): services=services, target_status='running' ) + + def test_object_storage(self): + """Verify object storage API. + + Verify that the object storage API works as expected. + """ + logging.info('Checking Swift REST API') + keystone_session = zaza_openstack.get_overcloud_keystone_session() + swift_client = zaza_openstack.get_swift_session_client( + keystone_session) + _container = 'demo-container' + swift_client.put_container(_container) + swift_client.put_object('testfile', + container=_container, + contents='Test data from Zaza') + _, content = swift_client.get_object('testfile', + container=_container) + self.assertEqual(content, 'Test data from Zaza') diff --git a/zaza/utilities/openstack.py b/zaza/utilities/openstack.py index b3ae064..139afae 100644 --- a/zaza/utilities/openstack.py +++ b/zaza/utilities/openstack.py @@ -38,6 +38,7 @@ from novaclient import client as novaclient_client from neutronclient.v2_0 import client as neutronclient from neutronclient.common import exceptions as neutronexceptions from octaviaclient.api.v2 import octavia as octaviaclient +from swiftclient import client as swiftclient import io import juju_wait @@ -201,6 +202,17 @@ def get_neutron_session_client(session): return neutronclient.Client(session=session) +def get_swift_session_client(session): + """Return swiftclient authenticated by keystone session. + + :param session: Keystone session object + :type session: keystoneauth1.session.Session object + :returns: Authenticated swiftclient + :rtype: swiftclient.Client object + """ + return swiftclient.Connection(session=session) + + def get_octavia_session_client(session, service_type='load-balancer', interface='internal'): """Return neutronclient authenticated by keystone session. From 4dd28679eff5bec1715fbb710906744e238d9a33 Mon Sep 17 00:00:00 2001 From: James Page Date: Mon, 4 Feb 2019 11:26:45 +0000 Subject: [PATCH 5/8] Fixup put object call --- zaza/charm_tests/ceph/tests.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/zaza/charm_tests/ceph/tests.py b/zaza/charm_tests/ceph/tests.py index d52ff3b..069f3c5 100644 --- a/zaza/charm_tests/ceph/tests.py +++ b/zaza/charm_tests/ceph/tests.py @@ -559,9 +559,10 @@ class CephRGWTest(test_utils.OpenStackBaseTest): keystone_session) _container = 'demo-container' swift_client.put_container(_container) - swift_client.put_object('testfile', - container=_container, - contents='Test data from Zaza') + swift_client.put_object(_container, + 'testfile', + contents='Test data from Zaza', + content_type='text/plain') _, content = swift_client.get_object('testfile', container=_container) self.assertEqual(content, 'Test data from Zaza') From eda78c178fae0ad650fe016c1ec6ec8afb6f7c5a Mon Sep 17 00:00:00 2001 From: James Page Date: Mon, 4 Feb 2019 11:28:13 +0000 Subject: [PATCH 6/8] Fix get_object call --- zaza/charm_tests/ceph/tests.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/zaza/charm_tests/ceph/tests.py b/zaza/charm_tests/ceph/tests.py index 069f3c5..5cd234b 100644 --- a/zaza/charm_tests/ceph/tests.py +++ b/zaza/charm_tests/ceph/tests.py @@ -563,6 +563,5 @@ class CephRGWTest(test_utils.OpenStackBaseTest): 'testfile', contents='Test data from Zaza', content_type='text/plain') - _, content = swift_client.get_object('testfile', - container=_container) + _, content = swift_client.get_object(_container, 'testfile') self.assertEqual(content, 'Test data from Zaza') From 7f6730e7ca18c02c24899c7a962af0036f871676 Mon Sep 17 00:00:00 2001 From: James Page Date: Mon, 4 Feb 2019 11:29:41 +0000 Subject: [PATCH 7/8] Sort out encoding --- zaza/charm_tests/ceph/tests.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/zaza/charm_tests/ceph/tests.py b/zaza/charm_tests/ceph/tests.py index 5cd234b..2a09fb6 100644 --- a/zaza/charm_tests/ceph/tests.py +++ b/zaza/charm_tests/ceph/tests.py @@ -564,4 +564,5 @@ class CephRGWTest(test_utils.OpenStackBaseTest): contents='Test data from Zaza', content_type='text/plain') _, content = swift_client.get_object(_container, 'testfile') - self.assertEqual(content, 'Test data from Zaza') + self.assertEqual(content.decode('UTF-8'), + 'Test data from Zaza') From 7bc8fb6da2a777aa89c94f4c47b508b4d2113a58 Mon Sep 17 00:00:00 2001 From: James Page Date: Tue, 5 Feb 2019 10:55:46 +0000 Subject: [PATCH 8/8] Allow configure section to be absent --- zaza/charm_lifecycle/func_test_runner.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/zaza/charm_lifecycle/func_test_runner.py b/zaza/charm_lifecycle/func_test_runner.py index 55c6bf1..f99c90d 100644 --- a/zaza/charm_lifecycle/func_test_runner.py +++ b/zaza/charm_lifecycle/func_test_runner.py @@ -57,8 +57,9 @@ def func_test_runner(keep_model=False, smoke=False, dev=False, bundle=None): deploy.deploy( os.path.join(utils.BUNDLE_DIR, '{}.yaml'.format(t)), model_name) - # Configure - configure.configure(model_name, test_config['configure']) + if 'configure' in test_config: + # Configure + configure.configure(model_name, test_config['configure']) # Test test.test(model_name, test_config['tests']) # Destroy