return -1;
}
-TEST_F(LibRadosTwoPoolsPP, HitSetWrite) {
- int num_pg = _get_pg_num(cluster, pool_name);
- ceph_assert(num_pg > 0);
-
- // make it a tier
- bufferlist inbl;
- ASSERT_EQ(0, cluster.mon_command(
- "{\"prefix\": \"osd tier add\", \"pool\": \"" + pool_name +
- "\", \"tierpool\": \"" + cache_pool_name +
- "\", \"force_nonempty\": \"--force-nonempty\" }",
- inbl, NULL, NULL));
-
- // enable hitset tracking for this pool
- ASSERT_EQ(0, cluster.mon_command(set_pool_str(cache_pool_name, "hit_set_count", 8),
- inbl, NULL, NULL));
- ASSERT_EQ(0, cluster.mon_command(set_pool_str(cache_pool_name, "hit_set_period", 600),
- inbl, NULL, NULL));
- ASSERT_EQ(0, cluster.mon_command(set_pool_str(cache_pool_name, "hit_set_type",
- "explicit_hash"),
- inbl, NULL, NULL));
-
- // wait for maps to settle
- cluster.wait_for_latest_osdmap();
-
- cache_ioctx.set_namespace("");
-
- int num = 200;
-
+int make_hitset(Rados& cluster, librados::IoCtx& cache_ioctx, int num_pg,
+ int num, std::map<int, HitSet>& hitsets, std::string& cache_pool_name)
+{
+ int pg = num_pg;
// do a bunch of writes
for (int i=0; i<num; ++i) {
bufferlist bl;
bl.append("a");
- ASSERT_EQ(0, cache_ioctx.write(stringify(i), bl, 1, 0));
+ ceph_assert(0 == cache_ioctx.write(stringify(i), bl, 1, 0));
}
// get HitSets
- std::map<int,HitSet> hitsets;
- for (int i=0; i<num_pg; ++i) {
+ for (int i=0; i<pg; ++i) {
list< pair<time_t,time_t> > ls;
AioCompletion *c = librados::Rados::aio_create_completion();
- ASSERT_EQ(0, cache_ioctx.hit_set_list(i, c, &ls));
+ ceph_assert(0 == cache_ioctx.hit_set_list(i, c, &ls));
c->wait_for_complete();
c->release();
std::cout << "pg " << i << " ls " << ls << std::endl;
- ASSERT_FALSE(ls.empty());
+ ceph_assert(!ls.empty());
// get the latest
c = librados::Rados::aio_create_completion();
bufferlist bl;
- ASSERT_EQ(0, cache_ioctx.hit_set_get(i, c, ls.back().first, &bl));
+ ceph_assert(0 == cache_ioctx.hit_set_get(i, c, ls.back().first, &bl));
c->wait_for_complete();
c->release();
}
// cope with racing splits by refreshing pg_num
- if (i == num_pg - 1)
- num_pg = _get_pg_num(cluster, cache_pool_name);
+ if (i == pg - 1)
+ pg = _get_pg_num(cluster, cache_pool_name);
}
+ return pg;
+}
+
+TEST_F(LibRadosTwoPoolsPP, HitSetWrite) {
+ int num_pg = _get_pg_num(cluster, pool_name);
+ ceph_assert(num_pg > 0);
+
+ // make it a tier
+ bufferlist inbl;
+ ASSERT_EQ(0, cluster.mon_command(
+ "{\"prefix\": \"osd tier add\", \"pool\": \"" + pool_name +
+ "\", \"tierpool\": \"" + cache_pool_name +
+ "\", \"force_nonempty\": \"--force-nonempty\" }",
+ inbl, NULL, NULL));
+
+ // enable hitset tracking for this pool
+ ASSERT_EQ(0, cluster.mon_command(set_pool_str(cache_pool_name, "hit_set_count", 8),
+ inbl, NULL, NULL));
+ ASSERT_EQ(0, cluster.mon_command(set_pool_str(cache_pool_name, "hit_set_period", 600),
+ inbl, NULL, NULL));
+ ASSERT_EQ(0, cluster.mon_command(set_pool_str(cache_pool_name, "hit_set_type",
+ "explicit_hash"),
+ inbl, NULL, NULL));
+
+ // wait for maps to settle
+ cluster.wait_for_latest_osdmap();
+
+ cache_ioctx.set_namespace("");
+
+ int num = 200;
+
+ std::map<int,HitSet> hitsets;
+
+ num_pg = make_hitset(cluster, cache_ioctx, num_pg, num, hitsets, cache_pool_name);
+
+ int retry = 0;
for (int i=0; i<num; ++i) {
string n = stringify(i);
break;
}
}
+ if (!found && retry < 5) {
+ num_pg = make_hitset(cluster, cache_ioctx, num_pg, num, hitsets, cache_pool_name);
+ i--;
+ retry++;
+ continue;
+ }
ASSERT_TRUE(found);
}
}