From 31f1d5c94fd59d0f67478d8747f9db18b55c3ef6 Mon Sep 17 00:00:00 2001 From: Liam Young Date: Tue, 16 Aug 2022 09:45:00 +0000 Subject: [PATCH 1/2] Add test for Trilio Horizon encryption settings --- zaza/openstack/charm_tests/trilio/tests.py | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/zaza/openstack/charm_tests/trilio/tests.py b/zaza/openstack/charm_tests/trilio/tests.py index ebcdb1a..1988870 100644 --- a/zaza/openstack/charm_tests/trilio/tests.py +++ b/zaza/openstack/charm_tests/trilio/tests.py @@ -469,3 +469,52 @@ class TrilioWLMS3Test(TrilioWLMBaseTest): """Tests for Trilio WLM charm backed by S3.""" application_name = "trilio-wlm" + + +class TrilioHorizonPluginTest(test_utils.OpenStackBaseTest): + """Tests for Trilio Horizon Plugin charm.""" + + application_name = "trilio-horizon-plugin" + local_settings_file = '/etc/openstack-dashboard/local_settings.py' + + def installed_trilio_version(self): + """Get the Trilio version from the installed package.""" + action_out = zaza_model.run_on_leader( + self.application_name, + ("dpkg-query --showformat='${Version}' " + "--show python3-tvault-horizon-plugin")) + return float('.'.join(action_out['stdout'].split('.')[:2])) + + def set_openstack_encryption_support(self, os_enc_support): + """Set the openstack-encryption-support option.""" + zaza_model.set_application_config( + self.application_name, + {'openstack-encryption-support': str(os_enc_support)}) + logging.info( + "Checking openstack encryption support is set to {}".format( + os_enc_support)) + zaza_model.block_until_file_has_contents( + self.application_name, + self.local_settings_file, + 'OPENSTACK_ENCRYPTION_SUPPORT = {}'.format(os_enc_support)) + + def test_encryption_settings(self): + """Test trilio encryption options.""" + expect = self.installed_trilio_version() >= 4.2 + logging.info( + "Checking Trilio encryption support is set to {}".format(expect)) + zaza_model.block_until_file_has_contents( + self.application_name, + self.local_settings_file, + 'TRILIO_ENCRYPTION_SUPPORT = {}'.format(expect)) + expect = zaza_model.get_application_config( + self.application_name)['openstack-encryption-support']['value'] + self.set_openstack_encryption_support( + expect) + expect = not expect + self.set_openstack_encryption_support( + expect) + # Put config back to original setting + expect = not expect + self.set_openstack_encryption_support( + expect) From 87211cd2be9c7808994dbc84372be605e3dacb7d Mon Sep 17 00:00:00 2001 From: Liam Young Date: Fri, 19 Aug 2022 06:58:29 +0000 Subject: [PATCH 2/2] Fix test for queens package name --- zaza/openstack/charm_tests/trilio/tests.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/zaza/openstack/charm_tests/trilio/tests.py b/zaza/openstack/charm_tests/trilio/tests.py index 1988870..a0d0ca0 100644 --- a/zaza/openstack/charm_tests/trilio/tests.py +++ b/zaza/openstack/charm_tests/trilio/tests.py @@ -483,6 +483,11 @@ class TrilioHorizonPluginTest(test_utils.OpenStackBaseTest): self.application_name, ("dpkg-query --showformat='${Version}' " "--show python3-tvault-horizon-plugin")) + if 'no packages found' in action_out['stderr']: + action_out = zaza_model.run_on_leader( + self.application_name, + ("dpkg-query --showformat='${Version}' " + "--show tvault-horizon-plugin")) return float('.'.join(action_out['stdout'].split('.')[:2])) def set_openstack_encryption_support(self, os_enc_support):