Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/svn/tests/test_loader.py
Show First 20 Lines • Show All 124 Lines • ▼ Show 20 Lines | def test_loader_svnrdump_no_such_revision(swh_storage, tmp_path, datadir): | ||||
It used to fail the ingestion on the second visit with a "No such revision x, | It used to fail the ingestion on the second visit with a "No such revision x, | ||||
160006" message. | 160006" message. | ||||
""" | """ | ||||
archive_dump = os.path.join(datadir, "penguinsdbtools2018.dump.gz") | archive_dump = os.path.join(datadir, "penguinsdbtools2018.dump.gz") | ||||
loading_path = str(tmp_path / "loading") | loading_path = str(tmp_path / "loading") | ||||
os.mkdir(loading_path) | |||||
# Prepare the dump as a local svn repository for test purposes | # Prepare the dump as a local svn repository for test purposes | ||||
temp_dir, repo_path = init_svn_repo_from_dump( | temp_dir, repo_path = init_svn_repo_from_dump( | ||||
archive_dump, root_dir=tmp_path, gzip=True | archive_dump, root_dir=tmp_path, gzip=True | ||||
) | ) | ||||
repo_url = f"file://{repo_path}" | repo_url = f"file://{repo_path}" | ||||
loader = SvnLoaderFromRemoteDump( | loader = SvnLoaderFromRemoteDump( | ||||
▲ Show 20 Lines • Show All 1,020 Lines • ▼ Show 20 Lines | for filename in ("foo", "bar", "baz"): | ||||
path=filename, | path=filename, | ||||
data=f"{filename}\n".encode(), | data=f"{filename}\n".encode(), | ||||
) | ) | ||||
], | ], | ||||
) | ) | ||||
loader = SvnLoader(swh_storage, repo_url, destination_path=tmp_path) | loader = SvnLoader(swh_storage, repo_url, destination_path=tmp_path) | ||||
assert loader.load() == {"status": "eventful"} | # post loading will detect an issue and make a partial visit with a snapshot | ||||
assert loader.visit_status() == "full" | assert loader.load() == {"status": "failed"} | ||||
assert_last_visit_matches( | |||||
loader.storage, repo_url, status="partial", type="svn", | |||||
) | |||||
assert get_stats(loader.storage) == { | assert get_stats(loader.storage) == { | ||||
"content": 2, | "content": 2, | ||||
"directory": 2, | "directory": 2, | ||||
"origin": 1, | "origin": 1, | ||||
"origin_visit": 1, | "origin_visit": 1, | ||||
"release": 0, | "release": 0, | ||||
"revision": 2, | "revision": 2, | ||||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | ): | ||||
# the repository filesystem it reconstructed does not differ from a subversion | # the repository filesystem it reconstructed does not differ from a subversion | ||||
# export of that revision | # export of that revision | ||||
loader = SvnLoader( | loader = SvnLoader( | ||||
swh_storage, repo_url, destination_path=tmp_path, check_revision=1 | swh_storage, repo_url, destination_path=tmp_path, check_revision=1 | ||||
) | ) | ||||
assert loader.load() == {"status": "eventful"} | assert loader.load() == {"status": "eventful"} | ||||
assert loader.visit_status() == "full" | assert loader.visit_status() == "full" | ||||
def test_loader_last_revision_divergence(swh_storage, datadir, tmp_path): | |||||
archive_name = "pkg-gourmet" | |||||
archive_path = os.path.join(datadir, f"{archive_name}.tgz") | |||||
repo_url = prepare_repository_from_archive(archive_path, archive_name, tmp_path) | |||||
class SvnLoaderRevisionDivergence(SvnLoader): | |||||
def _check_revision_divergence(self, count, rev, dir_id): | |||||
raise ValueError("revision divergence detected") | |||||
loader = SvnLoaderRevisionDivergence( | |||||
swh_storage, repo_url, destination_path=tmp_path | |||||
) | |||||
assert loader.load() == {"status": "failed"} | |||||
assert_last_visit_matches( | |||||
loader.storage, | |||||
repo_url, | |||||
status="partial", | |||||
type="svn", | |||||
snapshot=GOURMET_SNAPSHOT.id, | |||||
) |