def test_delete_snapshot(self): testsnap = {'id': 'ca253fd0-8068-11e4-98c0-5254008ea111'} dmd = DrbdManageDriver(configuration=self.configuration) dmd.odm = DrbdManageFakeDriver() dmd.delete_snapshot(testsnap) self.assertEqual(dmd.odm.calls[0][0], "list_snapshots") self.assertEqual(dmd.odm.calls[1][0], "remove_snapshot")
def test_create_snapshot(self): testsnap = {'id': 'ca253fd0-8068-11e4-98c0-5254008ea111', 'volume_id': 'ba253fd0-8068-11e4-98c0-5254008ea111'} dmd = DrbdManageDriver(configuration=self.configuration) dmd.odm = DrbdManageFakeDriver() dmd.create_snapshot(testsnap) self.assertEqual(dmd.odm.calls[0][0], "list_volumes") self.assertEqual(dmd.odm.calls[1][0], "list_assignments") self.assertEqual(dmd.odm.calls[2][0], "create_snapshot") self.assertTrue('node' in dmd.odm.calls[2][3])
def test_local_path(self): testvol = {'project_id': 'testprjid', 'name': 'testvol', 'size': 1, 'id': 'ba253fd0-8068-11e4-98c0-5254008ea111', 'volume_type_id': 'drbdmanage', 'created_at': timeutils.utcnow()} dmd = DrbdManageDriver(configuration=self.configuration) dmd.odm = DrbdManageFakeDriver() data = dmd.local_path(testvol) self.assertTrue(data.startswith("/dev/drbd"))
def test_create_snapshot(self): testsnap = { 'id': 'ca253fd0-8068-11e4-98c0-5254008ea111', 'volume_id': 'ba253fd0-8068-11e4-98c0-5254008ea111' } dmd = DrbdManageDriver(configuration=self.configuration) dmd.odm = DrbdManageFakeDriver() dmd.create_snapshot(testsnap) self.assertEqual(dmd.odm.calls[0][0], "list_volumes") self.assertEqual(dmd.odm.calls[1][0], "list_assignments") self.assertEqual(dmd.odm.calls[2][0], "create_snapshot") self.assertTrue('node' in dmd.odm.calls[2][3])
def test_delete_volume(self): testvol = {'project_id': 'testprjid', 'name': 'testvol', 'size': 1, 'id': 'ba253fd0-8068-11e4-98c0-5254008ea111', 'volume_type_id': 'drbdmanage', 'created_at': timeutils.utcnow()} dmd = DrbdManageDriver(configuration=self.configuration) dmd.odm = DrbdManageFakeDriver() dmd.delete_volume(testvol) self.assertEqual(dmd.odm.calls[0][0], "list_volumes") self.assertEqual(dmd.odm.calls[0][3]["cinder-id"], testvol['id']) self.assertEqual(dmd.odm.calls[1][0], "remove_volume")
def test_local_path(self): testvol = { 'project_id': 'testprjid', 'name': 'testvol', 'size': 1, 'id': 'ba253fd0-8068-11e4-98c0-5254008ea111', 'volume_type_id': 'drbdmanage', 'created_at': timeutils.utcnow() } dmd = DrbdManageDriver(configuration=self.configuration) dmd.odm = DrbdManageFakeDriver() data = dmd.local_path(testvol) self.assertTrue(data.startswith("/dev/drbd"))
def test_create_volume(self): testvol = {'project_id': 'testprjid', 'name': 'testvol', 'size': 1, 'id': 'ba253fd0-8068-11e4-98c0-5254008ea111', 'volume_type_id': 'drbdmanage', 'created_at': timeutils.utcnow()} dmd = DrbdManageDriver(configuration=self.configuration) dmd.odm = DrbdManageFakeDriver() dmd.create_volume(testvol) self.assertEqual(dmd.odm.calls[0][0], "create_resource") self.assertEqual(dmd.odm.calls[1][0], "create_volume") self.assertEqual(dmd.odm.calls[1][2], 1048576) self.assertEqual(dmd.odm.calls[2][0], "auto_deploy")
def test_delete_volume(self): testvol = { 'project_id': 'testprjid', 'name': 'testvol', 'size': 1, 'id': 'ba253fd0-8068-11e4-98c0-5254008ea111', 'volume_type_id': 'drbdmanage', 'created_at': timeutils.utcnow() } dmd = DrbdManageDriver(configuration=self.configuration) dmd.odm = DrbdManageFakeDriver() dmd.delete_volume(testvol) self.assertEqual(dmd.odm.calls[0][0], "list_volumes") self.assertEqual(dmd.odm.calls[0][3]["cinder-id"], testvol['id']) self.assertEqual(dmd.odm.calls[1][0], "remove_volume")
def test_create_volume(self): testvol = { 'project_id': 'testprjid', 'name': 'testvol', 'size': 1, 'id': 'ba253fd0-8068-11e4-98c0-5254008ea111', 'volume_type_id': 'drbdmanage', 'created_at': timeutils.utcnow() } dmd = DrbdManageDriver(configuration=self.configuration) dmd.odm = DrbdManageFakeDriver() dmd.create_volume(testvol) self.assertEqual(dmd.odm.calls[0][0], "create_resource") self.assertEqual(dmd.odm.calls[1][0], "create_volume") self.assertEqual(dmd.odm.calls[1][2], 1048576) self.assertEqual(dmd.odm.calls[2][0], "auto_deploy")
def test_create_cloned_volume(self): srcvol = {'project_id': 'testprjid', 'name': 'testvol', 'size': 1, 'id': 'ba253fd0-8068-11e4-98c0-5254008ea111', 'volume_type_id': 'drbdmanage', 'created_at': timeutils.utcnow()} newvol = {'id': 'ca253fd0-8068-11e4-98c0-5254008ea111'} dmd = DrbdManageDriver(configuration=self.configuration) dmd.odm = DrbdManageFakeDriver() dmd.create_cloned_volume(newvol, srcvol) self.assertEqual(dmd.odm.calls[0][0], "list_volumes") self.assertEqual(dmd.odm.calls[1][0], "list_assignments") self.assertEqual(dmd.odm.calls[2][0], "create_snapshot") self.assertEqual(dmd.odm.calls[3][0], "list_snapshots") self.assertEqual(dmd.odm.calls[4][0], "restore_snapshot") self.assertEqual(dmd.odm.calls[5][0], "list_snapshots") self.assertEqual(dmd.odm.calls[6][0], "remove_snapshot") self.assertEqual(dmd.odm.calls[6][0], "remove_snapshot")
def test_create_cloned_volume(self): srcvol = { 'project_id': 'testprjid', 'name': 'testvol', 'size': 1, 'id': 'ba253fd0-8068-11e4-98c0-5254008ea111', 'volume_type_id': 'drbdmanage', 'created_at': timeutils.utcnow() } newvol = {'id': 'ca253fd0-8068-11e4-98c0-5254008ea111'} dmd = DrbdManageDriver(configuration=self.configuration) dmd.odm = DrbdManageFakeDriver() dmd.create_cloned_volume(newvol, srcvol) self.assertEqual(dmd.odm.calls[0][0], "list_volumes") self.assertEqual(dmd.odm.calls[1][0], "list_assignments") self.assertEqual(dmd.odm.calls[2][0], "create_snapshot") self.assertEqual(dmd.odm.calls[3][0], "list_snapshots") self.assertEqual(dmd.odm.calls[4][0], "restore_snapshot") self.assertEqual(dmd.odm.calls[5][0], "list_snapshots") self.assertEqual(dmd.odm.calls[6][0], "remove_snapshot") self.assertEqual(dmd.odm.calls[6][0], "remove_snapshot")