Skip to content

Commit

Permalink
refactor: address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
BorysTheDev committed Dec 26, 2024
1 parent 1cebba5 commit fe1f4ef
Showing 1 changed file with 2 additions and 18 deletions.
20 changes: 2 additions & 18 deletions src/server/dragonfly_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> 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<std::string> 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)
Expand Down

0 comments on commit fe1f4ef

Please sign in to comment.