self = <swh.storage.tests.test_cassandra.TestCassandraStorage object at 0x7f3add75c278>
swh_storage = <swh.storage.cassandra.storage.CassandraStorage object at 0x7f38b4f39710>
sample_data = <swh.storage.tests.storage_data.StorageData object at 0x7f3927c5a400>
mocker = <pytest_mock.plugin.MockerFixture object at 0x7f3927c5a048>
insert_algo = 'concurrent'
@pytest.mark.parametrize("insert_algo", DIRECTORY_ENTRIES_INSERT_ALGOS)
def test_directory_add_atomic(self, swh_storage, sample_data, mocker, insert_algo):
"""Checks that a crash occurring after some directory entries were written
does not cause the directory to be (partially) visible.
ie. checks directories are added somewhat atomically."""
# Disable the journal writer, it would detect the CrashyEntry exception too
# early for this test to be relevant
swh_storage.journal_writer.journal = None
mocker.patch.object(swh_storage, "_directory_entries_insert_algo", insert_algo)
class CrashyEntry(DirectoryEntry):
def __init__(self):
super().__init__(**{**directory.entries[0].to_dict(), "name": b"crash"})
def to_dict(self):
return {**super().to_dict(), "perms": "abcde"}
directory = self._directory_with_entries(sample_data, BATCH_INSERT_MAX_SIZE)
entries = directory.entries
directory = attr.evolve(directory, entries=entries + (CrashyEntry(),))
with pytest.raises(TypeError):
swh_storage.directory_add([directory])
# This should have written some of the entries to the database:
entry_rows = swh_storage._cql_runner.directory_entry_get([directory.id])
> assert {row.name for row in entry_rows} == {entry.name for entry in entries}
E AssertionError: assert {b'file ... 5', ...} == {b'file ... 5', ...}
E Extra items in the right set:
E b'file 957'
E Full diff:
E {
E b'file 0',
E b'file 1',
E b'file 2',...
E
E ...Full output truncated (999 lines hidden), use '-vv' to show
.tox/py3/lib/python3.7/site-packages/swh/storage/tests/test_cassandra.py:575: AssertionError
TEST RESULT
TEST RESULT
- Run At
- Aug 5 2022, 11:36 AM