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 ea10bed
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 19 deletions.
21 changes: 2 additions & 19 deletions src/server/dragonfly_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ extern "C" {
#include <absl/strings/ascii.h>
#include <absl/strings/charconv.h>
#include <absl/strings/str_join.h>
#include <absl/strings/str_split.h>
#include <absl/strings/strip.h>
#include <fast_float/fast_float.h>
#include <gmock/gmock.h>
Expand Down Expand Up @@ -808,30 +807,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
1 change: 1 addition & 0 deletions tests/dragonfly/memory_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from .instance import DflyInstance, DflyInstanceFactory


@pytest.mark.slow
@pytest.mark.opt_only
@pytest.mark.parametrize(
"type, keys, val_size, elements",
Expand Down

0 comments on commit ea10bed

Please sign in to comment.