Adding new test case for InforTrend driver

create_volume_from_snapshot can specify a volume size larger
than the original snapshot. InforTrend driver handles this case:
    creating a new empty volume which size is the new volume['size']
    copying the data from the snapshot to the new volume
This patch is to add unit test case to verify the scenario.

Change-Id: I84712af94c597a36b0464206fd442692feaa9a99
This commit is contained in:
Xinli Guan 2017-03-22 14:24:28 +00:00
parent c605d6b687
commit 3bf8ca293e
1 changed files with 37 additions and 0 deletions

View File

@ -1211,6 +1211,43 @@ class InfortrendiSCSICommonTestCase(InfortrendTestCass):
self.assertDictEqual(test_model_update, model_update)
self.assertEqual(1, log_info.call_count)
@mock.patch('oslo_service.loopingcall.FixedIntervalLoopingCall',
new=utils.ZeroIntervalLoopingCall)
@mock.patch.object(common_cli.LOG, 'info')
def test_create_volume_from_snapshot_with_different_size(self, log_info):
test_snapshot = self.cli_data.test_snapshot
test_snapshot_id = self.cli_data.fake_snapshot_id[0]
test_dst_volume = self.cli_data.test_dst_volume
test_dst_volume['size'] = 10
test_dst_volume_id = test_dst_volume['id'].replace('-', '')
test_dst_part_id = self.cli_data.fake_partition_id[1]
test_model_update = {
'provider_location': 'partition_id^%s@system_id^%s' % (
self.cli_data.fake_partition_id[1],
int(self.cli_data.fake_system_id[0], 16))
}
mock_commands = {
'ShowSnapshot':
self.cli_data.get_test_show_snapshot_detail_filled_block(),
'CreatePartition': SUCCEED,
'ShowPartition': self.cli_data.get_test_show_partition(),
'ShowDevice': self.cli_data.get_test_show_device(),
'CreateReplica': SUCCEED,
'ShowLV': self._mock_show_lv,
'ShowReplica':
self.cli_data.get_test_show_replica_detail_for_migrate(
test_snapshot_id, test_dst_part_id, test_dst_volume_id),
'DeleteReplica': SUCCEED,
}
self._driver_setup(mock_commands)
model_update = self.driver.create_volume_from_snapshot(
test_dst_volume, test_snapshot)
self.assertDictEqual(test_model_update, model_update)
self.assertEqual(1, log_info.call_count)
self.assertEqual(10, test_dst_volume['size'])
@mock.patch('oslo_service.loopingcall.FixedIntervalLoopingCall',
new=utils.ZeroIntervalLoopingCall)
@mock.patch.object(common_cli.LOG, 'info')