From: JINMEI Tatuya Date: Wed, 20 Feb 2013 04:19:37 +0000 (-0800) Subject: [2689] eliminte need for thread from test_config. X-Git-Tag: bind10-1.1.0beta1-release~76^2~7 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0f795237b2b0384cde3a60bb49df75cd529e31bc;p=thirdparty%2Fkea.git [2689] eliminte need for thread from test_config. --- diff --git a/src/bin/stats/tests/b10-stats_test.py b/src/bin/stats/tests/b10-stats_test.py index 812a77a6af..48656a75ad 100644 --- a/src/bin/stats/tests/b10-stats_test.py +++ b/src/bin/stats/tests/b10-stats_test.py @@ -802,8 +802,8 @@ class TestStats(unittest.TestCase): def test_config(self): orig_get_timestamp = stats.get_timestamp stats.get_timestamp = lambda : self.const_timestamp - stats_server = ThreadingServerManager(MyStats) - stat = stats_server.server + stat = SimpleStats() + # test updating poll-interval self.assertEqual(stat.config['poll-interval'], 60) self.assertEqual(stat.get_interval(), 60) @@ -827,14 +827,25 @@ class TestStats(unittest.TestCase): self.assertEqual(stat.config_handler({'poll-interval': 0}), isc.config.create_answer(0)) self.assertEqual(stat.config['poll-interval'], 0) - stats_server.run() + + # see the comment for test_update_statistics_data_withmid. We abuse + # do_polling here, too. With #2781 we should make it more direct. + create_answer = isc.config.ccsession.create_answer # shortcut + stat._answers = [\ + # Answer for "show_processes" + (create_answer(0, []), None), + # Answers for "getstats" for Init (the other one for Auth, but + # that doesn't matter for this test) + (create_answer(0, stat._init_sdata), {'from': 'init'}), + (create_answer(0, stat._init_sdata), {'from': 'init'}) + ] + stat.update_modules = lambda: None + self.assertEqual( - send_command( - 'show', 'Stats', - params={ 'owner' : 'Init', - 'name' : 'boot_time' }), + self.__send_command( + stat, 'show', + params={ 'owner' : 'Init', 'name' : 'boot_time' }), (0, {'Init': {'boot_time': self.const_datetime}})) - stats_server.shutdown() def test_commands(self): self.stats = stats.Stats() diff --git a/src/bin/stats/tests/test_utils.py b/src/bin/stats/tests/test_utils.py index 1750e7a336..6fe9ce4ac3 100644 --- a/src/bin/stats/tests/test_utils.py +++ b/src/bin/stats/tests/test_utils.py @@ -487,6 +487,9 @@ class SimpleStats(stats.Stats): json.loads(MockAuth.spec_str)['module_spec']['statistics'] }) self.__init_auth_stat() + self._init_sdata = { + 'boot_time': time.strftime('%Y-%m-%dT%H:%M:%SZ', CONST_BASETIME) + } # Since we replace _init_statistics_data, this doesn't cause # any network I/O