"""Unit tests for the NetApp-specific ssc module."""
import copy
+import ddt
from lxml import etree
import mock
from mox3 import mox
return vol
+@ddt.ddt
class SscUtilsTestCase(test.TestCase):
"""Test ssc utis."""
vol1 = createNetAppVolume(name='vola', vs='openstack',
self.stubs.Set(http_client, 'HTTPConnection',
FakeDirectCmodeHTTPConnection)
+ @ddt.data({'na_server_exists': False, 'volume': None},
+ {'na_server_exists': True, 'volume': 'vol'},
+ {'na_server_exists': True, 'volume': None})
+ @ddt.unpack
+ def test_query_cluster_vols_for_ssc(self, na_server_exists, volume):
+ if na_server_exists:
+ na_server = netapp_api.NaServer('127.0.0.1')
+ fake_api_return = mock.Mock(return_value=[])
+ self.mock_object(ssc_cmode.netapp_api, 'invoke_api',
+ new_attr=fake_api_return)
+ ssc_cmode.query_cluster_vols_for_ssc(na_server, 'vserver',
+ volume)
+ else:
+ na_server = None
+ fake_api_error = mock.Mock(side_effect=exception.InvalidInput)
+ self.mock_object(ssc_cmode.netapp_api, 'invoke_api',
+ new_attr=fake_api_error)
+ self.assertRaises(KeyError, ssc_cmode.query_cluster_vols_for_ssc,
+ na_server, 'vserver', volume)
+
def test_cl_vols_ssc_all(self):
"""Test cluster ssc for all vols."""
na_server = netapp_api.NaServer('127.0.0.1')
def query_cluster_vols_for_ssc(na_server, vserver, volume=None):
"""Queries cluster volumes for ssc."""
query = {'volume-attributes': None}
- volume_id = {'volume-id-attributes': {'owning-vserver-name': vserver}}
+ volume_id = {
+ 'volume-id-attributes': {
+ 'owning-vserver-name': vserver,
+ 'type': 'rw',
+ 'style': 'flex',
+ },
+ }
if volume:
volume_id['volume-id-attributes']['name'] = volume
query['volume-attributes'] = volume_id