summaryrefslogtreecommitdiffstats
path: root/src/test/librbd
diff options
context:
space:
mode:
authorHaomai Wang <haomai@xsky.com>2015-09-18 06:17:53 +0200
committerHaomai Wang <haomai@xsky.com>2015-09-18 11:20:23 +0200
commit4f553b0e2b2b83dcd1a8e69f70ee53a031631883 (patch)
tree68723c7a3e17f4eb2aa86691a944d309897b8e53 /src/test/librbd
parentMerge pull request #5841 from ceph/wip-12994-rbd-replay-packaging (diff)
downloadceph-4f553b0e2b2b83dcd1a8e69f70ee53a031631883.tar.xz
ceph-4f553b0e2b2b83dcd1a8e69f70ee53a031631883.zip
Librbd: Fix incorrect metadata filter behavior
Signed-off-by: Haomai Wang <haomai@xsky.com>
Diffstat (limited to 'src/test/librbd')
-rw-r--r--src/test/librbd/test_internal.cc47
1 files changed, 46 insertions, 1 deletions
diff --git a/src/test/librbd/test_internal.cc b/src/test/librbd/test_internal.cc
index 36a58f5f355..bf551165416 100644
--- a/src/test/librbd/test_internal.cc
+++ b/src/test/librbd/test_internal.cc
@@ -369,7 +369,7 @@ TEST_F(TestInternal, MultipleResize) {
ASSERT_EQ(0U, size);
}
-TEST_F(TestInternal, MetadatConfig) {
+TEST_F(TestInternal, Metadata) {
REQUIRE_FEATURE(RBD_FEATURE_LAYERING);
map<string, bool> test_confs = boost::assign::map_list_of(
@@ -411,6 +411,51 @@ TEST_F(TestInternal, MetadatConfig) {
ASSERT_STREQ(val.c_str(), "value3");
}
+TEST_F(TestInternal, MetadataFilter) {
+ REQUIRE_FEATURE(RBD_FEATURE_LAYERING);
+
+ map<string, bool> test_confs = boost::assign::map_list_of(
+ "aaaaaaa", false)(
+ "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", false)(
+ "cccccccccccccc", false);
+ map<string, bool>::iterator it = test_confs.begin();
+ const string prefix = "test_config_";
+ bool is_continue;
+ librbd::ImageCtx *ictx;
+ ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+ librbd::Image image1;
+ map<string, bufferlist> pairs, res;
+ pairs["abc"].append("value");
+ pairs["abcabc"].append("value");
+ pairs[prefix+it->first].append("value1");
+ ++it;
+ pairs[prefix+it->first].append("value2");
+ ++it;
+ pairs[prefix+it->first].append("value3");
+ pairs[prefix+"asdfsdaf"].append("value6");
+ pairs[prefix+"zxvzxcv123"].append("value5");
+
+ is_continue = ictx->_filter_metadata_confs(prefix, test_confs, pairs, &res);
+ ASSERT_TRUE(is_continue);
+ ASSERT_TRUE(res.size() == 3U);
+ it = test_confs.begin();
+ ASSERT_TRUE(res.count(it->first));
+ ASSERT_TRUE(it->second);
+ ++it;
+ ASSERT_TRUE(res.count(it->first));
+ ASSERT_TRUE(it->second);
+ ++it;
+ ASSERT_TRUE(res.count(it->first));
+ ASSERT_TRUE(it->second);
+ res.clear();
+
+ pairs["zzzzzzzz"].append("value7");
+ is_continue = ictx->_filter_metadata_confs(prefix, test_confs, pairs, &res);
+ ASSERT_FALSE(is_continue);
+ ASSERT_TRUE(res.size() == 3U);
+}
+
TEST_F(TestInternal, SnapshotCopyup)
{
REQUIRE_FEATURE(RBD_FEATURE_LAYERING);