[live-media] Use subvariants in logging

Print the subvariant together with variant UID and arches. This should
make the global log easier to understand.

The output of koji command should now be split into multiple files in
logs/{arch}/livemedia-{variant}-{subvariant}.{arch}.log instead of
having them all in one file.

The tests were updated to use more sensible value for the subvariant
field.

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2016-03-17 09:02:17 +01:00
parent 4afd21952c
commit f1974d3f03
2 changed files with 16 additions and 14 deletions

View File

@ -157,22 +157,24 @@ class LiveMediaPhase(PhaseBase):
class LiveMediaThread(WorkerThread):
def process(self, item, num):
compose, variant, config = item
subvariant = config.pop('subvariant')
self.num = num
try:
self.worker(compose, variant, config)
self.worker(compose, variant, subvariant, config)
except Exception as exc:
if not compose.can_fail(variant, '*', 'live-media'):
raise
else:
msg = ('[FAIL] live-media for variant %s failed, but going on anyway.\n%s'
% (variant.uid, exc))
msg = ('[FAIL] live-media for variant %s (%s) failed, but going on anyway.\n%s'
% (variant.uid, subvariant, exc))
self.pool.log_info(msg)
tb = traceback.format_exc()
self.pool.log_debug(tb)
def _get_log_file(self, compose, variant, config):
def _get_log_file(self, compose, variant, subvariant, config):
arches = '-'.join(config['arches'])
return compose.paths.log.log_file(arches, 'livemedia-%s' % variant.uid)
return compose.paths.log.log_file(arches, 'livemedia-%s-%s'
% (variant.uid, subvariant))
def _run_command(self, koji_wrapper, cmd, compose, log_file):
time.sleep(self.num * 3)
@ -190,17 +192,15 @@ class LiveMediaThread(WorkerThread):
copy['arch'] = ','.join(copy.pop('arches', []))
return koji_wrapper.get_live_media_cmd(copy)
def worker(self, compose, variant, config):
msg = 'Live media: %s (arches: %s, variant: %s)' % (config['name'],
' '.join(config['arches']),
variant.uid)
def worker(self, compose, variant, subvariant, config):
msg = ('Live media: %s (arches: %s, variant: %s, subvariant: %s)'
% (config['name'], ' '.join(config['arches']), variant.uid, subvariant))
self.pool.log_info('[BEGIN] %s' % msg)
subvariant = config.pop('subvariant')
koji_wrapper = KojiWrapper(compose.conf['koji_profile'])
cmd = self._get_cmd(koji_wrapper, config)
log_file = self._get_log_file(compose, variant, config)
log_file = self._get_log_file(compose, variant, subvariant, config)
output = self._run_command(koji_wrapper, cmd, compose, log_file)
# collect results and update manifest

View File

@ -296,7 +296,7 @@ class TestLiveMediaThread(PungiTestCase):
'target': 'f24',
'title': None,
'version': 'Rawhide',
'subvariant': 'DATA',
'subvariant': 'KDE',
}
pool = mock.Mock()
@ -333,7 +333,7 @@ class TestLiveMediaThread(PungiTestCase):
self.assertEqual(
run_blocking_cmd.mock_calls,
[mock.call('koji-spin-livemedia',
log_file=self.topdir + '/logs/amd64-x86_64/livemedia-Server.amd64-x86_64.log')])
log_file=self.topdir + '/logs/amd64-x86_64/livemedia-Server-KDE.amd64-x86_64.log')])
self.assertEqual(get_live_media_cmd.mock_calls,
[mock.call({'arch': 'amd64,x86_64',
'ksfile': 'file.ks',
@ -375,7 +375,7 @@ class TestLiveMediaThread(PungiTestCase):
self.assertIn(image.path, image_relative_paths)
self.assertEqual('iso', image.format)
self.assertEqual('live', image.type)
self.assertEqual('DATA', image.subvariant)
self.assertEqual('KDE', image.subvariant)
@mock.patch('pungi.phases.livemedia_phase.KojiWrapper')
def test_handle_koji_fail(self, KojiWrapper):
@ -398,6 +398,7 @@ class TestLiveMediaThread(PungiTestCase):
'target': 'f24',
'title': None,
'version': 'Rawhide',
'subvariant': 'KDE',
}
pool = mock.Mock()
@ -437,6 +438,7 @@ class TestLiveMediaThread(PungiTestCase):
'target': 'f24',
'title': None,
'version': 'Rawhide',
'subvariant': 'KDE',
}
pool = mock.Mock()