datadir = '/var/lib/jenkins/workspace/DLDSVN/tests-on-diff/.tox/py3/lib/python3.7/site-packages/swh/loader/svn/tests/data'
tmp_path = PosixPath('/tmp/pytest-of-jenkins/pytest-0/test_init_svn_repo_from_archiv0')
def test_init_svn_repo_from_archive_dump(datadir, tmp_path):
"""Mounting svn repository out of an archive dump is ok"""
dump_name = "penguinsdbtools2018.dump.gz"
dump_path = os.path.join(datadir, dump_name)
tmp_repo, repo_path = utils.init_svn_repo_from_archive_dump(
> dump_path, cleanup_dump=False
)
.tox/py3/lib/python3.7/site-packages/swh/loader/svn/tests/test_utils.py:84:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3/lib/python3.7/site-packages/swh/loader/svn/utils.py:188: in init_svn_repo_from_archive_dump
cleanup_dump=cleanup_dump,
.tox/py3/lib/python3.7/site-packages/swh/loader/svn/utils.py:144: in init_svn_repo_from_dump
raise e
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
dump_path = '/var/lib/jenkins/workspace/DLDSVN/tests-on-diff/.tox/py3/lib/python3.7/site-packages/swh/loader/svn/tests/data/penguinsdbtools2018.dump.gz'
prefix = None, suffix = None, root_dir = '/tmp', gzip = True
cleanup_dump = False
def init_svn_repo_from_dump(
dump_path: str,
prefix: Optional[str] = None,
suffix: Optional[str] = None,
root_dir: str = "/tmp",
gzip: bool = False,
cleanup_dump: bool = True,
) -> Tuple[str, str]:
"""Given a path to a svn dump, initialize an svn repository with the content of said
dump.
Args:
dump_path: The dump to the path
prefix: optional prefix file name for the working directory
suffix: optional suffix file name for the working directory
root_dir: the root directory where the working directory is created
gzip: Boolean to determine whether we treat the dump as compressed or not.
cleanup_dump: Whether we want this function call to clean up the dump at the end
of the repository initialization.
Returns:
A tuple:
- temporary folder: containing the mounted repository
- repo_path: path to the mounted repository inside the temporary folder
Raises:
ValueError in case of failure to run the command to uncompress and load the
dump.
"""
project_name = os.path.basename(os.path.dirname(dump_path))
temp_dir = tempfile.mkdtemp(prefix=prefix, suffix=suffix, dir=root_dir)
try:
repo_path = os.path.join(temp_dir, project_name)
# create the repository that will be loaded with the dump
cmd = ["svnadmin", "create", repo_path]
r = call(cmd)
if r != 0:
raise ValueError(
"Failed to initialize empty svn repo for %s" % project_name
)
read_dump_cmd = ["cat", dump_path]
if gzip:
read_dump_cmd = ["gzip", "-dc", dump_path]
with Popen(read_dump_cmd, stdout=PIPE) as dump:
# load dump and bypass properties validation as Unicode decoding errors
# are already handled in loader implementation (see _ra_codecs_error_handler
# in ra.py)
cmd = ["svnadmin", "load", "-q", "--bypass-prop-validation", repo_path]
r = call(cmd, stdin=dump.stdout)
if r != 0:
raise ValueError(
> "Failed to mount the svn dump for project %s" % project_name
)
E ValueError: Failed to mount the svn dump for project data
.tox/py3/lib/python3.7/site-packages/swh/loader/svn/utils.py:139: ValueError
TEST RESULT
TEST RESULT
- Run At
- Nov 9 2021, 11:24 AM