rotation: second-precision rotated filenames, int-days retention
- Rotated filename timestamp is now ISO basic at second precision (20260902T143000Z); the exact cutoff ts remains inside the files. - Kanta(retention=N) accepts a plain int as number of days.
This commit is contained in:
+16
-2
@@ -77,7 +77,7 @@ async def test_rotation_splits_history(tmp_path, format_config):
|
||||
|
||||
# Rotated file holds exactly the dropped history, ending at the last
|
||||
# dropped record whose ts matches the filename.
|
||||
stamp = (T0 - 40 * DAY).strftime("%Y%m%dT%H%M%S.%fZ")
|
||||
stamp = (T0 - 40 * DAY).strftime("%Y%m%dT%H%M%SZ")
|
||||
assert rotated[0].name == f"data@{stamp}.kantadb"
|
||||
rrecords = read_all(rotated[0], format_config)
|
||||
assert [r.a for r in rrecords] == ["bootstrap", "day-40"]
|
||||
@@ -181,10 +181,24 @@ async def test_rotated_naming_normalizes_extension(tmp_path, format_config, name
|
||||
async with kanta:
|
||||
pass
|
||||
|
||||
stamp = (T0 - 40 * DAY).strftime("%Y%m%dT%H%M%S.%fZ")
|
||||
stamp = (T0 - 40 * DAY).strftime("%Y%m%dT%H%M%SZ")
|
||||
assert (tmp_path / f"data@{stamp}.kantadb").exists()
|
||||
|
||||
|
||||
async def test_retention_accepts_int_days(tmp_path, format_config):
|
||||
path = tmp_path / "data.kantadb"
|
||||
await write_history(path, format_config, days=[-40, -5])
|
||||
|
||||
cell = [T0]
|
||||
kanta = make_kanta(path, Data, format_config, retention=30)
|
||||
kanta.clock(make_clock(cell))
|
||||
async with kanta:
|
||||
assert kanta.data.counter == 2
|
||||
|
||||
assert len(rotated_files(path)) == 1
|
||||
assert [c.a for c in read_changes(path, format_config)] == ["day-5"]
|
||||
|
||||
|
||||
async def test_rotation_disabled_by_default(tmp_path, format_config):
|
||||
path = tmp_path / "data.kantadb"
|
||||
await write_history(path, format_config, days=[-40, -5])
|
||||
|
||||
Reference in New Issue
Block a user