mirror of https://github.com/facebook/rocksdb.git
Move down the time consuming tests in table_test
Summary: it helps us to better check the tests we really care. Test Plan: make
This commit is contained in:
parent
8a46ecd357
commit
551ecfa416
|
@ -783,80 +783,6 @@ TEST(Harness, SimpleSpecialKey) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(Harness, Randomized) {
|
|
||||||
std::vector<TestArgs> args = Generate_Arg_List();
|
|
||||||
for (unsigned int i = 0; i < args.size(); i++) {
|
|
||||||
Init(args[i]);
|
|
||||||
Random rnd(test::RandomSeed() + 5);
|
|
||||||
for (int num_entries = 0; num_entries < 2000;
|
|
||||||
num_entries += (num_entries < 50 ? 1 : 200)) {
|
|
||||||
if ((num_entries % 10) == 0) {
|
|
||||||
fprintf(stderr, "case %d of %d: num_entries = %d\n",
|
|
||||||
(i + 1), int(args.size()), num_entries);
|
|
||||||
}
|
|
||||||
for (int e = 0; e < num_entries; e++) {
|
|
||||||
std::string v;
|
|
||||||
Add(test::RandomKey(&rnd, rnd.Skewed(4)),
|
|
||||||
test::RandomString(&rnd, rnd.Skewed(5), &v).ToString());
|
|
||||||
}
|
|
||||||
Test(&rnd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(Harness, RandomizedLongDB) {
|
|
||||||
Random rnd(test::RandomSeed());
|
|
||||||
TestArgs args = { DB_TEST, false, 16, kNoCompression };
|
|
||||||
Init(args);
|
|
||||||
int num_entries = 100000;
|
|
||||||
for (int e = 0; e < num_entries; e++) {
|
|
||||||
std::string v;
|
|
||||||
Add(test::RandomKey(&rnd, rnd.Skewed(4)),
|
|
||||||
test::RandomString(&rnd, rnd.Skewed(5), &v).ToString());
|
|
||||||
}
|
|
||||||
Test(&rnd);
|
|
||||||
|
|
||||||
// We must have created enough data to force merging
|
|
||||||
int files = 0;
|
|
||||||
for (int level = 0; level < db()->NumberLevels(); level++) {
|
|
||||||
std::string value;
|
|
||||||
char name[100];
|
|
||||||
snprintf(name, sizeof(name), "rocksdb.num-files-at-level%d", level);
|
|
||||||
ASSERT_TRUE(db()->GetProperty(name, &value));
|
|
||||||
files += atoi(value.c_str());
|
|
||||||
}
|
|
||||||
ASSERT_GT(files, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
class MemTableTest { };
|
|
||||||
|
|
||||||
TEST(MemTableTest, Simple) {
|
|
||||||
InternalKeyComparator cmp(BytewiseComparator());
|
|
||||||
auto table_factory = std::make_shared<SkipListFactory>();
|
|
||||||
MemTable* memtable = new MemTable(cmp, table_factory);
|
|
||||||
memtable->Ref();
|
|
||||||
WriteBatch batch;
|
|
||||||
Options options = GetDefaultOptions();
|
|
||||||
WriteBatchInternal::SetSequence(&batch, 100);
|
|
||||||
batch.Put(std::string("k1"), std::string("v1"));
|
|
||||||
batch.Put(std::string("k2"), std::string("v2"));
|
|
||||||
batch.Put(std::string("k3"), std::string("v3"));
|
|
||||||
batch.Put(std::string("largekey"), std::string("vlarge"));
|
|
||||||
ASSERT_TRUE(WriteBatchInternal::InsertInto(&batch, memtable, &options).ok());
|
|
||||||
|
|
||||||
Iterator* iter = memtable->NewIterator();
|
|
||||||
iter->SeekToFirst();
|
|
||||||
while (iter->Valid()) {
|
|
||||||
fprintf(stderr, "key: '%s' -> '%s'\n",
|
|
||||||
iter->key().ToString().c_str(),
|
|
||||||
iter->value().ToString().c_str());
|
|
||||||
iter->Next();
|
|
||||||
}
|
|
||||||
|
|
||||||
delete iter;
|
|
||||||
memtable->Unref();
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool Between(uint64_t val, uint64_t low, uint64_t high) {
|
static bool Between(uint64_t val, uint64_t low, uint64_t high) {
|
||||||
bool result = (val >= low) && (val <= high);
|
bool result = (val >= low) && (val <= high);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
|
@ -1117,6 +1043,81 @@ TEST(TableTest, BlockCacheLeak) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(Harness, Randomized) {
|
||||||
|
std::vector<TestArgs> args = Generate_Arg_List();
|
||||||
|
for (unsigned int i = 0; i < args.size(); i++) {
|
||||||
|
Init(args[i]);
|
||||||
|
Random rnd(test::RandomSeed() + 5);
|
||||||
|
for (int num_entries = 0; num_entries < 2000;
|
||||||
|
num_entries += (num_entries < 50 ? 1 : 200)) {
|
||||||
|
if ((num_entries % 10) == 0) {
|
||||||
|
fprintf(stderr, "case %d of %d: num_entries = %d\n",
|
||||||
|
(i + 1), int(args.size()), num_entries);
|
||||||
|
}
|
||||||
|
for (int e = 0; e < num_entries; e++) {
|
||||||
|
std::string v;
|
||||||
|
Add(test::RandomKey(&rnd, rnd.Skewed(4)),
|
||||||
|
test::RandomString(&rnd, rnd.Skewed(5), &v).ToString());
|
||||||
|
}
|
||||||
|
Test(&rnd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(Harness, RandomizedLongDB) {
|
||||||
|
Random rnd(test::RandomSeed());
|
||||||
|
TestArgs args = { DB_TEST, false, 16, kNoCompression };
|
||||||
|
Init(args);
|
||||||
|
int num_entries = 100000;
|
||||||
|
for (int e = 0; e < num_entries; e++) {
|
||||||
|
std::string v;
|
||||||
|
Add(test::RandomKey(&rnd, rnd.Skewed(4)),
|
||||||
|
test::RandomString(&rnd, rnd.Skewed(5), &v).ToString());
|
||||||
|
}
|
||||||
|
Test(&rnd);
|
||||||
|
|
||||||
|
// We must have created enough data to force merging
|
||||||
|
int files = 0;
|
||||||
|
for (int level = 0; level < db()->NumberLevels(); level++) {
|
||||||
|
std::string value;
|
||||||
|
char name[100];
|
||||||
|
snprintf(name, sizeof(name), "rocksdb.num-files-at-level%d", level);
|
||||||
|
ASSERT_TRUE(db()->GetProperty(name, &value));
|
||||||
|
files += atoi(value.c_str());
|
||||||
|
}
|
||||||
|
ASSERT_GT(files, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
class MemTableTest { };
|
||||||
|
|
||||||
|
TEST(MemTableTest, Simple) {
|
||||||
|
InternalKeyComparator cmp(BytewiseComparator());
|
||||||
|
auto table_factory = std::make_shared<SkipListFactory>();
|
||||||
|
MemTable* memtable = new MemTable(cmp, table_factory);
|
||||||
|
memtable->Ref();
|
||||||
|
WriteBatch batch;
|
||||||
|
Options options = GetDefaultOptions();
|
||||||
|
WriteBatchInternal::SetSequence(&batch, 100);
|
||||||
|
batch.Put(std::string("k1"), std::string("v1"));
|
||||||
|
batch.Put(std::string("k2"), std::string("v2"));
|
||||||
|
batch.Put(std::string("k3"), std::string("v3"));
|
||||||
|
batch.Put(std::string("largekey"), std::string("vlarge"));
|
||||||
|
ASSERT_TRUE(WriteBatchInternal::InsertInto(&batch, memtable, &options).ok());
|
||||||
|
|
||||||
|
Iterator* iter = memtable->NewIterator();
|
||||||
|
iter->SeekToFirst();
|
||||||
|
while (iter->Valid()) {
|
||||||
|
fprintf(stderr, "key: '%s' -> '%s'\n",
|
||||||
|
iter->key().ToString().c_str(),
|
||||||
|
iter->value().ToString().c_str());
|
||||||
|
iter->Next();
|
||||||
|
}
|
||||||
|
|
||||||
|
delete iter;
|
||||||
|
memtable->Unref();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace rocksdb
|
} // namespace rocksdb
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
|
|
Loading…
Reference in New Issue