From cf2ba8eb842f132dfd6b0fe2436c5b1b8334e64d Mon Sep 17 00:00:00 2001 From: adiholden <117041239+adiholden@users.noreply.github.com> Date: Tue, 29 Nov 2022 15:14:43 +0200 Subject: [PATCH] feat(rdb save): add unit test to save df with all compression levels (#517) feat(rdb save): add unit test to save df with all comression levels Signed-off-by: adi_holden --- src/server/rdb_save.cc | 2 +- src/server/rdb_test.cc | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/server/rdb_save.cc b/src/server/rdb_save.cc index ba0a1a9c2..864549720 100644 --- a/src/server/rdb_save.cc +++ b/src/server/rdb_save.cc @@ -952,7 +952,7 @@ RdbSaver::RdbSaver(::io::Sink* sink, SaveMode save_mode, bool align_writes) { } break; } - + VLOG(1) << "Rdb save using compression mode:" << uint32_t(compression_mode_); impl_.reset(new Impl(align_writes, producer_count, compression_mode_, sink)); save_mode_ = save_mode; } diff --git a/src/server/rdb_test.cc b/src/server/rdb_test.cc index 2c5d4fd1d..ff17cb499 100644 --- a/src/server/rdb_test.cc +++ b/src/server/rdb_test.cc @@ -30,6 +30,7 @@ using absl::StrCat; ABSL_DECLARE_FLAG(int32, list_compress_depth); ABSL_DECLARE_FLAG(int32, list_max_listpack_size); +ABSL_DECLARE_FLAG(int, compression_mode); namespace dfly { @@ -144,6 +145,20 @@ TEST_F(RdbTest, Stream) { Run({"save"}); } +TEST_F(RdbTest, ComressionModeSaveDragonflyAndReload) { + Run({"debug", "populate", "500000"}); + + for (int i = 0; i <= 2; ++i) { + SetFlag(&FLAGS_compression_mode, i); + RespExpr resp = Run({"save", "df"}); + ASSERT_EQ(resp, "OK"); + + auto save_info = service_->server_family().GetLastSaveInfo(); + resp = Run({"debug", "load", save_info->file_name}); + ASSERT_EQ(resp, "OK"); + } +} + TEST_F(RdbTest, Reload) { absl::FlagSaver fs;