summaryrefslogtreecommitdiffstats
path: root/testsuite
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2012-11-27 11:49:47 -0500
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-11-27 12:12:34 -0500
commitc19e7da20ca6b67956338f9808a80673e06b1e94 (patch)
tree5d62c7c7aaf71e062f8bf22cbce987b8555ad78b /testsuite
parentfbecb8553136649eaf563d4f7ec21553500e5f16 (diff)
downloadbcfg2-c19e7da20ca6b67956338f9808a80673e06b1e94.tar.gz
bcfg2-c19e7da20ca6b67956338f9808a80673e06b1e94.tar.bz2
bcfg2-c19e7da20ca6b67956338f9808a80673e06b1e94.zip
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
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testinterfaces.py23
1 files changed, 19 insertions, 4 deletions
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", "<foo/>"),
("bar.example.com", "<bar/>")]
+ 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)