Skip to content

Commit 15b1531

Browse files
SeanMooneygibizer
authored andcommitted
adapt to oslo.log changes
This change refactors prvisep util test cases to account for the fact that oslo.log now conditionally uses an internal pipe mutex when logging under eventlet. This was added by Iac1b0891ae584ce4b95964e6cdc0ff2483a4e57d which is part of oslo.log 5.3.0 As a result we need to mock all calls to oslo.log in unit tests that are assertign if os.write is called. when the internal pipe mutex is used oslo.log calls os.write when the mutex is released. Related-Bug: #1983863 Change-Id: Id313669df80f9190b79690fff25f8e3fce2a4aca (cherry picked from commit ea07f96)
1 parent 945aabc commit 15b1531

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

nova/tests/unit/privsep/test_utils.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# under the License.
1414

1515
import errno
16+
import fixtures
1617
import os
1718
from unittest import mock
1819

@@ -55,6 +56,13 @@ def setUp(self):
5556
self.mock_close = close_patcher.start()
5657
self.mock_unlink = unlink_patcher.start()
5758
random_string_patcher.start()
59+
# as of change Iac1b0891ae584ce4b95964e6cdc0ff2483a4e57d in oslo.log
60+
# oslo.log will now internally call os.write() in its PipeMutex code.
61+
# This causes the mock_write() to be called which breaks some of
62+
# the testcases as we expect mock_write() to be called only
63+
# by the code under test.
64+
self.useFixture(fixtures.MonkeyPatch(
65+
"nova.privsep.utils.LOG", mock.Mock()))
5866

5967
def test_supports_direct_io(self):
6068
self.mock_open.return_value = 3
@@ -85,6 +93,7 @@ def test_supports_direct_io_with_exception_in_write(self):
8593
def test_supports_direct_io_with_exception_in_open(self):
8694
self.mock_open.side_effect = ValueError()
8795

96+
self.mock_open.assert_not_called()
8897
self.assertRaises(ValueError, nova.privsep.utils.supports_direct_io,
8998
'.')
9099

0 commit comments

Comments
 (0)