From 86b440a46ba253019e84b1499545bc86a1c8eb9a Mon Sep 17 00:00:00 2001 From: Luciano Lo Giudice Date: Mon, 13 Sep 2021 13:31:36 -0300 Subject: [PATCH 1/5] Add the cinder-netapp tests --- .../charm_tests/cinder_netapp/__init__.py | 15 ++++ .../charm_tests/cinder_netapp/tests.py | 77 +++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 zaza/openstack/charm_tests/cinder_netapp/__init__.py create mode 100644 zaza/openstack/charm_tests/cinder_netapp/tests.py diff --git a/zaza/openstack/charm_tests/cinder_netapp/__init__.py b/zaza/openstack/charm_tests/cinder_netapp/__init__.py new file mode 100644 index 0000000..31c5165 --- /dev/null +++ b/zaza/openstack/charm_tests/cinder_netapp/__init__.py @@ -0,0 +1,15 @@ +# Copyright 2021 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 cinder-netapp.""" diff --git a/zaza/openstack/charm_tests/cinder_netapp/tests.py b/zaza/openstack/charm_tests/cinder_netapp/tests.py new file mode 100644 index 0000000..ef6cff9 --- /dev/null +++ b/zaza/openstack/charm_tests/cinder_netapp/tests.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python3 + +# Copyright 2021 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 cinder-netapp testing.""" + +import logging +import uuid + +import zaza.model +import zaza.openstack.charm_tests.test_utils as test_utils +import zaza.openstack.utilities.openstack as openstack_utils + + +class CindernetappTest(test_utils.OpenStackBaseTest): + """Encapsulate netapp tests.""" + + @classmethod + def setUpClass(cls): + """Run class setup for running tests.""" + super(CindernetappTest, cls).setUpClass() + cls.keystone_session = openstack_utils.get_overcloud_keystone_session() + cls.model_name = zaza.model.get_juju_model() + cls.cinder_client = openstack_utils.get_cinder_session_client( + cls.keystone_session) + + def test_cinder_config(self): + """Test that configuration options match our expectations.""" + logging.info('cinder-netapp') + expected_contents = { + 'cinder-netapp': { + 'netapp_storage_family': ['ontap_cluster'], + 'netapp_storage_protocol': ['iscsi'], + 'volume_backend_name': ['cinder_netapp'], + 'volume_driver': + ['cinder.volume.drivers.netapp.common.NetAppDriver'], + }} + + zaza.model.run_on_leader( + 'cinder', + 'sudo cp /etc/cinder/cinder.conf /tmp/') + zaza.model.block_until_oslo_config_entries_match( + 'cinder', + '/tmp/cinder.conf', + expected_contents, + timeout=2) + + def test_create_volume(self): + """Test creating a volume with basic configuration.""" + test_vol_name = "zaza{}".format(uuid.uuid1().fields[0]) + vol_new = self.cinder_client.volumes.create( + name=test_vol_name, + size='1') + openstack_utils.resource_reaches_status( + self.cinder_client.volumes, + vol_new.id, + wait_iteration_max_time=12000, + stop_after_attempt=5, + expected_status='available', + msg='Volume status wait') + test_vol = self.cinder_client.volumes.find(name=test_vol_name) + self.assertEqual( + getattr(test_vol, 'os-vol-host-attr:host').split('#')[0], + 'cinder@cinder-netapp') + self.cinder_client.volumes.delete(vol_new) From a94cbb1d3a13949c1dedaf5e75823fc0151e99f8 Mon Sep 17 00:00:00 2001 From: Luciano Lo Giudice Date: Mon, 13 Sep 2021 14:00:36 -0300 Subject: [PATCH 2/5] Rename the test class to be more uniform --- zaza/openstack/charm_tests/cinder_netapp/tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zaza/openstack/charm_tests/cinder_netapp/tests.py b/zaza/openstack/charm_tests/cinder_netapp/tests.py index ef6cff9..5ef9ea3 100644 --- a/zaza/openstack/charm_tests/cinder_netapp/tests.py +++ b/zaza/openstack/charm_tests/cinder_netapp/tests.py @@ -24,7 +24,7 @@ import zaza.openstack.charm_tests.test_utils as test_utils import zaza.openstack.utilities.openstack as openstack_utils -class CindernetappTest(test_utils.OpenStackBaseTest): +class CinderNetAppTest(test_utils.OpenStackBaseTest): """Encapsulate netapp tests.""" @classmethod From 89d47dc016bdb8134fceabf2d3ab7f277eae35df Mon Sep 17 00:00:00 2001 From: Luciano Lo Giudice Date: Mon, 13 Sep 2021 14:07:15 -0300 Subject: [PATCH 3/5] Fix name in call to super --- zaza/openstack/charm_tests/cinder_netapp/tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zaza/openstack/charm_tests/cinder_netapp/tests.py b/zaza/openstack/charm_tests/cinder_netapp/tests.py index 5ef9ea3..b5ce8fb 100644 --- a/zaza/openstack/charm_tests/cinder_netapp/tests.py +++ b/zaza/openstack/charm_tests/cinder_netapp/tests.py @@ -30,7 +30,7 @@ class CinderNetAppTest(test_utils.OpenStackBaseTest): @classmethod def setUpClass(cls): """Run class setup for running tests.""" - super(CindernetappTest, cls).setUpClass() + super(CinderNetAppTest, cls).setUpClass() cls.keystone_session = openstack_utils.get_overcloud_keystone_session() cls.model_name = zaza.model.get_juju_model() cls.cinder_client = openstack_utils.get_cinder_session_client( From 40a9a5bfb3a786e8c2911786a740d4671bf5dab6 Mon Sep 17 00:00:00 2001 From: Luciano Lo Giudice Date: Mon, 20 Sep 2021 11:55:52 -0300 Subject: [PATCH 4/5] Safely remove volume Move the checks inside a 'try' block so that the volume can be safely remove as a 'finally' statement. --- .../charm_tests/cinder_netapp/tests.py | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/zaza/openstack/charm_tests/cinder_netapp/tests.py b/zaza/openstack/charm_tests/cinder_netapp/tests.py index b5ce8fb..11bfe01 100644 --- a/zaza/openstack/charm_tests/cinder_netapp/tests.py +++ b/zaza/openstack/charm_tests/cinder_netapp/tests.py @@ -63,15 +63,17 @@ class CinderNetAppTest(test_utils.OpenStackBaseTest): vol_new = self.cinder_client.volumes.create( name=test_vol_name, size='1') - openstack_utils.resource_reaches_status( - self.cinder_client.volumes, - vol_new.id, - wait_iteration_max_time=12000, - stop_after_attempt=5, - expected_status='available', - msg='Volume status wait') - test_vol = self.cinder_client.volumes.find(name=test_vol_name) - self.assertEqual( - getattr(test_vol, 'os-vol-host-attr:host').split('#')[0], - 'cinder@cinder-netapp') - self.cinder_client.volumes.delete(vol_new) + try: + openstack_utils.resource_reaches_status( + self.cinder_client.volumes, + vol_new.id, + wait_iteration_max_time=12000, + stop_after_attempt=5, + expected_status='available', + msg='Volume status wait') + test_vol = self.cinder_client.volumes.find(name=test_vol_name) + self.assertEqual( + getattr(test_vol, 'os-vol-host-attr:host').split('#')[0], + 'cinder@cinder-netapp') + finally: + self.cinder_client.volumes.delete(vol_new) From a5831c43df11d772e4da50c08d1efb1539488362 Mon Sep 17 00:00:00 2001 From: Luciano Lo Giudice Date: Mon, 20 Sep 2021 11:57:06 -0300 Subject: [PATCH 5/5] Remove pointless tracing. --- zaza/openstack/charm_tests/cinder_netapp/tests.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/zaza/openstack/charm_tests/cinder_netapp/tests.py b/zaza/openstack/charm_tests/cinder_netapp/tests.py index 11bfe01..41456ba 100644 --- a/zaza/openstack/charm_tests/cinder_netapp/tests.py +++ b/zaza/openstack/charm_tests/cinder_netapp/tests.py @@ -16,7 +16,6 @@ """Encapsulate cinder-netapp testing.""" -import logging import uuid import zaza.model @@ -38,7 +37,6 @@ class CinderNetAppTest(test_utils.OpenStackBaseTest): def test_cinder_config(self): """Test that configuration options match our expectations.""" - logging.info('cinder-netapp') expected_contents = { 'cinder-netapp': { 'netapp_storage_family': ['ontap_cluster'],