From patchwork Mon May 25 03:32:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Wang X-Patchwork-Id: 6472501 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3B6C79F399 for ; Mon, 25 May 2015 03:34:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 56F7020462 for ; Mon, 25 May 2015 03:34:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 572E32046F for ; Mon, 25 May 2015 03:34:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751784AbbEYDd6 (ORCPT ); Sun, 24 May 2015 23:33:58 -0400 Received: from m199-177.yeah.net ([123.58.177.199]:58210 "EHLO m199-177.yeah.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751741AbbEYDd4 (ORCPT ); Sun, 24 May 2015 23:33:56 -0400 Received: from localhost.localdomain (unknown [113.240.220.93]) by m199-177.yeah.net (HMail) with ESMTPA id 5AA8D110105A; Mon, 25 May 2015 11:33:38 +0800 (CST) From: Li Wang To: Sage Weil Cc: ceph-devel@vger.kernel.org, Min Chen Subject: [PATCH 2/2] Rados: add test case for CEPH_OP_FLAG_TIER_NOCACHE Date: Mon, 25 May 2015 11:32:17 +0800 Message-Id: <5def53d1d0f1ec1a7d3756b33ff54483a260e9ef.1432523122.git.liwang@ubuntukylin.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: In-Reply-To: References: X-HM-Spam-Status: e1koWUFPN1dZCBgUCR5ZQUlMVUNJQkJCQkJJSExLTUtOTldZCQ4XHghZQV koKz0kKDQ9Lz06MjckMjUkMz46Pz4pQUtVS0A2IyQiPigkMjUkMz46Pz4pQUtVS0ArLykkNTQkMj UkMz46Pz4pQUlVS0A4NC41LykiJDg1QUtVS0ApPjwyNDUkOigyOkFLVUtAKyk0LTI1OD4kMy41Oj VBS1VLQD8iNTo2MjgkMiskNTQkMjUkMz46Pz4pQUtVS0ApPjo3JDIrJDI1JCk5NyQyNSQzPjo*Pi lBSklVS0A2LjcvMiQpOCsvJD8yPT0#KT41LyQyNSQzPjo*PilBSVVLQDIrJE4kNjI1Li8#JDg1Ly RLJEpLQUtVS0AyKyRISyQ2MjUuLz4kODUvJEskTktBS1VLQDIrJEokMzQuKSQ4NS8kSyRKS0tBS1 VLQDIrJEokNjI1Li8#JDg1LyRLJEpLQUtVS0AyKyQvND86IiQ4NS8kSyRKS0tBS1VLQCguOTE#OC 8kTiQ2MjUuLz4kODUvJEskSktBS1VLQCguOTE#OC8kLzQ*OiIkODUvJEskSktLQUtVS0AoLjkxPj gvJEokMzQuKSQ4NS8kSyRKS0tBS1VLQDU0LyQ9OjY0LigkPzQ2OjI1JCgrPSQ9OjI3QUpLVUtAKC 45JD5BSlVOTkA9NSQoLjkkPjUsNCk*KCQzNzEkSktLSUtKQUtVSUNZBg++ X-HM-Sender-Digest: e1kSHx4VD1lBWUc6MBg6Ejo6HTorDgEKTCIuFjlWPiIwCzNVSlVKT0hJ TklPQ0pDTkJDVTMWGhIXVRcSDBoVHDsOGQ4VDw4QAhcSFVUYFBZFWVdZDB4ZWUEdGhcIHldZCAFZ QUNKTkk3V1kSC1lBWUpKSFVJT0tVSUlLVUJIWQY+ X-HM-Tid: 0a4d8922082164275aa8d110105a Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Min Chen Signed-off-by: Min Chen Reviewed-by: Li Wang --- src/test/librados/tier.cc | 176 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 176 insertions(+) diff --git a/src/test/librados/tier.cc b/src/test/librados/tier.cc index 60b56f9..0b3368e 100644 --- a/src/test/librados/tier.cc +++ b/src/test/librados/tier.cc @@ -2390,6 +2390,94 @@ TEST_F(LibRadosTwoPoolsPP, ProxyRead) { cluster.wait_for_latest_osdmap(); } +TEST_F(LibRadosTwoPoolsPP, TierNocache) { + // configure cache + 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)); + ASSERT_EQ(0, cluster.mon_command( + "{\"prefix\": \"osd tier set-overlay\", \"pool\": \"" + pool_name + + "\", \"overlaypool\": \"" + cache_pool_name + "\"}", + inbl, NULL, NULL)); + + std::string cache_modes[] = {"writeback", "forward", "readonly", "readforward", "readproxy"}; + int count = (int) sizeof(cache_modes)/sizeof(cache_modes[0]); + int i; + // test write/read with TierNocache in each cache-mode + for (i = 0; i < count; i++) + { + std::cout << "set cache-mode:" + cache_modes[i] << std::endl; + ASSERT_EQ(0, cluster.mon_command( + "{\"prefix\": \"osd tier cache-mode\", \"pool\": \"" + cache_pool_name + + "\", \"mode\": \"" + cache_modes[i] + "\"}", + inbl, NULL, NULL)); + + // wait for maps to settle + cluster.wait_for_latest_osdmap(); + + std::string content(cache_modes[i]); + std::string object(cache_modes[i]+"_obj"); + ObjectWriteOperation wr; + librados::AioCompletion *completion = cluster.aio_create_completion(); + + //writeback: create a new object + bufferlist bl; + bl.append(content); + wr.write_full(bl); + ioctx.aio_operate(object, completion, &wr, librados::OPERATION_TIER_NOCACHE); + completion->wait_for_safe(); + completion->release(); + + // verify the object is NOT present in the cache tier + { + NObjectIterator it = cache_ioctx.nobjects_begin(); + ASSERT_TRUE(it == cache_ioctx.nobjects_end()); + } + + //writeback: read the object content + ObjectReadOperation rd; + uint64_t len = bl.length(); + completion = cluster.aio_create_completion(); + bufferlist bl2; + bufferlist bl3; + rd.read(0, len+1, &bl3, NULL); + ASSERT_EQ(0, ioctx.aio_operate( + object, completion, &rd, + librados::OPERATION_TIER_NOCACHE, NULL)); + completion->wait_for_complete(); + + ASSERT_EQ(0, completion->get_return_value()); + uint64_t n = 0; + for (n = 0; n < len; n++) { + bl2.append(bl3[n]); + } + ASSERT_EQ(content, bl2.c_str()); + completion->release(); + + // verify the object is NOT present in the cache tier + { + NObjectIterator it = cache_ioctx.nobjects_begin(); + ASSERT_TRUE(it == cache_ioctx.nobjects_end()); + } + } + + // tear down tiers + ASSERT_EQ(0, cluster.mon_command( + "{\"prefix\": \"osd tier remove-overlay\", \"pool\": \"" + pool_name + + "\"}", + inbl, NULL, NULL)); + ASSERT_EQ(0, cluster.mon_command( + "{\"prefix\": \"osd tier remove\", \"pool\": \"" + pool_name + + "\", \"tierpool\": \"" + cache_pool_name + "\"}", + inbl, NULL, NULL)); + + // wait for maps to settle before next test + cluster.wait_for_latest_osdmap(); +} + class LibRadosTwoPoolsECPP : public RadosTestECPP { public: @@ -4439,6 +4527,94 @@ TEST_F(LibRadosTwoPoolsECPP, ProxyRead) { cluster.wait_for_latest_osdmap(); } +TEST_F(LibRadosTwoPoolsECPP, TierNocache) { + // configure cache + 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)); + ASSERT_EQ(0, cluster.mon_command( + "{\"prefix\": \"osd tier set-overlay\", \"pool\": \"" + pool_name + + "\", \"overlaypool\": \"" + cache_pool_name + "\"}", + inbl, NULL, NULL)); + + std::string cache_modes[] = {"writeback", "forward", "readonly", "readforward", "readproxy"}; + int count = (int) sizeof(cache_modes)/sizeof(cache_modes[0]); + int i; + // test write/read with TierNocache in each cache-mode + for (i = 0; i < count; i++) + { + std::cout << "set cache-mode:" + cache_modes[i] << std::endl; + ASSERT_EQ(0, cluster.mon_command( + "{\"prefix\": \"osd tier cache-mode\", \"pool\": \"" + cache_pool_name + + "\", \"mode\": \"" + cache_modes[i] + "\"}", + inbl, NULL, NULL)); + + // wait for maps to settle + cluster.wait_for_latest_osdmap(); + + std::string content(cache_modes[i]); + std::string object(cache_modes[i]+"_obj"); + ObjectWriteOperation wr; + librados::AioCompletion *completion = cluster.aio_create_completion(); + + //writeback: create a new object + bufferlist bl; + bl.append(content); + wr.write_full(bl); + ioctx.aio_operate(object, completion, &wr, librados::OPERATION_TIER_NOCACHE); + completion->wait_for_safe(); + completion->release(); + + // verify the object is NOT present in the cache tier + { + NObjectIterator it = cache_ioctx.nobjects_begin(); + ASSERT_TRUE(it == cache_ioctx.nobjects_end()); + } + + //writeback: read the object content + ObjectReadOperation rd; + uint64_t len = bl.length(); + completion = cluster.aio_create_completion(); + bufferlist bl2; + bufferlist bl3; + rd.read(0, len+1, &bl3, NULL); + ASSERT_EQ(0, ioctx.aio_operate( + object, completion, &rd, + librados::OPERATION_TIER_NOCACHE, NULL)); + completion->wait_for_complete(); + + ASSERT_EQ(0, completion->get_return_value()); + uint64_t n = 0; + for (n = 0; n < len; n++) { + bl2.append(bl3[n]); + } + ASSERT_EQ(content, bl2.c_str()); + completion->release(); + + // verify the object is NOT present in the cache tier + { + NObjectIterator it = cache_ioctx.nobjects_begin(); + ASSERT_TRUE(it == cache_ioctx.nobjects_end()); + } + } + + // tear down tiers + ASSERT_EQ(0, cluster.mon_command( + "{\"prefix\": \"osd tier remove-overlay\", \"pool\": \"" + pool_name + + "\"}", + inbl, NULL, NULL)); + ASSERT_EQ(0, cluster.mon_command( + "{\"prefix\": \"osd tier remove\", \"pool\": \"" + pool_name + + "\", \"tierpool\": \"" + cache_pool_name + "\"}", + inbl, NULL, NULL)); + + // wait for maps to settle before next test + cluster.wait_for_latest_osdmap(); +} + //Make ecpool as cache pool; no-ecpool as data pool //Judge promote object which has omap from no-ecpool into ecpool. TEST_F(LibRadosTwoPoolsECPP, OmapOperation) {