Browse Source

modify test

main
李畅 1 month ago
parent
commit
e5aaef2f4c
1 changed files with 35 additions and 35 deletions
  1. +35
    -35
      test/ttl_test.cc

+ 35
- 35
test/ttl_test.cc View File

@ -40,41 +40,41 @@ void GetData(DB *db, int size = (1 << 30)) {
}
}
// TEST(TestTTL, ReadTTL) {
// DB *db;
// if(OpenDB("testdb", &db).ok() == false) {
// std::cerr << "open db failed" << std::endl;
// abort();
// }
// uint64_t ttl = 20;
// InsertData(db, ttl);
// ReadOptions readOptions;
// Status status;
// int key_num = data_size / value_size;
// srand(0);
// for (int i = 0; i < 100; i++) {
// int key_ = rand() % key_num+1;
// std::string key = std::to_string(key_);
// std::string value;
// status = db->Get(readOptions, key, &value);
// ASSERT_TRUE(status.ok());
// }
// Env::Default()->SleepForMicroseconds(ttl * 1000000);
// for (int i = 0; i < 100; i++) {
// int key_ = rand() % key_num+1;
// std::string key = std::to_string(key_);
// std::string value;
// status = db->Get(readOptions, key, &value);
// ASSERT_FALSE(status.ok());
// }
// delete db;
// }
TEST(TestTTL, ReadTTL) {
DB *db;
if(OpenDB("testdb", &db).ok() == false) {
std::cerr << "open db failed" << std::endl;
abort();
}
uint64_t ttl = 20;
InsertData(db, ttl);
ReadOptions readOptions;
Status status;
int key_num = data_size / value_size;
srand(0);
for (int i = 0; i < 100; i++) {
int key_ = rand() % key_num+1;
std::string key = std::to_string(key_);
std::string value;
status = db->Get(readOptions, key, &value);
ASSERT_TRUE(status.ok());
}
Env::Default()->SleepForMicroseconds(ttl * 1000000);
for (int i = 0; i < 100; i++) {
int key_ = rand() % key_num+1;
std::string key = std::to_string(key_);
std::string value;
status = db->Get(readOptions, key, &value);
ASSERT_FALSE(status.ok());
}
delete db;
}
TEST(TestTTL, CompactionTTL) {
DB *db;

Loading…
Cancel
Save