Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/svn/tests/test_loader.py
Show First 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | |||||
class SvnLoaderTest(SvnLoader): | class SvnLoaderTest(SvnLoader): | ||||
"""An SVNLoader with no persistence. | """An SVNLoader with no persistence. | ||||
Context: | Context: | ||||
Load a new svn repository using the swh policy (so no update). | Load a new svn repository using the swh policy (so no update). | ||||
""" | """ | ||||
def __init__(self, last_snp_rev={}): | def __init__(self, url, last_snp_rev={}, destination_path=None, | ||||
super().__init__() | start_from_scratch=False, swh_revision=None): | ||||
super().__init__(url, destination_path=destination_path, | |||||
start_from_scratch=start_from_scratch, | |||||
swh_revision=swh_revision) | |||||
self.origin = { | self.origin = { | ||||
'id': 1, | 'id': 1, | ||||
'url': '/dev/null', | 'url': url, | ||||
'type': 'svn', | |||||
} | } | ||||
self.visit = { | self.visit = { | ||||
'origin': 1, | 'origin': 1, | ||||
'visit': 1, | 'visit': 1, | ||||
} | } | ||||
self.last_snp_rev = last_snp_rev | self.last_snp_rev = last_snp_rev | ||||
def parse_config_file(self, *args, **kwargs): | def parse_config_file(self, *args, **kwargs): | ||||
Show All 13 Lines | |||||
class BaseSvnLoaderTest(BaseLoaderTest): | class BaseSvnLoaderTest(BaseLoaderTest): | ||||
"""Base test loader class. | """Base test loader class. | ||||
In its setup, it's uncompressing a local svn mirror to /tmp. | In its setup, it's uncompressing a local svn mirror to /tmp. | ||||
""" | """ | ||||
def setUp(self, archive_name='pkg-gourmet.tgz', filename='pkg-gourmet', | def setUp(self, archive_name='pkg-gourmet.tgz', filename='pkg-gourmet', | ||||
loader=None): | loader=None, snapshot=None, type='default', | ||||
start_from_scratch=False, swh_revision=None): | |||||
super().setUp(archive_name=archive_name, filename=filename, | super().setUp(archive_name=archive_name, filename=filename, | ||||
prefix_tmp_folder_name='swh.loader.svn.', | prefix_tmp_folder_name='swh.loader.svn.', | ||||
start_path=os.path.dirname(__file__)) | start_path=os.path.dirname(__file__)) | ||||
self.svn_mirror_url = self.repo_url | self.svn_mirror_url = self.repo_url | ||||
self.loader = loader or SvnLoaderTest() | if type == 'default': | ||||
loader_test_class = SvnLoaderTest | |||||
else: | |||||
loader_test_class = SvnLoaderTestFromRemoteDump | |||||
if loader: | |||||
self.loader = loader | |||||
elif snapshot: | |||||
self.loader = loader_test_class( | |||||
self.svn_mirror_url, | |||||
destination_path=self.destination_path, | |||||
start_from_scratch=start_from_scratch, | |||||
swh_revision=swh_revision, | |||||
last_snp_rev=snapshot, | |||||
) | |||||
else: | |||||
self.loader = loader_test_class( | |||||
self.svn_mirror_url, | |||||
destination_path=self.destination_path, | |||||
start_from_scratch=start_from_scratch, | |||||
swh_revision=swh_revision | |||||
) | |||||
self.storage = self.loader.storage | self.storage = self.loader.storage | ||||
class SvnLoaderTest1(BaseSvnLoaderTest): | class SvnLoaderTest1(BaseSvnLoaderTest): | ||||
"""Load an unknown svn repository results in new data. | """Load an unknown svn repository results in new data. | ||||
""" | """ | ||||
def test_load(self): | def test_load(self): | ||||
"""Load a new repository results in new swh object and snapshot | """Load a new repository results in new swh object and snapshot | ||||
""" | """ | ||||
# when | # when | ||||
self.loader.load( | self.loader.load() | ||||
svn_url=self.svn_mirror_url, | |||||
destination_path=self.destination_path) | |||||
# then | # then | ||||
self.assertCountRevisions(6) | self.assertCountRevisions(6) | ||||
self.assertCountReleases(0) | self.assertCountReleases(0) | ||||
last_revision = '4876cb10aec6f708f7466dddf547567b65f6c39c' | last_revision = '4876cb10aec6f708f7466dddf547567b65f6c39c' | ||||
# cf. test_loader.org for explaining from where those hashes | # cf. test_loader.org for explaining from where those hashes | ||||
# come from | # come from | ||||
Show All 40 Lines | |||||
class SvnLoaderTest2(BaseSvnLoaderTest): | class SvnLoaderTest2(BaseSvnLoaderTest): | ||||
"""Load a visited repository with no new change results in no data | """Load a visited repository with no new change results in no data | ||||
change. | change. | ||||
""" | """ | ||||
def setUp(self): | def setUp(self): | ||||
super().setUp(loader=SvnLoaderTest(last_snp_rev=_LAST_SNP_REV)) | super().setUp(snapshot=_LAST_SNP_REV) | ||||
def test_load(self): | def test_load(self): | ||||
"""Load a repository without new changes results in same snapshot | """Load a repository without new changes results in same snapshot | ||||
""" | """ | ||||
# when | # when | ||||
self.loader.load( | self.loader.load() | ||||
svn_url=self.svn_mirror_url, | |||||
destination_path=self.destination_path) | |||||
# then | # then | ||||
self.assertCountContents(0) | self.assertCountContents(0) | ||||
self.assertCountDirectories(0) | self.assertCountDirectories(0) | ||||
self.assertCountRevisions(0) | self.assertCountRevisions(0) | ||||
self.assertCountReleases(0) | self.assertCountReleases(0) | ||||
self.assertCountSnapshots(1) | self.assertCountSnapshots(1) | ||||
Show All 14 Lines | class SvnLoaderTest3(BaseSvnLoaderTest): | ||||
def setUp(self): | def setUp(self): | ||||
last_snp_rev = copy.deepcopy(_LAST_SNP_REV) | last_snp_rev = copy.deepcopy(_LAST_SNP_REV) | ||||
last_snp_rev['snapshot'] = None | last_snp_rev['snapshot'] = None | ||||
# Changed the revision id's hash to simulate history altered | # Changed the revision id's hash to simulate history altered | ||||
last_snp_rev['revision']['id'] = \ | last_snp_rev['revision']['id'] = \ | ||||
hashutil.hash_to_bytes('badbadbadbadf708f7466dddf547567b65f6c39d') | hashutil.hash_to_bytes('badbadbadbadf708f7466dddf547567b65f6c39d') | ||||
# the svn repository pkg-gourmet has been updated with changes | # the svn repository pkg-gourmet has been updated with changes | ||||
super().setUp(archive_name='pkg-gourmet-with-updates.tgz', | super().setUp(archive_name='pkg-gourmet-with-updates.tgz', | ||||
loader=SvnLoaderTest(last_snp_rev=last_snp_rev)) | snapshot=last_snp_rev) | ||||
def test_load(self): | def test_load(self): | ||||
"""Load known repository with history altered should do nothing | """Load known repository with history altered should do nothing | ||||
""" | """ | ||||
# when | # when | ||||
self.loader.load(svn_url=self.svn_mirror_url, | self.loader.load() | ||||
destination_path=self.destination_path) | |||||
# then | # then | ||||
# we got the previous run's last revision (rev 6) | # we got the previous run's last revision (rev 6) | ||||
# so 2 news + 1 old | # so 2 news + 1 old | ||||
self.assertCountContents(0) | self.assertCountContents(0) | ||||
self.assertCountDirectories(0) | self.assertCountDirectories(0) | ||||
self.assertCountRevisions(0) | self.assertCountRevisions(0) | ||||
self.assertCountReleases(0) | self.assertCountReleases(0) | ||||
self.assertCountSnapshots(0) | self.assertCountSnapshots(0) | ||||
# FIXME: Check the snapshot's state | # FIXME: Check the snapshot's state | ||||
# self.assertEqual(self.loader.all_snapshots[0], {}) | # self.assertEqual(self.loader.all_snapshots[0], {}) | ||||
self.assertEqual(self.loader.load_status(), {'status': 'uneventful'}) | self.assertEqual(self.loader.load_status(), {'status': 'uneventful'}) | ||||
self.assertEqual(self.loader.visit_status(), 'partial') | self.assertEqual(self.loader.visit_status(), 'partial') | ||||
class SvnLoaderTest4(BaseSvnLoaderTest): | class SvnLoaderTest4(BaseSvnLoaderTest): | ||||
"""In this scenario, the repository has been updated with new changes. | """In this scenario, the repository has been updated with new changes. | ||||
The loading visit should result in new objects stored and 1 new | The loading visit should result in new objects stored and 1 new | ||||
snapshot. | snapshot. | ||||
""" | """ | ||||
def setUp(self): | def setUp(self): | ||||
# the svn repository pkg-gourmet has been updated with changes | # the svn repository pkg-gourmet has been updated with changes | ||||
super().setUp(archive_name='pkg-gourmet-with-updates.tgz', | super().setUp(archive_name='pkg-gourmet-with-updates.tgz', | ||||
loader=SvnLoaderTest(last_snp_rev=_LAST_SNP_REV)) | snapshot=_LAST_SNP_REV) | ||||
def test_process_repository(self): | def test_process_repository(self): | ||||
"""Process updated repository should yield new objects | """Process updated repository should yield new objects | ||||
""" | """ | ||||
# when | # when | ||||
self.loader.load(svn_url=self.svn_mirror_url, | self.loader.load() | ||||
destination_path=self.destination_path) | |||||
# then | # then | ||||
# we got the previous run's last revision (rev 6) | # we got the previous run's last revision (rev 6) | ||||
# so 2 new | # so 2 new | ||||
self.assertCountRevisions(5) | self.assertCountRevisions(5) | ||||
self.assertCountReleases(0) | self.assertCountReleases(0) | ||||
last_revision = '171dc35522bfd17dda4e90a542a0377fb2fc707a' | last_revision = '171dc35522bfd17dda4e90a542a0377fb2fc707a' | ||||
Show All 22 Lines | """Context: | ||||
- Repository already injected with successful data | - Repository already injected with successful data | ||||
- New visit from scratch done with successful load | - New visit from scratch done with successful load | ||||
""" | """ | ||||
def setUp(self): | def setUp(self): | ||||
# the svn repository pkg-gourmet has been updated with changes | # the svn repository pkg-gourmet has been updated with changes | ||||
super().setUp(archive_name='pkg-gourmet-with-updates.tgz', | super().setUp(archive_name='pkg-gourmet-with-updates.tgz', | ||||
loader=SvnLoaderTest(last_snp_rev=_LAST_SNP_REV)) | snapshot=_LAST_SNP_REV, | ||||
start_from_scratch=True) | |||||
def test_load(self): | def test_load(self): | ||||
"""Load an existing repository from scratch yields same swh objects | """Load an existing repository from scratch yields same swh objects | ||||
""" | """ | ||||
# when | # when | ||||
self.loader.load(svn_url=self.svn_mirror_url, | self.loader.load() | ||||
destination_path=self.destination_path, | |||||
start_from_scratch=True) | |||||
# then | # then | ||||
# we got the previous run's last revision (rev 6) | # we got the previous run's last revision (rev 6) | ||||
# but we do not inspect that as we start from from scratch so | # but we do not inspect that as we start from from scratch so | ||||
# we should have all revisions so 11 | # we should have all revisions so 11 | ||||
self.assertCountRevisions(11) | self.assertCountRevisions(11) | ||||
self.assertCountReleases(0) | self.assertCountReleases(0) | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | def setUp(self): | ||||
'extra_headers': [ | 'extra_headers': [ | ||||
['svn_repo_uuid', '3187e211-bb14-4c82-9596-0b59d67cd7f4'], # noqa | ['svn_repo_uuid', '3187e211-bb14-4c82-9596-0b59d67cd7f4'], # noqa | ||||
['svn_revision', '6'] | ['svn_revision', '6'] | ||||
] | ] | ||||
} | } | ||||
} | } | ||||
} | } | ||||
super().setUp(archive_name='pkg-gourmet-with-updates.tgz', | super().setUp(archive_name='pkg-gourmet-with-updates.tgz', | ||||
loader=SvnLoaderTest(last_snp_rev=last_snp_rev)) | snapshot=last_snp_rev) | ||||
def test_load(self): | def test_load(self): | ||||
"""Load from partial previous visit result in new changes | """Load from partial previous visit result in new changes | ||||
""" | """ | ||||
# when | # when | ||||
self.loader.load( | self.loader.load() | ||||
svn_url=self.svn_mirror_url, | |||||
destination_path=self.destination_path) | |||||
# then | # then | ||||
# we got the previous run's last revision (rev 6) | # we got the previous run's last revision (rev 6) | ||||
# so 2 new | # so 2 new | ||||
self.assertCountRevisions(5) | self.assertCountRevisions(5) | ||||
self.assertCountReleases(0) | self.assertCountReleases(0) | ||||
last_revision = '171dc35522bfd17dda4e90a542a0377fb2fc707a' | last_revision = '171dc35522bfd17dda4e90a542a0377fb2fc707a' | ||||
Show All 19 Lines | |||||
class SvnLoaderTest7(BaseSvnLoaderTest): | class SvnLoaderTest7(BaseSvnLoaderTest): | ||||
"""Context: | """Context: | ||||
- repository already visited with load successful | - repository already visited with load successful | ||||
- Changes on existing repository | - Changes on existing repository | ||||
- New Visit done with successful new data | - New Visit done with successful new data | ||||
""" | """ | ||||
def setUp(self): | def setUp(self): | ||||
super().setUp(archive_name='pkg-gourmet-with-updates.tgz', | |||||
loader=SvnLoaderTest(last_snp_rev=_LAST_SNP_REV)) | |||||
def test_load(self): | |||||
"""Load known and partial repository should start from last visit | |||||
""" | |||||
previous_unfinished_revision = { | previous_unfinished_revision = { | ||||
'id': hashutil.hash_to_bytes( | 'id': hashutil.hash_to_bytes( | ||||
'a3a577948fdbda9d1061913b77a1588695eadb41'), | 'a3a577948fdbda9d1061913b77a1588695eadb41'), | ||||
'parents': [hashutil.hash_to_bytes( | 'parents': [hashutil.hash_to_bytes( | ||||
'3f51abf3b3d466571be0855dfa67e094f9ceff1b')], | '3f51abf3b3d466571be0855dfa67e094f9ceff1b')], | ||||
'directory': hashutil.hash_to_bytes( | 'directory': hashutil.hash_to_bytes( | ||||
'7dc52cc04c3b8bd7c085900d60c159f7b846f866'), | '7dc52cc04c3b8bd7c085900d60c159f7b846f866'), | ||||
'target_type': 'revision', | 'target_type': 'revision', | ||||
'metadata': { | 'metadata': { | ||||
'extra_headers': [ | 'extra_headers': [ | ||||
['svn_repo_uuid', '3187e211-bb14-4c82-9596-0b59d67cd7f4'], | ['svn_repo_uuid', '3187e211-bb14-4c82-9596-0b59d67cd7f4'], | ||||
['svn_revision', '5'] | ['svn_revision', '5'] | ||||
] | ] | ||||
} | } | ||||
} | } | ||||
super().setUp(archive_name='pkg-gourmet-with-updates.tgz', | |||||
snapshot=_LAST_SNP_REV, | |||||
swh_revision=previous_unfinished_revision) | |||||
def test_load(self): | |||||
"""Load known and partial repository should start from last visit | |||||
""" | |||||
# when | # when | ||||
self.loader.load( | self.loader.load() | ||||
svn_url=self.svn_mirror_url, | |||||
destination_path=self.destination_path, | |||||
swh_revision=previous_unfinished_revision) | |||||
# then | # then | ||||
# we got the previous run's last revision (rev 6) | # we got the previous run's last revision (rev 6) | ||||
# so 2 new | # so 2 new | ||||
self.assertCountRevisions(5) | self.assertCountRevisions(5) | ||||
self.assertCountReleases(0) | self.assertCountReleases(0) | ||||
last_revision = '171dc35522bfd17dda4e90a542a0377fb2fc707a' | last_revision = '171dc35522bfd17dda4e90a542a0377fb2fc707a' | ||||
Show All 39 Lines | def setUp(self): | ||||
'extra_headers': [ | 'extra_headers': [ | ||||
['svn_repo_uuid', | ['svn_repo_uuid', | ||||
'3187e211-bb14-4c82-9596-0b59d67cd7f4'], | '3187e211-bb14-4c82-9596-0b59d67cd7f4'], | ||||
['svn_revision', '5'] | ['svn_revision', '5'] | ||||
] | ] | ||||
} | } | ||||
} | } | ||||
} | } | ||||
super().setUp(archive_name='pkg-gourmet-with-updates.tgz', | |||||
loader=SvnLoaderTest(last_snp_rev=last_snp_rev)) | |||||
def test_load(self): | |||||
"""Load repository should yield revisions starting from last visit | |||||
""" | |||||
previous_unfinished_revision = { | previous_unfinished_revision = { | ||||
'id': hashutil.hash_to_bytes( | 'id': hashutil.hash_to_bytes( | ||||
'4876cb10aec6f708f7466dddf547567b65f6c39c'), | '4876cb10aec6f708f7466dddf547567b65f6c39c'), | ||||
'parents': [hashutil.hash_to_bytes( | 'parents': [hashutil.hash_to_bytes( | ||||
'a3a577948fdbda9d1061913b77a1588695eadb41')], | 'a3a577948fdbda9d1061913b77a1588695eadb41')], | ||||
'directory': hashutil.hash_to_bytes( | 'directory': hashutil.hash_to_bytes( | ||||
'0deab3023ac59398ae467fc4bff5583008af1ee2'), | '0deab3023ac59398ae467fc4bff5583008af1ee2'), | ||||
'target_type': 'revision', | 'target_type': 'revision', | ||||
'metadata': { | 'metadata': { | ||||
'extra_headers': [ | 'extra_headers': [ | ||||
['svn_repo_uuid', '3187e211-bb14-4c82-9596-0b59d67cd7f4'], | ['svn_repo_uuid', '3187e211-bb14-4c82-9596-0b59d67cd7f4'], | ||||
['svn_revision', '6'] | ['svn_revision', '6'] | ||||
] | ] | ||||
} | } | ||||
} | } | ||||
# when | super().setUp(archive_name='pkg-gourmet-with-updates.tgz', | ||||
self.loader.load( | snapshot=last_snp_rev, | ||||
svn_url=self.svn_mirror_url, | |||||
destination_path=self.destination_path, | |||||
swh_revision=previous_unfinished_revision) | swh_revision=previous_unfinished_revision) | ||||
def test_load(self): | |||||
"""Load repository should yield revisions starting from last visit | |||||
""" | |||||
# when | |||||
self.loader.load() | |||||
# then | # then | ||||
# we got the previous run's last revision (rev 6) | # we got the previous run's last revision (rev 6) | ||||
# so 2 new | # so 2 new | ||||
self.assertCountRevisions(5) | self.assertCountRevisions(5) | ||||
self.assertCountReleases(0) | self.assertCountReleases(0) | ||||
last_revision = '171dc35522bfd17dda4e90a542a0377fb2fc707a' | last_revision = '171dc35522bfd17dda4e90a542a0377fb2fc707a' | ||||
# cf. test_loader.org for explaining from where those hashes | # cf. test_loader.org for explaining from where those hashes | ||||
Show All 26 Lines | def setUp(self): | ||||
super().setUp(archive_name='mediawiki-repo-r407-eol-native-crlf.tgz', | super().setUp(archive_name='mediawiki-repo-r407-eol-native-crlf.tgz', | ||||
filename='mediawiki-repo-r407-eol-native-crlf') | filename='mediawiki-repo-r407-eol-native-crlf') | ||||
def test_process_repository(self): | def test_process_repository(self): | ||||
"""Load repository with CRLF endings (svn:eol-style: native) is ok | """Load repository with CRLF endings (svn:eol-style: native) is ok | ||||
""" | """ | ||||
# when | # when | ||||
self.loader.load(svn_url=self.svn_mirror_url, | self.loader.load() | ||||
destination_path=self.destination_path) | |||||
expected_revisions = { | expected_revisions = { | ||||
'7da4975c363101b819756d33459f30a866d01b1b': 'f63637223ee0f7d4951ffd2d4d9547a4882c5d8b' # noqa | '7da4975c363101b819756d33459f30a866d01b1b': 'f63637223ee0f7d4951ffd2d4d9547a4882c5d8b' # noqa | ||||
} | } | ||||
self.assertRevisionsContain(expected_revisions) | self.assertRevisionsContain(expected_revisions) | ||||
self.assertCountSnapshots(1) | self.assertCountSnapshots(1) | ||||
# FIXME: Check the snapshot's state | # FIXME: Check the snapshot's state | ||||
# self.assertEqual(self.loader.all_snapshots[0], {}) | # self.assertEqual(self.loader.all_snapshots[0], {}) | ||||
Show All 13 Lines | def setUp(self): | ||||
super().setUp( | super().setUp( | ||||
archive_name='pyang-repo-r343-eol-native-mixed-lf-crlf.tgz', | archive_name='pyang-repo-r343-eol-native-mixed-lf-crlf.tgz', | ||||
filename='pyang-repo-r343-eol-native-mixed-lf-crlf') | filename='pyang-repo-r343-eol-native-mixed-lf-crlf') | ||||
def test_load(self): | def test_load(self): | ||||
"""Load repo with mixed CRLF/LF endings (svn:eol-style:native) is ok | """Load repo with mixed CRLF/LF endings (svn:eol-style:native) is ok | ||||
""" | """ | ||||
self.loader.load(svn_url=self.svn_mirror_url, | self.loader.load() | ||||
destination_path=self.destination_path) | |||||
expected_revisions = { | expected_revisions = { | ||||
'9c6962eeb9164a636c374be700672355e34a98a7': '16aa6b6271f3456d4643999d234cf39fe3d0cc5a' # noqa | '9c6962eeb9164a636c374be700672355e34a98a7': '16aa6b6271f3456d4643999d234cf39fe3d0cc5a' # noqa | ||||
} | } | ||||
self.assertRevisionsContain(expected_revisions) | self.assertRevisionsContain(expected_revisions) | ||||
self.assertCountSnapshots(1) | self.assertCountSnapshots(1) | ||||
# FIXME: Check the snapshot's state | # FIXME: Check the snapshot's state | ||||
# self.assertEqual(self.loader.all_snapshots[0], {}) | # self.assertEqual(self.loader.all_snapshots[0], {}) | ||||
self.assertEqual(self.loader.load_status(), {'status': 'eventful'}) | self.assertEqual(self.loader.load_status(), {'status': 'eventful'}) | ||||
self.assertEqual(self.loader.visit_status(), 'full') | self.assertEqual(self.loader.visit_status(), 'full') | ||||
class SvnLoaderTest11(BaseSvnLoaderTest): | class SvnLoaderTest11(BaseSvnLoaderTest): | ||||
"""Context: | """Context: | ||||
- Repository with svn:external (which is not deal with for now) | - Repository with svn:external (which is not deal with for now) | ||||
- Visit is partial with as much data loaded as possible | - Visit is partial with as much data loaded as possible | ||||
""" | """ | ||||
def setUp(self): | def setUp(self): | ||||
super().setUp(archive_name='pkg-gourmet-with-external-id.tgz') | previous_unfinished_revision = None | ||||
super().setUp(archive_name='pkg-gourmet-with-external-id.tgz', | |||||
swh_revision=previous_unfinished_revision) | |||||
def test_load(self): | def test_load(self): | ||||
"""Repository with svn:externals property, will stop raising an error | """Repository with svn:externals property, will stop raising an error | ||||
""" | """ | ||||
previous_unfinished_revision = None | |||||
# when | # when | ||||
self.loader.load( | self.loader.load() | ||||
svn_url=self.svn_mirror_url, | |||||
destination_path=self.destination_path, | |||||
swh_revision=previous_unfinished_revision) | |||||
# then repositories holds 21 revisions, but the last commit | # then repositories holds 21 revisions, but the last commit | ||||
# one holds an 'svn:externals' property which will make the | # one holds an 'svn:externals' property which will make the | ||||
# loader-svn stops at the last revision prior to the bad one | # loader-svn stops at the last revision prior to the bad one | ||||
self.assertCountRevisions(20) | self.assertCountRevisions(20) | ||||
self.assertCountReleases(0) | self.assertCountReleases(0) | ||||
last_revision = '82a7a4a09f9549223429143ba36ad77375e33c5c' | last_revision = '82a7a4a09f9549223429143ba36ad77375e33c5c' | ||||
Show All 32 Lines | |||||
class SvnLoaderTest12(BaseSvnLoaderTest): | class SvnLoaderTest12(BaseSvnLoaderTest): | ||||
"""Edge cases: | """Edge cases: | ||||
- first create a file and commit it. | - first create a file and commit it. | ||||
Remove it, then add folder holding the same name, commit. | Remove it, then add folder holding the same name, commit. | ||||
- do the same scenario with symbolic link (instead of file) | - do the same scenario with symbolic link (instead of file) | ||||
""" | """ | ||||
def setUp(self): | def setUp(self): | ||||
previous_unfinished_revision = None | |||||
super().setUp( | super().setUp( | ||||
archive_name='pkg-gourmet-with-edge-case-links-and-files.tgz') | archive_name='pkg-gourmet-with-edge-case-links-and-files.tgz', | ||||
swh_revision=previous_unfinished_revision) | |||||
def test_load(self): | def test_load(self): | ||||
"""File/Link removed prior to folder with same name creation is ok | """File/Link removed prior to folder with same name creation is ok | ||||
""" | """ | ||||
previous_unfinished_revision = None | |||||
# when | # when | ||||
self.loader.load( | self.loader.load() | ||||
svn_url=self.svn_mirror_url, | |||||
destination_path=self.destination_path, | |||||
swh_revision=previous_unfinished_revision) | |||||
# then repositories holds 14 revisions, but the last commit | # then repositories holds 14 revisions, but the last commit | ||||
self.assertCountRevisions(19) | self.assertCountRevisions(19) | ||||
self.assertCountReleases(0) | self.assertCountReleases(0) | ||||
last_revision = '3f43af2578fccf18b0d4198e48563da7929dc608' | last_revision = '3f43af2578fccf18b0d4198e48563da7929dc608' | ||||
expected_revisions = { | expected_revisions = { | ||||
# revision hash | directory hash | # revision hash | directory hash | ||||
Show All 35 Lines | def setUp(self): | ||||
super().setUp( | super().setUp( | ||||
archive_name='pkg-gourmet-with-wrong-link-cases.tgz') | archive_name='pkg-gourmet-with-wrong-link-cases.tgz') | ||||
def test_load(self): | def test_load(self): | ||||
"""Wrong link or empty space-named link should be ok | """Wrong link or empty space-named link should be ok | ||||
""" | """ | ||||
# when | # when | ||||
self.loader.load( | self.loader.load() | ||||
svn_url=self.svn_mirror_url, | |||||
destination_path=self.destination_path) | |||||
# then repositories holds 14 revisions, but the last commit | # then repositories holds 14 revisions, but the last commit | ||||
self.assertCountRevisions(21) | self.assertCountRevisions(21) | ||||
self.assertCountReleases(0) | self.assertCountReleases(0) | ||||
last_revision = 'cf30d3bb9d5967d0a2bbeacc405f10a5dd9b138a' | last_revision = 'cf30d3bb9d5967d0a2bbeacc405f10a5dd9b138a' | ||||
expected_revisions = { | expected_revisions = { | ||||
Show All 33 Lines | |||||
class SvnLoaderFromRemoteDumpTest(BaseSvnLoaderTest): | class SvnLoaderFromRemoteDumpTest(BaseSvnLoaderTest): | ||||
""" | """ | ||||
Check that the results obtained with the remote svn dump loader | Check that the results obtained with the remote svn dump loader | ||||
and the base svn loader are the same. | and the base svn loader are the same. | ||||
""" | """ | ||||
def setUp(self): | def setUp(self): | ||||
super().setUp(archive_name='pkg-gourmet.tgz', | _LOADER_TEST_CONFIG['debug'] = True # to avoid cleanup in between load | ||||
loader=SvnLoaderTestFromRemoteDump()) | super().setUp(archive_name='pkg-gourmet.tgz', type='remote') | ||||
def test_load(self): | def test_load(self): | ||||
""" | """ | ||||
Compare results of remote dump loader and base loader | Compare results of remote dump loader and base loader | ||||
""" | """ | ||||
dump_loader = self.loader | dump_loader = self.loader | ||||
dump_loader.load(svn_url=self.svn_mirror_url) | dump_loader.load() | ||||
self.assertCountContents(19) | self.assertCountContents(19) | ||||
self.assertCountDirectories(17) | self.assertCountDirectories(17) | ||||
self.assertCountRevisions(6) | self.assertCountRevisions(6) | ||||
self.assertCountSnapshots(1) | self.assertCountSnapshots(1) | ||||
base_loader = SvnLoaderTest() | base_loader = SvnLoaderTest(self.svn_mirror_url) | ||||
base_loader.load(svn_url=self.svn_mirror_url) | base_loader.load() | ||||
dump_storage_stat = dump_loader.storage.stat_counters() | dump_storage_stat = dump_loader.storage.stat_counters() | ||||
base_storage_stat = base_loader.storage.stat_counters() | base_storage_stat = base_loader.storage.stat_counters() | ||||
self.assertEqual(dump_storage_stat, base_storage_stat) | self.assertEqual(dump_storage_stat, base_storage_stat) | ||||
class SvnLoaderTest14(BaseSvnLoaderTest): | class SvnLoaderTest14(BaseSvnLoaderTest): | ||||
"""Edge cases: The repository held some user defined svn-properties | """Edge cases: The repository held some user defined svn-properties | ||||
with special encodings, this prevented the repository from | with special encodings, this prevented the repository from | ||||
being loaded even though we do not ingest those information. | being loaded even though we do not ingest those information. | ||||
""" | """ | ||||
def setUp(self): | def setUp(self): | ||||
super().setUp(archive_name='httthttt.tgz', filename='httthttt') | super().setUp(archive_name='httthttt.tgz', filename='httthttt') | ||||
def test_load(self): | def test_load(self): | ||||
"""Decoding user defined svn properties error should not fail loading | """Decoding user defined svn properties error should not fail loading | ||||
""" | """ | ||||
# when | # when | ||||
self.loader.load( | self.loader.load() | ||||
svn_url=self.svn_mirror_url, | |||||
destination_path=self.destination_path) | |||||
self.assertCountRevisions(7, '7 svn commits') | self.assertCountRevisions(7, '7 svn commits') | ||||
self.assertCountReleases(0) | self.assertCountReleases(0) | ||||
last_revision = '604a17dbb15e8d7ecb3e9f3768d09bf493667a93' | last_revision = '604a17dbb15e8d7ecb3e9f3768d09bf493667a93' | ||||
expected_revisions = { | expected_revisions = { | ||||
'e6ae8487c6d14df9e6cb7196c6aac045798fd5be': '75ed58f260bfa4102d0e09657803511f5f0ab372', # noqa | 'e6ae8487c6d14df9e6cb7196c6aac045798fd5be': '75ed58f260bfa4102d0e09657803511f5f0ab372', # noqa | ||||
Show All 22 Lines |