]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test_librbd: add a simple io to clone test
authorJosh Durgin <josh.durgin@inktank.com>
Mon, 30 Jul 2012 17:41:41 +0000 (10:41 -0700)
committerJosh Durgin <josh.durgin@inktank.com>
Sat, 4 Aug 2012 01:48:53 +0000 (18:48 -0700)
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
src/test/pybind/test_rbd.py
src/test/test_librbd.cc

index 2ae47dbf2f547f2783ba0cf09316747a4e401d5f..294b704d4cc600a6980a07f6cca03a841d410cfa 100644 (file)
@@ -429,6 +429,16 @@ class TestClone(object):
         eq(self.clone.overlap(), IMG_SIZE / 2)
 
     def test_resize_io(self):
+        parent_data = self.image.read(IMG_SIZE / 2, 256)
+        self.clone.resize(IMG_SIZE / 2 + 128)
+        child_data = self.clone.read(IMG_SIZE / 2, 128)
+        eq(child_data, parent_data[:128])
+        self.clone.resize(IMG_SIZE)
+        child_data = self.clone.read(IMG_SIZE / 2, 256)
+        eq(child_data, parent_data[:128] + ('\0' * 128))
+        self.clone.resize(IMG_SIZE / 2 + 1)
+        child_data = self.clone.read(IMG_SIZE / 2, 1)
+        eq(child_data, parent_data[0])
         self.clone.resize(0)
         self.clone.resize(IMG_SIZE)
         child_data = self.clone.read(IMG_SIZE / 2, 256)
index 9132157d795b524f954c3d9ec3eb467526722e27..785254eadfe437f0b528d6fae0c8485ed0d62087 100644 (file)
@@ -989,6 +989,9 @@ TEST(LibRBD, TestClone)
   ASSERT_EQ(0, rbd_open(ioctx, "parent", &parent, NULL));
   printf("made parent image \"parent\"\n");
 
+  char *data = (char *)"testdata";
+  ASSERT_EQ((ssize_t)strlen(data), rbd_write(parent, 0, strlen(data), data));
+
   // can't clone a non-snapshot, expect failure
   EXPECT_NE(0, rbd_clone(ioctx, "parent", NULL, ioctx, "child", features, &order));
 
@@ -1004,7 +1007,15 @@ TEST(LibRBD, TestClone)
   ASSERT_EQ(0, rbd_clone(ioctx, "parent", "parent_snap", ioctx, "child", features,
            &order));
   ASSERT_EQ(0, rbd_open(ioctx, "child", &child, NULL));
-  printf("made and opened clone \"child\"\n"); 
+  printf("made and opened clone \"child\"\n");
+
+  // check read
+  read_test_data(child, data, 0, strlen(data));
+
+  // check write
+  ASSERT_EQ((ssize_t)strlen(data), rbd_write(child, 20, strlen(data), data));
+  read_test_data(child, data, 20, strlen(data));
+  read_test_data(child, data, 0, strlen(data));
 
   // check attributes
   ASSERT_EQ(0, rbd_stat(parent, &pinfo, sizeof(pinfo)));