Skip to content

Commit

Permalink
test/store_test.cc: verify collection_list_partial results are sorted
Browse files Browse the repository at this point in the history
Synthetic test now also varies snapshots and uses a small variety of
hashes.

Signed-off-by: Samuel Just <sam.just@inktank.com>
  • Loading branch information
Samuel Just committed Jul 20, 2012
1 parent adc9b91 commit 9e207aa
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/test/filestore/store_test.cc
Expand Up @@ -50,6 +50,17 @@ class StoreTest : public ::testing::Test {
}
};

bool sorted(const vector<hobject_t> &in) {
hobject_t start;
for (vector<hobject_t>::const_iterator i = in.begin();
i != in.end();
++i) {
if (start > *i) return false;
start = *i;
}
return true;
}

TEST_F(StoreTest, SimpleColTest) {
coll_t cid = coll_t("initial");
int r = 0;
Expand Down Expand Up @@ -194,9 +205,10 @@ TEST_F(StoreTest, ManyObjectTest) {
r = store->collection_list_partial(cid, start,
50,
60,
CEPH_NOSNAP,
0,
&objects,
&next);
ASSERT_TRUE(sorted(objects));
ASSERT_EQ(r, 0);
listed.insert(objects.begin(), objects.end());
if (objects.size() < 50) {
Expand Down Expand Up @@ -257,7 +269,7 @@ class MixedGenerator : public ObjectGenerator {
// hash
//boost::binomial_distribution<uint32_t> bin(0xFFFFFF, 0.5);
++seq;
return hobject_t(name, string(), CEPH_NOSNAP, rand(), 0);
return hobject_t(name, string(), rand() & 2 ? CEPH_NOSNAP : rand(), rand() & 0xFF, 0);
}
};

Expand Down Expand Up @@ -368,8 +380,9 @@ class SyntheticWorkloadState {
while (1) {
cerr << "scanning..." << std::endl;
int r = store->collection_list_partial(cid, current, 50, 100,
CEPH_NOSNAP, &objects, &next);
0, &objects, &next);
ASSERT_EQ(r, 0);
ASSERT_TRUE(sorted(objects));
objects_set.insert(objects.begin(), objects.end());
objects.clear();
if (next.max) break;
Expand Down Expand Up @@ -447,7 +460,7 @@ TEST_F(StoreTest, Synthetic) {
if (!(i % 10)) cerr << "seeding object " << i << std::endl;
test_obj.touch();
}
for (int i = 0; i < 1000; ++i) {
for (int i = 0; i < 10000; ++i) {
if (!(i % 10)) {
cerr << "Op " << i << std::endl;
test_obj.print_internal_state();
Expand Down Expand Up @@ -505,8 +518,9 @@ TEST_F(StoreTest, HashCollisionTest) {
hobject_t current, next;
while (1) {
r = store->collection_list_partial(cid, current, 50, 60,
CEPH_NOSNAP, &objects, &next);
0, &objects, &next);
ASSERT_EQ(r, 0);
ASSERT_TRUE(sorted(objects));
for (vector<hobject_t>::iterator i = objects.begin();
i != objects.end();
++i) {
Expand Down

0 comments on commit 9e207aa

Please sign in to comment.