Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/tests/test_cassandra.py
Show First 20 Lines • Show All 187 Lines • ▼ Show 20 Lines | class TestCassandraStorage(_TestStorage): | ||||
def test_content_add_murmur3_collision(self, swh_storage, mocker, sample_data): | def test_content_add_murmur3_collision(self, swh_storage, mocker, sample_data): | ||||
"""The Murmur3 token is used as link from index tables to the main | """The Murmur3 token is used as link from index tables to the main | ||||
table; and non-matching contents with colliding murmur3-hash | table; and non-matching contents with colliding murmur3-hash | ||||
are filtered-out when reading the main table. | are filtered-out when reading the main table. | ||||
This test checks the content methods do filter out these collision. | This test checks the content methods do filter out these collision. | ||||
""" | """ | ||||
called = 0 | called = 0 | ||||
cont, cont2 = sample_data["content"][:2] | cont, cont2 = sample_data.contents[:2] | ||||
# always return a token | # always return a token | ||||
def mock_cgtfsh(algo, hash_): | def mock_cgtfsh(algo, hash_): | ||||
nonlocal called | nonlocal called | ||||
called += 1 | called += 1 | ||||
assert algo in ("sha1", "sha1_git") | assert algo in ("sha1", "sha1_git") | ||||
return [123456] | return [123456] | ||||
Show All 26 Lines | class TestCassandraStorage(_TestStorage): | ||||
): | ): | ||||
"""The Murmur3 token is used as link from index tables to the main | """The Murmur3 token is used as link from index tables to the main | ||||
table; and non-matching contents with colliding murmur3-hash | table; and non-matching contents with colliding murmur3-hash | ||||
are filtered-out when reading the main table. | are filtered-out when reading the main table. | ||||
This test checks the content methods do filter out these collisions. | This test checks the content methods do filter out these collisions. | ||||
""" | """ | ||||
called = 0 | called = 0 | ||||
cont, cont2 = [attr.evolve(c, ctime=now()) for c in sample_data["content"][:2]] | cont, cont2 = [attr.evolve(c, ctime=now()) for c in sample_data.contents[:2]] | ||||
# always return a token | # always return a token | ||||
def mock_cgtfsh(algo, hash_): | def mock_cgtfsh(algo, hash_): | ||||
nonlocal called | nonlocal called | ||||
called += 1 | called += 1 | ||||
assert algo in ("sha1", "sha1_git") | assert algo in ("sha1", "sha1_git") | ||||
return [123456] | return [123456] | ||||
Show All 31 Lines | class TestCassandraStorage(_TestStorage): | ||||
def test_content_find_murmur3_collision(self, swh_storage, mocker, sample_data): | def test_content_find_murmur3_collision(self, swh_storage, mocker, sample_data): | ||||
"""The Murmur3 token is used as link from index tables to the main | """The Murmur3 token is used as link from index tables to the main | ||||
table; and non-matching contents with colliding murmur3-hash | table; and non-matching contents with colliding murmur3-hash | ||||
are filtered-out when reading the main table. | are filtered-out when reading the main table. | ||||
This test checks the content methods do filter out these collisions. | This test checks the content methods do filter out these collisions. | ||||
""" | """ | ||||
called = 0 | called = 0 | ||||
cont, cont2 = [attr.evolve(c, ctime=now()) for c in sample_data["content"][:2]] | cont, cont2 = [attr.evolve(c, ctime=now()) for c in sample_data.contents[:2]] | ||||
# always return a token | # always return a token | ||||
def mock_cgtfsh(algo, hash_): | def mock_cgtfsh(algo, hash_): | ||||
nonlocal called | nonlocal called | ||||
called += 1 | called += 1 | ||||
assert algo in ("sha1", "sha1_git") | assert algo in ("sha1", "sha1_git") | ||||
return [123456] | return [123456] | ||||
▲ Show 20 Lines • Show All 101 Lines • Show Last 20 Lines |