}
}
+TEST_F(LibRadosIoPP, CrcZeroWrite) {
+ char buf[128];
+ bufferlist bl;
+
+ ASSERT_EQ(0, ioctx.write("foo", bl, 0, 0));
+ ASSERT_EQ(0, ioctx.write("foo", bl, 0, sizeof(buf)));
+
+ ObjectReadOperation read;
+ read.read(0, bl.length(), NULL, NULL);
+ ASSERT_EQ(0, ioctx.operate("foo", &read, &bl));
+}
+
TEST_F(LibRadosIoECPP, SimpleWritePP) {
SKIP_IF_CRIMSON();
char buf[128];
ASSERT_EQ(-ENOENT, ioctx.rmxattr("foo_rmxattr", attr2));
}
+TEST_F(LibRadosIoECPP, CrcZeroWrite) {
+ SKIP_IF_CRIMSON();
+ set_allow_ec_overwrites(pool_name, true);
+ char buf[128];
+ memset(buf, 0xcc, sizeof(buf));
+ bufferlist bl;
+
+ ASSERT_EQ(0, ioctx.write("foo", bl, 0, 0));
+ ASSERT_EQ(0, ioctx.write("foo", bl, 0, sizeof(buf)));
+
+ ObjectReadOperation read;
+ read.read(0, bl.length(), NULL, NULL);
+ ASSERT_EQ(0, ioctx.operate("foo", &read, &bl));
+ recreate_pool();
+}
+
TEST_F(LibRadosIoECPP, XattrListPP) {
SKIP_IF_CRIMSON();
char buf[128];
return "";
}
+std::string set_allow_ec_overwrites_pp(const std::string &pool_name, Rados &cluster, bool allow)
+{
+ std::ostringstream oss;
+ bufferlist inbl;
+ int ret = cluster.mon_command(
+ "{\"prefix\": \"osd pool set\", \"pool\": \"" + pool_name + "\", \"var\": \"allow_ec_overwrites\", \"val\": \"" + (allow ? "true" : "false") + "\"}",
+ inbl, NULL, NULL);
+ if (ret) {
+ cluster.shutdown();
+ oss << "mon_command osd pool set pool:" << pool_name << " pool_type:erasure allow_ec_overwrites true failed with error " << ret;
+ return oss.str();
+ }
+ return "";
+}
+
std::string connect_cluster_pp(librados::Rados &cluster)
{
return connect_cluster_pp(cluster, {});
const std::map<std::string, std::string> &config);
std::string create_one_ec_pool_pp(const std::string &pool_name,
librados::Rados &cluster);
+std::string set_allow_ec_overwrites_pp(const std::string &pool_name,
+ librados::Rados &cluster, bool allow);
std::string connect_cluster_pp(librados::Rados &cluster);
std::string connect_cluster_pp(librados::Rados &cluster,
const std::map<std::string, std::string> &config);
void RadosTestPP::SetUpTestCase()
{
init_rand();
-
auto pool_prefix = fmt::format("{}_", ::testing::UnitTest::GetInstance()->current_test_case()->name());
pool_name = get_temp_pool_name(pool_prefix);
ASSERT_EQ("", create_one_pool_pp(pool_name, s_cluster));
ioctx.close();
}
+void RadosTestECPP::recreate_pool()
+{
+ SKIP_IF_CRIMSON();
+ ASSERT_EQ(0, destroy_one_ec_pool_pp(pool_name, s_cluster));
+ ASSERT_EQ("", create_one_ec_pool_pp(pool_name, s_cluster));
+ SetUp();
+}
+
+void RadosTestECPP::set_allow_ec_overwrites(std::string pool, bool allow)
+{
+ ASSERT_EQ("", set_allow_ec_overwrites_pp(pool, cluster, allow));
+}
\ No newline at end of file
protected:
static void SetUpTestCase();
static void TearDownTestCase();
+ void recreate_pool();
+ void set_allow_ec_overwrites(std::string pool, bool allow=true);
static librados::Rados s_cluster;
static std::string pool_name;