mirror of
https://github.com/facebook/sapling.git
synced 2024-10-08 07:49:11 +03:00
Test FUSE and HgBackingStore stat collection
Summary: I am refactoring edenfs' EdenStats class. In doing so, I accidentally removed a call to `aggregate`, causing `flushStatsNow` to not expose accurate counters. This wasn't caught by any existing tests, only by manual testing. Add some tests to prevent FUSE and HgBackingStore statistics collection from completely regressing. Reviewed By: simpkins Differential Revision: D15274275 fbshipit-source-id: c8a9c9848dd60aee7f252a93f10ddce6d7560799
This commit is contained in:
parent
9e6a39e951
commit
1775680391
@ -14,6 +14,63 @@ from .lib import testcase
|
||||
from .lib.hgrepo import HgRepository
|
||||
|
||||
|
||||
class FUSEStatsTest(testcase.EdenRepoTest):
|
||||
def test_reading_committed_file_bumps_read_counter(self) -> None:
|
||||
counters_before = self.get_counters()
|
||||
path = Path(self.mount) / "file"
|
||||
path.read_bytes()
|
||||
counters_after = self.get_counters()
|
||||
|
||||
self.assertGreater(
|
||||
counters_after.get("fuse.read_us.count", 0),
|
||||
counters_before.get("fuse.read_us.count", 0),
|
||||
f"Reading {path} should increment fuse.read_us.count",
|
||||
)
|
||||
|
||||
def test_writing_untracked_file_bumps_write_counter(self) -> None:
|
||||
counters_before = self.get_counters()
|
||||
path = Path(self.mount) / "new_file"
|
||||
path.write_bytes(b"hello")
|
||||
counters_after = self.get_counters()
|
||||
|
||||
self.assertGreater(
|
||||
counters_after.get("fuse.write_us.count", 0),
|
||||
counters_before.get("fuse.write_us.count", 0),
|
||||
f"Writing to {path} should increment fuse.write_us.count",
|
||||
)
|
||||
|
||||
def create_repo(self, name: str) -> HgRepository:
|
||||
return self.create_hg_repo(name)
|
||||
|
||||
def populate_repo(self) -> None:
|
||||
self.repo.write_file("file", "hello world!\n")
|
||||
self.repo.commit("Initial commit.")
|
||||
|
||||
|
||||
class HgBackingStoreStatsTest(testcase.EdenRepoTest):
|
||||
def test_reading_file_gets_file_from_hg(self) -> None:
|
||||
counters_before = self.get_counters()
|
||||
path = Path(self.mount) / "dir" / "subdir" / "file"
|
||||
path.read_bytes()
|
||||
counters_after = self.get_counters()
|
||||
|
||||
self.assertEqual(
|
||||
counters_after.get("store.hg.get_file.count", 0),
|
||||
counters_before.get("store.hg.get_file.count", 0) + 1,
|
||||
f"Reading {path} should increment store.hg.get_file.count",
|
||||
)
|
||||
|
||||
def create_repo(self, name: str) -> HgRepository:
|
||||
return self.create_hg_repo(name)
|
||||
|
||||
def populate_repo(self) -> None:
|
||||
# This file evades EdenFS' automatic prefetching by being two levels
|
||||
# inside the root.
|
||||
self.repo.write_file("dir/subdir/file", "hello world!\n")
|
||||
|
||||
self.repo.commit("Initial commit.")
|
||||
|
||||
|
||||
class HgImporterStatsTest(testcase.EdenRepoTest):
|
||||
def test_reading_file_imports_blob(self) -> None:
|
||||
counters_before = self.get_counters()
|
||||
|
Loading…
Reference in New Issue
Block a user