Skip to content
Snippets Groups Projects
Commit 9e62dfcb authored by Georges Racinet's avatar Georges Racinet
Browse files

Gitaly Comparison tests: Gitaly Blob chunking can vary

This fixes a flakiness in the comparison tests for `get_blob` and
`get_blobs`: Gitaly's chunking is not constant, seems to depend
on the (circumstantial) size of some inner buffers or similar.
Hence a direct comparison of Gitaly and HGitaly responses is
flay.

Instead, we are focusing on what matters: repetition of metadata
like oid and size (or not) and of course that the whole content
is correct.
parent 1a917e02
No related branches found
No related tags found
1 merge request!61Blob(s): fix flakiness in Gitaly Comparison tests and settle for chunks of length WRITE_BUFFER_SIZE
......@@ -24,8 +24,6 @@
from hgitaly.stub.blob_pb2_grpc import BlobServiceStub
from hgitaly.stub.commit_pb2_grpc import CommitServiceStub
from hgitaly.service.blob import CHUNK_SIZE
from . import skip_comparison_tests
if skip_comparison_tests(): # pragma no cover
pytestmark = pytest.mark.skip
......@@ -170,7 +168,7 @@
git_repo = fixture.git_repo
wrapper = fixture.hg_repo_wrapper
large_data = b'\xbe\xef' * CHUNK_SIZE # twice as CHUNK_SIZE
large_data = b'\xbe' * WRITE_BUFFER_SIZE + b'\xefdata'
wrapper.commit_file('small', message="Small file")
changeset = wrapper.commit_file('foo', message="Large foo",
......@@ -197,7 +195,10 @@
git_resps = fixture.get_blob('git', oids['git'])
# checking more assumptions implemented for hg
assert git_resps[0].oid == oids['git']
assert git_resps[1].oid == ''
hg_resps = fixture.get_blob('hg', oids['hg'])
# Gitaly chunking is not fully deterministic, so the most
# we can check is that chunking occurs for both servers
# and that the first and second responses have the same metadata
assert len(hg_resps) > 1
assert len(git_resps) > 1
......@@ -203,5 +204,7 @@
hg_resps = fixture.get_blob('hg', oids['hg'])
assert len(hg_resps) == 2
assert len(git_resps) == 2
assert hg_resps[0].oid == oids['hg']
assert git_resps[0].oid == oids['git']
assert hg_resps[1].oid == git_resps[1].oid
for hgr, gitr in zip(hg_resps[:2], git_resps[:2]):
assert hgr.size == gitr.size
......@@ -207,11 +210,11 @@
for git_resp, hg_resp in zip(git_resps, hg_resps):
assert hg_resp.size == git_resp.size
assert hg_resp.data == git_resp.data
assert all(git_resps[i].size == hg_resps[i].size for i in (0, 1))
assert (
b''.join(r.data for r in hg_resps)
==
b''.join(r.data for r in git_resps)
)
# now with get_blobs
rev_paths = ((b'branch/default', b'small'),
(b'branch/default', b'does-not-exist'),
(b'no-such-revision', b'small'),
......@@ -213,9 +216,9 @@
# now with get_blobs
rev_paths = ((b'branch/default', b'small'),
(b'branch/default', b'does-not-exist'),
(b'no-such-revision', b'small'),
(b'branch/default', b'foo'))
)
hg_resps = fixture.get_blobs('hg', rev_paths)
git_resps = fixture.get_blobs('git', rev_paths)
......@@ -237,3 +240,26 @@
resp.oid = ''
assert hg_resps == git_resps
# chunking in get_blobs, again non-deterministic for Gitaly
rev_paths = ((b'branch/default', b'small'),
(b'branch/default', b'foo'),
)
hg_resps = fixture.get_blobs('hg', rev_paths)
git_resps = fixture.get_blobs('git', rev_paths)
assert len(hg_resps) > 2
assert len(git_resps) > 2
assert hg_resps[0].oid != ""
assert git_resps[0].oid != ""
assert hg_resps[1].oid != ""
assert git_resps[1].oid != ""
assert hg_resps[2].oid == ""
assert git_resps[2].oid == ""
for hgr, gitr in zip(hg_resps[:3], git_resps[:3]):
assert hgr.size == gitr.size
assert ( # content of the big file at 'foo'
b''.join(r.data for r in hg_resps[1:])
==
b''.join(r.data for r in git_resps[1:])
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment