From 28de49811e556c3963206929d30d4c5c686e2950 Mon Sep 17 00:00:00 2001 From: "camille.rodriguez" Date: Thu, 20 Aug 2020 13:47:12 -0500 Subject: [PATCH 1/3] test block function instead of ls --- zaza/openstack/charm_tests/gnocchi/tests.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/zaza/openstack/charm_tests/gnocchi/tests.py b/zaza/openstack/charm_tests/gnocchi/tests.py index 7bd4523..73c32a9 100644 --- a/zaza/openstack/charm_tests/gnocchi/tests.py +++ b/zaza/openstack/charm_tests/gnocchi/tests.py @@ -133,13 +133,15 @@ class GnocchiExternalCATest(test_utils.OpenStackBaseTest): ) model.block_until_all_units_idle() - cert_location = '/usr/local/share/ca-certificates' - cert_name = 'gnocchi-external.crt' - cmd = 'ls ' + cert_location + '/' + cert_name - logging.info("Validating that the file {} is created in \ - {}".format(cert_name, cert_location)) - result = model.run_on_unit('gnocchi/0', cmd) - self.assertEqual(result['Code'], '0') + # cert_location = '/usr/local/share/ca-certificates' + # cert_name = 'gnocchi-external.crt' + # cmd = 'ls ' + cert_location + '/' + cert_name + # logging.info("Validating that the file {} is created in \ + # {}".format(cert_name, cert_location)) + # result = model.run_on_unit('gnocchi/0', cmd) + remote_file = '/usr/local/share/ca-certificates/gnocchi-external.crt' + result = model.block_until_file_ready('gnocchi', remote_file, b64_cert) + self.assertTrue(result) linked_cert_location = '/etc/ssl/certs' linked_cert_name = 'gnocchi-external.pem' From cece0d3096fff512303c23de10f611e1e27be768 Mon Sep 17 00:00:00 2001 From: "camille.rodriguez" Date: Thu, 20 Aug 2020 13:47:12 -0500 Subject: [PATCH 2/3] test block function instead of ls --- zaza/openstack/charm_tests/gnocchi/tests.py | 36 ++++++++++++--------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/zaza/openstack/charm_tests/gnocchi/tests.py b/zaza/openstack/charm_tests/gnocchi/tests.py index 7bd4523..b099fa6 100644 --- a/zaza/openstack/charm_tests/gnocchi/tests.py +++ b/zaza/openstack/charm_tests/gnocchi/tests.py @@ -76,7 +76,7 @@ class GnocchiS3Test(test_utils.OpenStackBaseTest): session = openstack_utils.get_overcloud_keystone_session() ks_client = openstack_utils.get_keystone_session_client(session) - # Get token data so we can glean our user_id and project_id + # Get token data so we can clean our user_id and project_id token_data = ks_client.tokens.get_token_data(session.get_token()) project_id = token_data['token']['project']['id'] user_id = token_data['token']['user']['id'] @@ -133,18 +133,24 @@ class GnocchiExternalCATest(test_utils.OpenStackBaseTest): ) model.block_until_all_units_idle() - cert_location = '/usr/local/share/ca-certificates' - cert_name = 'gnocchi-external.crt' - cmd = 'ls ' + cert_location + '/' + cert_name - logging.info("Validating that the file {} is created in \ - {}".format(cert_name, cert_location)) - result = model.run_on_unit('gnocchi/0', cmd) - self.assertEqual(result['Code'], '0') + # cert_location = '/usr/local/share/ca-certificates' + # cert_name = 'gnocchi-external.crt' + # cmd = 'ls ' + cert_location + '/' + cert_name + # logging.info("Validating that the file {} is created in \ + # {}".format(cert_name, cert_location)) + # result = model.run_on_unit('gnocchi/0', cmd) + remote_file = '/usr/local/share/ca-certificates/gnocchi-external.crt' + logging.info("Validating that {} is created.".format(remote_file)) + result = model.block_until_file_ready('gnocchi', remote_file, b64_cert) + self.assertTrue(result) - linked_cert_location = '/etc/ssl/certs' - linked_cert_name = 'gnocchi-external.pem' - cmd = 'ls ' + linked_cert_location + '/' + linked_cert_name - logging.info("Validating that the link {} is created in \ - {}".format(linked_cert_name, linked_cert_location)) - result = model.run_on_unit('gnocchi/0', cmd) - self.assertEqual(result['Code'], '0') + # linked_cert_location = '/etc/ssl/certs' + # linked_cert_name = 'gnocchi-external.pem' + # cmd = 'ls ' + linked_cert_location + '/' + linked_cert_name + # logging.info("Validating that the link {} is created in \ + # {}".format(linked_cert_name, linked_cert_location)) + # result = model.run_on_unit('gnocchi/0', cmd) + remote_linked_file = '/etc/ssl/certs/gnocchi-external.pem' + result = model.block_until_file_ready('gnocchi', remote_linked_file, b64_cert) + # self.assertEqual(result['Code'], '0') + self.assertTrue(result) From 6b822ee8ecec179ad5d888666d79f2decbc48172 Mon Sep 17 00:00:00 2001 From: "camille.rodriguez" Date: Thu, 20 Aug 2020 16:03:04 -0500 Subject: [PATCH 3/3] replace ls with file_has_contents --- zaza/openstack/charm_tests/gnocchi/tests.py | 28 ++++++--------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/zaza/openstack/charm_tests/gnocchi/tests.py b/zaza/openstack/charm_tests/gnocchi/tests.py index b099fa6..ed4bac0 100644 --- a/zaza/openstack/charm_tests/gnocchi/tests.py +++ b/zaza/openstack/charm_tests/gnocchi/tests.py @@ -133,24 +133,12 @@ class GnocchiExternalCATest(test_utils.OpenStackBaseTest): ) model.block_until_all_units_idle() - # cert_location = '/usr/local/share/ca-certificates' - # cert_name = 'gnocchi-external.crt' - # cmd = 'ls ' + cert_location + '/' + cert_name - # logging.info("Validating that the file {} is created in \ - # {}".format(cert_name, cert_location)) - # result = model.run_on_unit('gnocchi/0', cmd) - remote_file = '/usr/local/share/ca-certificates/gnocchi-external.crt' - logging.info("Validating that {} is created.".format(remote_file)) - result = model.block_until_file_ready('gnocchi', remote_file, b64_cert) - self.assertTrue(result) + files = [ + '/usr/local/share/ca-certificates/gnocchi-external.crt', + '/etc/ssl/certs/gnocchi-external.pem', + ] - # linked_cert_location = '/etc/ssl/certs' - # linked_cert_name = 'gnocchi-external.pem' - # cmd = 'ls ' + linked_cert_location + '/' + linked_cert_name - # logging.info("Validating that the link {} is created in \ - # {}".format(linked_cert_name, linked_cert_location)) - # result = model.run_on_unit('gnocchi/0', cmd) - remote_linked_file = '/etc/ssl/certs/gnocchi-external.pem' - result = model.block_until_file_ready('gnocchi', remote_linked_file, b64_cert) - # self.assertEqual(result['Code'], '0') - self.assertTrue(result) + for file in files: + logging.info("Validating that {} is created.".format(file)) + model.block_until_file_has_contents('gnocchi', file, 'CERTIFICATE') + logging.info("Found {} successfully.".format(file))