Skip to content

Commit

Permalink
test: add test_infomemory_for_stream
Browse files Browse the repository at this point in the history
  • Loading branch information
BorysTheDev committed Dec 23, 2024
1 parent 9ca36f4 commit 0e9ab52
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/dragonfly/snapshot_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,3 +639,34 @@ async def check_flag(key, flag):

await check_flag("key1", 2)
await check_flag("key2", 123456)


@pytest.mark.parametrize("format", FILE_FORMATS)
@dfly_args({**BASIC_ARGS})
async def test_infomemory_for_stream(df_factory, format: str):
dbfilename = f"dump_{tmp_file_name()}"
instance = df_factory.create(dbfilename=dbfilename)
instance.start()
async_client = instance.client()
await async_client.execute_command("XADD test 1 var val1")
await async_client.execute_command("XADD test 2 var val2")

async def assert_stream_mem_not_zero():
res = await async_client.execute_command("INFO MEMORY")

for line in res.splitlines():
if line.startswith("type_used_memory_stream"):
_, v = line.split(":")
assert int(v) != 0

await assert_stream_mem_not_zero()

await async_client.execute_command("SAVE", format)

await async_client.execute_command(
"DFLY",
"LOAD",
f"{dbfilename}.rdb" if format == "RDB" else f"{dbfilename}-summary.dfs",
)

await assert_stream_mem_not_zero()

0 comments on commit 0e9ab52

Please sign in to comment.