Improve patronictl reinit (#576)

Make it possible to cancel a running task if you want to reinitialize replica.
There are two possible ways to trigger it:
1. patronictl will ask whether you want to cancel already running task if an attempt to trigger reinitialize has failed
2. if you are using `--force` argument with `patronictl reinit`
This commit is contained in:
Alexander Kukushkin
2018-01-04 10:31:44 +01:00
committed by GitHub
parent b6425cab85
commit 0e01bb33bb
11 changed files with 239 additions and 90 deletions
+7 -1
View File
@@ -8,7 +8,7 @@ from threading import Thread
class TestAsyncExecutor(unittest.TestCase):
def setUp(self):
self.a = AsyncExecutor(Mock())
self.a = AsyncExecutor(Mock(), Mock())
@patch.object(Thread, 'start', Mock())
def test_run_async(self):
@@ -17,6 +17,12 @@ class TestAsyncExecutor(unittest.TestCase):
def test_run(self):
self.a.run(Mock(side_effect=Exception()))
def test_cancel(self):
self.a.cancel()
self.a.schedule('foo')
self.a.cancel()
self.a.run(Mock())
class TestCriticalTask(unittest.TestCase):