swh_scheduler = <swh.scheduler.backend.SchedulerBackend object at 0x7f57a4665748>
swh_scheduler_celery_app = <Celery celery.tests at 0x7f57ac354e80>
storage = <swh.storage.postgresql.storage.Storage object at 0x7f57a43be2b0>
caplog = <_pytest.logging.LogCaptureFixture object at 0x7f57a4579940>
listed_origins_by_type = {'git': [ListedOrigin(lister_id=UUID('19cae058-420a-4bf5-a1a1-23c00b517120'), url='https://git.example.com/0000', visi...etime(2020, 6, 15, 16, 0, 0, 1005, tzinfo=datetime.timezone.utc), enabled=True, first_seen=None, last_seen=None), ...]}
mocker = <pytest_mock.plugin.MockerFixture object at 0x7f57ac10c048>
def test_orchestrator_scheduling(
swh_scheduler,
swh_scheduler_celery_app,
storage,
caplog,
listed_origins_by_type,
mocker,
):
"""Orchestrator schedules known tasks."""
nb_total_origins = 1000
mock = mocker.patch("swh.scheduler.celery_backend.orchestrator.get_available_slots")
mock.return_value = nb_total_origins # Slots available in queue
nb_total_origins = 50
origins = _fill_storage_with_origins(storage, nb_total_origins)
# Make sure the schedule is properly configured in terms of visit/task types
all_task_types = {
task_type_d["type"]: task_type_d
for task_type_d in swh_scheduler.get_task_types()
}
visit_types = list(listed_origins_by_type.keys())
assert len(visit_types) > 0
task_types = []
origins = []
for visit_type, _origins in listed_origins_by_type.items():
origins.extend(swh_scheduler.record_listed_origins(_origins))
task_type_name = f"load-{visit_type}"
assert task_type_name in all_task_types.keys()
task_types.append(all_task_types[task_type_name])
orchestrate(swh_scheduler, swh_scheduler_celery_app, task_types)
records = [
record.message for record in caplog.records if record.levelname == "INFO"
]
# Mapping over the dict ratio/policies entries can change overall order so let's
# check the set of records
> assert set(records) == set(
[
"git: 1000 slots available in queue swh.loader.git.tasks",
"git: 490.0 tasks to send with policy already_visited_order_by_lag",
"git: 490.0 tasks to send with policy never_visited_oldest_update_first",
"git: 20.0 tasks to send with policy origins_without_last_update",
"git: 490 sent visits to queue swh.loader.git.tasks",
"svn: 1000 slots available in queue swh.loader.svn.tasks",
"svn: 490.0 tasks to send with policy already_visited_order_by_lag",
"svn: 490.0 tasks to send with policy never_visited_oldest_update_first",
"svn: 20.0 tasks to send with policy origins_without_last_update",
"svn: 490 sent visits to queue swh.loader.svn.tasks",
]
)
E AssertionError: assert {'git: 1000 s...er.svn.tasks'} == {'git: 1000 s...n.tasks', ...}
E Extra items in the right set:
E 'svn: 490 sent visits to queue swh.loader.svn.tasks'
E 'svn: 490.0 tasks to send with policy never_visited_oldest_update_first'
E 'git: 490.0 tasks to send with policy never_visited_oldest_update_first'
E 'svn: 20.0 tasks to send with policy origins_without_last_update'
E 'svn: 490.0 tasks to send with policy already_visited_order_by_lag'
E 'git: 490.0 tasks to send with policy already_visited_order_by_lag'...
E
E ...Full output truncated (16 lines hidden), use '-vv' to show
.tox/py3/lib/python3.7/site-packages/swh/scheduler/tests/test_orchestrator.py:106: AssertionError
TEST RESULT
TEST RESULT
- Run At
- Oct 21 2021, 11:38 AM