]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Add unit tests for NetApp do_setup methods
authorAndrew Kerr <andrew.kerr@netapp.com>
Tue, 25 Nov 2014 20:47:01 +0000 (15:47 -0500)
committerAndrew Kerr <andrew.kerr@netapp.com>
Mon, 22 Dec 2014 14:23:35 +0000 (14:23 +0000)
We need to ensure that our do_setup methods are properly calling check_flags.
This patch adds tests to that effect.  We also need to ensure that our config
documentation is accurate; this also fixes a minor issue for that.

Change-Id: I99eea59c2451fe1508bafa6ae1ed792b3d0b952e

cinder/tests/volume/drivers/netapp/dataontap/test_block_base.py
cinder/tests/volume/drivers/netapp/dataontap/test_nfs_base.py [new file with mode: 0644]
cinder/tests/volume/drivers/netapp/dataontap/test_nfs_cmode.py [new file with mode: 0644]
cinder/tests/volume/drivers/netapp/eseries/test_iscsi.py [new file with mode: 0644]
cinder/volume/drivers/netapp/options.py

index 392db4315d0662847b210ae29138d5e8d33cf07c..4d1995c021fa5a6156994bc939a98fcdded84e2a 100644 (file)
@@ -1,5 +1,7 @@
 # Copyright (c) 2014 Alex Meade.  All rights reserved.
 # Copyright (c) 2014 Clinton Knight.  All rights reserved.
+# Copyright (c) 2014 Andrew Kerr.  All rights reserved.
+# All Rights Reserved.
 #
 #    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
@@ -312,3 +314,9 @@ class NetAppBlockStorageLibraryTestCase(test.TestCase):
         warn_msg = 'Extra spec netapp_thick_provisioned is deprecated.  ' \
                    'Use netapp_thin_provisioned instead.'
         na_utils.LOG.warning.assert_called_once_with(warn_msg)
+
+    @mock.patch.object(na_utils, 'check_flags')
+    def test_do_setup(self, mock_check_flags):
+        self.library.do_setup(mock.Mock())
+
+        self.assertTrue(mock_check_flags.called)
diff --git a/cinder/tests/volume/drivers/netapp/dataontap/test_nfs_base.py b/cinder/tests/volume/drivers/netapp/dataontap/test_nfs_base.py
new file mode 100644 (file)
index 0000000..436707d
--- /dev/null
@@ -0,0 +1,47 @@
+# Copyright (c) 2014 Andrew Kerr.  All rights reserved.
+# All Rights Reserved.
+#
+#    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.
+"""
+Mock unit tests for the NetApp nfs storage driver
+"""
+
+import mock
+
+from cinder.brick.remotefs import remotefs as remotefs_brick
+from cinder import test
+from cinder import utils
+from cinder.volume.drivers.netapp.dataontap import nfs_base
+from cinder.volume.drivers.netapp import utils as na_utils
+from cinder.volume.drivers.nfs import NfsDriver as nfs_lib
+
+
+class NetAppNfsDriverTestCase(test.TestCase):
+    def setUp(self):
+        super(NetAppNfsDriverTestCase, self).setUp()
+
+        kwargs = {'configuration': mock.Mock()}
+
+        with mock.patch.object(utils, 'get_root_helper',
+                               return_value=mock.Mock()):
+            with mock.patch.object(remotefs_brick, 'RemoteFsClient',
+                                   return_value=mock.Mock()):
+                self.driver = nfs_base.NetAppNfsDriver(**kwargs)
+
+    @mock.patch.object(nfs_lib, 'do_setup')
+    @mock.patch.object(na_utils, 'check_flags')
+    def test_do_setup(self, mock_check_flags, mock_super_do_setup):
+        self.driver.do_setup(mock.Mock())
+
+        self.assertTrue(mock_check_flags.called)
+        self.assertTrue(mock_super_do_setup.called)
diff --git a/cinder/tests/volume/drivers/netapp/dataontap/test_nfs_cmode.py b/cinder/tests/volume/drivers/netapp/dataontap/test_nfs_cmode.py
new file mode 100644 (file)
index 0000000..ca9a4f3
--- /dev/null
@@ -0,0 +1,61 @@
+# Copyright (c) 2014 Andrew Kerr.  All rights reserved.
+# All Rights Reserved.
+#
+#    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.
+"""
+Mock unit tests for the NetApp cmode nfs storage driver
+"""
+
+import mock
+
+from cinder.brick.remotefs import remotefs as remotefs_brick
+from cinder import test
+from cinder.tests.volume.drivers.netapp import fakes as na_fakes
+from cinder import utils
+from cinder.volume.drivers.netapp.dataontap.client import client_cmode
+from cinder.volume.drivers.netapp.dataontap import nfs_cmode
+from cinder.volume.drivers.netapp import utils as na_utils
+from cinder.volume.drivers.nfs import NfsDriver as nfs_lib
+
+
+class NetAppCmodeNfsDriverTestCase(test.TestCase):
+    def setUp(self):
+        super(NetAppCmodeNfsDriverTestCase, self).setUp()
+
+        kwargs = {'configuration': self.get_config_cmode()}
+
+        with mock.patch.object(utils, 'get_root_helper',
+                               return_value=mock.Mock()):
+            with mock.patch.object(remotefs_brick, 'RemoteFsClient',
+                                   return_value=mock.Mock()):
+                self.driver = nfs_cmode.NetAppCmodeNfsDriver(**kwargs)
+
+    def get_config_cmode(self):
+        config = na_fakes.create_configuration_cmode()
+        config.netapp_storage_protocol = 'nfs'
+        config.netapp_login = 'admin'
+        config.netapp_password = 'pass'
+        config.netapp_server_hostname = '127.0.0.1'
+        config.netapp_transport_type = 'http'
+        config.netapp_server_port = '80'
+        config.netapp_vserver = 'openstack'
+        return config
+
+    @mock.patch.object(client_cmode, 'Client', mock.Mock())
+    @mock.patch.object(nfs_lib, 'do_setup')
+    @mock.patch.object(na_utils, 'check_flags')
+    def test_do_setup(self, mock_check_flags, mock_super_do_setup):
+        self.driver.do_setup(mock.Mock())
+
+        self.assertTrue(mock_check_flags.called)
+        self.assertTrue(mock_super_do_setup.called)
diff --git a/cinder/tests/volume/drivers/netapp/eseries/test_iscsi.py b/cinder/tests/volume/drivers/netapp/eseries/test_iscsi.py
new file mode 100644 (file)
index 0000000..2b5e2eb
--- /dev/null
@@ -0,0 +1,58 @@
+# Copyright (c) 2014 Andrew Kerr.  All rights reserved.
+# All Rights Reserved.
+#
+#    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.
+"""
+Mock unit tests for the NetApp E-series iscsi driver
+"""
+
+import mock
+
+from cinder import test
+from cinder.tests.volume.drivers.netapp import fakes as na_fakes
+from cinder.volume.drivers.netapp.eseries import client as es_client
+from cinder.volume.drivers.netapp.eseries import iscsi as es_iscsi
+from cinder.volume.drivers.netapp import utils as na_utils
+
+
+class NetAppEseriesISCSIDriverTestCase(test.TestCase):
+    def setUp(self):
+        super(NetAppEseriesISCSIDriverTestCase, self).setUp()
+
+        kwargs = {'configuration': self.get_config_eseries()}
+
+        self.driver = es_iscsi.NetAppEseriesISCSIDriver(**kwargs)
+
+    def get_config_eseries(self):
+        config = na_fakes.create_configuration_eseries()
+        config.netapp_storage_protocol = 'iscsi'
+        config.netapp_login = 'rw'
+        config.netapp_password = 'rw'
+        config.netapp_server_hostname = '127.0.0.1'
+        config.netapp_transport_type = 'http'
+        config.netapp_server_port = '8080'
+        config.netapp_storage_pools = 'DDP'
+        config.netapp_storage_family = 'eseries'
+        config.netapp_sa_password = 'saPass'
+        config.netapp_controller_ips = '10.11.12.13,10.11.12.14'
+        config.netapp_webservice_path = '/devmgr/v2'
+        return config
+
+    @mock.patch.object(es_iscsi.NetAppEseriesISCSIDriver,
+                       '_check_mode_get_or_register_storage_system')
+    @mock.patch.object(es_client, 'RestClient', mock.Mock())
+    @mock.patch.object(na_utils, 'check_flags', mock.Mock())
+    def test_do_setup(self, mock_check_flags):
+        self.driver.do_setup(mock.Mock())
+
+        self.assertTrue(mock_check_flags.called)
index c66af37a39d564b63923052bbe8a07e3510f3378..d07f32640b662846dfc4387894ef8ab5352d6cd7 100644 (file)
@@ -90,15 +90,7 @@ netapp_cluster_opts = [
                default=None,
                help=('This option specifies the virtual storage server '
                      '(Vserver) name on the storage cluster on which '
-                     'provisioning of block storage volumes should occur. If '
-                     'using the NFS storage protocol, this parameter is '
-                     'mandatory for storage service catalog support (utilized'
-                     ' by Cinder volume type extra_specs support). If this '
-                     'option is specified, the exports belonging to the '
-                     'Vserver will only be used for provisioning in the '
-                     'future. Block storage volumes on exports not belonging '
-                     'to the Vserver specified by this option will continue '
-                     'to function normally.')), ]
+                     'provisioning of block storage volumes should occur.')), ]
 
 netapp_7mode_opts = [
     cfg.StrOpt('netapp_vfiler',