def test_finalize_md5_processes(): with pytest.raises(ValueError): ops.LocalFileMd5Offload(num_workers=0) a = None try: a = ops.LocalFileMd5Offload(num_workers=1) finally: if a: a.finalize_processes() for proc in a._procs: assert not proc.is_alive()
def test_from_add_to_done_pagealigned(tmpdir): file = tmpdir.join('a') file.write('abc') fpath = str(file) key = 'key' remote_md5 = ops.compute_md5_for_file_asbase64(str(file), True) a = None try: a = ops.LocalFileMd5Offload(num_workers=1) result = a.pop_done_queue() assert result is None a.add_localfile_for_md5_check(key, fpath, fpath, remote_md5, azmodels.StorageModes.Page, None) i = 33 checked = False while i > 0: result = a.pop_done_queue() if result is None: time.sleep(0.3) i -= 1 continue assert len(result) == 4 assert result[0] == key assert result[1] == str(file) assert result[2] is None assert result[3] checked = True break assert checked finally: if a: a.finalize_processes()
def test_done_cv(): a = None try: a = ops.LocalFileMd5Offload(num_workers=1) assert a.done_cv == a._done_cv finally: if a: a.finalize_processes()
def test_from_add_to_done_lpview(tmpdir): file = tmpdir.join('a') file.write('abc') fpath = str(file) key = 'key' remote_md5 = ops.compute_md5_for_file_asbase64(str(file)) a = None lpview = modelsul.LocalPathView( fd_start=0, fd_end=3, mode=None, next=None, slice_num=None, total_slices=1, ) try: a = ops.LocalFileMd5Offload(num_workers=1) result = a.pop_done_queue() assert result is None a.add_localfile_for_md5_check(key, fpath, fpath, remote_md5, azmodels.StorageModes.Block, lpview) i = 33 checked = False while i > 0: result = a.pop_done_queue() if result is None: time.sleep(0.3) i -= 1 continue assert len(result) == 5 assert result[0] == key assert result[1] == str(file) assert result[2] == 3 assert result[3] == remote_md5 assert result[4] checked = True break assert checked finally: if a: a.finalize_processes()