from distutils import version as ver
+import ddt
import mock
from mox3 import mox
from oslo_utils import units
# TODO(vbala) Split test methods handling multiple cases into multiple methods,
# each handling a specific case.
+@ddt.ddt
class VMwareVcVmdkDriverTestCase(test.TestCase):
"""Test class for VMwareVcVmdkDriver."""
version = self._driver._get_vc_version()
self.assertEqual(ver.LooseVersion('6.0.1'), version)
- @mock.patch('cinder.volume.drivers.vmware.vmdk.LOG')
- def test_validate_vcenter_version(self, log):
- vc_version = ver.LooseVersion('5.5')
- self._driver._validate_vcenter_version(vc_version)
- self.assertFalse(log.warning.called)
-
- @mock.patch('cinder.volume.drivers.vmware.vmdk.LOG')
- def test_validate_vcenter_version_with_min_supported_version(self, log):
- vc_version = self._driver.MIN_SUPPORTED_VC_VERSION
- self._driver._validate_vcenter_version(vc_version)
- self.assertFalse(log.warning.called)
+ @ddt.data('5.1', '5.5')
+ def test_validate_vcenter_version(self, version):
+ # vCenter versions 5.1 and above should pass validation.
+ self._driver._validate_vcenter_version(ver.LooseVersion(version))
- @mock.patch('cinder.volume.drivers.vmware.vmdk.LOG')
def test_validate_vcenter_version_with_less_than_min_supported_version(
- self, log):
+ self):
vc_version = ver.LooseVersion('5.0')
- self._driver._validate_vcenter_version(vc_version)
- self.assertTrue(log.warning.called)
+ # Validation should fail for vCenter version less than 5.1.
+ self.assertRaises(exceptions.VMwareDriverException,
+ self._driver._validate_vcenter_version,
+ vc_version)
@mock.patch('cinder.volume.drivers.vmware.vmdk.VMwareVcVmdkDriver.'
'_validate_vcenter_version')
def _validate_vcenter_version(self, vc_version):
if vc_version < self.MIN_SUPPORTED_VC_VERSION:
- # TODO(vbala): enforce vCenter version in M release.
- LOG.warning(
- _LW('Running Cinder with a VMware vCenter version less than '
- '%(min_version)s is deprecated. The minimum required '
- 'version of vCenter server will be raised to '
- '%(min_version)s in the 8.0.0 release.'),
- {'min_version': self.MIN_SUPPORTED_VC_VERSION})
+ msg = _('Running Cinder with a VMware vCenter version less than '
+ '%s is not allowed.') % self.MIN_SUPPORTED_VC_VERSION
+ LOG.error(msg)
+ raise exceptions.VMwareDriverException(message=msg)
def do_setup(self, context):
"""Any initialization the volume driver does while starting."""