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: FS online RW file and sync #6541

Open
Tracked by #7631 ...
touilleMan opened this issue Feb 27, 2024 · 0 comments
Open
Tracked by #7631 ...

Port Hypothesis test: FS online RW file and sync #6541

touilleMan opened this issue Feb 27, 2024 · 0 comments
Labels
I-Rust Impact: Rust-related stuff I-Test Test-related issue

Comments

@touilleMan
Copy link
Member

@pytest.fixture
@customize_fixtures(real_data_storage=True, alternate_workspace_storage=True)
def fs_online_rw_file_and_sync(user_fs_online_state_machine, alice: LocalDevice):
# We reduce the hypothesis to 50 (from 100) because this test can be really slow :(
@settings(max_examples=50)
class FSOnlineRwFileAndSync(user_fs_online_state_machine):
user_fs: UserFS
@initialize()
async def init(self):
await self.reset_all()
await self.start_backend()
self.device = self.correct_addr(alice)
await self.restart_user_fs(self.device)
self.wid = await self.user_fs.workspace_create(EntryName("w"))
workspace = self.user_fs.get_workspace(self.wid)
await workspace.touch("/foo.txt")
await workspace.sync()
await self.user_fs.sync()
self.file_oracle = FileOracle(base_version=1)
@rule()
async def restart(self):
await self.restart_user_fs(self.device)
@rule()
async def reset(self):
await self.reset_user_fs(self.device)
await self.user_fs.sync()
# Retrieve workspace manifest v1 to replace the default empty speculative placeholder
await self.user_fs.get_workspace(self.wid).sync()
self.file_oracle.reset()
@rule()
async def sync(self):
workspace = self.user_fs.get_workspace(self.wid)
await workspace.sync()
self.file_oracle.sync()
@rule(
size=st.integers(min_value=0, max_value=PLAYGROUND_SIZE),
offset=st.integers(min_value=0, max_value=PLAYGROUND_SIZE),
)
async def atomic_read(self, size, offset):
workspace = self.user_fs.get_workspace(self.wid)
async with await workspace.open_file("/foo.txt", "rb") as f:
await f.seek(offset)
content = await f.read(size)
expected_content = self.file_oracle.read(size, offset)
assert content == expected_content
@rule(
offset=st.integers(min_value=0, max_value=PLAYGROUND_SIZE),
content=st.binary(max_size=PLAYGROUND_SIZE),
)
async def atomic_write(self, offset, content):
workspace = self.user_fs.get_workspace(self.wid)
async with await workspace.open_file("/foo.txt", "rb+") as f:
await f.seek(offset)
await f.write(content)
self.file_oracle.write(offset, content)
@rule(length=st.integers(min_value=0, max_value=PLAYGROUND_SIZE))
async def atomic_truncate(self, length):
workspace = self.user_fs.get_workspace(self.wid)
await workspace.truncate("/foo.txt", length=length)
self.file_oracle.truncate(length)
@rule()
async def stat(self):
workspace = self.user_fs.get_workspace(self.wid)
path_info = await workspace.path_info("/foo.txt")
assert path_info["type"] == "file"
assert path_info["base_version"] == self.file_oracle.base_version
assert not path_info["is_placeholder"]
assert path_info["need_sync"] == self.file_oracle.need_sync
assert path_info["size"] == self.file_oracle.size
return FSOnlineRwFileAndSync

@touilleMan touilleMan added this to the v3.0 milestone Feb 27, 2024
@touilleMan touilleMan changed the title Port Hypothesis test: FS only RW file and sync Port Hypothesis test: FS online RW file and sync 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 mmmarcos modified the milestones: v3.0-beta, v3.0 Mar 27, 2024
@mmmarcos mmmarcos modified the milestones: v3.0, v3.1 May 17, 2024
@mmmarcos mmmarcos mentioned this issue Jun 24, 2024
6 tasks
@mmmarcos mmmarcos removed this from the Q3 2024 milestone Jun 24, 2024
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

No branches or pull requests

3 participants