diff --git a/tests/test_ctl.py b/tests/test_ctl.py index 5ba8a9553..0d8015c9e 100644 --- a/tests/test_ctl.py +++ b/tests/test_ctl.py @@ -466,6 +466,15 @@ def test_runjob(pub): call_command('runjob', '--domain=example.net', '--job-id=%s' % job.id) assert AfterJob.get(job.id).status == 'completed' assert AfterJob.get(job.id).l10n_month == 'octobre' + completion_time = AfterJob.get(job.id).completion_time + + # running again the job will skip it + call_command('runjob', '--domain=example.net', '--job-id=%s' % job.id) + assert AfterJob.get(job.id).completion_time == completion_time + + # --force-replay will force the job to run again + call_command('runjob', '--domain=example.net', '--job-id=%s' % job.id, '--force-replay') + assert AfterJob.get(job.id).completion_time != completion_time def test_ctl_print_help(capsys): diff --git a/wcs/ctl/management/commands/runjob.py b/wcs/ctl/management/commands/runjob.py index 934b16229..9bc8c12a4 100644 --- a/wcs/ctl/management/commands/runjob.py +++ b/wcs/ctl/management/commands/runjob.py @@ -27,6 +27,7 @@ class Command(TenantCommand): def add_arguments(self, parser): parser.add_argument('--domain', action='store', required=True) parser.add_argument('--job-id', action='store', required=True) + parser.add_argument('--force-replay', action='store_true', default=False) def handle(self, *args, **options): domain = options.pop('domain') @@ -35,4 +36,6 @@ class Command(TenantCommand): job = AfterJob.get(options['job_id']) except KeyError: raise CommandError('missing job') + if options.get('force_replay'): + job.completion_time = None job.run()