From fe1f4efeb4bacaa90b724ab962a7a6d85f346370 Mon Sep 17 00:00:00 2001 From: Borys Date: Thu, 26 Dec 2024 14:14:00 +0200 Subject: [PATCH] refactor: address comments --- src/server/dragonfly_test.cc | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/src/server/dragonfly_test.cc b/src/server/dragonfly_test.cc index 6120c5045f17..cf9a2f31ecf4 100644 --- a/src/server/dragonfly_test.cc +++ b/src/server/dragonfly_test.cc @@ -808,30 +808,14 @@ TEST_F(DflyEngineTest, StreamMemInfo) { Run({"XADD", "test", std::to_string(i), "var", "val" + std::to_string(i)}); } - auto resp = Run({"info", "memory"}); - auto str_resp = absl::StrSplit(resp.GetString(), "\r\n"); - int64_t stream_mem_first; - for (const auto& s : str_resp) { - if (absl::StartsWith(s, "type_used_memory_stream")) { - std::vector stream_mem = absl::StrSplit(s, ":"); - stream_mem_first = std::stol(stream_mem[1]); - } - } + int64_t stream_mem_first = GetMetrics().db_stats[0].memory_usage_by_type[OBJ_STREAM]; EXPECT_GT(stream_mem_first, 0); auto dump = Run({"dump", "test"}); Run({"del", "test"}); Run({"restore", "test", "0", facade::ToSV(dump.GetBuf())}); - resp = Run({"info", "memory"}); - auto str_resp1 = absl::StrSplit(resp.GetString(), "\r\n"); - int64_t stream_mem_second; - for (const auto& s : str_resp1) { - if (absl::StartsWith(s, "type_used_memory_stream")) { - std::vector stream_mem = absl::StrSplit(s, ":"); - stream_mem_second = std::stol(stream_mem[1]); - } - } + int64_t stream_mem_second = GetMetrics().db_stats[0].memory_usage_by_type[OBJ_STREAM]; // stream_mem_first != stream_mem_second due to a preallocation in XADD command (see // STREAM_LISTPACK_MAX_PRE_ALLOCATE)