From e3a81dcbb88badafb7321424eac7eb1188ef2f01 Mon Sep 17 00:00:00 2001 From: Anton Kurbatov Date: Fri, 9 Jun 2023 11:55:36 +0000 Subject: [PATCH] Mock access to tuned active_profile file in unittests In some environments /etc/tuned/active_profile may be present, and then running unittests in such an environment can result in an failure. This patch mocks access to /etc/tuned/active_profile. file in two test cases test_compile_amphora_details{_for_ipvs} Closes-Bug: #2023384 Signed-off-by: Anton Kurbatov Change-Id: I43416b32b9bef359f7ae7885353721e73a48e006 --- .../amphorae/backends/agent/api_server/test_amphora_info.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/octavia/tests/unit/amphorae/backends/agent/api_server/test_amphora_info.py b/octavia/tests/unit/amphorae/backends/agent/api_server/test_amphora_info.py index 615891493c..44666e9a95 100644 --- a/octavia/tests/unit/amphorae/backends/agent/api_server/test_amphora_info.py +++ b/octavia/tests/unit/amphorae/backends/agent/api_server/test_amphora_info.py @@ -185,6 +185,7 @@ class TestAmphoraInfo(base.TestCase): u'packages': {}, u'topology': u'SINGLE', u'topology_status': u'OK'} + self.useFixture(test_utils.OpenFixture('/etc/tuned/active_profile')) actual = self.amp_info.compile_amphora_details() self.assertEqual(expected_dict, actual.json) m_count.assert_called_once_with(sorted(mget_loadbalancers())) @@ -277,6 +278,7 @@ class TestAmphoraInfo(base.TestCase): u'packages': {}, u'topology': u'SINGLE', u'topology_status': u'OK'} + self.useFixture(test_utils.OpenFixture('/etc/tuned/active_profile')) actual = self.amp_info.compile_amphora_details(self.lvs_driver) self.assertEqual(expected_dict, actual.json) api_server.VERSION = original_version