tests: Attempt to use configured tmp in xprofile tests

My home server has more strict controls on /tmp as it run selinux etc.
When running unittests and the default log_filename_prefix deep under
/tmp gets permission denied. It would be better to override this setting
in the tests with a good known tmp location

Change-Id: I6c95ca3a0045a8f268802c6abb633bdfb0e56b73
This commit is contained in:
Matthew Oliver 2024-08-15 14:20:06 +10:00 committed by Tim Burke
parent e6b73612d1
commit becb3ffc1a

View File

@ -83,8 +83,12 @@ class TestProfileMiddleware(unittest.TestCase):
@unittest.skipIf(xprofile is None, "can't import xprofile")
def setUp(self):
self.got_statuses = []
self.app = ProfileMiddleware(FakeApp, {})
self.tempdir = os.path.dirname(self.app.log_filename_prefix)
self.tempdir = tempfile.mkdtemp()
log_filename_prefix = os.path.join(
self.tempdir,
'log/swift/profile/default.profile')
conf = {'log_filename_prefix': log_filename_prefix}
self.app = ProfileMiddleware(FakeApp, conf)
self.pids = ['123', '456', str(os.getpid())]
profiler = xprofile.get_profiler('eventlet.green.profile')
for pid in self.pids: