diff --git a/swh/loader/core/loader.py b/swh/loader/core/loader.py --- a/swh/loader/core/loader.py +++ b/swh/loader/core/loader.py @@ -243,9 +243,7 @@ result to the scheduler, allowing tuning of the task recurrence mechanism. """ - return { - "status": "eventful", - } + return self._return_status("eventful") def post_load(self, success: bool = True) -> None: """Permit the loader to do some additional actions according to status @@ -277,6 +275,14 @@ """ pass + def _return_status(self, status: str) -> Dict[str, Any]: + assert self.origin is not None and self.origin.url is not None + return { + "origin": self.origin.url, + "visit_type": self.visit_type, + "status": status, + } + def load(self, *args, **kwargs) -> Dict[str, str]: r"""Loading logic for the loader to follow: @@ -309,6 +315,7 @@ try: self.prepare(*args, **kwargs) + self.log.info("'%s' load origin '%s'", self.visit_type, self.origin.url) while True: more_data_to_fetch = self.fetch_data() @@ -340,7 +347,7 @@ ) self.storage.origin_visit_status_add([visit_status]) self.post_load(success=False) - return {"status": "failed"} + return self._return_status("failed") finally: self.flush() self.cleanup() diff --git a/swh/loader/core/tests/test_loader.py b/swh/loader/core/tests/test_loader.py --- a/swh/loader/core/tests/test_loader.py +++ b/swh/loader/core/tests/test_loader.py @@ -108,13 +108,21 @@ loader = DummyBaseLoader() result = loader.load() - assert result == {"status": "eventful"} + assert result == { + "origin": loader.origin.url, + "visit_type": loader.visit_type, + "status": "eventful", + } def test_dvcs_loader(): loader = DummyDVCSLoader() result = loader.load() - assert result == {"status": "eventful"} + assert result == { + "origin": loader.origin.url, + "visit_type": loader.visit_type, + "status": "eventful", + } def test_loader_logger_default_name(): @@ -186,7 +194,11 @@ loader = DummyDVCSLoaderExc(logging_class=logger_name) result = loader.load() - assert result == {"status": "failed"} + assert result == { + "origin": loader.origin.url, + "visit_type": loader.visit_type, + "status": "failed", + } _check_load_failure(caplog, loader, RuntimeError, "Failed to get contents!") @@ -217,6 +229,10 @@ loader = DummyDVCSLoaderStorageExc(logging_class=logger_name) result = loader.load() - assert result == {"status": "failed"} + assert result == { + "origin": loader.origin.url, + "visit_type": loader.visit_type, + "status": "failed", + } _check_load_failure(caplog, loader, RuntimeError, "Failed to add snapshot!")