- Rewrite worker.py: each Worker uses a ProcessPoolExecutor(max_workers=1), tools run via loop.run_in_executor() in a forked OS subprocess - Remove create_process(), main(), stdin/stdout IPC, os.killpg - Remove eris-worker entry point from [project.scripts] in pyproject.toml - Update tests/worker_test.py for new Worker API - Guard _sweep_up/_sweep_down against IndexError when _entries is empty; keep cursor_position() try/except for stale y after row deletion
39 lines
1 KiB
Python
Executable file
39 lines
1 KiB
Python
Executable file
|
|
import asyncio
|
|
import os
|
|
import shutil
|
|
import tempfile
|
|
import unittest
|
|
|
|
import eris.tools as tools
|
|
import eris.worker as worker
|
|
|
|
|
|
class WorkerTestCase(unittest.TestCase):
|
|
|
|
def setUp(self):
|
|
self.temp_dir = tempfile.mkdtemp()
|
|
self.original_working_dir = os.getcwd()
|
|
os.chdir(self.temp_dir)
|
|
os.mkdir(tools.CACHE_PATH)
|
|
open("foo", "w").close()
|
|
|
|
def tearDown(self):
|
|
if hasattr(self, "worker_"):
|
|
self.worker_.kill()
|
|
shutil.rmtree(self.temp_dir)
|
|
os.chdir(self.original_working_dir)
|
|
|
|
def test_run_job(self):
|
|
loop = asyncio.new_event_loop()
|
|
compression = "none"
|
|
self.worker_ = worker.Worker(compression)
|
|
future = self.worker_.run_tool("foo", tools.metadata)
|
|
status = loop.run_until_complete(future)
|
|
self.assertEqual(status, tools.Status.ok)
|
|
result_path = os.path.join(tools.CACHE_PATH, "foo-metadata")
|
|
self.assertTrue(os.path.exists(result_path))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|