def test_verify_image_volume_ok(self, _mock_create_image_volume, _mock_get_sf_volume, _mock_get_sfaccount, _mock_issue_api_request): _mock_issue_api_request.return_value = self.mock_stats_data _mock_get_sfaccount.return_value = { 'username': '******', 'accountID': 7777 } _mock_get_sf_volume.return_value =\ {'status': 'active', 'volumeID': 1, 'attributes': { 'image_info': {'image_updated_at': '2013-09-28T15:27:36.325355', 'image_id': '17c550bb-a411-44c0-9aaf-0d96dd47f501', 'image_name': 'fake-image', 'image_created_at': '2014-12-17T00:16:23+00:00'}}} _mock_create_image_volume.return_value = None image_meta = { 'id': '17c550bb-a411-44c0-9aaf-0d96dd47f501', 'updated_at': datetime.datetime(2013, 9, 28, 15, 27, 36, 325355) } image_service = 'null' sfv = SolidFireDriver(configuration=self.configuration) _mock_issue_api_request.return_value = {'result': 'ok'} sfv._verify_image_volume(self.ctxt, image_meta, image_service) self.assertFalse(_mock_create_image_volume.called)
def test_verify_image_volume_ok(self, _mock_create_image_volume, _mock_get_sf_volume, _mock_get_sfaccount, _mock_issue_api_request): _mock_issue_api_request.return_value = self.mock_stats_data _mock_get_sfaccount.return_value = {'username': '******', 'accountID': 7777} _mock_get_sf_volume.return_value =\ {'status': 'active', 'volumeID': 1, 'attributes': { 'image_info': {'image_updated_at': '2013-09-28T15:27:36.325355', 'image_id': '17c550bb-a411-44c0-9aaf-0d96dd47f501', 'image_name': 'fake-image', 'image_created_at': '2014-12-17T00:16:23+00:00'}}} _mock_create_image_volume.return_value = None image_meta = {'id': '17c550bb-a411-44c0-9aaf-0d96dd47f501', 'updated_at': datetime.datetime(2013, 9, 28, 15, 27, 36, 325355)} image_service = 'null' sfv = SolidFireDriver(configuration=self.configuration) _mock_issue_api_request.return_value = {'result': 'ok'} sfv._verify_image_volume(self.ctxt, image_meta, image_service) self.assertFalse(_mock_create_image_volume.called)
def test_verify_image_volume_out_of_date(self, _mock_create_image_volume, _mock_get_sf_volume, _mock_get_sfaccount, _mock_issue_api_request): fake_sf_vref = { 'status': 'active', 'volumeID': 1, 'attributes': { 'image_info': { 'image_updated_at': '2014-12-17T00:16:23+00:00', 'image_id': '17c550bb-a411-44c0-9aaf-0d96dd47f501', 'image_name': 'fake-image', 'image_created_at': '2014-12-17T00:16:23+00:00' } } } stats_data =\ {'result': {'clusterCapacity': {'maxProvisionedSpace': 107374182400, 'usedSpace': 1073741824, 'compressionPercent': 100, 'deDuplicationPercent': 100, 'thinProvisioningPercent': 100}}} _mock_issue_api_request.return_value = stats_data _mock_get_sfaccount.return_value = { 'username': '******', 'accountID': 7777 } _mock_get_sf_volume.return_value = fake_sf_vref _mock_create_image_volume.return_value = fake_sf_vref image_meta = { 'id': '17c550bb-a411-44c0-9aaf-0d96dd47f501', 'updated_at': datetime.datetime(2013, 9, 28, 15, 27, 36, 325355) } image_service = 'null' sfv = SolidFireDriver(configuration=self.configuration) _mock_issue_api_request.return_value = {'result': 'ok'} sfv._verify_image_volume(self.ctxt, image_meta, image_service) self.assertTrue(_mock_create_image_volume.called)
def test_verify_image_volume_out_of_date(self, _mock_create_image_volume, _mock_get_sf_volume, _mock_get_sfaccount, _mock_issue_api_request): fake_sf_vref = { 'status': 'active', 'volumeID': 1, 'attributes': { 'image_info': {'image_updated_at': '2014-12-17T00:16:23+00:00', 'image_id': '17c550bb-a411-44c0-9aaf-0d96dd47f501', 'image_name': 'fake-image', 'image_created_at': '2014-12-17T00:16:23+00:00'}}} stats_data =\ {'result': {'clusterCapacity': {'maxProvisionedSpace': 107374182400, 'usedSpace': 1073741824, 'compressionPercent': 100, 'deDuplicationPercent': 100, 'thinProvisioningPercent': 100}}} _mock_issue_api_request.return_value = stats_data _mock_get_sfaccount.return_value = {'username': '******', 'accountID': 7777} _mock_get_sf_volume.return_value = fake_sf_vref _mock_create_image_volume.return_value = fake_sf_vref image_meta = {'id': '17c550bb-a411-44c0-9aaf-0d96dd47f501', 'updated_at': datetime.datetime(2013, 9, 28, 15, 27, 36, 325355)} image_service = 'null' sfv = SolidFireDriver(configuration=self.configuration) _mock_issue_api_request.return_value = {'result': 'ok'} sfv._verify_image_volume(self.ctxt, image_meta, image_service) self.assertTrue(_mock_create_image_volume.called)