Merge "Set modification time in tarfile of ramdisk logs"
This commit is contained in:
commit
2d8e139f03
ironic_python_agent
@ -324,6 +324,7 @@ def collect_logs(data, failures):
|
||||
with tarfile.open(fileobj=fp, mode='w:gz') as tar:
|
||||
tarinfo = tarfile.TarInfo('journal')
|
||||
tarinfo.size = len(out)
|
||||
tarinfo.mtime = time.time()
|
||||
tar.addfile(tarinfo, journal)
|
||||
|
||||
fp.seek(0)
|
||||
|
@ -391,12 +391,13 @@ class TestCollectLogs(unittest.TestCase):
|
||||
mock_execute.return_value = (contents, '')
|
||||
|
||||
data = {}
|
||||
inspector.collect_logs(data, None)
|
||||
with mock.patch('time.time', return_value=42):
|
||||
inspector.collect_logs(data, None)
|
||||
res = io.BytesIO(base64.b64decode(data['logs']))
|
||||
|
||||
with tarfile.open(fileobj=res) as tar:
|
||||
members = [(m.name, m.size) for m in tar]
|
||||
self.assertEqual([('journal', len(contents))], members)
|
||||
members = [(m.name, m.size, m.mtime) for m in tar]
|
||||
self.assertEqual([('journal', len(contents), 42)], members)
|
||||
|
||||
member = tar.extractfile('journal')
|
||||
self.assertEqual(expected_contents, member.read().decode('utf-8'))
|
||||
|
Loading…
x
Reference in New Issue
Block a user