Skip to content

Commit

Permalink
chore(facade): Fix bad new IO glue (#3940)
Browse files Browse the repository at this point in the history
* chore(facade): Fix bad new IO glue

---------

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
  • Loading branch information
dranikpg authored Oct 18, 2024
1 parent 14220a6 commit 32a31cf
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/facade/reply_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ class RedisReplyBuilder2Base : public SinkReplyBuilder2, public RedisReplyBuilde
}

void StartAggregate() override {
aggregators_.emplace_back(SinkReplyBuilder2::ReplyAggregator(this));
aggregators_.emplace_back(this);
}

void StopAggregate() override {
Expand Down
53 changes: 53 additions & 0 deletions tests/dragonfly/connection_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,59 @@ async def test_keyspace_events_config_set(async_client: aioredis.Redis):
pass


async def test_reply_count(async_client: aioredis.Redis):
"""Make sure reply aggregations reduce reply counts for common cases"""

async def get_reply_count():
return (await async_client.info("STATS"))["reply_count"]

async def measure(aw):
before = await get_reply_count()
await aw
return await get_reply_count() - before - 1

base = await get_reply_count()
info_diff = await get_reply_count() - base
assert info_diff == 1

# Warm client buffer up
await async_client.lpush("warmup", *(i for i in range(500)))
await async_client.lrange("warmup", 0, -1)

# Integer list
await async_client.lpush("list-1", *(i for i in range(100)))
assert await measure(async_client.lrange("list-1", 0, -1)) == 1

# Integer set
await async_client.sadd("set-1", *(i for i in range(100)))
assert await measure(async_client.smembers("set-1")) == 1

# Sorted sets
await async_client.zadd("zset-1", mapping={str(i): i for i in range(50)})
assert await measure(async_client.zrange("zset-1", 0, -1, withscores=True)) == 1

# Exec call
e = async_client.pipeline(transaction=True)
for _ in range(100):
e.incr("num-1")
assert await measure(e.execute()) == 2 # OK + Response

# Just pipeline
p = async_client.pipeline(transaction=False)
for _ in range(100):
p.incr("num-1")
assert await measure(p.execute()) == 1

# Script result
assert await measure(async_client.eval('return {1,2,{3,4},5,6,7,8,"nine"}', 0)) == 1

# Search results
await async_client.execute_command("FT.CREATE i1 SCHEMA name text")
for i in range(50):
await async_client.hset(f"key-{i}", "name", f"name number {i}")
assert await measure(async_client.ft("i1").search("*")) == 1


async def test_big_command(df_server, size=8 * 1024):
reader, writer = await asyncio.open_connection("127.0.0.1", df_server.port)

Expand Down

0 comments on commit 32a31cf

Please sign in to comment.