Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port Hypothesis test: file operations #6534

Closed
Tracked by #5137
touilleMan opened this issue Feb 27, 2024 · 1 comment · Fixed by #6577
Closed
Tracked by #5137

Port Hypothesis test: file operations #6534

touilleMan opened this issue Feb 27, 2024 · 1 comment · Fixed by #6577
Assignees
Labels
I-Rust Impact: Rust-related stuff I-Test Test-related issue
Milestone

Comments

@touilleMan
Copy link
Member

touilleMan commented Feb 27, 2024

see

@pytest.mark.slow
def test_file_operations(hypothesis_settings, tmpdir, alice):
class FileOperations(RuleBasedStateMachine):
def __init__(self) -> None:
super().__init__()
self.oracle = open(tmpdir / "oracle.txt", "w+b")
self.manifest = LocalFileManifest.new_placeholder(
alice.device_id, parent=EntryID.new(), blocksize=8, timestamp=alice.timestamp()
)
self.storage = Storage()
def teardown(self) -> None:
self.oracle.close()
self.storage.clear()
@invariant()
def integrity(self) -> None:
self.manifest.assert_integrity()
@invariant()
def leaks(self) -> None:
all_ids = {chunk.id for chunks in self.manifest.blocks for chunk in chunks}
assert set(self.storage) == all_ids
@rule(size=size, offset=size)
def read(self, size: int, offset: int) -> None:
data = self.storage.read(self.manifest, size, offset)
self.oracle.seek(offset)
expected = self.oracle.read(size)
assert data == expected
@rule(content=strategies.binary(max_size=MAX_SIZE), offset=size)
def write(self, content: bytes, offset: int) -> None:
self.manifest = self.storage.write(self.manifest, content, offset, alice.timestamp())
self.oracle.seek(offset)
self.oracle.write(content)
@rule(length=size)
def resize(self, length: int) -> None:
self.manifest = self.storage.resize(self.manifest, length, alice.timestamp())
self.oracle.truncate(length)
@rule()
def reshape(self) -> None:
self.manifest = self.storage.reshape(self.manifest)
assert self.manifest.is_reshaped()
run_state_machine_as_test(FileOperations, settings=hypothesis_settings)

component to be tested are location in https://github.com/Scille/parsec-cloud/blob/master/libparsec/crates/client/src/workspace/transactions/file_operations.rs

can be implemented with PropTest

@touilleMan touilleMan added this to the v3.0 milestone Feb 27, 2024
@mmmarcos mmmarcos mentioned this issue Feb 27, 2024
37 tasks
@mmmarcos mmmarcos added I-Rust Impact: Rust-related stuff I-Test Test-related issue labels Feb 27, 2024
@mmmarcos
Copy link
Contributor

mmmarcos commented Mar 6, 2024

Done in #6577

@mmmarcos mmmarcos closed this as completed Mar 6, 2024
@mmmarcos mmmarcos linked a pull request Mar 8, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-Rust Impact: Rust-related stuff I-Test Test-related issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants