def test_teardown_failure(self): job_id = make_uuid() sp_id = make_uuid() sd_id = make_uuid() img0_id = make_uuid() img1_id = TEARDOWN_ERROR_IMAGE_ID vol0_id = make_uuid() vol1_id = make_uuid() images = [ {'sd_id': sd_id, 'img_id': img0_id, 'vol_id': vol0_id}, {'sd_id': sd_id, 'img_id': img1_id, 'vol_id': vol1_id}, ] expected = [ ('prepareImage', (sd_id, sp_id, img0_id, vol0_id), {'allowIllegal': True}), ('prepareImage', (sd_id, sp_id, img1_id, vol1_id), {'allowIllegal': True}), ('teardownImage', (sd_id, sp_id, img1_id), {}), ('teardownImage', (sd_id, sp_id, img0_id), {}), ] with namedTemporaryDir() as base: irs = FakeIRS(base) with MonkeyPatchScope([ (utils, '_COMMANDS_LOG_DIR', base) ]): job = seal.Job(BLANK_UUID, job_id, sp_id, images, irs) job.autodelete = False job.run() assert jobs.STATUS.FAILED == job.status assert expected == irs.__calls__
def test_job(self): job_id = make_uuid() sp_id = make_uuid() sd_id = make_uuid() img0_id = make_uuid() img1_id = make_uuid() vol0_id = make_uuid() vol1_id = make_uuid() images = [ { 'sd_id': sd_id, 'img_id': img0_id, 'vol_id': vol0_id }, { 'sd_id': sd_id, 'img_id': img1_id, 'vol_id': vol1_id }, ] expected = [ ('prepareImage', (sd_id, sp_id, img0_id, vol0_id), { 'allowIllegal': True }), ('prepareImage', (sd_id, sp_id, img1_id, vol1_id), { 'allowIllegal': True }), ('teardownImage', (sd_id, sp_id, img1_id), {}), ('teardownImage', (sd_id, sp_id, img0_id), {}), ] with namedTemporaryDir() as base: irs = FakeIRS(base) job = seal.Job(job_id, sp_id, images, irs) job.autodelete = False job.run() wait_for_job(job) self.assertEqual(jobs.STATUS.DONE, job.status) self.assertEqual(expected, irs.__calls__) for image in images: resultpath = _vol_path(base, image['sd_id'], sp_id, image['img_id'], ext='.res') with open(resultpath) as f: data = f.read() self.assertEqual(data, 'fake-virt-sysprep was here')
def test_teardown_failure(self): job_id = make_uuid() sp_id = make_uuid() sd_id = make_uuid() img0_id = make_uuid() img1_id = TEARDOWN_ERROR_IMAGE_ID vol0_id = make_uuid() vol1_id = make_uuid() images = [ { 'sd_id': sd_id, 'img_id': img0_id, 'vol_id': vol0_id }, { 'sd_id': sd_id, 'img_id': img1_id, 'vol_id': vol1_id }, ] expected = [ ('prepareImage', (sd_id, sp_id, img0_id, vol0_id), { 'allowIllegal': True }), ('prepareImage', (sd_id, sp_id, img1_id, vol1_id), { 'allowIllegal': True }), ('teardownImage', (sd_id, sp_id, img1_id), {}), ('teardownImage', (sd_id, sp_id, img0_id), {}), ] with namedTemporaryDir() as base: irs = FakeIRS(base) job = seal.Job(job_id, sp_id, images, irs) job.autodelete = False job.run() wait_for_job(job) self.assertEqual(jobs.STATUS.FAILED, job.status) self.assertEqual(expected, irs.__calls__)
def test_job(self): job_id = make_uuid() sp_id = make_uuid() sd_id = make_uuid() img0_id = make_uuid() img1_id = make_uuid() vol0_id = make_uuid() vol1_id = make_uuid() images = [ {'sd_id': sd_id, 'img_id': img0_id, 'vol_id': vol0_id}, {'sd_id': sd_id, 'img_id': img1_id, 'vol_id': vol1_id}, ] expected = [ ('prepareImage', (sd_id, sp_id, img0_id, vol0_id), {'allowIllegal': True}), ('prepareImage', (sd_id, sp_id, img1_id, vol1_id), {'allowIllegal': True}), ('teardownImage', (sd_id, sp_id, img1_id), {}), ('teardownImage', (sd_id, sp_id, img0_id), {}), ] with namedTemporaryDir() as base: irs = FakeIRS(base) with MonkeyPatchScope([ (utils, '_COMMANDS_LOG_DIR', base) ]): job = seal.Job(BLANK_UUID, job_id, sp_id, images, irs) job.autodelete = False job.run() assert jobs.STATUS.DONE == job.status assert expected == irs.__calls__ for image in images: resultpath = _vol_path(base, image['sd_id'], sp_id, image['img_id'], ext='.res') with open(resultpath) as f: data = f.read() assert data == 'fake-virt-sysprep was here'