diff options
author | Sage Weil <sage@inktank.com> | 2013-10-22 17:23:39 -0700 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2013-10-22 17:23:39 -0700 |
commit | 5507d9b7b6d4300237543b9cbc2932bf86e18281 (patch) | |
tree | 223ee097ad59c42e21c3217ebd07e90ca728255c | |
parent | 9ef8ffc9657a50be0cf19d6511ffa2a0c58a9f8a (diff) | |
download | ceph-5507d9b7b6d4300237543b9cbc2932bf86e18281.tar.gz |
ceph_test_rados_api_tier: add simple promote-on-read test
Signed-off-by: Sage Weil <sage@inktank.com>
-rw-r--r-- | src/test/librados/tier.cc | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/src/test/librados/tier.cc b/src/test/librados/tier.cc index 195538ead43..81f2061c66e 100644 --- a/src/test/librados/tier.cc +++ b/src/test/librados/tier.cc @@ -82,6 +82,76 @@ TEST(LibRadosTier, Dirty) { ASSERT_EQ(0, destroy_one_pool_pp(pool_name, cluster)); } +TEST(LibRadosTier, Promote) { + Rados cluster; + std::string base_pool_name = get_temp_pool_name(); + std::string cache_pool_name = base_pool_name + "-cache"; + ASSERT_EQ("", create_one_pool_pp(base_pool_name, cluster)); + ASSERT_EQ(0, cluster.pool_create(cache_pool_name.c_str())); + IoCtx cache_ioctx; + ASSERT_EQ(0, cluster.ioctx_create(cache_pool_name.c_str(), cache_ioctx)); + IoCtx base_ioctx; + ASSERT_EQ(0, cluster.ioctx_create(base_pool_name.c_str(), base_ioctx)); + + // create object + { + bufferlist bl; + bl.append("hi there"); + ObjectWriteOperation op; + op.write_full(bl); + ASSERT_EQ(0, base_ioctx.operate("foo", &op)); + } + + // configure cache + bufferlist inbl; + ASSERT_EQ(0, cluster.mon_command( + "{\"prefix\": \"osd tier add\", \"pool\": \"" + base_pool_name + + "\", \"tierpool\": \"" + cache_pool_name + "\"}", + inbl, NULL, NULL)); + ASSERT_EQ(0, cluster.mon_command( + "{\"prefix\": \"osd tier set-overlay\", \"pool\": \"" + base_pool_name + + "\", \"overlaypool\": \"" + cache_pool_name + "\"}", + inbl, NULL, NULL)); + ASSERT_EQ(0, cluster.mon_command( + "{\"prefix\": \"osd tier cache-mode\", \"pool\": \"" + cache_pool_name + + "\", \"mode\": \"writeback\"}", + inbl, NULL, NULL)); + + // wait for maps to settle + cluster.wait_for_latest_map(); + + // read, trigger a promote + { + bufferlist bl; + ASSERT_EQ(1, base_ioctx.read("foo", bl, 1, 0)); + } + + // verify the object is present in the cache tier + { + ObjectIterator it = cache_ioctx.objects_begin(); + ASSERT_TRUE(it != cache_ioctx.objects_end()); + ASSERT_EQ(it->first, string("foo")); + ++it; + ASSERT_TRUE(it == cache_ioctx.objects_end()); + } + + // tear down tiers + ASSERT_EQ(0, cluster.mon_command( + "{\"prefix\": \"osd tier remove-overlay\", \"pool\": \"" + base_pool_name + + "\"}", + inbl, NULL, NULL)); + ASSERT_EQ(0, cluster.mon_command( + "{\"prefix\": \"osd tier remove\", \"pool\": \"" + base_pool_name + + "\", \"tierpool\": \"" + cache_pool_name + "\"}", + inbl, NULL, NULL)); + + base_ioctx.close(); + cache_ioctx.close(); + + cluster.pool_delete(cache_pool_name.c_str()); + ASSERT_EQ(0, destroy_one_pool_pp(base_pool_name, cluster)); +} + TEST(LibRadosTier, HitSetNone) { Rados cluster; std::string pool_name = get_temp_pool_name(); |