pcs/tests-properly-mock-os.kill-in-scheduler-deadlock.patch
Miroslav Lisik 9455af1d47 Resolves: rhbz#1493416 rhbz#1796827 rhbz#2059147 rhbz#2092950 rhbz#2112079 rhbz#2112270 rhbz#2112293 rhbz#2117599 rhbz#2117601
- Rebased to latest upstream sources (see CHANGELOG.md)
- Updated pcs-web-ui
- Added bundled rubygem: childprocess
- Removed bundled rubygem: open4
- Updated bundled rubygems: mustermann, rack, rack-protection, rack-test, sinatra, tilt
2022-10-25 16:01:39 +02:00

62 lines
2.3 KiB
Diff

From 7d9285475e669e805483b50076a55a0ca617cf54 Mon Sep 17 00:00:00 2001
From: Ondrej Mular <omular@redhat.com>
Date: Tue, 25 Oct 2022 09:18:19 +0200
Subject: [PATCH] tests: properly mock os.kill in scheduler deadlock test
---
pcs_test/tier0/daemon/async_tasks/test_integration.py | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/pcs_test/tier0/daemon/async_tasks/test_integration.py b/pcs_test/tier0/daemon/async_tasks/test_integration.py
index 289da60f..a5ad801f 100644
--- a/pcs_test/tier0/daemon/async_tasks/test_integration.py
+++ b/pcs_test/tier0/daemon/async_tasks/test_integration.py
@@ -1,4 +1,5 @@
import dataclasses
+import signal
from datetime import timedelta
from logging import Logger
from multiprocessing import Process
@@ -507,6 +508,7 @@ class TaskResultsTests(MockOsKillMixin, IntegrationBaseTestCase):
self.assertEqual(RESULT, task_info.result)
+@mock.patch("pcs.daemon.async_tasks.task.os.kill")
class DeadlockTests(
MockOsKillMixin, AssertTaskStatesMixin, IntegrationBaseTestCase
):
@@ -526,7 +528,7 @@ class DeadlockTests(
).start()
@gen_test
- async def test_deadlock_mitigation(self):
+ async def test_deadlock_mitigation(self, mock_kill):
self._create_tasks(2)
self.execute_tasks(["id0"])
await self.perform_actions(1)
@@ -554,13 +556,15 @@ class DeadlockTests(
self.process_obj_mock.close.assert_not_called()
self.finish_tasks(["id1"])
self.process_obj_mock.is_alive.return_value = False
+ mock_kill.assert_not_called()
await self.perform_actions(1)
+ mock_kill.assert_called_once_with(1, signal.SIGCONT)
# tmp worker finished the task and terminated itself
self.assert_task_state_counts_equal(0, 0, 1, 1)
self.process_obj_mock.close.assert_called_once_with()
@gen_test
- async def test_max_worker_count_reached(self):
+ async def test_max_worker_count_reached(self, mock_kill):
self.scheduler._config = dataclasses.replace(
self.scheduler._config, max_worker_count=1
)
@@ -570,3 +574,4 @@ class DeadlockTests(
self.assert_task_state_counts_equal(0, 2, 1, 0)
self.process_cls_mock.assert_not_called()
self.process_obj_mock.assert_not_called()
+ mock_kill.assert_not_called()
--
2.37.3