Generate the temp collection for a pg collection.
Signed-off-by: Sage Weil <sage@redhat.com>
return str != rhs.str;
}
+ // get a TEMP collection that corresponds to the current collection,
+ // which we presume is a pg collection.
+ coll_t get_temp() {
+ spg_t pgid;
+ snapid_t snap;
+ bool foo = is_pg(pgid, snap);
+ assert(foo);
+ assert(snap == CEPH_NOSNAP);
+ return coll_t(str.substr(0, str.length() - 4) + "TEMP");
+ }
+
void dump(Formatter *f) const;
static void generate_test_instances(list<coll_t*>& o);
ASSERT_EQ(out.str(), "0,1,2");
}
+TEST(coll_t, temp) {
+ spg_t pgid;
+ coll_t foo(pgid);
+ ASSERT_EQ(foo.to_str(), string("0.0_head"));
+
+ coll_t temp = foo.get_temp();
+ ASSERT_EQ(temp.to_str(), string("0.0_TEMP"));
+
+ spg_t pgid2;
+ ASSERT_TRUE(temp.is_temp());
+ ASSERT_TRUE(temp.is_temp(pgid2));
+ ASSERT_EQ(pgid, pgid2);
+}
+
/*
* Local Variables:
* compile-command: "cd ../.. ;