mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 10:25:47 +02:00
fix(test): Fix failing tests. (#1612)
Solution is to wait until snapshot is ready, instead of hard coding a sleep schedule. Also don't reuse files by other test cases.
This commit is contained in:
parent
3a4b3c97c8
commit
3b0bd212f4
1 changed files with 12 additions and 4 deletions
|
@ -2,6 +2,7 @@ import time
|
||||||
import pytest
|
import pytest
|
||||||
import os
|
import os
|
||||||
import glob
|
import glob
|
||||||
|
import asyncio
|
||||||
from redis import asyncio as aioredis
|
from redis import asyncio as aioredis
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
@ -26,6 +27,13 @@ class SnapshotTestBase:
|
||||||
assert len(possible_mains) == 1, possible_mains
|
assert len(possible_mains) == 1, possible_mains
|
||||||
return possible_mains[0]
|
return possible_mains[0]
|
||||||
|
|
||||||
|
async def wait_for_save(self, pattern):
|
||||||
|
while True:
|
||||||
|
files = glob.glob(str(self.tmp_dir.absolute()) + "/" + pattern)
|
||||||
|
if not len(files) == 0:
|
||||||
|
break
|
||||||
|
await asyncio.sleep(1)
|
||||||
|
|
||||||
|
|
||||||
@dfly_args({**BASIC_ARGS, "dbfilename": "test-rdb-{{timestamp}}"})
|
@dfly_args({**BASIC_ARGS, "dbfilename": "test-rdb-{{timestamp}}"})
|
||||||
class TestRdbSnapshot(SnapshotTestBase):
|
class TestRdbSnapshot(SnapshotTestBase):
|
||||||
|
@ -155,13 +163,13 @@ class TestPeriodicSnapshot(SnapshotTestBase):
|
||||||
)
|
)
|
||||||
await seeder.run(target_deviation=0.5)
|
await seeder.run(target_deviation=0.5)
|
||||||
|
|
||||||
time.sleep(60)
|
await super().wait_for_save("test-periodic-summary.dfs")
|
||||||
|
|
||||||
assert super().get_main_file("test-periodic-summary.dfs")
|
assert super().get_main_file("test-periodic-summary.dfs")
|
||||||
|
|
||||||
|
|
||||||
# save every 2 seconds
|
# save every 2 seconds
|
||||||
@dfly_args({**BASIC_ARGS, "dbfilename": "test-periodic", "snapshot_cron": "*/2 * * * * *"})
|
@dfly_args({**BASIC_ARGS, "dbfilename": "test-cron", "snapshot_cron": "*/2 * * * * *"})
|
||||||
class TestCronPeriodicSnapshot(SnapshotTestBase):
|
class TestCronPeriodicSnapshot(SnapshotTestBase):
|
||||||
"""Test periodic snapshotting"""
|
"""Test periodic snapshotting"""
|
||||||
|
|
||||||
|
@ -176,9 +184,9 @@ class TestCronPeriodicSnapshot(SnapshotTestBase):
|
||||||
)
|
)
|
||||||
await seeder.run(target_deviation=0.5)
|
await seeder.run(target_deviation=0.5)
|
||||||
|
|
||||||
time.sleep(60)
|
await super().wait_for_save("test-cron-summary.dfs")
|
||||||
|
|
||||||
assert super().get_main_file("test-periodic-summary.dfs")
|
assert super().get_main_file("test-cron-summary.dfs")
|
||||||
|
|
||||||
|
|
||||||
@dfly_args({**BASIC_ARGS})
|
@dfly_args({**BASIC_ARGS})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue