Added timeout and limit to script entries

This commit is contained in:
Niels Geens
2024-11-13 17:48:39 +01:00
parent 65478e0b17
commit 834ce12e8f
21 changed files with 262 additions and 141 deletions

View File

@@ -40,7 +40,7 @@ class BackgroundEntryTest(unittest.TestCase):
def test_initialization(self):
"""Test entry initialization"""
entry = BackgroundEntry("echo test", self.test_id, self.test_timestamp)
entry = BackgroundEntry(self.test_id, self.test_timestamp, "echo test")
context = entry.generate_context()
# Initial context should have script but no pid or exit_code
@@ -50,7 +50,7 @@ class BackgroundEntryTest(unittest.TestCase):
def test_short_running_process(self):
"""Test execution of a quick process"""
entry = BackgroundEntry("echo 'test'", self.test_id, self.test_timestamp)
entry = BackgroundEntry(self.test_id, self.test_timestamp, "echo 'test'")
# Wait for process to complete
def is_complete(ctx):
@@ -74,7 +74,7 @@ class BackgroundEntryTest(unittest.TestCase):
'"'
)
entry = BackgroundEntry(script, self.test_id, self.test_timestamp)
entry = BackgroundEntry(self.test_id, self.test_timestamp, script)
# Wait for process to complete
def has_all_output(ctx):
@@ -85,7 +85,7 @@ class BackgroundEntryTest(unittest.TestCase):
def test_process_failure(self):
"""Test handling of process failures"""
entry = BackgroundEntry("nonexistentcommand", self.test_id, self.test_timestamp)
entry = BackgroundEntry(self.test_id, self.test_timestamp, "nonexistentcommand")
# Wait for process to fail
def has_failed(ctx):
@@ -100,7 +100,7 @@ class BackgroundEntryTest(unittest.TestCase):
def test_cleanup_running_process(self):
"""Test cleanup of running process"""
entry = BackgroundEntry("sleep 10", self.test_id, self.test_timestamp)
entry = BackgroundEntry(self.test_id, self.test_timestamp, "sleep 10")
# Wait for process to start
def has_started(ctx):
@@ -122,7 +122,7 @@ class BackgroundEntryTest(unittest.TestCase):
def test_cleanup_completed_process(self):
"""Test cleanup of already completed process"""
entry = BackgroundEntry("echo test", self.test_id, self.test_timestamp)
entry = BackgroundEntry(self.test_id, self.test_timestamp, "echo test")
# Wait for completion
def is_complete(ctx):
@@ -135,7 +135,7 @@ class BackgroundEntryTest(unittest.TestCase):
def test_multiple_cleanup_calls(self):
"""Test that multiple cleanup calls are safe"""
entry = BackgroundEntry("sleep 10", self.test_id, self.test_timestamp)
entry = BackgroundEntry(self.test_id, self.test_timestamp, "sleep 10")
# Wait for process to start
def has_started(ctx):