}
}
+
+
+void simple_write_cb(rbd_completion_t cb, void *arg)
+{
+ printf("write completion cb called!\n");
+}
+
+void simple_read_cb(rbd_completion_t cb, void *arg)
+{
+ printf("read completion cb called!\n");
+}
+
+void aio_write_test_data_and_poll(rbd_image_t image, int fd, const char *test_data,
+ uint64_t off, size_t len, uint32_t iohint, bool *passed)
+{
+ rbd_completion_t comp;
+ uint64_t data = 0x123;
+ rbd_aio_create_completion((void*)&data, (rbd_callback_t) simple_write_cb, &comp);
+ printf("created completion\n");
+ printf("started write\n");
+ if (iohint)
+ rbd_aio_write2(image, off, len, test_data, comp, iohint);
+ else
+ rbd_aio_write(image, off, len, test_data, comp);
+
+ struct pollfd pfd;
+ pfd.fd = fd;
+ pfd.events = POLLIN;
+
+ ASSERT_EQ(1, poll(&pfd, 1, -1));
+ ASSERT_TRUE(pfd.revents & POLLIN);
+
+ rbd_completion_t comps[1];
+ ASSERT_EQ(1, rbd_poll_io_events(image, comps, 1));
+ uint64_t count;
+ ASSERT_EQ(static_cast<ssize_t>(sizeof(count)),
+ read(fd, &count, sizeof(count)));
+ int r = rbd_aio_get_return_value(comps[0]);
+ ASSERT_TRUE(rbd_aio_is_complete(comps[0]));
+ ASSERT_TRUE(*(uint64_t*)rbd_aio_get_arg(comps[0]) == data);
+ printf("return value is: %d\n", r);
+ ASSERT_EQ(0, r);
+ printf("finished write\n");
+ rbd_aio_release(comps[0]);
+ *passed = true;
+}
+
+void aio_write_test_data(rbd_image_t image, const char *test_data, uint64_t off, size_t len, uint32_t iohint, bool *passed)
+{
+ rbd_completion_t comp;
+ rbd_aio_create_completion(NULL, (rbd_callback_t) simple_write_cb, &comp);
+ printf("created completion\n");
+ if (iohint)
+ rbd_aio_write2(image, off, len, test_data, comp, iohint);
+ else
+ rbd_aio_write(image, off, len, test_data, comp);
+ printf("started write\n");
+ rbd_aio_wait_for_complete(comp);
+ int r = rbd_aio_get_return_value(comp);
+ printf("return value is: %d\n", r);
+ ASSERT_EQ(0, r);
+ printf("finished write\n");
+ rbd_aio_release(comp);
+ *passed = true;
+}
+
+void write_test_data(rbd_image_t image, const char *test_data, uint64_t off, size_t len, uint32_t iohint, bool *passed)
+{
+ ssize_t written;
+ if (iohint)
+ written = rbd_write2(image, off, len, test_data, iohint);
+ else
+ written = rbd_write(image, off, len, test_data);
+ printf("wrote: %d\n", (int) written);
+ ASSERT_EQ(len, static_cast<size_t>(written));
+ *passed = true;
+}
+
+void aio_discard_test_data(rbd_image_t image, uint64_t off, uint64_t len, bool *passed)
+{
+ rbd_completion_t comp;
+ rbd_aio_create_completion(NULL, (rbd_callback_t) simple_write_cb, &comp);
+ rbd_aio_discard(image, off, len, comp);
+ rbd_aio_wait_for_complete(comp);
+ int r = rbd_aio_get_return_value(comp);
+ ASSERT_EQ(0, r);
+ printf("aio discard: %d~%d = %d\n", (int)off, (int)len, (int)r);
+ rbd_aio_release(comp);
+ *passed = true;
+}
+
+void discard_test_data(rbd_image_t image, uint64_t off, size_t len, bool *passed)
+{
+ ssize_t written;
+ written = rbd_discard(image, off, len);
+ printf("discard: %d~%d = %d\n", (int)off, (int)len, (int)written);
+ ASSERT_EQ(len, static_cast<size_t>(written));
+ *passed = true;
+}
+
+void aio_read_test_data_and_poll(rbd_image_t image, int fd, const char *expected,
+ uint64_t off, size_t len, uint32_t iohint, bool *passed)
+{
+ rbd_completion_t comp;
+ char *result = (char *)malloc(len + 1);
+
+ ASSERT_NE(static_cast<char *>(NULL), result);
+ rbd_aio_create_completion(NULL, (rbd_callback_t) simple_read_cb, &comp);
+ printf("created completion\n");
+ printf("started read\n");
+ if (iohint)
+ rbd_aio_read2(image, off, len, result, comp, iohint);
+ else
+ rbd_aio_read(image, off, len, result, comp);
+
+ struct pollfd pfd;
+ pfd.fd = fd;
+ pfd.events = POLLIN;
+
+ ASSERT_EQ(1, poll(&pfd, 1, -1));
+ ASSERT_TRUE(pfd.revents & POLLIN);
+
+ rbd_completion_t comps[1];
+ ASSERT_EQ(1, rbd_poll_io_events(image, comps, 1));
+ uint64_t count;
+ ASSERT_EQ(static_cast<ssize_t>(sizeof(count)),
+ read(fd, &count, sizeof(count)));
+
+ int r = rbd_aio_get_return_value(comps[0]);
+ ASSERT_TRUE(rbd_aio_is_complete(comps[0]));
+ printf("return value is: %d\n", r);
+ ASSERT_EQ(len, static_cast<size_t>(r));
+ rbd_aio_release(comps[0]);
+ if (memcmp(result, expected, len)) {
+ printf("read: %s\nexpected: %s\n", result, expected);
+ ASSERT_EQ(0, memcmp(result, expected, len));
+ }
+ free(result);
+ *passed = true;
+}
+
+void aio_read_test_data(rbd_image_t image, const char *expected, uint64_t off, size_t len, uint32_t iohint, bool *passed)
+{
+ rbd_completion_t comp;
+ char *result = (char *)malloc(len + 1);
+
+ ASSERT_NE(static_cast<char *>(NULL), result);
+ rbd_aio_create_completion(NULL, (rbd_callback_t) simple_read_cb, &comp);
+ printf("created completion\n");
+ if (iohint)
+ rbd_aio_read2(image, off, len, result, comp, iohint);
+ else
+ rbd_aio_read(image, off, len, result, comp);
+ printf("started read\n");
+ rbd_aio_wait_for_complete(comp);
+ int r = rbd_aio_get_return_value(comp);
+ printf("return value is: %d\n", r);
+ ASSERT_EQ(len, static_cast<size_t>(r));
+ rbd_aio_release(comp);
+ if (memcmp(result, expected, len)) {
+ printf("read: %s\nexpected: %s\n", result, expected);
+ ASSERT_EQ(0, memcmp(result, expected, len));
+ }
+ free(result);
+ *passed = true;
+}
+
+void read_test_data(rbd_image_t image, const char *expected, uint64_t off, size_t len, uint32_t iohint, bool *passed)
+{
+ ssize_t read;
+ char *result = (char *)malloc(len + 1);
+
+ ASSERT_NE(static_cast<char *>(NULL), result);
+ if (iohint)
+ read = rbd_read2(image, off, len, result, iohint);
+ else
+ read = rbd_read(image, off, len, result);
+ printf("read: %d\n", (int) read);
+ ASSERT_EQ(len, static_cast<size_t>(read));
+ result[len] = '\0';
+ if (memcmp(result, expected, len)) {
+ printf("read: %s\nexpected: %s\n", result, expected);
+ ASSERT_EQ(0, memcmp(result, expected, len));
+ }
+ free(result);
+ *passed = true;
+}
+
+void aio_writesame_test_data(rbd_image_t image, const char *test_data, uint64_t off, uint64_t len,
+ uint64_t data_len, uint32_t iohint, bool *passed)
+{
+ rbd_completion_t comp;
+ rbd_aio_create_completion(NULL, (rbd_callback_t) simple_write_cb, &comp);
+ printf("created completion\n");
+ int r;
+ r = rbd_aio_writesame(image, off, len, test_data, data_len, comp, iohint);
+ printf("started writesame\n");
+ if (len % data_len) {
+ ASSERT_EQ(-EINVAL, r);
+ printf("expected fail, finished writesame\n");
+ rbd_aio_release(comp);
+ *passed = true;
+ return;
+ }
+
+ rbd_aio_wait_for_complete(comp);
+ r = rbd_aio_get_return_value(comp);
+ printf("return value is: %d\n", r);
+ ASSERT_EQ(0, r);
+ printf("finished writesame\n");
+ rbd_aio_release(comp);
+
+ //verify data
+ printf("to verify the data\n");
+ ssize_t read;
+ char *result = (char *)malloc(data_len+ 1);
+ ASSERT_NE(static_cast<char *>(NULL), result);
+ uint64_t left = len;
+ while (left > 0) {
+ read = rbd_read(image, off, data_len, result);
+ ASSERT_EQ(data_len, static_cast<size_t>(read));
+ result[data_len] = '\0';
+ if (memcmp(result, test_data, data_len)) {
+ printf("read: %d ~ %d\n", (int) off, (int) read);
+ printf("read: %s\nexpected: %s\n", result, test_data);
+ ASSERT_EQ(0, memcmp(result, test_data, data_len));
+ }
+ off += data_len;
+ left -= data_len;
+ }
+ ASSERT_EQ(0U, left);
+ free(result);
+ printf("verified\n");
+
+ *passed = true;
+}
+
+void writesame_test_data(rbd_image_t image, const char *test_data, uint64_t off, uint64_t len,
+ uint64_t data_len, uint32_t iohint, bool *passed)
+{
+ ssize_t written;
+ written = rbd_writesame(image, off, len, test_data, data_len, iohint);
+ if (len % data_len) {
+ ASSERT_EQ(-EINVAL, written);
+ printf("expected fail, finished writesame\n");
+ *passed = true;
+ return;
+ }
+ ASSERT_EQ(len, static_cast<size_t>(written));
+ printf("wrote: %d\n", (int) written);
+
+ //verify data
+ printf("to verify the data\n");
+ ssize_t read;
+ char *result = (char *)malloc(data_len+ 1);
+ ASSERT_NE(static_cast<char *>(NULL), result);
+ uint64_t left = len;
+ while (left > 0) {
+ read = rbd_read(image, off, data_len, result);
+ ASSERT_EQ(data_len, static_cast<size_t>(read));
+ result[data_len] = '\0';
+ if (memcmp(result, test_data, data_len)) {
+ printf("read: %d ~ %d\n", (int) off, (int) read);
+ printf("read: %s\nexpected: %s\n", result, test_data);
+ ASSERT_EQ(0, memcmp(result, test_data, data_len));
+ }
+ off += data_len;
+ left -= data_len;
+ }
+ ASSERT_EQ(0U, left);
+ free(result);
+ printf("verified\n");
+
+ *passed = true;
+}
+
+void aio_compare_and_write_test_data(rbd_image_t image, const char *cmp_data,
+ const char *test_data, uint64_t off,
+ size_t len, uint32_t iohint, bool *passed)
+{
+ rbd_completion_t comp;
+ rbd_aio_create_completion(NULL, (rbd_callback_t) simple_write_cb, &comp);
+ printf("created completion\n");
+
+ uint64_t mismatch_offset;
+ rbd_aio_compare_and_write(image, off, len, cmp_data, test_data, comp, &mismatch_offset, iohint);
+ printf("started aio compare and write\n");
+ rbd_aio_wait_for_complete(comp);
+ int r = rbd_aio_get_return_value(comp);
+ printf("return value is: %d\n", r);
+ ASSERT_EQ(0, r);
+ printf("finished aio compare and write\n");
+ rbd_aio_release(comp);
+ *passed = true;
+}
+
+void compare_and_write_test_data(rbd_image_t image, const char *cmp_data,
+ const char *test_data, uint64_t off, size_t len,
+ uint64_t *mismatch_off, uint32_t iohint, bool *passed)
+{
+ printf("start compare and write\n");
+ ssize_t written;
+ written = rbd_compare_and_write(image, off, len, cmp_data, test_data, mismatch_off, iohint);
+ printf("compare and wrote: %d\n", (int) written);
+ ASSERT_EQ(len, static_cast<size_t>(written));
+ *passed = true;
+}
+
class TestLibRBD : public ::testing::Test {
public:
EXPECT_EQ("", create_one_pool_pp(pool_name, rados));
_pool_names.push_back(pool_name);
}
- ++m_pool_number;
- return pool_name;
+ ++m_pool_number;
+ return pool_name;
+ }
+
+ void test_io(rbd_image_t image) {
+ bool skip_discard = is_skip_partial_discard_enabled(image);
+
+ char test_data[TEST_IO_SIZE + 1];
+ char zero_data[TEST_IO_SIZE + 1];
+ char mismatch_data[TEST_IO_SIZE + 1];
+ int i;
+ uint64_t mismatch_offset;
+
+ for (i = 0; i < TEST_IO_SIZE; ++i) {
+ test_data[i] = (char) (rand() % (126 - 33) + 33);
+ }
+ test_data[TEST_IO_SIZE] = '\0';
+ memset(zero_data, 0, sizeof(zero_data));
+ memset(mismatch_data, 9, sizeof(mismatch_data));
+
+ for (i = 0; i < 5; ++i)
+ ASSERT_PASSED(write_test_data, image, test_data, TEST_IO_SIZE * i,
+ TEST_IO_SIZE, 0);
+
+ for (i = 5; i < 10; ++i)
+ ASSERT_PASSED(aio_write_test_data, image, test_data, TEST_IO_SIZE * i,
+ TEST_IO_SIZE, 0);
+
+ for (i = 0; i < 5; ++i)
+ ASSERT_PASSED(compare_and_write_test_data, image, test_data, test_data,
+ TEST_IO_SIZE * i, TEST_IO_SIZE, &mismatch_offset, 0);
+
+ for (i = 5; i < 10; ++i)
+ ASSERT_PASSED(aio_compare_and_write_test_data, image, test_data, test_data,
+ TEST_IO_SIZE * i, TEST_IO_SIZE, 0);
+
+ for (i = 0; i < 5; ++i)
+ ASSERT_PASSED(read_test_data, image, test_data, TEST_IO_SIZE * i,
+ TEST_IO_SIZE, 0);
+
+ for (i = 5; i < 10; ++i)
+ ASSERT_PASSED(aio_read_test_data, image, test_data, TEST_IO_SIZE * i,
+ TEST_IO_SIZE, 0);
+
+ // discard 2nd, 4th sections.
+ ASSERT_PASSED(discard_test_data, image, TEST_IO_SIZE, TEST_IO_SIZE);
+ ASSERT_PASSED(aio_discard_test_data, image, TEST_IO_SIZE*3, TEST_IO_SIZE);
+
+ ASSERT_PASSED(read_test_data, image, test_data, 0, TEST_IO_SIZE, 0);
+ ASSERT_PASSED(read_test_data, image, skip_discard ? test_data : zero_data,
+ TEST_IO_SIZE, TEST_IO_SIZE, 0);
+ ASSERT_PASSED(read_test_data, image, test_data, TEST_IO_SIZE*2,
+ TEST_IO_SIZE, 0);
+ ASSERT_PASSED(read_test_data, image, skip_discard ? test_data : zero_data,
+ TEST_IO_SIZE*3, TEST_IO_SIZE, 0);
+ ASSERT_PASSED(read_test_data, image, test_data, TEST_IO_SIZE*4,
+ TEST_IO_SIZE, 0);
+
+ for (i = 0; i < 15; ++i) {
+ if (i % 3 == 2) {
+ ASSERT_PASSED(writesame_test_data, image, test_data, TEST_IO_SIZE * i,
+ TEST_IO_SIZE * i * 32 + i, TEST_IO_SIZE, 0);
+ ASSERT_PASSED(writesame_test_data, image, zero_data, TEST_IO_SIZE * i,
+ TEST_IO_SIZE * i * 32 + i, TEST_IO_SIZE, 0);
+ } else if (i % 3 == 1) {
+ ASSERT_PASSED(writesame_test_data, image, test_data, TEST_IO_SIZE + i,
+ TEST_IO_SIZE * i * 32, TEST_IO_SIZE, 0);
+ ASSERT_PASSED(writesame_test_data, image, zero_data, TEST_IO_SIZE + i,
+ TEST_IO_SIZE * i * 32, TEST_IO_SIZE, 0);
+ } else {
+ ASSERT_PASSED(writesame_test_data, image, test_data, TEST_IO_SIZE * i,
+ TEST_IO_SIZE * i * 32, TEST_IO_SIZE, 0);
+ ASSERT_PASSED(writesame_test_data, image, zero_data, TEST_IO_SIZE * i,
+ TEST_IO_SIZE * i * 32, TEST_IO_SIZE, 0);
+ }
+ }
+ for (i = 0; i < 15; ++i) {
+ if (i % 3 == 2) {
+ ASSERT_PASSED(aio_writesame_test_data, image, test_data,
+ TEST_IO_SIZE * i, TEST_IO_SIZE * i * 32 + i, TEST_IO_SIZE,
+ 0);
+ ASSERT_PASSED(aio_writesame_test_data, image, zero_data,
+ TEST_IO_SIZE * i, TEST_IO_SIZE * i * 32 + i, TEST_IO_SIZE,
+ 0);
+ } else if (i % 3 == 1) {
+ ASSERT_PASSED(aio_writesame_test_data, image, test_data,
+ TEST_IO_SIZE + i, TEST_IO_SIZE * i * 32, TEST_IO_SIZE, 0);
+ ASSERT_PASSED(aio_writesame_test_data, image, zero_data,
+ TEST_IO_SIZE + i, TEST_IO_SIZE * i * 32, TEST_IO_SIZE, 0);
+ } else {
+ ASSERT_PASSED(aio_writesame_test_data, image, test_data,
+ TEST_IO_SIZE * i, TEST_IO_SIZE * i * 32, TEST_IO_SIZE, 0);
+ ASSERT_PASSED(aio_writesame_test_data, image, zero_data,
+ TEST_IO_SIZE * i, TEST_IO_SIZE * i * 32, TEST_IO_SIZE, 0);
+ }
+ }
+
+ rbd_image_info_t info;
+ rbd_completion_t comp;
+ ASSERT_EQ(0, rbd_stat(image, &info, sizeof(info)));
+ // can't read or write starting past end
+ ASSERT_EQ(-EINVAL, rbd_write(image, info.size, 1, test_data));
+ ASSERT_EQ(-EINVAL, rbd_read(image, info.size, 1, test_data));
+ // reading through end returns amount up to end
+ ASSERT_EQ(10, rbd_read(image, info.size - 10, 100, test_data));
+ // writing through end returns amount up to end
+ ASSERT_EQ(10, rbd_write(image, info.size - 10, 100, test_data));
+
+ rbd_aio_create_completion(NULL, (rbd_callback_t) simple_read_cb, &comp);
+ ASSERT_EQ(0, rbd_aio_write(image, info.size, 1, test_data, comp));
+ ASSERT_EQ(0, rbd_aio_wait_for_complete(comp));
+ ASSERT_EQ(-EINVAL, rbd_aio_get_return_value(comp));
+ rbd_aio_release(comp);
+
+ rbd_aio_create_completion(NULL, (rbd_callback_t) simple_read_cb, &comp);
+ ASSERT_EQ(0, rbd_aio_read(image, info.size, 1, test_data, comp));
+ ASSERT_EQ(0, rbd_aio_wait_for_complete(comp));
+ ASSERT_EQ(-EINVAL, rbd_aio_get_return_value(comp));
+ rbd_aio_release(comp);
+
+ ASSERT_PASSED(write_test_data, image, zero_data, 0, TEST_IO_SIZE,
+ LIBRADOS_OP_FLAG_FADVISE_NOCACHE);
+ ASSERT_EQ(-EILSEQ, rbd_compare_and_write(image, 0, TEST_IO_SIZE,
+ mismatch_data, mismatch_data, &mismatch_offset, 0));
+ ASSERT_EQ(0U, mismatch_offset);
+ rbd_aio_create_completion(NULL, (rbd_callback_t) simple_read_cb, &comp);
+ ASSERT_EQ(0, rbd_aio_compare_and_write(image, 0, TEST_IO_SIZE, mismatch_data,
+ mismatch_data, comp, &mismatch_offset, 0));
+ ASSERT_EQ(0, rbd_aio_wait_for_complete(comp));
+ ASSERT_EQ(0U, mismatch_offset);
+ rbd_aio_release(comp);
+
+ ASSERT_PASSED(validate_object_map, image);
}
static std::vector<std::string> _pool_names;
keys_len = sizeof(keys);
vals_len = sizeof(vals);
- ASSERT_EQ(0, rbd_open(ioctx, name6.c_str(), &image6, NULL));
- BOOST_SCOPE_EXIT_ALL( (&image6) ) {
- ASSERT_EQ(0, rbd_close(image6));
- };
- ASSERT_EQ(0, rbd_metadata_list(image6, "key", 70, keys, &keys_len, vals,
- &vals_len));
- ASSERT_EQ(keys_len, sum_key_len);
- ASSERT_EQ(vals_len, sum_value_len);
-
- for (int i = 1; i <= 70; i++) {
- key = "key" + stringify(i);
- val = "value" + stringify(i);
- ASSERT_EQ(0, rbd_metadata_get(image6, key.c_str(), value, &value_len));
- ASSERT_STREQ(val.c_str(), value);
-
- value_len = sizeof(value);
- }
-}
-
-TEST_F(TestLibRBD, TestDeepCopyPP)
-{
- REQUIRE_FORMAT_V2();
-
- librados::IoCtx ioctx;
- ASSERT_EQ(0, _rados.ioctx_create(create_pool(true).c_str(), ioctx));
-
- {
- librbd::RBD rbd;
- librbd::Image image;
- librbd::Image image2;
- librbd::Image image3;
- int order = 0;
- std::string name = get_temp_image_name();
- std::string name2 = get_temp_image_name();
- std::string name3 = get_temp_image_name();
- uint64_t size = 2 << 20;
- librbd::ImageOptions opts;
- PrintProgress pp;
-
- ASSERT_EQ(0, create_image_pp(rbd, ioctx, name.c_str(), size, &order));
- ASSERT_EQ(0, rbd.open(ioctx, image, name.c_str(), NULL));
-
- std::string key;
- std::string val;
- for (int i = 1; i <= 70; i++) {
- key = "key" + stringify(i);
- val = "value" + stringify(i);
- ASSERT_EQ(0, image.metadata_set(key, val));
- }
-
- ASSERT_EQ(1, test_ls_pp(rbd, ioctx, 1, name.c_str()));
- ASSERT_EQ(0, image.deep_copy(ioctx, name2.c_str(), opts));
- ASSERT_EQ(2, test_ls_pp(rbd, ioctx, 2, name.c_str(), name2.c_str()));
- ASSERT_EQ(0, rbd.open(ioctx, image2, name2.c_str(), NULL));
-
- map<string, bufferlist> pairs;
- std::string value;
- ASSERT_EQ(0, image2.metadata_list("", 70, &pairs));
- ASSERT_EQ(70U, pairs.size());
-
- for (int i = 1; i <= 70; i++) {
- key = "key" + stringify(i);
- val = "value" + stringify(i);
- ASSERT_EQ(0, image2.metadata_get(key.c_str(), &value));
- ASSERT_STREQ(val.c_str(), value.c_str());
- }
-
- ASSERT_EQ(0, image.deep_copy_with_progress(ioctx, name3.c_str(), opts, pp));
- ASSERT_EQ(3, test_ls_pp(rbd, ioctx, 3, name.c_str(), name2.c_str(),
- name3.c_str()));
- ASSERT_EQ(0, rbd.open(ioctx, image3, name3.c_str(), NULL));
-
- pairs.clear();
- ASSERT_EQ(0, image3.metadata_list("", 70, &pairs));
- ASSERT_EQ(70U, pairs.size());
-
- for (int i = 1; i <= 70; i++) {
- key = "key" + stringify(i);
- val = "value" + stringify(i);
- ASSERT_EQ(0, image3.metadata_get(key.c_str(), &value));
- ASSERT_STREQ(val.c_str(), value.c_str());
- }
- }
-
- ioctx.close();
-}
-
-int test_ls_snaps(rbd_image_t image, int num_expected, ...)
-{
- int num_snaps, i, j, max_size = 10;
- va_list ap;
- rbd_snap_info_t snaps[max_size];
- num_snaps = rbd_snap_list(image, snaps, &max_size);
- printf("num snaps is: %d\nexpected: %d\n", num_snaps, num_expected);
-
- for (i = 0; i < num_snaps; i++) {
- printf("snap: %s\n", snaps[i].name);
- }
-
- va_start(ap, num_expected);
- for (i = num_expected; i > 0; i--) {
- char *expected = va_arg(ap, char *);
- uint64_t expected_size = va_arg(ap, uint64_t);
- bool found = false;
- for (j = 0; j < num_snaps; j++) {
- if (snaps[j].name == NULL)
- continue;
- if (strcmp(snaps[j].name, expected) == 0) {
- printf("found %s with size %llu\n", snaps[j].name, (unsigned long long) snaps[j].size);
- EXPECT_EQ(expected_size, snaps[j].size);
- free((void *) snaps[j].name);
- snaps[j].name = NULL;
- found = true;
- break;
- }
- }
- EXPECT_TRUE(found);
- }
- va_end(ap);
-
- for (i = 0; i < num_snaps; i++) {
- EXPECT_EQ((const char *)0, snaps[i].name);
- }
-
- return num_snaps;
-}
-
-TEST_F(TestLibRBD, TestCreateLsDeleteSnap)
-{
- rados_ioctx_t ioctx;
- rados_ioctx_create(_cluster, m_pool_name.c_str(), &ioctx);
-
- rbd_image_t image;
- int order = 0;
- std::string name = get_temp_image_name();
- uint64_t size = 2 << 20;
- uint64_t size2 = 4 << 20;
-
- ASSERT_EQ(0, create_image(ioctx, name.c_str(), size, &order));
- ASSERT_EQ(0, rbd_open(ioctx, name.c_str(), &image, NULL));
-
- ASSERT_EQ(0, rbd_snap_create(image, "snap1"));
- ASSERT_EQ(1, test_ls_snaps(image, 1, "snap1", size));
- ASSERT_EQ(0, rbd_resize(image, size2));
- ASSERT_EQ(0, rbd_snap_create(image, "snap2"));
- ASSERT_EQ(2, test_ls_snaps(image, 2, "snap1", size, "snap2", size2));
- ASSERT_EQ(0, rbd_snap_remove(image, "snap1"));
- ASSERT_EQ(1, test_ls_snaps(image, 1, "snap2", size2));
- ASSERT_EQ(0, rbd_snap_remove(image, "snap2"));
- ASSERT_EQ(0, test_ls_snaps(image, 0));
-
- ASSERT_EQ(0, rbd_close(image));
-
- rados_ioctx_destroy(ioctx);
-}
-
-int test_get_snapshot_timestamp(rbd_image_t image, uint64_t snap_id)
-{
- struct timespec timestamp;
- EXPECT_EQ(0, rbd_snap_get_timestamp(image, snap_id, ×tamp));
- EXPECT_LT(0, timestamp.tv_sec);
- return 0;
-}
-
-TEST_F(TestLibRBD, TestGetSnapShotTimeStamp)
-{
- REQUIRE_FORMAT_V2();
-
- rados_ioctx_t ioctx;
- rados_ioctx_create(_cluster, m_pool_name.c_str(), &ioctx);
-
- rbd_image_t image;
- int order = 0;
- std::string name = get_temp_image_name();
- uint64_t size = 2 << 20;
- int num_snaps, max_size = 10;
- rbd_snap_info_t snaps[max_size];
-
- ASSERT_EQ(0, create_image(ioctx, name.c_str(), size, &order));
- ASSERT_EQ(0, rbd_open(ioctx, name.c_str(), &image, NULL));
-
- ASSERT_EQ(0, rbd_snap_create(image, "snap1"));
- num_snaps = rbd_snap_list(image, snaps, &max_size);
- ASSERT_EQ(1, num_snaps);
- ASSERT_EQ(0, test_get_snapshot_timestamp(image, snaps[0].id));
- free((void *)snaps[0].name);
-
- ASSERT_EQ(0, rbd_snap_create(image, "snap2"));
- num_snaps = rbd_snap_list(image, snaps, &max_size);
- ASSERT_EQ(2, num_snaps);
- ASSERT_EQ(0, test_get_snapshot_timestamp(image, snaps[0].id));
- ASSERT_EQ(0, test_get_snapshot_timestamp(image, snaps[1].id));
- free((void *)snaps[0].name);
- free((void *)snaps[1].name);
-
- ASSERT_EQ(0, rbd_close(image));
-
- rados_ioctx_destroy(ioctx);
-}
-
-
-int test_ls_snaps(librbd::Image& image, size_t num_expected, ...)
-{
- int r;
- size_t i, j;
- va_list ap;
- vector<librbd::snap_info_t> snaps;
- r = image.snap_list(snaps);
- EXPECT_TRUE(r >= 0);
- cout << "num snaps is: " << snaps.size() << std::endl
- << "expected: " << num_expected << std::endl;
-
- for (i = 0; i < snaps.size(); i++) {
- cout << "snap: " << snaps[i].name << std::endl;
- }
-
- va_start(ap, num_expected);
- for (i = num_expected; i > 0; i--) {
- char *expected = va_arg(ap, char *);
- uint64_t expected_size = va_arg(ap, uint64_t);
- int found = 0;
- for (j = 0; j < snaps.size(); j++) {
- if (snaps[j].name == "")
- continue;
- if (strcmp(snaps[j].name.c_str(), expected) == 0) {
- cout << "found " << snaps[j].name << " with size " << snaps[j].size
- << std::endl;
- EXPECT_EQ(expected_size, snaps[j].size);
- snaps[j].name = "";
- found = 1;
- break;
- }
- }
- EXPECT_TRUE(found);
- }
- va_end(ap);
-
- for (i = 0; i < snaps.size(); i++) {
- EXPECT_EQ("", snaps[i].name);
- }
-
- return snaps.size();
-}
+ ASSERT_EQ(0, rbd_open(ioctx, name6.c_str(), &image6, NULL));
+ BOOST_SCOPE_EXIT_ALL( (&image6) ) {
+ ASSERT_EQ(0, rbd_close(image6));
+ };
+ ASSERT_EQ(0, rbd_metadata_list(image6, "key", 70, keys, &keys_len, vals,
+ &vals_len));
+ ASSERT_EQ(keys_len, sum_key_len);
+ ASSERT_EQ(vals_len, sum_value_len);
-TEST_F(TestLibRBD, TestCreateLsDeleteSnapPP)
-{
- librados::IoCtx ioctx;
- ASSERT_EQ(0, _rados.ioctx_create(m_pool_name.c_str(), ioctx));
+ for (int i = 1; i <= 70; i++) {
+ key = "key" + stringify(i);
+ val = "value" + stringify(i);
+ ASSERT_EQ(0, rbd_metadata_get(image6, key.c_str(), value, &value_len));
+ ASSERT_STREQ(val.c_str(), value);
- {
- librbd::RBD rbd;
- librbd::Image image;
- int order = 0;
- std::string name = get_temp_image_name();
- uint64_t size = 2 << 20;
- uint64_t size2 = 4 << 20;
-
- ASSERT_EQ(0, create_image_pp(rbd, ioctx, name.c_str(), size, &order));
- ASSERT_EQ(0, rbd.open(ioctx, image, name.c_str(), NULL));
-
- bool exists;
- ASSERT_EQ(0, image.snap_exists2("snap1", &exists));
- ASSERT_FALSE(exists);
- ASSERT_EQ(0, image.snap_create("snap1"));
- ASSERT_EQ(0, image.snap_exists2("snap1", &exists));
- ASSERT_TRUE(exists);
- ASSERT_EQ(1, test_ls_snaps(image, 1, "snap1", size));
- ASSERT_EQ(0, image.resize(size2));
- ASSERT_EQ(0, image.snap_exists2("snap2", &exists));
- ASSERT_FALSE(exists);
- ASSERT_EQ(0, image.snap_create("snap2"));
- ASSERT_EQ(0, image.snap_exists2("snap2", &exists));
- ASSERT_TRUE(exists);
- ASSERT_EQ(2, test_ls_snaps(image, 2, "snap1", size, "snap2", size2));
- ASSERT_EQ(0, image.snap_remove("snap1"));
- ASSERT_EQ(0, image.snap_exists2("snap1", &exists));
- ASSERT_FALSE(exists);
- ASSERT_EQ(1, test_ls_snaps(image, 1, "snap2", size2));
- ASSERT_EQ(0, image.snap_remove("snap2"));
- ASSERT_EQ(0, image.snap_exists2("snap2", &exists));
- ASSERT_FALSE(exists);
- ASSERT_EQ(0, test_ls_snaps(image, 0));
+ value_len = sizeof(value);
}
-
- ioctx.close();
}
-TEST_F(TestLibRBD, TestGetNameIdSnapPP)
+TEST_F(TestLibRBD, TestDeepCopyPP)
{
+ REQUIRE_FORMAT_V2();
+
librados::IoCtx ioctx;
- ASSERT_EQ(0, _rados.ioctx_create(m_pool_name.c_str(), ioctx));
+ ASSERT_EQ(0, _rados.ioctx_create(create_pool(true).c_str(), ioctx));
{
librbd::RBD rbd;
librbd::Image image;
+ librbd::Image image2;
+ librbd::Image image3;
int order = 0;
std::string name = get_temp_image_name();
+ std::string name2 = get_temp_image_name();
+ std::string name3 = get_temp_image_name();
uint64_t size = 2 << 20;
+ librbd::ImageOptions opts;
+ PrintProgress pp;
ASSERT_EQ(0, create_image_pp(rbd, ioctx, name.c_str(), size, &order));
ASSERT_EQ(0, rbd.open(ioctx, image, name.c_str(), NULL));
- ASSERT_EQ(0, image.snap_create("snap1"));
- ASSERT_EQ(0, image.snap_create("snap2"));
- ASSERT_EQ(0, image.snap_create("snap3"));
- vector<librbd::snap_info_t> snaps;
- int r = image.snap_list(snaps);
- EXPECT_TRUE(r >= 0);
-
- for (size_t i = 0; i < snaps.size(); ++i) {
- std::string expected_snap_name;
- image.snap_get_name(snaps[i].id, &expected_snap_name);
- ASSERT_EQ(expected_snap_name, snaps[i].name);
+ std::string key;
+ std::string val;
+ for (int i = 1; i <= 70; i++) {
+ key = "key" + stringify(i);
+ val = "value" + stringify(i);
+ ASSERT_EQ(0, image.metadata_set(key, val));
}
- for (size_t i = 0; i < snaps.size(); ++i) {
- uint64_t expected_snap_id;
- image.snap_get_id(snaps[i].name, &expected_snap_id);
- ASSERT_EQ(expected_snap_id, snaps[i].id);
- }
+ ASSERT_EQ(1, test_ls_pp(rbd, ioctx, 1, name.c_str()));
+ ASSERT_EQ(0, image.deep_copy(ioctx, name2.c_str(), opts));
+ ASSERT_EQ(2, test_ls_pp(rbd, ioctx, 2, name.c_str(), name2.c_str()));
+ ASSERT_EQ(0, rbd.open(ioctx, image2, name2.c_str(), NULL));
- ASSERT_EQ(0, image.snap_remove("snap1"));
- ASSERT_EQ(0, image.snap_remove("snap2"));
- ASSERT_EQ(0, image.snap_remove("snap3"));
- ASSERT_EQ(0, test_ls_snaps(image, 0));
- }
+ map<string, bufferlist> pairs;
+ std::string value;
+ ASSERT_EQ(0, image2.metadata_list("", 70, &pairs));
+ ASSERT_EQ(70U, pairs.size());
- ioctx.close();
-}
+ for (int i = 1; i <= 70; i++) {
+ key = "key" + stringify(i);
+ val = "value" + stringify(i);
+ ASSERT_EQ(0, image2.metadata_get(key.c_str(), &value));
+ ASSERT_STREQ(val.c_str(), value.c_str());
+ }
-TEST_F(TestLibRBD, TestCreateLsRenameSnapPP)
-{
- librados::IoCtx ioctx;
- ASSERT_EQ(0, _rados.ioctx_create(m_pool_name.c_str(), ioctx));
+ ASSERT_EQ(0, image.deep_copy_with_progress(ioctx, name3.c_str(), opts, pp));
+ ASSERT_EQ(3, test_ls_pp(rbd, ioctx, 3, name.c_str(), name2.c_str(),
+ name3.c_str()));
+ ASSERT_EQ(0, rbd.open(ioctx, image3, name3.c_str(), NULL));
- {
- librbd::RBD rbd;
- librbd::Image image;
- int order = 0;
- std::string name = get_temp_image_name();
- uint64_t size = 2 << 20;
- uint64_t size2 = 4 << 20;
-
- ASSERT_EQ(0, create_image_pp(rbd, ioctx, name.c_str(), size, &order));
- ASSERT_EQ(0, rbd.open(ioctx, image, name.c_str(), NULL));
-
- bool exists;
- ASSERT_EQ(0, image.snap_exists2("snap1", &exists));
- ASSERT_FALSE(exists);
- ASSERT_EQ(0, image.snap_create("snap1"));
- ASSERT_EQ(0, image.snap_exists2("snap1", &exists));
- ASSERT_TRUE(exists);
- ASSERT_EQ(1, test_ls_snaps(image, 1, "snap1", size));
- ASSERT_EQ(0, image.resize(size2));
- ASSERT_EQ(0, image.snap_exists2("snap2", &exists));
- ASSERT_FALSE(exists);
- ASSERT_EQ(0, image.snap_create("snap2"));
- ASSERT_EQ(0, image.snap_exists2("snap2", &exists));
- ASSERT_TRUE(exists);
- ASSERT_EQ(2, test_ls_snaps(image, 2, "snap1", size, "snap2", size2));
- ASSERT_EQ(0, image.snap_rename("snap1","snap1-rename"));
- ASSERT_EQ(2, test_ls_snaps(image, 2, "snap1-rename", size, "snap2", size2));
- ASSERT_EQ(0, image.snap_exists2("snap1", &exists));
- ASSERT_FALSE(exists);
- ASSERT_EQ(0, image.snap_exists2("snap1-rename", &exists));
- ASSERT_TRUE(exists);
- ASSERT_EQ(0, image.snap_remove("snap1-rename"));
- ASSERT_EQ(0, image.snap_rename("snap2","snap2-rename"));
- ASSERT_EQ(1, test_ls_snaps(image, 1, "snap2-rename", size2));
- ASSERT_EQ(0, image.snap_exists2("snap2", &exists));
- ASSERT_FALSE(exists);
- ASSERT_EQ(0, image.snap_exists2("snap2-rename", &exists));
- ASSERT_TRUE(exists);
- ASSERT_EQ(0, image.snap_remove("snap2-rename"));
- ASSERT_EQ(0, test_ls_snaps(image, 0));
+ pairs.clear();
+ ASSERT_EQ(0, image3.metadata_list("", 70, &pairs));
+ ASSERT_EQ(70U, pairs.size());
+
+ for (int i = 1; i <= 70; i++) {
+ key = "key" + stringify(i);
+ val = "value" + stringify(i);
+ ASSERT_EQ(0, image3.metadata_get(key.c_str(), &value));
+ ASSERT_STREQ(val.c_str(), value.c_str());
+ }
}
ioctx.close();
}
-void simple_write_cb(rbd_completion_t cb, void *arg)
-{
- printf("write completion cb called!\n");
-}
-
-void simple_read_cb(rbd_completion_t cb, void *arg)
-{
- printf("read completion cb called!\n");
-}
-
-void aio_write_test_data_and_poll(rbd_image_t image, int fd, const char *test_data,
- uint64_t off, size_t len, uint32_t iohint, bool *passed)
+int test_ls_snaps(rbd_image_t image, int num_expected, ...)
{
- rbd_completion_t comp;
- uint64_t data = 0x123;
- rbd_aio_create_completion((void*)&data, (rbd_callback_t) simple_write_cb, &comp);
- printf("created completion\n");
- printf("started write\n");
- if (iohint)
- rbd_aio_write2(image, off, len, test_data, comp, iohint);
- else
- rbd_aio_write(image, off, len, test_data, comp);
+ int num_snaps, i, j, max_size = 10;
+ va_list ap;
+ rbd_snap_info_t snaps[max_size];
+ num_snaps = rbd_snap_list(image, snaps, &max_size);
+ printf("num snaps is: %d\nexpected: %d\n", num_snaps, num_expected);
- struct pollfd pfd;
- pfd.fd = fd;
- pfd.events = POLLIN;
+ for (i = 0; i < num_snaps; i++) {
+ printf("snap: %s\n", snaps[i].name);
+ }
- ASSERT_EQ(1, poll(&pfd, 1, -1));
- ASSERT_TRUE(pfd.revents & POLLIN);
+ va_start(ap, num_expected);
+ for (i = num_expected; i > 0; i--) {
+ char *expected = va_arg(ap, char *);
+ uint64_t expected_size = va_arg(ap, uint64_t);
+ bool found = false;
+ for (j = 0; j < num_snaps; j++) {
+ if (snaps[j].name == NULL)
+ continue;
+ if (strcmp(snaps[j].name, expected) == 0) {
+ printf("found %s with size %llu\n", snaps[j].name, (unsigned long long) snaps[j].size);
+ EXPECT_EQ(expected_size, snaps[j].size);
+ free((void *) snaps[j].name);
+ snaps[j].name = NULL;
+ found = true;
+ break;
+ }
+ }
+ EXPECT_TRUE(found);
+ }
+ va_end(ap);
- rbd_completion_t comps[1];
- ASSERT_EQ(1, rbd_poll_io_events(image, comps, 1));
- uint64_t count;
- ASSERT_EQ(static_cast<ssize_t>(sizeof(count)),
- read(fd, &count, sizeof(count)));
- int r = rbd_aio_get_return_value(comps[0]);
- ASSERT_TRUE(rbd_aio_is_complete(comps[0]));
- ASSERT_TRUE(*(uint64_t*)rbd_aio_get_arg(comps[0]) == data);
- printf("return value is: %d\n", r);
- ASSERT_EQ(0, r);
- printf("finished write\n");
- rbd_aio_release(comps[0]);
- *passed = true;
-}
+ for (i = 0; i < num_snaps; i++) {
+ EXPECT_EQ((const char *)0, snaps[i].name);
+ }
-void aio_write_test_data(rbd_image_t image, const char *test_data, uint64_t off, size_t len, uint32_t iohint, bool *passed)
-{
- rbd_completion_t comp;
- rbd_aio_create_completion(NULL, (rbd_callback_t) simple_write_cb, &comp);
- printf("created completion\n");
- if (iohint)
- rbd_aio_write2(image, off, len, test_data, comp, iohint);
- else
- rbd_aio_write(image, off, len, test_data, comp);
- printf("started write\n");
- rbd_aio_wait_for_complete(comp);
- int r = rbd_aio_get_return_value(comp);
- printf("return value is: %d\n", r);
- ASSERT_EQ(0, r);
- printf("finished write\n");
- rbd_aio_release(comp);
- *passed = true;
+ return num_snaps;
}
-void write_test_data(rbd_image_t image, const char *test_data, uint64_t off, size_t len, uint32_t iohint, bool *passed)
+TEST_F(TestLibRBD, TestCreateLsDeleteSnap)
{
- ssize_t written;
- if (iohint)
- written = rbd_write2(image, off, len, test_data, iohint);
- else
- written = rbd_write(image, off, len, test_data);
- printf("wrote: %d\n", (int) written);
- ASSERT_EQ(len, static_cast<size_t>(written));
- *passed = true;
-}
+ rados_ioctx_t ioctx;
+ rados_ioctx_create(_cluster, m_pool_name.c_str(), &ioctx);
-void aio_discard_test_data(rbd_image_t image, uint64_t off, uint64_t len, bool *passed)
-{
- rbd_completion_t comp;
- rbd_aio_create_completion(NULL, (rbd_callback_t) simple_write_cb, &comp);
- rbd_aio_discard(image, off, len, comp);
- rbd_aio_wait_for_complete(comp);
- int r = rbd_aio_get_return_value(comp);
- ASSERT_EQ(0, r);
- printf("aio discard: %d~%d = %d\n", (int)off, (int)len, (int)r);
- rbd_aio_release(comp);
- *passed = true;
+ rbd_image_t image;
+ int order = 0;
+ std::string name = get_temp_image_name();
+ uint64_t size = 2 << 20;
+ uint64_t size2 = 4 << 20;
+
+ ASSERT_EQ(0, create_image(ioctx, name.c_str(), size, &order));
+ ASSERT_EQ(0, rbd_open(ioctx, name.c_str(), &image, NULL));
+
+ ASSERT_EQ(0, rbd_snap_create(image, "snap1"));
+ ASSERT_EQ(1, test_ls_snaps(image, 1, "snap1", size));
+ ASSERT_EQ(0, rbd_resize(image, size2));
+ ASSERT_EQ(0, rbd_snap_create(image, "snap2"));
+ ASSERT_EQ(2, test_ls_snaps(image, 2, "snap1", size, "snap2", size2));
+ ASSERT_EQ(0, rbd_snap_remove(image, "snap1"));
+ ASSERT_EQ(1, test_ls_snaps(image, 1, "snap2", size2));
+ ASSERT_EQ(0, rbd_snap_remove(image, "snap2"));
+ ASSERT_EQ(0, test_ls_snaps(image, 0));
+
+ ASSERT_EQ(0, rbd_close(image));
+
+ rados_ioctx_destroy(ioctx);
}
-void discard_test_data(rbd_image_t image, uint64_t off, size_t len, bool *passed)
+int test_get_snapshot_timestamp(rbd_image_t image, uint64_t snap_id)
{
- ssize_t written;
- written = rbd_discard(image, off, len);
- printf("discard: %d~%d = %d\n", (int)off, (int)len, (int)written);
- ASSERT_EQ(len, static_cast<size_t>(written));
- *passed = true;
+ struct timespec timestamp;
+ EXPECT_EQ(0, rbd_snap_get_timestamp(image, snap_id, ×tamp));
+ EXPECT_LT(0, timestamp.tv_sec);
+ return 0;
}
-void aio_read_test_data_and_poll(rbd_image_t image, int fd, const char *expected,
- uint64_t off, size_t len, uint32_t iohint, bool *passed)
+TEST_F(TestLibRBD, TestGetSnapShotTimeStamp)
{
- rbd_completion_t comp;
- char *result = (char *)malloc(len + 1);
+ REQUIRE_FORMAT_V2();
- ASSERT_NE(static_cast<char *>(NULL), result);
- rbd_aio_create_completion(NULL, (rbd_callback_t) simple_read_cb, &comp);
- printf("created completion\n");
- printf("started read\n");
- if (iohint)
- rbd_aio_read2(image, off, len, result, comp, iohint);
- else
- rbd_aio_read(image, off, len, result, comp);
+ rados_ioctx_t ioctx;
+ rados_ioctx_create(_cluster, m_pool_name.c_str(), &ioctx);
- struct pollfd pfd;
- pfd.fd = fd;
- pfd.events = POLLIN;
+ rbd_image_t image;
+ int order = 0;
+ std::string name = get_temp_image_name();
+ uint64_t size = 2 << 20;
+ int num_snaps, max_size = 10;
+ rbd_snap_info_t snaps[max_size];
- ASSERT_EQ(1, poll(&pfd, 1, -1));
- ASSERT_TRUE(pfd.revents & POLLIN);
+ ASSERT_EQ(0, create_image(ioctx, name.c_str(), size, &order));
+ ASSERT_EQ(0, rbd_open(ioctx, name.c_str(), &image, NULL));
- rbd_completion_t comps[1];
- ASSERT_EQ(1, rbd_poll_io_events(image, comps, 1));
- uint64_t count;
- ASSERT_EQ(static_cast<ssize_t>(sizeof(count)),
- read(fd, &count, sizeof(count)));
+ ASSERT_EQ(0, rbd_snap_create(image, "snap1"));
+ num_snaps = rbd_snap_list(image, snaps, &max_size);
+ ASSERT_EQ(1, num_snaps);
+ ASSERT_EQ(0, test_get_snapshot_timestamp(image, snaps[0].id));
+ free((void *)snaps[0].name);
- int r = rbd_aio_get_return_value(comps[0]);
- ASSERT_TRUE(rbd_aio_is_complete(comps[0]));
- printf("return value is: %d\n", r);
- ASSERT_EQ(len, static_cast<size_t>(r));
- rbd_aio_release(comps[0]);
- if (memcmp(result, expected, len)) {
- printf("read: %s\nexpected: %s\n", result, expected);
- ASSERT_EQ(0, memcmp(result, expected, len));
- }
- free(result);
- *passed = true;
+ ASSERT_EQ(0, rbd_snap_create(image, "snap2"));
+ num_snaps = rbd_snap_list(image, snaps, &max_size);
+ ASSERT_EQ(2, num_snaps);
+ ASSERT_EQ(0, test_get_snapshot_timestamp(image, snaps[0].id));
+ ASSERT_EQ(0, test_get_snapshot_timestamp(image, snaps[1].id));
+ free((void *)snaps[0].name);
+ free((void *)snaps[1].name);
+
+ ASSERT_EQ(0, rbd_close(image));
+
+ rados_ioctx_destroy(ioctx);
}
-void aio_read_test_data(rbd_image_t image, const char *expected, uint64_t off, size_t len, uint32_t iohint, bool *passed)
+
+int test_ls_snaps(librbd::Image& image, size_t num_expected, ...)
{
- rbd_completion_t comp;
- char *result = (char *)malloc(len + 1);
+ int r;
+ size_t i, j;
+ va_list ap;
+ vector<librbd::snap_info_t> snaps;
+ r = image.snap_list(snaps);
+ EXPECT_TRUE(r >= 0);
+ cout << "num snaps is: " << snaps.size() << std::endl
+ << "expected: " << num_expected << std::endl;
- ASSERT_NE(static_cast<char *>(NULL), result);
- rbd_aio_create_completion(NULL, (rbd_callback_t) simple_read_cb, &comp);
- printf("created completion\n");
- if (iohint)
- rbd_aio_read2(image, off, len, result, comp, iohint);
- else
- rbd_aio_read(image, off, len, result, comp);
- printf("started read\n");
- rbd_aio_wait_for_complete(comp);
- int r = rbd_aio_get_return_value(comp);
- printf("return value is: %d\n", r);
- ASSERT_EQ(len, static_cast<size_t>(r));
- rbd_aio_release(comp);
- if (memcmp(result, expected, len)) {
- printf("read: %s\nexpected: %s\n", result, expected);
- ASSERT_EQ(0, memcmp(result, expected, len));
+ for (i = 0; i < snaps.size(); i++) {
+ cout << "snap: " << snaps[i].name << std::endl;
}
- free(result);
- *passed = true;
-}
-void read_test_data(rbd_image_t image, const char *expected, uint64_t off, size_t len, uint32_t iohint, bool *passed)
-{
- ssize_t read;
- char *result = (char *)malloc(len + 1);
+ va_start(ap, num_expected);
+ for (i = num_expected; i > 0; i--) {
+ char *expected = va_arg(ap, char *);
+ uint64_t expected_size = va_arg(ap, uint64_t);
+ int found = 0;
+ for (j = 0; j < snaps.size(); j++) {
+ if (snaps[j].name == "")
+ continue;
+ if (strcmp(snaps[j].name.c_str(), expected) == 0) {
+ cout << "found " << snaps[j].name << " with size " << snaps[j].size
+ << std::endl;
+ EXPECT_EQ(expected_size, snaps[j].size);
+ snaps[j].name = "";
+ found = 1;
+ break;
+ }
+ }
+ EXPECT_TRUE(found);
+ }
+ va_end(ap);
- ASSERT_NE(static_cast<char *>(NULL), result);
- if (iohint)
- read = rbd_read2(image, off, len, result, iohint);
- else
- read = rbd_read(image, off, len, result);
- printf("read: %d\n", (int) read);
- ASSERT_EQ(len, static_cast<size_t>(read));
- result[len] = '\0';
- if (memcmp(result, expected, len)) {
- printf("read: %s\nexpected: %s\n", result, expected);
- ASSERT_EQ(0, memcmp(result, expected, len));
+ for (i = 0; i < snaps.size(); i++) {
+ EXPECT_EQ("", snaps[i].name);
}
- free(result);
- *passed = true;
+
+ return snaps.size();
}
-void aio_writesame_test_data(rbd_image_t image, const char *test_data, uint64_t off, uint64_t len,
- uint64_t data_len, uint32_t iohint, bool *passed)
+TEST_F(TestLibRBD, TestCreateLsDeleteSnapPP)
{
- rbd_completion_t comp;
- rbd_aio_create_completion(NULL, (rbd_callback_t) simple_write_cb, &comp);
- printf("created completion\n");
- int r;
- r = rbd_aio_writesame(image, off, len, test_data, data_len, comp, iohint);
- printf("started writesame\n");
- if (len % data_len) {
- ASSERT_EQ(-EINVAL, r);
- printf("expected fail, finished writesame\n");
- rbd_aio_release(comp);
- *passed = true;
- return;
- }
-
- rbd_aio_wait_for_complete(comp);
- r = rbd_aio_get_return_value(comp);
- printf("return value is: %d\n", r);
- ASSERT_EQ(0, r);
- printf("finished writesame\n");
- rbd_aio_release(comp);
+ librados::IoCtx ioctx;
+ ASSERT_EQ(0, _rados.ioctx_create(m_pool_name.c_str(), ioctx));
- //verify data
- printf("to verify the data\n");
- ssize_t read;
- char *result = (char *)malloc(data_len+ 1);
- ASSERT_NE(static_cast<char *>(NULL), result);
- uint64_t left = len;
- while (left > 0) {
- read = rbd_read(image, off, data_len, result);
- ASSERT_EQ(data_len, static_cast<size_t>(read));
- result[data_len] = '\0';
- if (memcmp(result, test_data, data_len)) {
- printf("read: %d ~ %d\n", (int) off, (int) read);
- printf("read: %s\nexpected: %s\n", result, test_data);
- ASSERT_EQ(0, memcmp(result, test_data, data_len));
- }
- off += data_len;
- left -= data_len;
+ {
+ librbd::RBD rbd;
+ librbd::Image image;
+ int order = 0;
+ std::string name = get_temp_image_name();
+ uint64_t size = 2 << 20;
+ uint64_t size2 = 4 << 20;
+
+ ASSERT_EQ(0, create_image_pp(rbd, ioctx, name.c_str(), size, &order));
+ ASSERT_EQ(0, rbd.open(ioctx, image, name.c_str(), NULL));
+
+ bool exists;
+ ASSERT_EQ(0, image.snap_exists2("snap1", &exists));
+ ASSERT_FALSE(exists);
+ ASSERT_EQ(0, image.snap_create("snap1"));
+ ASSERT_EQ(0, image.snap_exists2("snap1", &exists));
+ ASSERT_TRUE(exists);
+ ASSERT_EQ(1, test_ls_snaps(image, 1, "snap1", size));
+ ASSERT_EQ(0, image.resize(size2));
+ ASSERT_EQ(0, image.snap_exists2("snap2", &exists));
+ ASSERT_FALSE(exists);
+ ASSERT_EQ(0, image.snap_create("snap2"));
+ ASSERT_EQ(0, image.snap_exists2("snap2", &exists));
+ ASSERT_TRUE(exists);
+ ASSERT_EQ(2, test_ls_snaps(image, 2, "snap1", size, "snap2", size2));
+ ASSERT_EQ(0, image.snap_remove("snap1"));
+ ASSERT_EQ(0, image.snap_exists2("snap1", &exists));
+ ASSERT_FALSE(exists);
+ ASSERT_EQ(1, test_ls_snaps(image, 1, "snap2", size2));
+ ASSERT_EQ(0, image.snap_remove("snap2"));
+ ASSERT_EQ(0, image.snap_exists2("snap2", &exists));
+ ASSERT_FALSE(exists);
+ ASSERT_EQ(0, test_ls_snaps(image, 0));
}
- ASSERT_EQ(0U, left);
- free(result);
- printf("verified\n");
- *passed = true;
+ ioctx.close();
}
-void writesame_test_data(rbd_image_t image, const char *test_data, uint64_t off, uint64_t len,
- uint64_t data_len, uint32_t iohint, bool *passed)
+TEST_F(TestLibRBD, TestGetNameIdSnapPP)
{
- ssize_t written;
- written = rbd_writesame(image, off, len, test_data, data_len, iohint);
- if (len % data_len) {
- ASSERT_EQ(-EINVAL, written);
- printf("expected fail, finished writesame\n");
- *passed = true;
- return;
- }
- ASSERT_EQ(len, static_cast<size_t>(written));
- printf("wrote: %d\n", (int) written);
+ librados::IoCtx ioctx;
+ ASSERT_EQ(0, _rados.ioctx_create(m_pool_name.c_str(), ioctx));
- //verify data
- printf("to verify the data\n");
- ssize_t read;
- char *result = (char *)malloc(data_len+ 1);
- ASSERT_NE(static_cast<char *>(NULL), result);
- uint64_t left = len;
- while (left > 0) {
- read = rbd_read(image, off, data_len, result);
- ASSERT_EQ(data_len, static_cast<size_t>(read));
- result[data_len] = '\0';
- if (memcmp(result, test_data, data_len)) {
- printf("read: %d ~ %d\n", (int) off, (int) read);
- printf("read: %s\nexpected: %s\n", result, test_data);
- ASSERT_EQ(0, memcmp(result, test_data, data_len));
+ {
+ librbd::RBD rbd;
+ librbd::Image image;
+ int order = 0;
+ std::string name = get_temp_image_name();
+ uint64_t size = 2 << 20;
+
+ ASSERT_EQ(0, create_image_pp(rbd, ioctx, name.c_str(), size, &order));
+ ASSERT_EQ(0, rbd.open(ioctx, image, name.c_str(), NULL));
+
+ ASSERT_EQ(0, image.snap_create("snap1"));
+ ASSERT_EQ(0, image.snap_create("snap2"));
+ ASSERT_EQ(0, image.snap_create("snap3"));
+ vector<librbd::snap_info_t> snaps;
+ int r = image.snap_list(snaps);
+ EXPECT_TRUE(r >= 0);
+
+ for (size_t i = 0; i < snaps.size(); ++i) {
+ std::string expected_snap_name;
+ image.snap_get_name(snaps[i].id, &expected_snap_name);
+ ASSERT_EQ(expected_snap_name, snaps[i].name);
}
- off += data_len;
- left -= data_len;
+
+ for (size_t i = 0; i < snaps.size(); ++i) {
+ uint64_t expected_snap_id;
+ image.snap_get_id(snaps[i].name, &expected_snap_id);
+ ASSERT_EQ(expected_snap_id, snaps[i].id);
+ }
+
+ ASSERT_EQ(0, image.snap_remove("snap1"));
+ ASSERT_EQ(0, image.snap_remove("snap2"));
+ ASSERT_EQ(0, image.snap_remove("snap3"));
+ ASSERT_EQ(0, test_ls_snaps(image, 0));
}
- ASSERT_EQ(0U, left);
- free(result);
- printf("verified\n");
- *passed = true;
+ ioctx.close();
}
-void aio_compare_and_write_test_data(rbd_image_t image, const char *cmp_data,
- const char *test_data, uint64_t off,
- size_t len, uint32_t iohint, bool *passed)
+TEST_F(TestLibRBD, TestCreateLsRenameSnapPP)
{
- rbd_completion_t comp;
- rbd_aio_create_completion(NULL, (rbd_callback_t) simple_write_cb, &comp);
- printf("created completion\n");
+ librados::IoCtx ioctx;
+ ASSERT_EQ(0, _rados.ioctx_create(m_pool_name.c_str(), ioctx));
- uint64_t mismatch_offset;
- rbd_aio_compare_and_write(image, off, len, cmp_data, test_data, comp, &mismatch_offset, iohint);
- printf("started aio compare and write\n");
- rbd_aio_wait_for_complete(comp);
- int r = rbd_aio_get_return_value(comp);
- printf("return value is: %d\n", r);
- ASSERT_EQ(0, r);
- printf("finished aio compare and write\n");
- rbd_aio_release(comp);
- *passed = true;
-}
+ {
+ librbd::RBD rbd;
+ librbd::Image image;
+ int order = 0;
+ std::string name = get_temp_image_name();
+ uint64_t size = 2 << 20;
+ uint64_t size2 = 4 << 20;
+
+ ASSERT_EQ(0, create_image_pp(rbd, ioctx, name.c_str(), size, &order));
+ ASSERT_EQ(0, rbd.open(ioctx, image, name.c_str(), NULL));
+
+ bool exists;
+ ASSERT_EQ(0, image.snap_exists2("snap1", &exists));
+ ASSERT_FALSE(exists);
+ ASSERT_EQ(0, image.snap_create("snap1"));
+ ASSERT_EQ(0, image.snap_exists2("snap1", &exists));
+ ASSERT_TRUE(exists);
+ ASSERT_EQ(1, test_ls_snaps(image, 1, "snap1", size));
+ ASSERT_EQ(0, image.resize(size2));
+ ASSERT_EQ(0, image.snap_exists2("snap2", &exists));
+ ASSERT_FALSE(exists);
+ ASSERT_EQ(0, image.snap_create("snap2"));
+ ASSERT_EQ(0, image.snap_exists2("snap2", &exists));
+ ASSERT_TRUE(exists);
+ ASSERT_EQ(2, test_ls_snaps(image, 2, "snap1", size, "snap2", size2));
+ ASSERT_EQ(0, image.snap_rename("snap1","snap1-rename"));
+ ASSERT_EQ(2, test_ls_snaps(image, 2, "snap1-rename", size, "snap2", size2));
+ ASSERT_EQ(0, image.snap_exists2("snap1", &exists));
+ ASSERT_FALSE(exists);
+ ASSERT_EQ(0, image.snap_exists2("snap1-rename", &exists));
+ ASSERT_TRUE(exists);
+ ASSERT_EQ(0, image.snap_remove("snap1-rename"));
+ ASSERT_EQ(0, image.snap_rename("snap2","snap2-rename"));
+ ASSERT_EQ(1, test_ls_snaps(image, 1, "snap2-rename", size2));
+ ASSERT_EQ(0, image.snap_exists2("snap2", &exists));
+ ASSERT_FALSE(exists);
+ ASSERT_EQ(0, image.snap_exists2("snap2-rename", &exists));
+ ASSERT_TRUE(exists);
+ ASSERT_EQ(0, image.snap_remove("snap2-rename"));
+ ASSERT_EQ(0, test_ls_snaps(image, 0));
+ }
-void compare_and_write_test_data(rbd_image_t image, const char *cmp_data,
- const char *test_data, uint64_t off, size_t len,
- uint64_t *mismatch_off, uint32_t iohint, bool *passed)
-{
- printf("start compare and write\n");
- ssize_t written;
- written = rbd_compare_and_write(image, off, len, cmp_data, test_data, mismatch_off, iohint);
- printf("compare and wrote: %d\n", (int) written);
- ASSERT_EQ(len, static_cast<size_t>(written));
- *passed = true;
+ ioctx.close();
}
-
TEST_F(TestLibRBD, TestIO)
{
rados_ioctx_t ioctx;
ASSERT_EQ(0, rados_conf_set(_cluster, "rbd_read_from_replica_policy", "balance"));
ASSERT_EQ(0, rbd_open(ioctx, name.c_str(), &image, NULL));
- bool skip_discard = is_skip_partial_discard_enabled(image);
+ test_io(image);
- char test_data[TEST_IO_SIZE + 1];
- char zero_data[TEST_IO_SIZE + 1];
- char mismatch_data[TEST_IO_SIZE + 1];
- int i;
- uint64_t mismatch_offset;
+ ASSERT_EQ(0, rbd_close(image));
- for (i = 0; i < TEST_IO_SIZE; ++i) {
- test_data[i] = (char) (rand() % (126 - 33) + 33);
- }
- test_data[TEST_IO_SIZE] = '\0';
- memset(zero_data, 0, sizeof(zero_data));
- memset(mismatch_data, 9, sizeof(mismatch_data));
+ rados_ioctx_destroy(ioctx);
+}
- for (i = 0; i < 5; ++i)
- ASSERT_PASSED(write_test_data, image, test_data, TEST_IO_SIZE * i, TEST_IO_SIZE, 0);
+TEST_F(TestLibRBD, TestEncryptionLUKS1)
+{
+ REQUIRE(!is_feature_enabled(RBD_FEATURE_JOURNALING));
- for (i = 5; i < 10; ++i)
- ASSERT_PASSED(aio_write_test_data, image, test_data, TEST_IO_SIZE * i, TEST_IO_SIZE, 0);
+ rados_ioctx_t ioctx;
+ rados_ioctx_create(_cluster, m_pool_name.c_str(), &ioctx);
- for (i = 0; i < 5; ++i)
- ASSERT_PASSED(compare_and_write_test_data, image, test_data, test_data, TEST_IO_SIZE * i, TEST_IO_SIZE, &mismatch_offset, 0);
+ int order = 0;
+ std::string name = get_temp_image_name();
+ uint64_t size = 32 << 20;
- for (i = 5; i < 10; ++i)
- ASSERT_PASSED(aio_compare_and_write_test_data, image, test_data, test_data, TEST_IO_SIZE * i, TEST_IO_SIZE, 0);
+ ASSERT_EQ(0, create_image(ioctx, name.c_str(), size, &order));
+ ASSERT_EQ(0, rados_conf_set(
+ _cluster, "rbd_read_from_replica_policy", "balance"));
- for (i = 0; i < 5; ++i)
- ASSERT_PASSED(read_test_data, image, test_data, TEST_IO_SIZE * i, TEST_IO_SIZE, 0);
+ rbd_image_t image;
+ rbd_encryption_luks1_format_options_t opts = {
+ .alg = RBD_ENCRYPTION_ALGORITHM_AES256,
+ .passphrase = "password",
+ .passphrase_size = 8,
+ };
+ ASSERT_EQ(0, rbd_open(ioctx, name.c_str(), &image, NULL));
- for (i = 5; i < 10; ++i)
- ASSERT_PASSED(aio_read_test_data, image, test_data, TEST_IO_SIZE * i, TEST_IO_SIZE, 0);
+#ifndef HAVE_LIBCRYPTSETUP
+ ASSERT_EQ(-ENOTSUP, rbd_encryption_format(
+ image, RBD_ENCRYPTION_FORMAT_LUKS1, &opts, sizeof(opts)));
+ ASSERT_EQ(-ENOTSUP, rbd_encryption_load(
+ image, RBD_ENCRYPTION_FORMAT_LUKS1, &opts, sizeof(opts)));
+#else
+ ASSERT_EQ(0, rbd_encryption_format(
+ image, RBD_ENCRYPTION_FORMAT_LUKS1, &opts, sizeof(opts)));
+ ASSERT_EQ(0, rbd_encryption_load(
+ image, RBD_ENCRYPTION_FORMAT_LUKS1, &opts, sizeof(opts)));
+
+ test_io(image);
+#endif
- // discard 2nd, 4th sections.
- ASSERT_PASSED(discard_test_data, image, TEST_IO_SIZE, TEST_IO_SIZE);
- ASSERT_PASSED(aio_discard_test_data, image, TEST_IO_SIZE*3, TEST_IO_SIZE);
+ ASSERT_EQ(0, rbd_close(image));
+ rados_ioctx_destroy(ioctx);
+}
- ASSERT_PASSED(read_test_data, image, test_data, 0, TEST_IO_SIZE, 0);
- ASSERT_PASSED(read_test_data, image, skip_discard ? test_data : zero_data,
- TEST_IO_SIZE, TEST_IO_SIZE, 0);
- ASSERT_PASSED(read_test_data, image, test_data, TEST_IO_SIZE*2, TEST_IO_SIZE, 0);
- ASSERT_PASSED(read_test_data, image, skip_discard ? test_data : zero_data,
- TEST_IO_SIZE*3, TEST_IO_SIZE, 0);
- ASSERT_PASSED(read_test_data, image, test_data, TEST_IO_SIZE*4, TEST_IO_SIZE, 0);
+TEST_F(TestLibRBD, TestEncryptionLUKS2)
+{
+ REQUIRE(!is_feature_enabled(RBD_FEATURE_JOURNALING));
- for (i = 0; i < 15; ++i) {
- if (i % 3 == 2) {
- ASSERT_PASSED(writesame_test_data, image, test_data, TEST_IO_SIZE * i, TEST_IO_SIZE * i * 32 + i, TEST_IO_SIZE, 0);
- ASSERT_PASSED(writesame_test_data, image, zero_data, TEST_IO_SIZE * i, TEST_IO_SIZE * i * 32 + i, TEST_IO_SIZE, 0);
- } else if (i % 3 == 1) {
- ASSERT_PASSED(writesame_test_data, image, test_data, TEST_IO_SIZE + i, TEST_IO_SIZE * i * 32, TEST_IO_SIZE, 0);
- ASSERT_PASSED(writesame_test_data, image, zero_data, TEST_IO_SIZE + i, TEST_IO_SIZE * i * 32, TEST_IO_SIZE, 0);
- } else {
- ASSERT_PASSED(writesame_test_data, image, test_data, TEST_IO_SIZE * i, TEST_IO_SIZE * i * 32, TEST_IO_SIZE, 0);
- ASSERT_PASSED(writesame_test_data, image, zero_data, TEST_IO_SIZE * i, TEST_IO_SIZE * i * 32, TEST_IO_SIZE, 0);
- }
- }
- for (i = 0; i < 15; ++i) {
- if (i % 3 == 2) {
- ASSERT_PASSED(aio_writesame_test_data, image, test_data, TEST_IO_SIZE * i, TEST_IO_SIZE * i * 32 + i, TEST_IO_SIZE, 0);
- ASSERT_PASSED(aio_writesame_test_data, image, zero_data, TEST_IO_SIZE * i, TEST_IO_SIZE * i * 32 + i, TEST_IO_SIZE, 0);
- } else if (i % 3 == 1) {
- ASSERT_PASSED(aio_writesame_test_data, image, test_data, TEST_IO_SIZE + i, TEST_IO_SIZE * i * 32, TEST_IO_SIZE, 0);
- ASSERT_PASSED(aio_writesame_test_data, image, zero_data, TEST_IO_SIZE + i, TEST_IO_SIZE * i * 32, TEST_IO_SIZE, 0);
- } else {
- ASSERT_PASSED(aio_writesame_test_data, image, test_data, TEST_IO_SIZE * i, TEST_IO_SIZE * i * 32, TEST_IO_SIZE, 0);
- ASSERT_PASSED(aio_writesame_test_data, image, zero_data, TEST_IO_SIZE * i, TEST_IO_SIZE * i * 32, TEST_IO_SIZE, 0);
- }
- }
+ rados_ioctx_t ioctx;
+ rados_ioctx_create(_cluster, m_pool_name.c_str(), &ioctx);
- rbd_image_info_t info;
- rbd_completion_t comp;
- ASSERT_EQ(0, rbd_stat(image, &info, sizeof(info)));
- // can't read or write starting past end
- ASSERT_EQ(-EINVAL, rbd_write(image, info.size, 1, test_data));
- ASSERT_EQ(-EINVAL, rbd_read(image, info.size, 1, test_data));
- // reading through end returns amount up to end
- ASSERT_EQ(10, rbd_read(image, info.size - 10, 100, test_data));
- // writing through end returns amount up to end
- ASSERT_EQ(10, rbd_write(image, info.size - 10, 100, test_data));
+ int order = 0;
+ std::string name = get_temp_image_name();
+ uint64_t size = 32 << 20;
- rbd_aio_create_completion(NULL, (rbd_callback_t) simple_read_cb, &comp);
- ASSERT_EQ(0, rbd_aio_write(image, info.size, 1, test_data, comp));
- ASSERT_EQ(0, rbd_aio_wait_for_complete(comp));
- ASSERT_EQ(-EINVAL, rbd_aio_get_return_value(comp));
- rbd_aio_release(comp);
+ ASSERT_EQ(0, create_image(ioctx, name.c_str(), size, &order));
+ ASSERT_EQ(0, rados_conf_set(
+ _cluster, "rbd_read_from_replica_policy", "balance"));
- rbd_aio_create_completion(NULL, (rbd_callback_t) simple_read_cb, &comp);
- ASSERT_EQ(0, rbd_aio_read(image, info.size, 1, test_data, comp));
- ASSERT_EQ(0, rbd_aio_wait_for_complete(comp));
- ASSERT_EQ(-EINVAL, rbd_aio_get_return_value(comp));
- rbd_aio_release(comp);
+ rbd_image_t image;
+ rbd_encryption_luks2_format_options_t opts = {
+ .alg = RBD_ENCRYPTION_ALGORITHM_AES256,
+ .passphrase = "password",
+ .passphrase_size = 8,
+ };
+ ASSERT_EQ(0, rbd_open(ioctx, name.c_str(), &image, NULL));
- ASSERT_PASSED(write_test_data, image, zero_data, 0, TEST_IO_SIZE, LIBRADOS_OP_FLAG_FADVISE_NOCACHE);
- ASSERT_EQ(-EILSEQ, rbd_compare_and_write(image, 0, TEST_IO_SIZE, mismatch_data, mismatch_data, &mismatch_offset, 0));
- ASSERT_EQ(0U, mismatch_offset);
- rbd_aio_create_completion(NULL, (rbd_callback_t) simple_read_cb, &comp);
- ASSERT_EQ(0, rbd_aio_compare_and_write(image, 0, TEST_IO_SIZE, mismatch_data, mismatch_data, comp, &mismatch_offset, 0));
- ASSERT_EQ(0, rbd_aio_wait_for_complete(comp));
- ASSERT_EQ(0U, mismatch_offset);
- rbd_aio_release(comp);
+#ifndef HAVE_LIBCRYPTSETUP
+ ASSERT_EQ(-ENOTSUP, rbd_encryption_format(
+ image, RBD_ENCRYPTION_FORMAT_LUKS2, &opts, sizeof(opts)));
+ ASSERT_EQ(-ENOTSUP, rbd_encryption_load(
+ image, RBD_ENCRYPTION_FORMAT_LUKS2, &opts, sizeof(opts)));
+#else
+ ASSERT_EQ(0, rbd_encryption_format(
+ image, RBD_ENCRYPTION_FORMAT_LUKS2, &opts, sizeof(opts)));
+ ASSERT_EQ(0, rbd_encryption_load(
+ image, RBD_ENCRYPTION_FORMAT_LUKS2, &opts, sizeof(opts)));
+
+ test_io(image);
+#endif
- ASSERT_PASSED(validate_object_map, image);
ASSERT_EQ(0, rbd_close(image));
-
rados_ioctx_destroy(ioctx);
}