Page MenuHomeSoftware Heritage

Jenkins > .tox.py3.lib.python3.7.site-packages.swh.scheduler.tests.test_cli_origin::test_send_to_celery[extra_cmd_args0]
Failed

TEST RESULT

Run At
Dec 6 2022, 4:24 PM
Details
mocker = <pytest_mock.plugin.MockerFixture object at 0x7fc385a06be0> swh_scheduler = <swh.scheduler.backend.SchedulerBackend object at 0x7fc385a06588> swh_scheduler_celery_app = <Celery celery.tests at 0x7fc385c07748> listed_origins_by_type = {'test-git': [ListedOrigin(lister_id=UUID('aa27422a-854c-4cf7-a9e6-9db97a65d69f'), url='https://test-git.example.com/0...etime(2020, 6, 15, 16, 0, 0, 1005, tzinfo=datetime.timezone.utc), enabled=True, first_seen=None, last_seen=None), ...]} extra_cmd_args = [] @pytest.mark.parametrize( "extra_cmd_args", [[], ["--lister-name", "github", "--lister-instance-name", "github"]], ) def test_send_to_celery( mocker, swh_scheduler, swh_scheduler_celery_app, listed_origins_by_type, extra_cmd_args, ): for task_type in TASK_TYPES.values(): swh_scheduler.create_task_type(task_type) visit_type = next(iter(listed_origins_by_type)) for origins in listed_origins_by_type.values(): swh_scheduler.record_listed_origins(origins) get_queue_length = mocker.patch( "swh.scheduler.celery_backend.config.get_queue_length" ) get_queue_length.return_value = None send_task = mocker.patch.object(swh_scheduler_celery_app, "send_task") send_task.return_value = None cmd_args = ["send-to-celery", visit_type] + extra_cmd_args > result = invoke(swh_scheduler, args=tuple(cmd_args)) .tox/py3/lib/python3.7/site-packages/swh/scheduler/tests/test_cli_origin.py:146: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ .tox/py3/lib/python3.7/site-packages/swh/scheduler/tests/test_cli_origin.py:17: in invoke scheduler, args=["origin", *args], catch_exceptions=catch_exceptions .tox/py3/lib/python3.7/site-packages/swh/scheduler/tests/test_cli.py:45: in invoke raise result.exception .tox/py3/lib/python3.7/site-packages/click/testing.py:408: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) .tox/py3/lib/python3.7/site-packages/click/core.py:1055: in main rv = self.invoke(ctx) .tox/py3/lib/python3.7/site-packages/click/core.py:1657: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) .tox/py3/lib/python3.7/site-packages/click/core.py:1657: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) .tox/py3/lib/python3.7/site-packages/click/core.py:1404: in invoke return ctx.invoke(self.callback, **ctx.params) .tox/py3/lib/python3.7/site-packages/click/core.py:760: in invoke return __callback(*args, **kwargs) .tox/py3/lib/python3.7/site-packages/click/decorators.py:26: in new_func return f(get_current_context(), *args, **kwargs) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ctx = <click.core.Context object at 0x7fc38571c400> policy = 'oldest_scheduled_first', queue = None, tablesample = None type = 'test-git', enabled = True, lister_name = None lister_instance_name = None @origin.command("send-to-celery") @click.option( "--policy", "-p", default="oldest_scheduled_first", help="Scheduling policy" ) @click.option( "--queue", "-q", help="Target celery queue", type=str, ) @click.option( "--tablesample", help="Table sampling percentage", type=float, ) @click.option( "--only-enabled/--only-disabled", "enabled", is_flag=True, default=True, help="""Determine whether we want to scheduled enabled or disabled origins. As default, we want to reasonably deal with enabled origins. For some edge case though, we might want the disabled ones.""", ) @click.option( "--lister-name", default=None, help="Limit origins to those listed from lister with provided name", ) @click.option( "--lister-instance-name", default=None, help="Limit origins to those listed from lister with instance name", ) @click.argument("type", type=str) @click.pass_context def send_to_celery( ctx, policy: str, queue: Optional[str], tablesample: Optional[float], type: str, enabled: bool, lister_name: Optional[str] = None, lister_instance_name: Optional[str] = None, ): """Send the next origin visits of the TYPE loader to celery, filling the queue.""" from kombu.utils.uuid import uuid from swh.scheduler.celery_backend.config import app, get_available_slots scheduler = ctx.obj["scheduler"] task_type = scheduler.get_task_type(f"load-{type}") task_name = task_type["backend_name"] queue_name = queue or task_name num_tasks = get_available_slots(app, queue_name, task_type["max_queue_length"]) click.echo(f"{num_tasks} slots available in celery queue") if lister_name and lister_instance_name: lister = scheduler.get_lister(lister_name, lister_instance_name) if lister: lister_uuid = lister.id origins = scheduler.grab_next_visits( type, num_tasks, policy=policy, tablesample=tablesample, enabled=enabled, > lister_uuid=lister_uuid, ) E UnboundLocalError: local variable 'lister_uuid' referenced before assignment .tox/py3/lib/python3.7/site-packages/swh/scheduler/cli/origin.py:222: UnboundLocalError