def test_create_snapshot(self): self.stubs.Set(SolidFireDriver, '_issue_api_request', self.fake_issue_api_request) self.stubs.Set(SolidFireDriver, '_get_model_info', self.fake_get_model_info) testvol = { 'project_id': 'testprjid', 'name': 'testvol', 'size': 1, 'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66', 'volume_type_id': None, 'created_at': timeutils.utcnow() } testsnap = { 'project_id': 'testprjid', 'name': 'testvol', 'volume_size': 1, 'id': 'b831c4d1-d1f0-11e1-9b23-0800200c9a66', 'volume_id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66', 'volume_type_id': None, 'created_at': timeutils.utcnow() } sfv = SolidFireDriver(configuration=self.configuration) sfv.create_volume(testvol) sfv.create_snapshot(testsnap)
def test_create_volume_for_migration(self): def _fake_do_v_create(self, project_id, params): return project_id, params self.stubs.Set(SolidFireDriver, '_issue_api_request', self.fake_issue_api_request) self.stubs.Set(SolidFireDriver, '_do_volume_create', _fake_do_v_create) testvol = {'project_id': 'testprjid', 'name': 'testvol', 'size': 1, 'id': 'b830b3c0-d1f0-11e1-9b23-1900200c9a77', 'volume_type_id': None, 'created_at': timeutils.utcnow(), 'migration_status': 'target:' 'a720b3c0-d1f0-11e1-9b23-0800200c9a66'} sfv = SolidFireDriver(configuration=self.configuration) proj_id, sf_vol_object = sfv.create_volume(testvol) self.assertEqual('a720b3c0-d1f0-11e1-9b23-0800200c9a66', sf_vol_object['attributes']['uuid']) self.assertEqual('b830b3c0-d1f0-11e1-9b23-1900200c9a77', sf_vol_object['attributes']['migration_uuid']) self.assertEqual('UUID-a720b3c0-d1f0-11e1-9b23-0800200c9a66', sf_vol_object['name'])
def test_create_snapshot(self): self.stubs.Set(SolidFireDriver, "_issue_api_request", self.fake_issue_api_request) self.stubs.Set(SolidFireDriver, "_get_model_info", self.fake_get_model_info) testvol = { "project_id": "testprjid", "name": "testvol", "size": 1, "id": "a720b3c0-d1f0-11e1-9b23-0800200c9a66", "volume_type_id": None, "created_at": timeutils.utcnow(), } testsnap = { "project_id": "testprjid", "name": "testvol", "volume_size": 1, "id": "b831c4d1-d1f0-11e1-9b23-0800200c9a66", "volume_id": "a720b3c0-d1f0-11e1-9b23-0800200c9a66", "volume_type_id": None, "created_at": timeutils.utcnow(), } sfv = SolidFireDriver(configuration=self.configuration) model_update = sfv.create_volume(testvol) sfv.create_snapshot(testsnap)
def test_create_volume_fails(self): # NOTE(JDG) This test just fakes update_cluster_status # this is inentional for this test self.stubs.Set(SolidFireDriver, '_update_cluster_status', self.fake_update_cluster_status) self.stubs.Set(SolidFireDriver, '_issue_api_request', self.fake_issue_api_request_fails) testvol = {'project_id': 'testprjid', 'name': 'testvol', 'size': 1, 'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66'} sfv = SolidFireDriver(configuration=self.configuration) try: sfv.create_volume(testvol) self.fail("Should have thrown Error") except Exception: pass
def test_create_volume_fails(self): # NOTE(JDG) This test just fakes update_cluster_status # this is inentional for this test self.stubs.Set(SolidFireDriver, '_update_cluster_status', self.fake_update_cluster_status) self.stubs.Set(SolidFireDriver, '_issue_api_request', self.fake_issue_api_request_fails) testvol = {'project_id': 'testprjid', 'name': 'testvol', 'size': 1, 'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66', 'created_at': timeutils.utcnow()} sfv = SolidFireDriver(configuration=self.configuration) try: sfv.create_volume(testvol) self.fail("Should have thrown Error") except Exception: pass
def test_create_volume_fails(self): # NOTE(JDG) This test just fakes update_cluster_status # this is inentional for this test self.stubs.Set(SolidFireDriver, "_update_cluster_status", self.fake_update_cluster_status) self.stubs.Set(SolidFireDriver, "_issue_api_request", self.fake_issue_api_request_fails) testvol = { "project_id": "testprjid", "name": "testvol", "size": 1, "id": "a720b3c0-d1f0-11e1-9b23-0800200c9a66", "created_at": timeutils.utcnow(), } sfv = SolidFireDriver(configuration=self.configuration) try: sfv.create_volume(testvol) self.fail("Should have thrown Error") except Exception: pass
def test_create_volume(self): self.stubs.Set(SolidFireDriver, '_issue_api_request', self.fake_issue_api_request) testvol = {'project_id': 'testprjid', 'name': 'testvol', 'size': 1, 'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66', 'volume_type_id': None} sfv = SolidFireDriver(configuration=self.configuration) model_update = sfv.create_volume(testvol) self.assertNotEqual(model_update, None) self.assertEqual(model_update.get('provider_geometry', None), None)
def test_create_snapshot(self): self.stubs.Set(SolidFireDriver, '_issue_api_request', self.fake_issue_api_request) self.stubs.Set(SolidFireDriver, '_get_model_info', self.fake_get_model_info) testvol = {'project_id': 'testprjid', 'name': 'testvol', 'size': 1, 'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66', 'volume_type_id': None, 'created_at': timeutils.utcnow()} testsnap = {'project_id': 'testprjid', 'name': 'testvol', 'volume_size': 1, 'id': 'b831c4d1-d1f0-11e1-9b23-0800200c9a66', 'volume_id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66', 'volume_type_id': None, 'created_at': timeutils.utcnow()} sfv = SolidFireDriver(configuration=self.configuration) sfv.create_volume(testvol) sfv.create_snapshot(testsnap)
def test_create_volume(self): self.stubs.Set(SolidFireDriver, '_issue_api_request', self.fake_issue_api_request) testvol = {'project_id': 'testprjid', 'name': 'testvol', 'size': 1, 'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66', 'volume_type_id': None, 'created_at': timeutils.utcnow()} sfv = SolidFireDriver(configuration=self.configuration) model_update = sfv.create_volume(testvol) self.assertIsNotNone(model_update) self.assertIsNone(model_update.get('provider_geometry', None))
def test_create_with_qos_type(self): self.stubs.Set(SolidFireDriver, '_issue_api_request', self.fake_issue_api_request) self.stubs.Set(SolidFireDriver, '_set_qos_by_volume_type', self.fake_set_qos_by_volume_type) testvol = {'project_id': 'testprjid', 'name': 'testvol', 'size': 1, 'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66', 'volume_type_id': 'fast'} sfv = SolidFireDriver(configuration=self.configuration) model_update = sfv.create_volume(testvol) self.assertNotEqual(model_update, None)
def test_create_with_qos_type(self): self.stubs.Set(SolidFireDriver, '_issue_api_request', self.fake_issue_api_request) self.stubs.Set(SolidFireDriver, '_set_qos_by_volume_type', self.fake_set_qos_by_volume_type) testvol = {'project_id': 'testprjid', 'name': 'testvol', 'size': 1, 'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66', 'volume_type_id': 'fast', 'created_at': timeutils.utcnow()} sfv = SolidFireDriver(configuration=self.configuration) model_update = sfv.create_volume(testvol) self.assertNotEqual(model_update, None)
def test_create_volume(self): self.stubs.Set(SolidFireDriver, "_issue_api_request", self.fake_issue_api_request) testvol = { "project_id": "testprjid", "name": "testvol", "size": 1, "id": "a720b3c0-d1f0-11e1-9b23-0800200c9a66", "volume_type_id": None, "created_at": timeutils.utcnow(), } sfv = SolidFireDriver(configuration=self.configuration) model_update = sfv.create_volume(testvol) self.assertIsNotNone(model_update) self.assertIsNone(model_update.get("provider_geometry", None))
def test_create_volume_non_512(self): self.stubs.Set(SolidFireDriver, '_issue_api_request', self.fake_issue_api_request) testvol = {'project_id': 'testprjid', 'name': 'testvol', 'size': 1, 'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66', 'volume_type_id': None, 'created_at': timeutils.utcnow()} self.configuration.sf_emulate_512 = False sfv = SolidFireDriver(configuration=self.configuration) model_update = sfv.create_volume(testvol) self.assertEqual(model_update.get('provider_geometry', None), '4096 4096') self.configuration.sf_emulate_512 = True
def test_create_volume_with_qos(self): preset_qos = {} preset_qos['qos'] = 'fast' self.stubs.Set(SolidFireDriver, '_issue_api_request', self.fake_issue_api_request) testvol = {'project_id': 'testprjid', 'name': 'testvol', 'size': 1, 'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66', 'metadata': [preset_qos], 'volume_type_id': None, 'created_at': timeutils.utcnow()} sfv = SolidFireDriver(configuration=self.configuration) model_update = sfv.create_volume(testvol) self.assertIsNotNone(model_update)
def test_create_volume_with_qos(self): preset_qos = {} preset_qos["qos"] = "fast" self.stubs.Set(SolidFireDriver, "_issue_api_request", self.fake_issue_api_request) testvol = { "project_id": "testprjid", "name": "testvol", "size": 1, "id": "a720b3c0-d1f0-11e1-9b23-0800200c9a66", "metadata": [preset_qos], "volume_type_id": None, "created_at": timeutils.utcnow(), } sfv = SolidFireDriver(configuration=self.configuration) model_update = sfv.create_volume(testvol) self.assertIsNotNone(model_update)