Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions irrd/mirroring/nrtm4/nrtm4_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ def _run_client(self, force_load_delta_even_after_snapshot=False) -> bool:
has_loaded_snapshot = True
next_delta_version = self._find_next_version(unf, unf.snapshot.version)

if has_loaded_snapshot and not force_load_delta_even_after_snapshot: # pragma: no cover
deltas_deferred = has_loaded_snapshot and not force_load_delta_even_after_snapshot
if deltas_deferred:
logger.info(
f"{self.source}: Loaded snapshot at version {unf.snapshot.version},"
" deferring deltas to next run"
Expand All @@ -101,7 +102,7 @@ def _run_client(self, force_load_delta_even_after_snapshot=False) -> bool:

new_status = NRTM4ClientDatabaseStatus(
session_id=unf.session_id,
version=unf.version,
version=unf.snapshot.version if deltas_deferred else unf.version,
current_key=used_key,
next_key=unf.next_signing_key,
previous_file_hashes=self._validate_aggregate_previous_file_hashes_from_unf(unf),
Expand Down
35 changes: 35 additions & 0 deletions irrd/mirroring/nrtm4/tests/test_nrtm4_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,41 @@ def test_valid_from_snapshot(self, prepare_nrtm4_test, caplog):
assert "import of snapshot at version 3" in caplog.text
assert "Updating from deltas, starting from version 4" in caplog.text

def test_valid_from_snapshot_deferring_deltas(self, prepare_nrtm4_test, caplog):
# #1087
mock_dh = MockDatabaseHandler()
mock_dh.reset_mock()
mock_dh.query_responses[DatabaseStatusQuery] = iter(
[
{
"force_reload": True,
"nrtm4_client_session_id": UUID(MOCK_SESSION_ID),
"nrtm4_client_version": 2,
"nrtm4_client_current_key": None,
"nrtm4_client_next_key": None,
"nrtm4_client_previous_file_hashes": None,
}
]
)
NRTM4Client("TEST", mock_dh).run_client()
assert "import of snapshot at version 3" in caplog.text
assert "Loaded snapshot at version 3, deferring deltas to next run" in caplog.text
assert "Updating from deltas" not in caplog.text
assert "delete_rpsl_object" not in {call[0] for call in mock_dh.other_calls}
assert (
"record_nrtm4_client_status",
{
"source": "TEST",
"status": NRTM4ClientDatabaseStatus(
session_id=UUID(MOCK_SESSION_ID),
version=3,
current_key=MOCK_UNF_PUBLIC_KEY,
next_key=MOCK_UNF_PUBLIC_KEY_OTHER,
previous_file_hashes=VALID_PREVIOUS_FILE_HASHES,
),
},
) in mock_dh.other_calls

def test_valid_from_delta(self, prepare_nrtm4_test, caplog):
mock_dh = MockDatabaseHandler()
mock_dh.reset_mock()
Expand Down
Loading