Skip to content

Commit

Permalink
test both types of file
Browse files Browse the repository at this point in the history
  • Loading branch information
incognitojam committed Jan 9, 2025
1 parent 66840bc commit d8ccc73
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions system/loggerd/tests/test_deleter.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,11 @@ def assertDeleteOrder(self, f_paths: Sequence[Path], timeout: int = 5) -> None:
def test_delete_order(self):
self.assertDeleteOrder([
self.make_file_with_data(self.seg_format.format(0), self.f_type),
self.make_file_with_data(self.seg_format.format(0), self.q_type),
self.make_file_with_data(self.seg_format.format(1), self.f_type),
self.make_file_with_data(self.seg_format.format(1), self.q_type),
self.make_file_with_data(self.seg_format2.format(0), self.f_type),
self.make_file_with_data(self.seg_format2.format(0), self.q_type),
])

def test_delete_oldest_training_data_over_limit_before_dashcam(self):
Expand Down Expand Up @@ -114,19 +117,19 @@ def test_delete_last(self):
])

def test_no_delete_when_available_space(self):
f_path = self.make_file_with_data(self.seg_dir, self.f_type)
f_paths = [self.make_file_with_data(self.seg_dir, f_type) for f_type in (self.f_type, self.q_type)]

block_size = 4096
available = (10 * 1024 * 1024 * 1024) / block_size # 10GB free
self.fake_stats = Stats(f_bavail=available, f_blocks=10, f_frsize=block_size)

self.start_thread()
start_time = time.monotonic()
while f_path.exists() and time.monotonic() - start_time < 2:
while all(f_path.exists() for f_path in f_paths) and time.monotonic() - start_time < 2:
time.sleep(0.01)
self.join_thread()

assert f_path.exists(), "File deleted with available space"
assert all(f_path.exists() for f_path in f_paths), "File deleted with available space"

def test_no_delete_with_lock_file(self):
f_path = self.make_file_with_data(self.seg_dir, self.f_type, lock=True)
Expand Down

0 comments on commit d8ccc73

Please sign in to comment.