Make --task-id mandatory in get_runroot_cmd

JIRA: COMPOSE-4027
Signed-off-by: Haibo Lin <hlin@redhat.com>
This commit is contained in:
Haibo Lin 2020-01-20 09:56:29 +08:00
parent bce57c2e66
commit 6eb6511aa6
7 changed files with 22 additions and 25 deletions

View File

@ -84,7 +84,7 @@ class Runroot(kobo.log.LoggingBase):
koji_wrapper = kojiwrapper.KojiWrapper(self.compose.conf["koji_profile"])
koji_cmd = koji_wrapper.get_runroot_cmd(
runroot_tag, arch, command,
channel=runroot_channel, use_shell=True, task_id=True,
channel=runroot_channel, use_shell=True,
packages=packages, **kwargs
)

View File

@ -72,8 +72,8 @@ class KojiWrapper(object):
def get_runroot_cmd(self, target, arch, command, quiet=False, use_shell=True,
channel=None, packages=None, mounts=None, weight=None,
task_id=True, new_chroot=False, chown_paths=None):
cmd = self._get_cmd("runroot", "--nowait")
new_chroot=False, chown_paths=None):
cmd = self._get_cmd("runroot", "--nowait", "--task-id")
if quiet:
cmd.append("--quiet")
@ -84,9 +84,6 @@ class KojiWrapper(object):
if use_shell:
cmd.append("--use-shell")
if task_id:
cmd.append("--task-id")
if channel:
cmd.append("--channel-override=%s" % channel)
else:
@ -142,11 +139,11 @@ class KojiWrapper(object):
yield None
def run_runroot_cmd(self, command, log_file=None):
"""
Run koji runroot command and wait for results.
"""Run koji runroot command and wait for results.
If the command specified --task-id, and the first line of output
contains the id, it will be captured and returned.
:param list command: runroot command returned by self.get_runroot_cmd()
:param str log_file: save logs to log_file
:return dict: {"retcode": 0, "output": "", "task_id": 1}
"""
task_id = None
with self.get_koji_cmd_env() as env:

View File

@ -623,7 +623,7 @@ class BuildinstallThreadTestCase(PungiTestCase):
get_runroot_cmd.mock_calls,
[mock.call(
'rrt', 'x86_64', self.cmd, channel=None,
use_shell=True, task_id=True,
use_shell=True,
packages=['lorax'], mounts=[self.topdir], weight=123,
chown_paths=[
destdir,
@ -694,7 +694,7 @@ class BuildinstallThreadTestCase(PungiTestCase):
get_runroot_cmd.mock_calls,
[mock.call(
"rrt", "amd64", self.cmd, channel=None,
use_shell=True, task_id=True,
use_shell=True,
packages=['anaconda'], mounts=[self.topdir], weight=None,
chown_paths=[destdir],
)])
@ -864,7 +864,7 @@ class BuildinstallThreadTestCase(PungiTestCase):
get_runroot_cmd.mock_calls,
[mock.call(
'rrt', 'x86_64', self.cmd, channel=None,
use_shell=True, task_id=True,
use_shell=True,
packages=['lorax'], mounts=[self.topdir], weight=123,
chown_paths=[
"/buildinstall_topdir/buildinstall-%s/x86_64/Server" % os.path.basename(self.topdir),

View File

@ -380,7 +380,7 @@ class CreateisoThreadTest(helpers.PungiTestCase):
mounts=[self.topdir],
packages=['coreutils', 'genisoimage', 'isomd5sum',
'jigdo'],
task_id=True, use_shell=True, weight=None)])
use_shell=True, weight=None)])
self.assertEqual(
run_runroot.call_args_list,
[mock.call(get_runroot_cmd.return_value,
@ -443,7 +443,7 @@ class CreateisoThreadTest(helpers.PungiTestCase):
[mock.call('f25-build', 'x86_64', cmd['cmd'], channel=None,
mounts=[self.topdir],
packages=['coreutils', 'genisoimage', 'isomd5sum'],
task_id=True, use_shell=True, weight=123)])
use_shell=True, weight=123)])
self.assertEqual(
run_runroot.call_args_list,
[mock.call(get_runroot_cmd.return_value,
@ -508,7 +508,7 @@ class CreateisoThreadTest(helpers.PungiTestCase):
mounts=[self.topdir],
packages=['coreutils', 'genisoimage', 'isomd5sum',
'jigdo', 'lorax', 'which'],
task_id=True, use_shell=True, weight=None)])
use_shell=True, weight=None)])
self.assertEqual(
run_runroot.call_args_list,
[mock.call(get_runroot_cmd.return_value,

View File

@ -424,13 +424,13 @@ class LiveImageKojiWrapperTest(KojiWrapperBaseTestCase):
class RunrootKojiWrapperTest(KojiWrapperBaseTestCase):
def test_get_cmd_minimal(self):
cmd = self.koji.get_runroot_cmd('tgt', 's390x', 'date', use_shell=False, task_id=False)
self.assertEqual(len(cmd), 8)
self.assertEqual(cmd[:3], ['koji', '--profile=custom-koji', 'runroot'])
cmd = self.koji.get_runroot_cmd('tgt', 's390x', 'date', use_shell=False)
self.assertEqual(len(cmd), 9)
self.assertEqual(cmd[:5], ['koji', '--profile=custom-koji', 'runroot', '--nowait', '--task-id'])
self.assertEqual(cmd[-3], 'tgt')
self.assertEqual(cmd[-2], 's390x')
self.assertEqual(cmd[-1], 'rm -f /var/lib/rpm/__db*; rm -rf /var/cache/yum/*; set -x; date')
six.assertCountEqual(self, cmd[4:-3], ["--channel-override=runroot-local"])
six.assertCountEqual(self, cmd[5:-3], ["--channel-override=runroot-local"])
def test_get_cmd_full(self):
cmd = self.koji.get_runroot_cmd('tgt', 's390x', ['/bin/echo', '&'],

View File

@ -156,7 +156,7 @@ class OstreeThreadTest(helpers.PungiTestCase):
'rm -rf %s && %s' % (outdir, ' '.join(lorax_cmd)),
channel=None, mounts=[self.topdir],
packages=['pungi', 'lorax', 'ostree'] + extra_pkgs,
task_id=True, use_shell=True, weight=weight,
use_shell=True, weight=weight,
chown_paths=[outdir])])
self.assertEqual(koji.run_runroot_cmd.call_args_list,
[mock.call(koji.get_runroot_cmd.return_value,

View File

@ -214,7 +214,7 @@ class OSTreeThreadTest(helpers.PungiTestCase):
'--extra-config=%s/extra_config.json' % (self.topdir + '/work/ostree-1')],
channel=None, mounts=[self.topdir, self.repo],
packages=['pungi', 'ostree', 'rpm-ostree'],
task_id=True, use_shell=True, new_chroot=True, weight=123)])
use_shell=True, new_chroot=True, weight=123)])
self.assertEqual(koji.run_runroot_cmd.call_args_list,
[mock.call(koji.get_runroot_cmd.return_value,
log_file=self.topdir + '/logs/x86_64/Everything/ostree-1/runroot.log')])
@ -384,7 +384,7 @@ class OSTreeThreadTest(helpers.PungiTestCase):
'--update-summary'],
channel=None, mounts=[self.topdir, self.repo],
packages=['pungi', 'ostree', 'rpm-ostree'],
task_id=True, use_shell=True, new_chroot=True, weight=None)])
use_shell=True, new_chroot=True, weight=None)])
self.assertEqual(koji.run_runroot_cmd.call_args_list,
[mock.call(koji.get_runroot_cmd.return_value,
log_file=self.topdir + '/logs/x86_64/Everything/ostree-1/runroot.log')])
@ -419,7 +419,7 @@ class OSTreeThreadTest(helpers.PungiTestCase):
'--extra-config=%s/work/ostree-1/extra_config.json' % self.topdir],
channel=None, mounts=[self.topdir, self.repo],
packages=['pungi', 'ostree', 'rpm-ostree'],
task_id=True, use_shell=True, new_chroot=True, weight=None)])
use_shell=True, new_chroot=True, weight=None)])
self.assertEqual(koji.run_runroot_cmd.call_args_list,
[mock.call(koji.get_runroot_cmd.return_value,
log_file=self.topdir + '/logs/x86_64/Everything/ostree-1/runroot.log')])
@ -454,7 +454,7 @@ class OSTreeThreadTest(helpers.PungiTestCase):
'--extra-config=%s/work/ostree-1/extra_config.json' % self.topdir],
channel=None, mounts=[self.topdir, self.repo],
packages=['pungi', 'ostree', 'rpm-ostree'],
task_id=True, use_shell=True, new_chroot=True, weight=None)])
use_shell=True, new_chroot=True, weight=None)])
self.assertEqual(koji.run_runroot_cmd.call_args_list,
[mock.call(koji.get_runroot_cmd.return_value,
log_file=self.topdir + '/logs/x86_64/Everything/ostree-1/runroot.log')])