'osd', 'pool', 'set', pool_name,
'allow_ec_overwrites',
'true')
+ self.raw_cluster_cmd(
+ 'osd', 'pool', 'application', 'enable',
+ pool_name, 'rados', '--yes-i-really-mean-it',
+ run.Raw('||'), 'true')
self.pools[pool_name] = pg_num
time.sleep(1)
# create 1 pg pool
log.info('creating foo')
manager.raw_cluster_cmd('osd', 'pool', 'create', 'foo', '1')
+ manager.raw_cluster_cmd(
+ 'osd', 'pool', 'application', 'enable',
+ pool_name, 'rados', run.Raw('||'), 'true')
# Remove extra pool to simlify log output
manager.raw_cluster_cmd('osd', 'pool', 'delete', 'rbd', 'rbd', '--yes-i-really-really-mean-it')
tear_down
ceph osd pool create $POOL_NAME $PG_NUM
ceph osd pool mksnap $POOL_NAME snap
- rbd pool init images
+ rbd pool init $POOL_NAME
}
trap tear_down EXIT HUP INT
ASSERT_EQ(0, test_data.m_cluster.pool_create(p.c_str()));
IoCtx ioctx;
ASSERT_EQ(0, test_data.m_cluster.ioctx_create(p.c_str(), ioctx));
+ ioctx.application_enable("rados", true);
bufferlist inbl;
ASSERT_EQ(0, test_data.m_cluster.mon_command(
#include <map>
#include <sstream>
#include <string>
-
+#include <boost/regex.hpp>
using namespace librados;
using std::map;
ASSERT_EQ("", create_one_ec_pool_pp(pool_name, s_cluster));
src_pool_name = get_temp_pool_name();
ASSERT_EQ(0, s_cluster.pool_create(src_pool_name.c_str()));
+
+ librados::IoCtx ioctx;
+ ASSERT_EQ(0, s_cluster.ioctx_create(pool_name.c_str(), ioctx));
+ ioctx.application_enable("rados", true);
+
+ librados::IoCtx src_ioctx;
+ ASSERT_EQ(0, s_cluster.ioctx_create(src_pool_name.c_str(), src_ioctx));
+ src_ioctx.application_enable("rados", true);
}
static void TearDownTestCase() {
ASSERT_EQ(0, s_cluster.pool_delete(src_pool_name.c_str()));
}
TEST_F(LibRadosMisc, Applications) {
+ const char *cmd[] = {"{\"prefix\":\"osd dump\"}", nullptr};
+ char *buf, *st;
+ size_t buflen, stlen;
+ ASSERT_EQ(0, rados_mon_command(cluster, (const char **)cmd, 1, "", 0, &buf,
+ &buflen, &st, &stlen));
+ ASSERT_LT(0u, buflen);
+ string result(buf);
+ rados_buffer_free(buf);
+ rados_buffer_free(st);
+ if (!boost::regex_search(result, boost::regex("require_osd_release [l-z]"))) {
+ std::cout << "SKIPPING";
+ return;
+ }
+
char apps[128];
size_t app_len;
app_len = sizeof(apps);
ASSERT_EQ(0, rados_application_list(ioctx, apps, &app_len));
- ASSERT_EQ(0U, app_len);
+ ASSERT_EQ(6U, app_len);
+ ASSERT_EQ(0, memcmp("rados\0", apps, app_len));
- ASSERT_EQ(0, rados_application_enable(ioctx, "app1", 0));
+ ASSERT_EQ(0, rados_application_enable(ioctx, "app1", 1));
ASSERT_EQ(-EPERM, rados_application_enable(ioctx, "app2", 0));
ASSERT_EQ(0, rados_application_enable(ioctx, "app2", 1));
ASSERT_EQ(-ERANGE, rados_application_list(ioctx, apps, &app_len));
- ASSERT_EQ(10U, app_len);
+ ASSERT_EQ(16U, app_len);
ASSERT_EQ(0, rados_application_list(ioctx, apps, &app_len));
- ASSERT_EQ(10U, app_len);
- ASSERT_EQ(0, memcmp("app1\0app2\0", apps, app_len));
+ ASSERT_EQ(16U, app_len);
+ ASSERT_EQ(0, memcmp("app1\0app2\0rados\0", apps, app_len));
char keys[128];
char vals[128];
}
TEST_F(LibRadosMiscPP, Applications) {
- std::set<std::string> expected_apps;
+ bufferlist inbl, outbl;
+ string outs;
+ ASSERT_EQ(0, cluster.mon_command("{\"prefix\": \"osd dump\"}",
+ inbl, &outbl, &outs));
+ ASSERT_LT(0u, outbl.length());
+ ASSERT_LE(0u, outs.length());
+ if (!boost::regex_search(outbl.to_str(),
+ boost::regex("require_osd_release [l-z]"))) {
+ std::cout << "SKIPPING";
+ return;
+ }
+
+ std::set<std::string> expected_apps = {"rados"};
std::set<std::string> apps;
ASSERT_EQ(0, ioctx.application_list(&apps));
ASSERT_EQ(expected_apps, apps);
- ASSERT_EQ(0, ioctx.application_enable("app1", false));
+ ASSERT_EQ(0, ioctx.application_enable("app1", true));
ASSERT_EQ(-EPERM, ioctx.application_enable("app2", false));
ASSERT_EQ(0, ioctx.application_enable("app2", true));
- expected_apps = {"app1", "app2"};
+ expected_apps = {"app1", "app2", "rados"};
ASSERT_EQ(0, ioctx.application_list(&apps));
ASSERT_EQ(expected_apps, apps);
return oss.str();
}
+ rados_ioctx_t ioctx;
+ ret = rados_ioctx_create(*cluster, pool_name.c_str(), &ioctx);
+ if (ret < 0) {
+ rados_shutdown(*cluster);
+ std::ostringstream oss;
+ oss << "rados_ioctx_create(" << pool_name << ") failed with error " << ret;
+ return oss.str();
+ }
+
+ rados_application_enable(ioctx, "rados", 1);
+ rados_ioctx_destroy(ioctx);
return "";
}
oss << "cluster.pool_create(" << pool_name << ") failed with error " << ret;
return oss.str();
}
+
+ IoCtx ioctx;
+ ret = cluster.ioctx_create(pool_name.c_str(), ioctx);
+ if (ret < 0) {
+ cluster.shutdown();
+ std::ostringstream oss;
+ oss << "cluster.ioctx_create(" << pool_name << ") failed with error "
+ << ret;
+ return oss.str();
+ }
+ ioctx.application_enable("rados", true);
return "";
}
cache_pool_name = get_temp_pool_name();
ASSERT_EQ(0, s_cluster.pool_create(cache_pool_name.c_str()));
RadosTestPP::SetUp();
+
ASSERT_EQ(0, cluster.ioctx_create(cache_pool_name.c_str(), cache_ioctx));
+ cache_ioctx.application_enable("rados", true);
cache_ioctx.set_namespace(nspace);
}
void TearDown() override {
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));
+ cache_ioctx.application_enable("rados", true);
IoCtx ioctx;
ASSERT_EQ(0, cluster.ioctx_create(pool_name.c_str(), ioctx));
cache_pool_name = get_temp_pool_name();
ASSERT_EQ(0, s_cluster.pool_create(cache_pool_name.c_str()));
RadosTestECPP::SetUp();
+
ASSERT_EQ(0, cluster.ioctx_create(cache_pool_name.c_str(), cache_ioctx));
+ cache_ioctx.application_enable("rados", true);
cache_ioctx.set_namespace(nspace);
}
void TearDown() override {
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));
+ cache_ioctx.application_enable("rados", true);
IoCtx ioctx;
ASSERT_EQ(0, cluster.ioctx_create(pool_name.c_str(), ioctx));
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));
+ cache_ioctx.application_enable("rados", true);
IoCtx ioctx;
ASSERT_EQ(0, cluster.ioctx_create(pool_name.c_str(), ioctx));
simple_err("Error creating ioctx", r);
goto failed_krbd;
}
+ rados_application_enable(ioctx, "rbd", 1);
+
if (clone_calls || journal_replay) {
uint64_t features = 0;
if (clone_calls) {
return 0;
}
+ librados::IoCtx ioctx;
+ r = rados.ioctx_create(pool.c_str(), ioctx);
+ if (r < 0) {
+ return r;
+ }
+ ioctx.application_enable("rbd", true);
+
return r;
}
std::cerr << "ioctx_create " << pool_name << " failed with " << ret << std::endl;
exit(1);
}
+ ioctx.application_enable("rados", true);
ret = ioctx.create(obj_name, false);
if (ret < 0) {
}
ioctx.close();
+ ret = cluster.pool_delete(pool_name.c_str());
+ if (ret < 0) {
+ std::cerr << "pool_delete failed with " << ret << std::endl;
+ exit(1);
+ }
}
#pragma GCC diagnostic pop
from __future__ import print_function
+from nose import SkipTest
from nose.tools import eq_ as eq, ok_ as ok, assert_raises
from rados import (Rados, Error, RadosStateError, Object, ObjectExists,
ObjectNotFound, ObjectBusy, requires, opt,
[i.remove() for i in self.ioctx.list_objects()]
def test_applications(self):
+ cmd = {"prefix":"osd dump", "format":"json"}
+ ret, buf, errs = self.rados.mon_command(json.dumps(cmd), b'')
+ eq(ret, 0)
+ assert len(buf) > 0
+ release = json.loads(buf.decode("utf-8")).get("require_osd_release",
+ None)
+ if not release or release[0] < 'l':
+ raise SkipTest
+
eq([], self.ioctx.application_list())
self.ioctx.application_enable("app1")
int64_t pool_id = m_cluster->pool_lookup(pool_name.c_str());
ASSERT_GE(pool_id, 0);
+
+ librados::IoCtx ioctx;
+ ASSERT_EQ(0, m_cluster->ioctx_create2(pool_id, ioctx));
+ ioctx.application_enable("rbd", true);
+
m_pools.insert(pool_name);
if (enable_mirroring) {
- librados::IoCtx ioctx;
- ASSERT_EQ(0, m_cluster->ioctx_create2(pool_id, ioctx));
ASSERT_EQ(0, librbd::api::Mirror<>::mode_set(ioctx,
RBD_MIRROR_MODE_POOL));
EXPECT_EQ(0, m_local_cluster->pool_create(m_local_pool_name.c_str()));
EXPECT_EQ(0, m_local_cluster->ioctx_create(m_local_pool_name.c_str(),
m_local_ioctx));
+ m_local_ioctx.application_enable("rbd", true);
EXPECT_EQ("", connect_cluster_pp(m_remote_cluster));
EXPECT_EQ(0, m_remote_cluster.conf_set("rbd_cache", "false"));
EXPECT_EQ(0, m_remote_cluster.ioctx_create(m_remote_pool_name.c_str(),
m_remote_ioctx));
+ m_remote_ioctx.application_enable("rbd", true);
+
EXPECT_EQ(0, librbd::api::Mirror<>::mode_set(m_remote_ioctx,
RBD_MIRROR_MODE_POOL));
librados::IoCtx ioctx;
ASSERT_EQ(0, m_cluster->ioctx_create2(pool_id, ioctx));
+ ioctx.application_enable("rbd", true);
m_pool_watcher.reset(new PoolWatcher<>(m_threads, ioctx,
m_pool_watcher_listener));
_local_pool_name = get_temp_pool_name("test-rbd-mirror-");
ASSERT_EQ(0, _rados->pool_create(_local_pool_name.c_str()));
+ librados::IoCtx local_ioctx;
+ ASSERT_EQ(0, _rados->ioctx_create(_local_pool_name.c_str(), local_ioctx));
+ local_ioctx.application_enable("rbd", true);
+
_remote_pool_name = get_temp_pool_name("test-rbd-mirror-");
ASSERT_EQ(0, _rados->pool_create(_remote_pool_name.c_str()));
+ librados::IoCtx remote_ioctx;
+ ASSERT_EQ(0, _rados->ioctx_create(_remote_pool_name.c_str(), remote_ioctx));
+ remote_ioctx.application_enable("rbd", true);
+
ASSERT_EQ(0, create_image_data_pool(_data_pool));
if (!_data_pool.empty()) {
printf("using image data pool: %s\n", _data_pool.c_str());
if (m_open_pool_sem)
m_open_pool_sem->post();
rados_ioctx_destroy(io_ctx);
+ rados_pool_delete(cl, m_pool_name.c_str());
rados_shutdown(cl);
return 0;
}
<< "': error " << ret << std::endl;
return 1;
}
+ ioctx.application_enable("rados", true);
+
librados::ObjectWriteOperation op;
op.create(true);
ret = ioctx.operate(oid, &op);