cli: show log urls for failed tasks

Fixes: https://pagure.io/koji/issue/2188
This commit is contained in:
Tomas Kopecek 2020-09-22 09:45:15 +02:00 committed by Mike McLean
parent 30e87348b8
commit bc478c2d68
17 changed files with 86 additions and 59 deletions

View file

@ -82,7 +82,8 @@ Task info: weburl/taskinfo?taskID=1
self.session.logout.assert_called()
watch_tasks_mock.assert_called_once_with(
self.session, [task_id], quiet=self.options.quiet,
poll_interval=self.options.poll_interval)
poll_interval=self.options.poll_interval,
topurl=self.options.topurl)
self.assertEqual(rv, 0)
@mock.patch('sys.stdout', new_callable=six.StringIO)
@ -131,7 +132,7 @@ Task info: weburl/taskinfo?taskID=1
self.session.logout.assert_called()
watch_tasks_mock.assert_called_once_with(
self.session, [task_id], quiet=self.options.quiet,
poll_interval=self.options.poll_interval)
poll_interval=self.options.poll_interval, topurl=self.options.topurl)
self.assertEqual(rv, 0)
@mock.patch('sys.stdout', new_callable=six.StringIO)
@ -326,7 +327,7 @@ Task info: weburl/taskinfo?taskID=1
self.session.logout.assert_called()
watch_tasks_mock.assert_called_once_with(
self.session, [task_id], quiet=self.options.quiet,
poll_interval=self.options.poll_interval)
poll_interval=self.options.poll_interval, topurl=self.options.topurl)
self.assertEqual(rv, 0)
@mock.patch('sys.stderr', new_callable=six.StringIO)
@ -510,7 +511,7 @@ Task info: weburl/taskinfo?taskID=1
self.session.logout.assert_called()
watch_tasks_mock.assert_called_once_with(
self.session, [task_id], quiet=self.options.quiet,
poll_interval=self.options.poll_interval)
poll_interval=self.options.poll_interval, topurl=self.options.topurl)
self.assertEqual(rv, 0)
@mock.patch('sys.stdout', new_callable=six.StringIO)
@ -559,7 +560,7 @@ Task info: weburl/taskinfo?taskID=1
self.session.logout.assert_called()
watch_tasks_mock.assert_called_once_with(
self.session, [task_id], quiet=self.options.quiet,
poll_interval=self.options.poll_interval)
poll_interval=self.options.poll_interval, topurl=self.options.topurl)
self.assertEqual(rv, 0)
@mock.patch('sys.stdout', new_callable=six.StringIO)
@ -663,7 +664,7 @@ Task info: weburl/taskinfo?taskID=1
self.session.logout.assert_called_once()
watch_tasks_mock.assert_called_once_with(
self.session, [task_id], quiet=self.options.quiet,
poll_interval=self.options.poll_interval)
poll_interval=self.options.poll_interval, topurl=self.options.topurl)
self.assertEqual(rv, 0)
@mock.patch('sys.stdout', new_callable=six.StringIO)
@ -713,7 +714,7 @@ Task info: weburl/taskinfo?taskID=1
self.session.logout.assert_called_once()
watch_tasks_mock.assert_called_once_with(
self.session, [task_id], quiet=quiet,
poll_interval=self.options.poll_interval)
poll_interval=self.options.poll_interval, topurl=self.options.topurl)
self.assertEqual(rv, 0)
@mock.patch('sys.stdout', new_callable=six.StringIO)
@ -767,7 +768,7 @@ Task info: weburl/taskinfo?taskID=1
self.session.logout.assert_called_once()
watch_tasks_mock.assert_called_once_with(
self.session, [task_id], quiet=self.options.quiet,
poll_interval=self.options.poll_interval)
poll_interval=self.options.poll_interval, topurl=self.options.topurl)
self.assertEqual(rv, 0)
@mock.patch('sys.stdout', new_callable=six.StringIO)

View file

@ -82,7 +82,7 @@ Task info: weburl/taskinfo?taskID=1
self.session.logout.assert_called()
watch_tasks_mock.assert_called_once_with(
self.session, [task_id], quiet=self.options.quiet,
poll_interval=self.options.poll_interval)
poll_interval=self.options.poll_interval, topurl=self.options.topurl)
self.assertEqual(rv, 0)
@mock.patch('sys.stdout', new_callable=six.StringIO)
@ -528,7 +528,7 @@ Task info: weburl/taskinfo?taskID=1
self.session.logout.assert_called()
watch_tasks_mock.assert_called_once_with(
self.session, [task_id], quiet=self.options.quiet,
poll_interval=self.options.poll_interval)
poll_interval=self.options.poll_interval, topurl=self.options.topurl)
self.assertEqual(rv, 0)
@mock.patch('sys.stdout', new_callable=six.StringIO)
@ -591,7 +591,7 @@ Task info: weburl/taskinfo?taskID=1
self.session.logout.assert_called()
watch_tasks_mock.assert_called_once_with(
self.session, [task_id], quiet=self.options.quiet,
poll_interval=self.options.poll_interval)
poll_interval=self.options.poll_interval, topurl=self.options.topurl)
self.assertEqual(rv, 0)
@mock.patch('sys.stdout', new_callable=six.StringIO)

View file

@ -97,7 +97,7 @@ via 'koji edit-tag -x distrepo.cancel_others=True'
self.session,
[self.task_id],
quiet=self.options.quiet,
poll_interval=self.options.poll_interval)
poll_interval=self.options.poll_interval, topurl=self.options.topurl)
def test_handle_dist_repo_nowait(self):
arguments = [self.tag_name, self.fake_key, '--nowait']

View file

@ -139,7 +139,7 @@ class TestBuildImageOz(utils.CliTestCase):
self.watch_tasks.assert_called_with(
self.session, [task_id],
quiet=self.options.quiet,
poll_interval=self.options.poll_interval)
poll_interval=self.options.poll_interval, topurl=self.options.topurl)
self.session.buildImageOz.assert_called_once()
def test_build_image_oz_background(self):

View file

@ -85,7 +85,7 @@ Task info: weburl/taskinfo?taskID=1
self.session.logout.assert_called()
watch_tasks_mock.assert_called_once_with(
self.session, [task_id], quiet=self.options.quiet,
poll_interval=self.options.poll_interval)
poll_interval=self.options.poll_interval, topurl=self.options.topurl)
self.assertEqual(rv, 0)
@mock.patch('sys.stdout', new_callable=six.StringIO)
@ -438,7 +438,7 @@ Task info: weburl/taskinfo?taskID=1
self.session.logout.assert_called_once()
watch_tasks_mock.assert_called_once_with(
self.session, [task_id], quiet=build_opts.quiet,
poll_interval=self.options.poll_interval)
poll_interval=self.options.poll_interval, topurl=self.options.topurl)
self.assertEqual(rv, 0)
stdout.seek(0)
@ -608,7 +608,7 @@ Task info: weburl/taskinfo?taskID=1
self.session.logout.assert_called_once()
watch_tasks_mock.assert_called_once_with(
self.session, [task_id], quiet=build_opts['quiet'],
poll_interval=self.options.poll_interval)
poll_interval=self.options.poll_interval, topurl=self.options.topurl)
self.assertEqual(rv, 0)
stdout.seek(0)
@ -678,7 +678,7 @@ Task info: weburl/taskinfo?taskID=1
self.session.logout.assert_called()
watch_tasks_mock.assert_called_once_with(
self.session, [task_id], quiet=self.options.quiet,
poll_interval=self.options.poll_interval)
poll_interval=self.options.poll_interval, topurl=self.options.topurl)
self.assertEqual(rv, 0)
@mock.patch('sys.stdout', new_callable=six.StringIO)

View file

@ -139,7 +139,7 @@ class TestMavenChain(utils.CliTestCase):
running_in_bg_mock.assert_called()
watch_tasks_mock.assert_called_with(
session, [self.task_id], quiet=options.quiet,
poll_interval=options.poll_interval)
poll_interval=options.poll_interval, topurl=options.topurl)
@mock.patch('sys.stdout', new_callable=six.StringIO)
@mock.patch('sys.stderr', new_callable=six.StringIO)

View file

@ -67,7 +67,7 @@ class TestMoveBuild(utils.CliTestCase):
self.session,
tasks,
quiet=self.options.quiet,
poll_interval=self.options.poll_interval)
poll_interval=self.options.poll_interval, topurl=self.options.topurl)
def test_handle_move_build_nowait(self):
"""Test handle_move_build function with --nowait option"""

View file

@ -46,7 +46,7 @@ class TestRestartHosts(utils.CliTestCase):
session.restartHosts.assert_called_with()
session.logout.assert_called_once()
watch_tasks_mock.assert_called_with(
session, [self.task_id], quiet=None, poll_interval=3)
session, [self.task_id], quiet=None, poll_interval=3, topurl=options.topurl)
@mock.patch('sys.stderr', new_callable=six.StringIO)
@mock.patch('sys.stdout', new_callable=six.StringIO)
@ -148,7 +148,7 @@ class TestRestartHosts(utils.CliTestCase):
session.restartHosts.assert_called_with()
session.logout.assert_called_once()
watch_tasks_mock.assert_called_with(
session, [self.task_id], quiet=None, poll_interval=3)
session, [self.task_id], quiet=None, poll_interval=3, topurl=options.topurl)
@mock.patch('koji_cli.commands.watch_tasks')
@mock.patch('koji_cli.commands._running_in_bg')

View file

@ -83,7 +83,8 @@ Log Files:
session,
[new_task_id],
quiet=True,
poll_interval=options.poll_interval)
poll_interval=options.poll_interval,
topurl=options.topurl)
session.logout.assert_called_once()
session.resubmitTask.assert_called_with(self.task_id)
session.resubmitTask.assert_called_once()

View file

@ -56,7 +56,7 @@ class TestTagBuild(utils.CliTestCase):
self.session,
tasks,
quiet=self.options.quiet,
poll_interval=self.options.poll_interval)
poll_interval=self.options.poll_interval, topurl=self.options.topurl)
def test_handle_tag_build_quiet_mode(self):
"""Test handle_tag_build function with --nowait option"""

View file

@ -47,7 +47,7 @@ class TestWatchTasks(unittest.TestCase):
@mock.patch('sys.stdout', new_callable=six.StringIO)
def test_watch_tasks_no_tasklist(self, stdout):
returned = watch_tasks(self.session, [], poll_interval=0)
returned = watch_tasks(self.session, [], poll_interval=0, topurl=self.options.topurl)
actual = stdout.getvalue()
expected = ""
self.assertIsNone(returned)
@ -60,7 +60,8 @@ class TestWatchTasks(unittest.TestCase):
with open(cfile) as fp:
cdata = json.load(fp)
self.session.load_calls(cdata)
rv = watch_tasks(self.session, [1188], quiet=False, poll_interval=0)
rv = watch_tasks(self.session, [1188], quiet=False, poll_interval=0,
topurl=self.options.topurl)
self.assertEqual(rv, 0)
expected = (
'''Watching tasks (this may be safely interrupted)...
@ -80,7 +81,7 @@ class TestWatchTasks(unittest.TestCase):
with open(cfile) as fp:
cdata = json.load(fp)
self.session.load_calls(cdata)
rv = watch_tasks(self.session, [1208], quiet=False, poll_interval=5)
rv = watch_tasks(self.session, [1208], quiet=False, poll_interval=5, topurl=None)
self.assertEqual(rv, 1)
expected = ('''Watching tasks (this may be safely interrupted)...
1208 build (f24, /users/mikem/fake.git:master): free
@ -108,7 +109,8 @@ class TestWatchTasks(unittest.TestCase):
sleep.side_effect = [None] * 10 + [KeyboardInterrupt]
with self.assertRaises(KeyboardInterrupt):
# watch_tasks catches and re-raises it to display a message
watch_tasks(self.session, [1208], quiet=False, poll_interval=5)
watch_tasks(self.session, [1208], quiet=False, poll_interval=5,
topurl=self.options.topurl)
expected = ('''Watching tasks (this may be safely interrupted)...
1208 build (f24, /users/mikem/fake.git:master): free
1208 build (f24, /users/mikem/fake.git:master): free -> open (builder-01)
@ -137,7 +139,7 @@ Running Tasks:
with self.assertRaises(KeyboardInterrupt):
# watch_tasks catches and re-raises it to display a message
watch_tasks(self.session, [1208], quiet=False, poll_interval=5,
ki_handler=customized_handler)
ki_handler=customized_handler, topurl=self.options.topurl)
expected = ('''Watching tasks (this may be safely interrupted)...
1208 build (f24, /users/mikem/fake.git:master): free
1208 build (f24, /users/mikem/fake.git:master): free -> open (builder-01)

View file

@ -80,7 +80,8 @@ class TestWrapperRpm(utils.CliTestCase):
activate_session_mock.assert_called_with(session, options)
watch_tasks_mock.assert_called_with(
session, [self.task_id], quiet=options.quiet,
poll_interval=options.poll_interval)
poll_interval=options.poll_interval,
topurl=options.topurl)
@mock.patch('sys.stdout', new_callable=six.StringIO)
@mock.patch('sys.stderr', new_callable=six.StringIO)
@ -190,7 +191,8 @@ class TestWrapperRpm(utils.CliTestCase):
activate_session_mock.assert_called_with(session, options)
watch_tasks_mock.assert_called_with(
session, [self.task_id], quiet=options.quiet,
poll_interval=options.poll_interval)
poll_interval=options.poll_interval,
topurl=options.topurl)
@mock.patch('sys.stdout', new_callable=six.StringIO)
@mock.patch('sys.stderr', new_callable=six.StringIO)

View file

@ -122,7 +122,8 @@ class TestSaveFailedTree(unittest.TestCase):
self.session.logout.assert_called_once_with()
save_failed_tree.watch_tasks.assert_called_once_with(self.session, [spawned_id],
poll_interval=options.poll_interval,
quiet=options.quiet)
quiet=options.quiet,
topurl=options.topurl)
@mock.patch('sys.stdout', new_callable=six.StringIO)
def test_handle_save_failed_tree_errors(self, stdout):