Skip to content
Snippets Groups Projects
Commit a20e6735 authored by David Douard's avatar David Douard
Browse files

journal_checker: Check the 'check_references' flag is not set

parent 566db2ac
No related branches found
No related tags found
No related merge requests found
......@@ -49,6 +49,12 @@ class JournalChecker:
self.db = db
self.config_id = config_id
if self.config.check_references:
raise ValueError(
"The journal checcker cannot check for references, please set "
"the 'check_references' to False in the config entry %s.",
self.config_id,
)
self.journal_client_config = journal.copy()
if "object_types" in self.journal_client_config:
raise ValueError(
......
......@@ -67,7 +67,11 @@ def test_no_corruption(
for object_type in ("directory", "revision", "release", "snapshot"):
journal_cfg["group_id"] = gid + object_type
config_id = scrubber_db.config_add(
f"cfg_{object_type}", datastore, getattr(ObjectType, object_type.upper()), 1
name=f"cfg_{object_type}",
datastore=datastore,
object_type=getattr(ObjectType, object_type.upper()),
nb_partitions=1,
check_references=False,
)
jc = JournalChecker(
db=scrubber_db,
......@@ -90,7 +94,11 @@ def test_corrupt_snapshot(
corrupt_idx,
):
config_id = scrubber_db.config_add(
"cfg_snapshot", datastore, ObjectType.SNAPSHOT, 1
name="cfg_snapshot",
datastore=datastore,
object_type=ObjectType.SNAPSHOT,
nb_partitions=1,
check_references=False,
)
snapshots = list(swh_model_data.SNAPSHOTS)
snapshots[corrupt_idx] = attr.evolve(snapshots[corrupt_idx], id=b"\x00" * 20)
......@@ -131,7 +139,11 @@ def test_corrupt_snapshots(
datastore,
):
config_id = scrubber_db.config_add(
"cfg_snapshot", datastore, ObjectType.SNAPSHOT, 1
name="cfg_snapshot",
datastore=datastore,
object_type=ObjectType.SNAPSHOT,
nb_partitions=1,
check_references=False,
)
snapshots = list(swh_model_data.SNAPSHOTS)
for i in (0, 1):
......@@ -155,3 +167,28 @@ def test_corrupt_snapshots(
"swh:1:snp:0101010101010101010101010101010101010101",
]
}
def test_check_references_raises(
scrubber_db,
kafka_server,
kafka_prefix,
kafka_consumer_group,
datastore,
):
config_id = scrubber_db.config_add(
name="cfg_snapshot",
datastore=datastore,
object_type=ObjectType.SNAPSHOT,
nb_partitions=1,
check_references=True,
)
journal_config = journal_client_config(
kafka_server, kafka_prefix, kafka_consumer_group
)
with pytest.raises(ValueError):
JournalChecker(
db=scrubber_db,
config_id=config_id,
journal=journal_config,
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment