chore: Add tiered_storage_test. (#613)

1. Support tiered deletion.
2. Add notion of tiered entity in "DEBUG OBJECT" output.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
Roman Gershman 2022-12-28 10:37:55 +02:00 committed by GitHub
parent e39d266abe
commit 63b83c5b99
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 225 additions and 62 deletions

View file

@ -17,6 +17,7 @@ extern "C" {
#include "base/logging.h"
#include "facade/facade_test.h" // needed to find operator== for RespExpr.
#include "io/file.h"
#include "io/file_util.h"
#include "server/engine_shard_set.h"
#include "server/rdb_load.h"
#include "server/test_utils.h"
@ -31,15 +32,32 @@ using absl::StrCat;
ABSL_DECLARE_FLAG(int32, list_compress_depth);
ABSL_DECLARE_FLAG(int32, list_max_listpack_size);
ABSL_DECLARE_FLAG(int, compression_mode);
ABSL_DECLARE_FLAG(string, dbfilename);
namespace dfly {
class RdbTest : public BaseFamilyTest {
protected:
protected:
static void SetUpTestSuite();
void TearDown();
io::FileSource GetSource(string name);
};
void RdbTest::SetUpTestSuite() {
BaseFamilyTest::SetUpTestSuite();
SetFlag(&FLAGS_dbfilename, "rdbtestdump");
}
void RdbTest::TearDown() {
auto rdb_files = io::StatFiles("rdbtestdump*");
CHECK(rdb_files);
for (const auto& fl : *rdb_files) {
unlink(fl.name.c_str());
}
BaseFamilyTest::TearDown();
}
inline const uint8_t* to_byte(const void* s) {
return reinterpret_cast<const uint8_t*>(s);
}
@ -146,7 +164,7 @@ TEST_F(RdbTest, Stream) {
}
TEST_F(RdbTest, ComressionModeSaveDragonflyAndReload) {
Run({"debug", "populate", "500000"});
Run({"debug", "populate", "50000"});
for (int i = 0; i <= 3; ++i) {
SetFlag(&FLAGS_compression_mode, i);
@ -156,7 +174,7 @@ TEST_F(RdbTest, ComressionModeSaveDragonflyAndReload) {
auto save_info = service_->server_family().GetLastSaveInfo();
resp = Run({"debug", "load", save_info->file_name});
ASSERT_EQ(resp, "OK");
ASSERT_EQ(500000, CheckedInt({"dbsize"}));
ASSERT_EQ(50000, CheckedInt({"dbsize"}));
}
}
@ -240,7 +258,8 @@ TEST_F(RdbTest, SaveManyDbs) {
Run({"select", "1"});
Run({"debug", "populate", "10000"});
});
auto metrics = service_->server_family().GetMetrics();
auto metrics = GetMetrics();
ASSERT_EQ(2, metrics.db.size());
EXPECT_EQ(50000, metrics.db[0].key_count);
EXPECT_EQ(10000, metrics.db[1].key_count);
@ -272,7 +291,7 @@ TEST_F(RdbTest, SaveManyDbs) {
auto resp = Run({"debug", "reload", "NOSAVE"});
EXPECT_EQ(resp, "OK");
metrics = service_->server_family().GetMetrics();
metrics = GetMetrics();
ASSERT_EQ(2, metrics.db.size());
EXPECT_EQ(50000, metrics.db[0].key_count);
EXPECT_EQ(10000, metrics.db[1].key_count);