Exemplo n.º 1
0
TEST(APC, SampleEntries) {
  auto store = new_store();
  // Empty store gives an empty sample.
  auto entries = store->sampleEntriesInfo(10);
  EXPECT_EQ(entries.size(), 0);
  // Single-element store results in repetition.
  store->set(s_foo, s_value1, 1500);
  for (uint32_t count = 0; count <= 10; ++count) {
    entries = store->sampleEntriesInfo(count);
    EXPECT_EQ(entries.size(), count);
    for (const auto& entry : entries) {
      EXPECT_STREQ(entry.key.c_str(), "foo");
    }
  }
  // More entries.
  store->set(s_key, s_value1, 1500);
  store->set(s_key2, s_value2, 1500);
  for (uint32_t count = 0; count <= 10; ++count) {
    entries = store->sampleEntriesInfo(count);
    EXPECT_EQ(entries.size(), count);
    for (const auto& entry : entries) {
      EXPECT_TRUE(entry.key == std::string("foo") ||
                  entry.key == std::string("key") ||
                  entry.key == std::string("key2"));
    }
  }
}
Exemplo n.º 2
0
void ConcurrentTableSharedStore::dumpRandomKeys(std::ostream& out,
                                                uint32_t count) {
  dumpEntriesInfo(sampleEntriesInfo(count), out);
}