self = <swh.loader.git.tests.test_loader.TestDumbGitLoaderWithPack object at 0x7f00617755c0>
swh_storage = <swh.storage.proxies.filter.FilteringProxyStorage object at 0x7f0061775be0>
datadir = '/var/lib/jenkins/workspace/DLDG/tests-on-diff/.tox/py3/lib/python3.7/site-packages/swh/loader/git/tests/data'
tmp_path = '/tmp/pytest-of-jenkins/pytest-0/test_load_with_missing_pack0'
@pytest.fixture(autouse=True)
def init(self, swh_storage, datadir, tmp_path):
# remove any proxy settings in order to successfully spawn a local HTTP server
http_proxy = os.environ.get("http_proxy")
https_proxy = os.environ.get("https_proxy")
if http_proxy:
del os.environ["http_proxy"]
if http_proxy:
del os.environ["https_proxy"]
# prepare test base repository using smart transfer protocol
archive_name = "testrepo"
archive_path = os.path.join(datadir, f"{archive_name}.tgz")
tmp_path = str(tmp_path)
base_repo_url = prepare_repository_from_archive(
archive_path, archive_name, tmp_path=tmp_path
)
destination_path = os.path.join(tmp_path, archive_name)
self.destination_path = destination_path
with_pack_files = self.with_pack_files
if with_pack_files:
# create a bare clone of that repository in another folder,
# all objects will be contained in one or two pack files in that case
bare_repo_path = os.path.join(tmp_path, archive_name + "_bare")
subprocess.run(
["git", "clone", "--bare", base_repo_url, bare_repo_path], check=True,
)
else:
# otherwise serve objects from the bare repository located in
# the .git folder of the base repository
bare_repo_path = os.path.join(destination_path, ".git")
# spawn local HTTP server that will serve the bare repository files
hostname = "localhost"
handler = partial(SimpleHTTPRequestHandler, directory=bare_repo_path)
httpd = HTTPServer((hostname, 0), handler, bind_and_activate=True)
def serve_forever(httpd):
with httpd:
httpd.serve_forever()
thread = Thread(target=serve_forever, args=(httpd,))
thread.start()
repo = dulwich.repo.Repo(self.destination_path)
class DumbGitLoaderTest(GitLoader):
def load(self):
"""
Override load method to ensure the bare repository will be synchronized
with the base one as tests can modify its content.
"""
if with_pack_files:
# ensure HEAD ref will be the same for both repositories
with open(os.path.join(bare_repo_path, "HEAD"), "wb") as fw:
with open(
os.path.join(destination_path, ".git/HEAD"), "rb"
) as fr:
head_ref = fr.read()
fw.write(head_ref)
# push possibly modified refs in the base repository to the bare one
for ref in repo.refs.allkeys():
if ref != b"HEAD" or head_ref in repo.refs:
push(
repo,
remote_location=f"file://{bare_repo_path}",
refspecs=ref,
)
# generate or update the info/refs file used in dumb protocol
subprocess.run(
["git", "-C", bare_repo_path, "update-server-info"], check=True,
)
return super().load()
# bare repository with dumb protocol only URL
self.repo_url = f"http://{httpd.server_name}:{httpd.server_port}"
> self.loader = DumbGitLoaderTest(swh_storage, self.repo_url)
.tox/py3/lib/python3.7/site-packages/swh/loader/git/tests/test_loader.py:217:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3/lib/python3.7/site-packages/swh/loader/git/loader.py:169: in __init__
self.tracemalloc_snapshot = tracemalloc.take_snapshot()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def take_snapshot():
"""
Take a snapshot of traces of memory blocks allocated by Python.
"""
if not is_tracing():
> raise RuntimeError("the tracemalloc module must be tracing memory "
"allocations to take a snapshot")
E RuntimeError: the tracemalloc module must be tracing memory allocations to take a snapshot
/usr/lib/python3.7/tracemalloc.py:530: RuntimeError
TEST RESULT
TEST RESULT
- Run At
- Oct 6 2021, 2:13 PM