From c19e7da20ca6b67956338f9808a80673e06b1e94 Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Tue, 27 Nov 2012 11:49:47 -0500 Subject: Threaded plugin fixes: * Added "Threaded" plugin interface for any plugin that uses threads * Start plugin threads after daemonization * Update existing plugins that use threads (Reporting, Snapshots, ThreadedStatistics interface) * Update unit tests --- .../TestServer/TestPlugin/Testinterfaces.py | 23 ++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'testsuite') diff --git a/testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testinterfaces.py b/testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testinterfaces.py index 1a7a0a6f7..343f088b3 100644 --- a/testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testinterfaces.py +++ b/testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testinterfaces.py @@ -108,15 +108,30 @@ class TestStatistics(TestPlugin): s.process_statistics, None, None) -class TestThreadedStatistics(TestStatistics): +class TestThreaded(Bcfg2TestCase): + test_obj = Threaded + + def get_obj(self): + return self.test_obj() + + def test_start_threads(self): + s = self.get_obj() + self.assertRaises(NotImplementedError, + s.start_threads) + + +class TestThreadedStatistics(TestStatistics, TestThreaded): test_obj = ThreadedStatistics data = [("foo.example.com", ""), ("bar.example.com", "")] + def get_obj(self, core=None): + return TestStatistics.get_obj(self, core=core) + @patch("threading.Thread.start") - def test__init(self, mock_start): - core = Mock() - ts = self.get_obj(core) + def test_start_threads(self, mock_start): + ts = self.get_obj() + ts.start_threads() mock_start.assert_any_call() @patch("%s.open" % builtins) -- cgit v1.2.3-1-g7c22