Skip to content

Commit

Permalink
refactor: small tests fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Stepan Bagritsevich <stefan@dragonflydb.io>
  • Loading branch information
BagritsevichStepan committed Nov 22, 2024
1 parent be1e525 commit 86d39c6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/server/string_family_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ TEST_F(StringFamilyTest, MGetSet) {
}

TEST_F(StringFamilyTest, MGetCachingModeBug2276) {
max_memory_limit = 3000000; // 3mb

absl::FlagSaver fs;
SetTestFlag("cache_mode", "true");
ResetService();
Expand Down
12 changes: 6 additions & 6 deletions tests/dragonfly/memory_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ async def test_rss_oom_ratio(df_factory: DflyInstanceFactory, admin_port):
}
)
async def test_cache_eviction_with_rss_deny_oom(
client: aioredis.Redis,
async_client: aioredis.Redis,
df_server: DflyInstance,
):
"""
Expand All @@ -136,12 +136,12 @@ async def test_cache_eviction_with_rss_deny_oom(
num_keys_second_fill = second_fill_size // key_size

# Step 1: Fill 15% of max memory using DEBUG POPULATE
await client.execute_command("DEBUG", "POPULATE", num_keys_first_fill, "key", key_size)
await async_client.execute_command("DEBUG", "POPULATE", num_keys_first_fill, "key", key_size)

await asyncio.sleep(1) # Wait for RSS heartbeat

# Get RSS memory before creating new connections
info_before_connections = await client.info("memory")
info_before_connections = await async_client.info("memory")
rss_before_connections = info_before_connections["used_memory_rss"]
logging.info(f"RSS after creating temporary large keys: {rss_before_connections}")

Expand All @@ -159,19 +159,19 @@ async def test_cache_eviction_with_rss_deny_oom(
await asyncio.sleep(1) # Wait for RSS heartbeat update

# Get RSS memory after creating new connections
info_after_connections = await client.info("memory")
info_after_connections = await async_client.info("memory")
rss_after_connections = info_after_connections["used_memory_rss"]
logging.info(f"RSS after creating new connections: {rss_after_connections}")

assert rss_after_connections > rss_before_connections, "RSS memory should have increased."

# Step 3: Attempt to insert another 30% of data
await client.execute_command("DEBUG", "POPULATE", num_keys_second_fill, "key2", key_size)
await async_client.execute_command("DEBUG", "POPULATE", num_keys_second_fill, "key2", key_size)

await asyncio.sleep(1) # Wait for RSS heartbeat

# Step 4: Check that eviction has occurred
info = await client.info("stats")
info = await async_client.info("stats")
assert info.get("evicted_keys", 0) > 0, "Eviction should have occurred due to memory pressure."

for conn in connections:
Expand Down

0 comments on commit 86d39c6

Please sign in to comment.