self = <swh.vault.tests.test_cookers.TestRevisionCooker object at 0x7f04f94e80f0>
swh_storage = <swh.storage.postgresql.storage.Storage object at 0x7f04f94e85f8>
cook_extract_revision = <function cook_extract_revision_git_bare at 0x7f04fce63598>
ingest_target_revision = True
@pytest.mark.parametrize("ingest_target_revision", [False, True])
def test_revision_submodule(
self, swh_storage, cook_extract_revision, ingest_target_revision
):
date = TimestampWithTimezone.from_datetime(
datetime.datetime.now(datetime.timezone.utc).replace(microsecond=0)
)
target_rev = Revision(
message=b"target_rev",
author=Person.from_fullname(b"me <test@example.org>"),
date=date,
committer=Person.from_fullname(b"me <test@example.org>"),
committer_date=date,
parents=(),
type=RevisionType.GIT,
directory=bytes.fromhex("3333333333333333333333333333333333333333"),
metadata={},
synthetic=True,
)
if ingest_target_revision:
swh_storage.revision_add([target_rev])
dir = Directory(
entries=(
DirectoryEntry(
name=b"submodule", type="rev", target=target_rev.id, perms=0o160000,
),
),
)
swh_storage.directory_add([dir])
rev = Revision(
message=b"msg",
author=Person.from_fullname(b"me <test@example.org>"),
date=date,
committer=Person.from_fullname(b"me <test@example.org>"),
committer_date=date,
parents=(),
type=RevisionType.GIT,
directory=dir.id,
metadata={},
synthetic=True,
)
swh_storage.revision_add([rev])
> with cook_extract_revision(swh_storage, rev.swhid()) as (ert, p):
.tox/py3/lib/python3.7/site-packages/swh/vault/tests/test_cookers.py:1021:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.7/contextlib.py:112: in __enter__
return next(self.gen)
.tox/py3/lib/python3.7/site-packages/swh/vault/tests/test_cookers.py:331: in cook_extract_revision_git_bare
with cook_extract_git_bare(storage, swhid, fsck=fsck,) as res:
/usr/lib/python3.7/contextlib.py:112: in __enter__
return next(self.gen)
.tox/py3/lib/python3.7/site-packages/swh/vault/tests/test_cookers.py:310: in cook_extract_git_bare
cooker.prepare_bundle()
.tox/py3/lib/python3.7/site-packages/swh/vault/cookers/git_bare.py:135: in prepare_bundle
self.push_subgraph(self.obj_type, self.obj_id)
.tox/py3/lib/python3.7/site-packages/swh/vault/cookers/git_bare.py:298: in push_subgraph
self.push_revision_subgraph(obj_id)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <swh.vault.cookers.git_bare.GitBareCooker object at 0x7f04fb8422e8>
obj_id = b'\xfb\xce&TD\xd2\xc9\xdd\xa6\x7f\xd2Qc\xdbOA\xbe\x84\xc0i'
def push_revision_subgraph(self, obj_id: Sha1Git) -> None:
"""Fetches a revision and all its children, and writes them to disk"""
loaded_from_graph = False
if self.graph:
from swh.graph.client import GraphArgumentException
# First, try to cook using swh-graph, as it is more efficient than
# swh-storage for querying the history
obj_swhid = CoreSWHID(object_type=ObjectType.REVISION, object_id=obj_id,)
try:
revision_ids = (
swhid.object_id
for swhid in map(
CoreSWHID.from_string,
self.graph.visit_nodes(str(obj_swhid), edges="rev:rev"),
)
)
self._push(self._rev_stack, revision_ids)
except GraphArgumentException as e:
logger.info(
"Revision %s not found in swh-graph, falling back to fetching "
"history using swh-storage. %s",
hash_to_hex(obj_id),
e.args[0],
)
else:
loaded_from_graph = True
if not loaded_from_graph:
# If swh-graph is not available, or the revision is not yet in
# swh-graph, fall back to self.storage.revision_log.
# self.storage.revision_log also gives us the full revisions,
# so we load them right now instead of just pushing them on the stack.
walker = DFSRevisionsWalker(self.storage, obj_id, state=self._walker_state)
for revision in walker:
self.write_revision_node(revision)
> self.nb_loaded += 1
E AttributeError: 'GitBareCooker' object has no attribute 'nb_loaded'
.tox/py3/lib/python3.7/site-packages/swh/vault/cookers/git_bare.py:384: AttributeError
TEST RESULT
TEST RESULT
- Run At
- Nov 23 2021, 4:08 PM