This is an automated email from the ASF dual-hosted git repository. aonishuk pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/ambari.git
commit a76eb18d940367a9376f317b11133a4eaf668e1c Author: Andrew Onishuk <[email protected]> AuthorDate: Thu Feb 22 15:24:19 2018 +0200 Fix unit tests --- .../test/python/ambari_agent/BaseStompServerTestCase.py | 7 +++++++ .../test/python/ambari_agent/TestAgentStompResponses.py | 17 +++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/ambari-agent/src/test/python/ambari_agent/BaseStompServerTestCase.py b/ambari-agent/src/test/python/ambari_agent/BaseStompServerTestCase.py index b7529a8..7df2388 100644 --- a/ambari-agent/src/test/python/ambari_agent/BaseStompServerTestCase.py +++ b/ambari-agent/src/test/python/ambari_agent/BaseStompServerTestCase.py @@ -173,6 +173,13 @@ class BaseStompServerTestCase(unittest.TestCase): else: func() + def assertDictEqual(self, d1, d2): + try: + super(BaseStompServerTestCase, self).assertDictEqual(d1, d2) + except AttributeError: + super(BaseStompServerTestCase, self).assertEqual(d1, d2) # Python 2.6 compatibility + + class TestStompServer(ThreadedStompServer): """ diff --git a/ambari-agent/src/test/python/ambari_agent/TestAgentStompResponses.py b/ambari-agent/src/test/python/ambari_agent/TestAgentStompResponses.py index 39542d1..ac7e037 100644 --- a/ambari-agent/src/test/python/ambari_agent/TestAgentStompResponses.py +++ b/ambari-agent/src/test/python/ambari_agent/TestAgentStompResponses.py @@ -41,6 +41,9 @@ from mock.mock import MagicMock, patch @patch("ambari_agent.hostname.hostname", new=MagicMock(return_value="c6401.ambari.apache.org")) class TestAgentStompResponses(BaseStompServerTestCase): def setUp(self): + self.maxDiff = None + self.initializer_module = None + self.remove_files(['/tmp/cluster_cache/configurations.json', '/tmp/cluster_cache/metadata.json', '/tmp/cluster_cache/topology.json', '/tmp/host_level_params.json', '/tmp/cluster_cache/alert_definitions.json']) if not os.path.exists("/tmp/ambari-agent"): @@ -51,6 +54,12 @@ class TestAgentStompResponses(BaseStompServerTestCase): return super(TestAgentStompResponses, self).setUp() + def tearDown(self): + if self.initializer_module: + self.initializer_module.stop_event.set() + + return super(TestAgentStompResponses, self).tearDown() + @patch.object(CustomServiceOrchestrator, "runCommand") def test_mock_server_can_start(self, runCommand_mock): runCommand_mock.return_value = {'stdout':'...', 'stderr':'...', 'structuredOut' : '{}', 'exitcode':1} @@ -286,9 +295,9 @@ class TestAgentStompResponses(BaseStompServerTestCase): #json_excepted_lopology = json.dumps(self.get_dict_from_file("topology_cache_expected.json"), indent=2, sort_keys=True) #print json_topology #print json_excepted_lopology - self.assertEquals(Utils.get_mutable_copy(self.initializer_module.topology_cache), self.get_dict_from_file("topology_cache_expected.json")) + self.assertDictEqual(Utils.get_mutable_copy(self.initializer_module.topology_cache), self.get_dict_from_file("topology_cache_expected.json")) - self.assert_with_retries(is_json_equal, tries=80, try_sleep=0.1) + self.assert_with_retries(is_json_equal, tries=160, try_sleep=0.1) self.initializer_module.stop_event.set() @@ -354,9 +363,9 @@ class TestAgentStompResponses(BaseStompServerTestCase): #json_excepted_definitions = json.dumps(self.get_dict_from_file("alert_definition_expected.json"), indent=2, sort_keys=True) #print json_definitions #print json_excepted_definitions - self.assertEquals(Utils.get_mutable_copy(self.initializer_module.alert_definitions_cache), self.get_dict_from_file("alert_definition_expected.json")) + self.assertDictEqual(Utils.get_mutable_copy(self.initializer_module.alert_definitions_cache), self.get_dict_from_file("alert_definition_expected.json")) - self.assert_with_retries(is_json_equal, tries=80, try_sleep=0.1) + self.assert_with_retries(is_json_equal, tries=160, try_sleep=0.1) self.initializer_module.stop_event.set() -- To stop receiving notification emails like this one, please contact [email protected].
