Mocking utils.check_deploy_backups in OvercloudDeploy tests

The `check_deploy_backups` makes calls to `stat` which can potentially
lead to I/O error in testing scenarios when the relevant file is
removed after path retrieval but before `stat` is called.

This can lead to tox test failure, in both CI and local environments.
Mocking the utils.check_deploy_backups in tests where it is indirectly
called should alleviate the problem.

Long term solution would be mocking all built in functions performing I/O calls by default.

Closes-Bug: #1969425

Signed-off-by: Jiri Podivin <jpodivin@redhat.com>
Change-Id: I96d4bfce84ffe36d476e3383ee264cea6fd93c24
This commit is contained in:
Jiri Podivin 2022-04-28 10:51:16 +02:00
parent c79a318263
commit 1a59023772
1 changed files with 5 additions and 0 deletions

View File

@ -126,6 +126,11 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
mock_copy_to_wd.start()
self.addCleanup(mock_copy_to_wd.stop)
mock_check_deploy_backups = mock.patch(
'tripleoclient.utils.check_deploy_backups', autospec=True)
mock_check_deploy_backups.start()
self.addCleanup(mock_check_deploy_backups.stop)
def tearDown(self):
super(TestDeployOvercloud, self).tearDown()
os.unlink(self.parameter_defaults_env_file)