Skip to content

Commit

Permalink
test/objectstore: make store_test also run collection_list_legacy
Browse files Browse the repository at this point in the history
Signed-off-by: Mykola Golub <[email protected]>
  • Loading branch information
trociny committed Aug 29, 2020
1 parent 2a67fc5 commit 08fab7a
Showing 1 changed file with 54 additions and 42 deletions.
96 changes: 54 additions & 42 deletions src/test/objectstore/store_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,17 @@ int queue_transaction(
}
}

template <typename T>
int collection_list(T &store, ObjectStore::CollectionHandle &c,
const ghobject_t& start, const ghobject_t& end, int max,
vector<ghobject_t> *ls, ghobject_t *pnext,
bool disable_legacy = false) {
if (disable_legacy || rand() % 2) {
return store->collection_list(c, start, end, max, ls, pnext);
} else {
return store->collection_list_legacy(c, start, end, max, ls, pnext);
}
}

bool sorted(const vector<ghobject_t> &in) {
ghobject_t start;
Expand Down Expand Up @@ -2840,9 +2851,8 @@ TEST_P(StoreTest, SimpleListTest) {
vector<ghobject_t> objects;
ghobject_t next, current;
while (!next.is_max()) {
int r = store->collection_list(ch, current, ghobject_t::get_max(),
50,
&objects, &next);
int r = collection_list(store, ch, current, ghobject_t::get_max(), 50,
&objects, &next);
ASSERT_EQ(r, 0);
ASSERT_TRUE(sorted(objects));
cout << " got " << objects.size() << " next " << next << std::endl;
Expand Down Expand Up @@ -2905,8 +2915,7 @@ TEST_P(StoreTest, ListEndTest) {
end.hobj.pool = 1;
vector<ghobject_t> objects;
ghobject_t next;
int r = store->collection_list(ch, ghobject_t(), end, 500,
&objects, &next);
int r = collection_list(store, ch, ghobject_t(), end, 500, &objects, &next);
ASSERT_EQ(r, 0);
for (auto &p : objects) {
ASSERT_NE(p, end);
Expand Down Expand Up @@ -2985,8 +2994,8 @@ TEST_P(StoreTest, MultipoolListTest) {
vector<ghobject_t> objects;
ghobject_t next, current;
while (!next.is_max()) {
int r = store->collection_list(ch, current, ghobject_t::get_max(), 50,
&objects, &next);
int r = collection_list(store, ch, current, ghobject_t::get_max(), 50,
&objects, &next);
ASSERT_EQ(r, 0);
cout << " got " << objects.size() << " next " << next << std::endl;
for (vector<ghobject_t>::iterator p = objects.begin(); p != objects.end();
Expand Down Expand Up @@ -3652,7 +3661,8 @@ TEST_P(StoreTest, ManyObjectTest) {

set<ghobject_t> listed, listed2;
vector<ghobject_t> objects;
r = store->collection_list(ch, ghobject_t(), ghobject_t::get_max(), INT_MAX, &objects, 0);
r = collection_list(store, ch, ghobject_t(), ghobject_t::get_max(), INT_MAX,
&objects, 0);
ASSERT_EQ(r, 0);

cerr << "objects.size() is " << objects.size() << std::endl;
Expand All @@ -3666,7 +3676,8 @@ TEST_P(StoreTest, ManyObjectTest) {

ghobject_t start, next;
objects.clear();
r = store->collection_list(
r = collection_list(
store,
ch,
ghobject_t::get_max(),
ghobject_t::get_max(),
Expand All @@ -3681,10 +3692,8 @@ TEST_P(StoreTest, ManyObjectTest) {
listed.clear();
ghobject_t start2, next2;
while (1) {
r = store->collection_list(ch, start, ghobject_t::get_max(),
50,
&objects,
&next);
r = collection_list(store, ch, start, ghobject_t::get_max(), 50, &objects,
&next);
ASSERT_TRUE(sorted(objects));
ASSERT_EQ(r, 0);
listed.insert(objects.begin(), objects.end());
Expand Down Expand Up @@ -3911,8 +3920,8 @@ class SyntheticWorkloadState {
ghobject_t next;
while (1) {
vector<ghobject_t> objects;
int r = store->collection_list(ch, next, ghobject_t::get_max(),
10, &objects, &next);
int r = collection_list(store, ch, next, ghobject_t::get_max(), 10,
&objects, &next);
ceph_assert(r >= 0);
if (objects.size() == 0)
break;
Expand Down Expand Up @@ -4563,8 +4572,8 @@ class SyntheticWorkloadState {
ghobject_t next, current;
while (1) {
//cerr << "scanning..." << std::endl;
int r = store->collection_list(ch, current, ghobject_t::get_max(), 100,
&objects, &next);
int r = collection_list(store, ch, current, ghobject_t::get_max(), 100,
&objects, &next);
ASSERT_EQ(r, 0);
ASSERT_TRUE(sorted(objects));
objects_set.insert(objects.begin(), objects.end());
Expand Down Expand Up @@ -4597,8 +4606,8 @@ class SyntheticWorkloadState {
ASSERT_GT(available_objects.count(*i), (unsigned)0);
}

int r = store->collection_list(ch, ghobject_t(), ghobject_t::get_max(),
INT_MAX, &objects, 0);
int r = collection_list(store, ch, ghobject_t(), ghobject_t::get_max(),
INT_MAX, &objects, 0);
ASSERT_EQ(r, 0);
objects_set2.insert(objects.begin(), objects.end());
ASSERT_EQ(objects_set2.size(), available_objects.size());
Expand Down Expand Up @@ -4977,7 +4986,8 @@ TEST_P(StoreTest, HashCollisionTest) {
}
}
vector<ghobject_t> objects;
r = store->collection_list(ch, ghobject_t(), ghobject_t::get_max(), INT_MAX, &objects, 0);
r = collection_list(store, ch, ghobject_t(), ghobject_t::get_max(), INT_MAX,
&objects, 0);
ASSERT_EQ(r, 0);
set<ghobject_t> listed(objects.begin(), objects.end());
cerr << "listed.size() is " << listed.size() << " and created.size() is " << created.size() << std::endl;
Expand All @@ -4986,8 +4996,8 @@ TEST_P(StoreTest, HashCollisionTest) {
listed.clear();
ghobject_t current, next;
while (1) {
r = store->collection_list(ch, current, ghobject_t::get_max(), 60,
&objects, &next);
r = collection_list(store, ch, current, ghobject_t::get_max(), 60, &objects,
&next);
ASSERT_EQ(r, 0);
ASSERT_TRUE(sorted(objects));
for (vector<ghobject_t>::iterator i = objects.begin();
Expand Down Expand Up @@ -5027,6 +5037,8 @@ TEST_P(StoreTest, HashCollisionTest) {
}

TEST_P(StoreTest, HashCollisionSorting) {
bool disable_legacy = (string(GetParam()) == "bluestore");

char buf121664318_1[] = {18, -119, -121, -111, 0};
char buf121664318_2[] = {19, 127, -121, 32, 0};
char buf121664318_3[] = {19, -118, 15, 19, 0};
Expand Down Expand Up @@ -5079,8 +5091,8 @@ TEST_P(StoreTest, HashCollisionSorting) {
}

vector<ghobject_t> objects;
int r = store->collection_list(ch, ghobject_t(), ghobject_t::get_max(),
INT_MAX, &objects, 0);
int r = collection_list(store, ch, ghobject_t(), ghobject_t::get_max(),
INT_MAX, &objects, 0, disable_legacy);
ASSERT_EQ(r, 0);
ASSERT_EQ(created.size(), objects.size());
auto it = objects.begin();
Expand All @@ -5095,9 +5107,8 @@ TEST_P(StoreTest, HashCollisionSorting) {
std::set<ghobject_t> created_sub(i, j);
objects.clear();
ghobject_t next;
r = store->collection_list(ch, *i, ghobject_t::get_max(),
created_sub.size(),
&objects, &next);
r = collection_list(store, ch, *i, ghobject_t::get_max(),
created_sub.size(), &objects, &next, disable_legacy);
ASSERT_EQ(r, 0);
ASSERT_EQ(created_sub.size(), objects.size());
it = objects.begin();
Expand All @@ -5119,7 +5130,8 @@ TEST_P(StoreTest, HashCollisionSorting) {
std::set<ghobject_t> created_sub(i, j);
objects.clear();
ghobject_t next;
r = store->collection_list(ch, *i, *j, INT_MAX, &objects, &next);
r = collection_list(store, ch, *i, *j, INT_MAX, &objects, &next,
disable_legacy);
ASSERT_EQ(r, 0);
ASSERT_EQ(created_sub.size(), objects.size());
it = objects.begin();
Expand Down Expand Up @@ -5185,8 +5197,8 @@ TEST_P(StoreTest, ScrubTest) {
}

vector<ghobject_t> objects;
r = store->collection_list(ch, ghobject_t(), ghobject_t::get_max(),
INT_MAX, &objects, 0);
r = collection_list(store, ch, ghobject_t(), ghobject_t::get_max(), INT_MAX,
&objects, 0);
ASSERT_EQ(r, 0);
set<ghobject_t> listed(objects.begin(), objects.end());
cerr << "listed.size() is " << listed.size() << " and created.size() is " << created.size() << std::endl;
Expand All @@ -5195,8 +5207,8 @@ TEST_P(StoreTest, ScrubTest) {
listed.clear();
ghobject_t current, next;
while (1) {
r = store->collection_list(ch, current, ghobject_t::get_max(), 60,
&objects, &next);
r = collection_list(store, ch, current, ghobject_t::get_max(), 60, &objects,
&next);
ASSERT_EQ(r, 0);
ASSERT_TRUE(sorted(objects));
for (vector<ghobject_t>::iterator i = objects.begin();
Expand Down Expand Up @@ -5660,8 +5672,8 @@ void colsplittest(

// check
vector<ghobject_t> objects;
r = store->collection_list(ch, ghobject_t(), ghobject_t::get_max(),
INT_MAX, &objects, 0);
r = collection_list(store, ch, ghobject_t(), ghobject_t::get_max(), INT_MAX,
&objects, 0);
ASSERT_EQ(r, 0);
ASSERT_EQ(objects.size(), num_objects);
for (vector<ghobject_t>::iterator i = objects.begin();
Expand All @@ -5671,8 +5683,8 @@ void colsplittest(
}

objects.clear();
r = store->collection_list(tch, ghobject_t(), ghobject_t::get_max(),
INT_MAX, &objects, 0);
r = collection_list(store, tch, ghobject_t(), ghobject_t::get_max(), INT_MAX,
&objects, 0);
ASSERT_EQ(r, 0);
ASSERT_EQ(objects.size(), num_objects);
for (vector<ghobject_t>::iterator i = objects.begin();
Expand All @@ -5693,8 +5705,8 @@ void colsplittest(
ObjectStore::Transaction t;
{
vector<ghobject_t> objects;
r = store->collection_list(ch, ghobject_t(), ghobject_t::get_max(),
INT_MAX, &objects, 0);
r = collection_list(store, ch, ghobject_t(), ghobject_t::get_max(), INT_MAX,
&objects, 0);
ASSERT_EQ(r, 0);
ASSERT_EQ(objects.size(), num_objects * 2); // both halves
unsigned size = 0;
Expand Down Expand Up @@ -5831,8 +5843,8 @@ void test_merge_skewed(ObjectStore *store,
// verify
{
vector<ghobject_t> got;
store->collection_list(cha, ghobject_t(), ghobject_t::get_max(), INT_MAX,
&got, 0);
collection_list(store, cha, ghobject_t(), ghobject_t::get_max(), INT_MAX,
&got, 0);
set<ghobject_t> gotset;
for (auto& o : got) {
ASSERT_TRUE(aobjects.count(o) || bobjects.count(o));
Expand Down Expand Up @@ -6140,8 +6152,8 @@ TEST_P(StoreTest, BigRGWObjectName) {

{
vector<ghobject_t> objects;
r = store->collection_list(ch, ghobject_t(), ghobject_t::get_max(),
INT_MAX, &objects, 0);
r = collection_list(store, ch, ghobject_t(), ghobject_t::get_max(), INT_MAX,
&objects, 0);
ASSERT_EQ(r, 0);
ASSERT_EQ(objects.size(), 1u);
ASSERT_EQ(objects[0], oid2);
Expand Down

0 comments on commit 08fab7a

Please sign in to comment.