def test__check_attachment_specs_fail(self): db.attachment_specs_update_or_create(self.context, self.uuid(), { 'k': 'v', 'k2': 'v2' }) result = self.checks._check_attachment_specs() self.assertEqual(uc.Code.FAILURE, result.code)
def test_migrate_attachment_specs(self): # Create an attachment. attachment = objects.VolumeAttachment( self.context, attach_status='attaching', volume_id=fake.VOLUME_ID) attachment.create() # Create some attachment_specs. Note that the key and value have to # be strings, the table doesn't handle things like a wwpns list # for a fibrechannel connector. connector = {'host': '127.0.0.1'} db.attachment_specs_update_or_create( self.context, attachment.id, connector) # Now get the volume attachment object from the database and make # sure the connector was migrated from the attachment_specs table # to the volume_attachment table and the specs were deleted. attachment = objects.VolumeAttachment.get_by_id( self.context, attachment.id) self.assertIn('connector', attachment) self.assertDictEqual(connector, attachment.connector) self.assertEqual(0, len(db.attachment_specs_get( self.context, attachment.id))) # Make sure we can store a fibrechannel type connector that has a wwpns # list value. connector['wwpns'] = ['21000024ff34c92d', '21000024ff34c92c'] attachment.connector = connector attachment.save() # Get the object from the DB again and make sure the connector is # there. attachment = objects.VolumeAttachment.get_by_id( self.context, attachment.id) self.assertIn('connector', attachment) self.assertDictEqual(connector, attachment.connector)
def test_migrate_attachment_specs(self): # Create an attachment. attachment = objects.VolumeAttachment(self.context, attach_status='attaching', volume_id=fake.VOLUME_ID) attachment.create() # Create some attachment_specs. Note that the key and value have to # be strings, the table doesn't handle things like a wwpns list # for a fibrechannel connector. connector = {'host': '127.0.0.1'} db.attachment_specs_update_or_create(self.context, attachment.id, connector) # Now get the volume attachment object from the database and make # sure the connector was migrated from the attachment_specs table # to the volume_attachment table and the specs were deleted. attachment = objects.VolumeAttachment.get_by_id( self.context, attachment.id) self.assertIn('connector', attachment) self.assertDictEqual(connector, attachment.connector) self.assertEqual( 0, len(db.attachment_specs_get(self.context, attachment.id))) # Make sure we can store a fibrechannel type connector that has a wwpns # list value. connector['wwpns'] = ['21000024ff34c92d', '21000024ff34c92c'] attachment.connector = connector attachment.save() # Get the object from the DB again and make sure the connector is # there. attachment = objects.VolumeAttachment.get_by_id( self.context, attachment.id) self.assertIn('connector', attachment) self.assertDictEqual(connector, attachment.connector)
def test__check_attachment_specs_ok(self): attach_uuid = self.uuid() # Confirm that we ignore deleted attachment specs db.attachment_specs_update_or_create(self.context, attach_uuid, {'k': 'v'}) db.attachment_specs_delete(self.context, attach_uuid, 'k') result = self.checks._check_attachment_specs() self.assertEqual(uc.Code.SUCCESS, result.code)