diff --git a/swh/scheduler/tests/test_recurrent_visits.py b/swh/scheduler/tests/test_recurrent_visits.py --- a/swh/scheduler/tests/test_recurrent_visits.py +++ b/swh/scheduler/tests/test_recurrent_visits.py @@ -14,6 +14,7 @@ from .test_cli import invoke TEST_MAX_QUEUE = 10000 +MODULE_NAME = "swh.scheduler.celery_backend.recurrent_visits" def _compute_backend_name(visit_type: str) -> str: @@ -56,7 +57,7 @@ """When passing no visit types, the recurrent visit scheduler should start.""" spawn_visit_scheduler_thread = mocker.patch( - "swh.scheduler.celery_backend.recurrent_visits.spawn_visit_scheduler_thread" + f"{MODULE_NAME}.spawn_visit_scheduler_thread" ) spawn_visit_scheduler_thread.side_effect = SystemExit @@ -72,14 +73,12 @@ ): """Orchestrator schedules known tasks.""" - caplog.set_level(logging.INFO, "swh.scheduler.celery_backend.orchestrator") + caplog.set_level(logging.DEBUG, MODULE_NAME) nb_origins = 1000 mock_celery_app = MagicMock() - mock_available_slots = mocker.patch( - "swh.scheduler.celery_backend.orchestrator.get_available_slots" - ) + mock_available_slots = mocker.patch(f"{MODULE_NAME}.get_available_slots") mock_available_slots.return_value = nb_origins # Slots available in queue # Make sure the scheduler is properly configured in terms of visit/task types @@ -102,15 +101,15 @@ # we'll limit the orchestrator to the origins' type we know task_types.append(task_type) - send_visits_for_visit_type( - swh_scheduler, mock_celery_app, "git", all_task_types["load-git"] - ) + for visit_type in ["git", "svn"]: + task_type = f"load-{visit_type}" + send_visits_for_visit_type( + swh_scheduler, mock_celery_app, visit_type, all_task_types[task_type] + ) assert mock_available_slots.called, "The available slots functions should be called" - records = [ - record.message for record in caplog.records if record.levelname == "INFO" - ] + records = [record.message for record in caplog.records] # Mapping over the dict ratio/policies entries can change overall order so let's # check the set of records @@ -118,7 +117,10 @@ for task_type in task_types: visit_type = task_type["visit_type"] queue_name = task_type["backend_name"] - msg = f"{visit_type}: {nb_origins} slots available in {queue_name}" + msg = ( + f"{nb_origins} available slots for visit type {visit_type} " + f"in queue {queue_name}" + ) expected_records.add(msg) for expected_record in expected_records: