def test_all(self): specs = {'spec1': 'val1', 'spec2': 'val2'} settings = QoSConfig(name='foo', consumer=Consumer.both, specs=specs) self.assertEqual('foo', settings.name) self.assertEqual(Consumer.both, settings.consumer) self.assertEqual(specs, settings.specs)
def test_config_all(self): settings = QoSConfig( **{'name': 'foo', 'consumer': 'both', 'specs': {'spec1': 'val1'}}) self.assertEqual('foo', settings.name) self.assertEqual(Consumer.both, settings.consumer) self.assertEqual({'spec1': 'val1'}, settings.specs)
def setUp(self): """ Creates objects for testing cinder_utils.py """ guid = uuid.uuid4() self.qos_name = self.__class__.__name__ + '-' + str(guid) + '-qos' self.vol_type_name = self.__class__.__name__ + '-' + str(guid) self.specs = {'foo': 'bar'} self.cinder = cinder_utils.cinder_client( self.os_creds, self.os_session) qos_settings = QoSConfig( name=self.qos_name, specs=self.specs, consumer=Consumer.both) self.qos = cinder_utils.create_qos(self.cinder, qos_settings) self.volume_type = None
def setUp(self): super(self.__class__, self).__start__() self.cinder = cinder_utils.cinder_client(self.admin_os_creds, self.admin_os_session) guid = self.__class__.__name__ + '-' + str(uuid.uuid4()) self.volume_type_name = guid + '-vol_type' self.volume_type_creator = None qos_settings = QoSConfig(name=guid + '-qos-spec', consumer=Consumer.both) self.qos_creator = OpenStackQoS(self.admin_os_creds, qos_settings) self.qos_creator.create()
def setUp(self): """ Instantiates the CreateQoS object that is responsible for downloading and creating an OS QoS Spec file within OpenStack """ super(self.__class__, self).__start__() guid = uuid.uuid4() qos_settings = QoSConfig(name=self.__class__.__name__ + '-' + str(guid), consumer=Consumer.both) self.cinder = cinder_utils.cinder_client(self.admin_os_creds, self.admin_os_session) self.qos_creator = create_qos.OpenStackQoS(self.admin_os_creds, qos_settings)
def test_create_qos_back(self): """ Tests the cinder_utils.create_qos() """ qos_settings = QoSConfig( name=self.qos_name, specs=self.specs, consumer=Consumer.back_end) self.qos = cinder_utils.create_qos(self.cinder, qos_settings) self.assertIsNotNone(self.qos) qos1 = cinder_utils.get_qos(self.cinder, qos_settings=qos_settings) self.assertIsNotNone(qos1) validation_utils.objects_equivalent(self.qos, qos1) qos2 = cinder_utils.get_qos_by_id(self.cinder, qos1.id) self.assertIsNotNone(qos2) validation_utils.objects_equivalent(self.qos, qos2)
def test_create_delete_qos(self): """ Tests the cinder_utils.create_qos() """ qos_settings = QoSConfig(name=self.qos_name, consumer=Consumer.both) self.qos = cinder_utils.create_qos(self.cinder, qos_settings) self.assertIsNotNone(self.qos) self.assertEqual(self.qos_name, self.qos.name) qos = cinder_utils.get_qos( self.cinder, qos_settings=qos_settings) self.assertIsNotNone(qos) validation_utils.objects_equivalent(self.qos, qos) cinder_utils.delete_qos(self.cinder, self.qos) self.assertIsNone(cinder_utils.get_qos( self.cinder, qos_settings=qos_settings))
def test_name_consumer_both_strings(self): settings = QoSConfig(name='foo', consumer='both') self.assertEqual('foo', settings.name) self.assertEqual(Consumer.both, settings.consumer) self.assertEqual(dict(), settings.specs)
def test_name_consumer_back_end_strings(self): settings = QoSConfig(name='foo', consumer='back-end') self.assertEqual('foo', settings.name) self.assertEqual(Consumer.back_end, settings.consumer) self.assertEqual(dict(), settings.specs)
def test_name_consumer(self): settings = QoSConfig(name='foo', consumer=Consumer.front_end) self.assertEqual('foo', settings.name) self.assertEqual(Consumer.front_end, settings.consumer) self.assertEqual(dict(), settings.specs)
def test_config_with_invalid_consumer(self): with self.assertRaises(QoSConfigError): QoSConfig(**{'name': 'foo', 'consumer': 'bar'})
def test_invalid_consumer(self): with self.assertRaises(QoSConfigError): QoSConfig(name='foo', consumer='bar')
def test_config_with_name_only(self): with self.assertRaises(QoSConfigError): QoSConfig(**{'name': 'foo'})
def test_name_only(self): with self.assertRaises(QoSConfigError): QoSConfig(name='foo')
def test_empty_config(self): with self.assertRaises(QoSConfigError): QoSConfig(**dict())
def test_no_params(self): with self.assertRaises(QoSConfigError): QoSConfig()