Skip to content

Commit

Permalink
rbd image_read.sh: add clone-of-clone testing
Browse files Browse the repository at this point in the history
Add testing to verify that a snapshot of a clone and a clone of
that snapshot both produce the correct results when read.

Signed-off-by: Alex Elder <[email protected]>
  • Loading branch information
Alex Elder committed May 21, 2013
1 parent a6b4847 commit 7ad5ceb
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion qa/workunits/rbd/image_read.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
#
# Clone functionality is tested as well, in which case a clone is
# made of the snapshot, and the same ranges of data are again read
# and compared with the original.
# and compared with the original. In addition, a snapshot of that
# clone is created, and a clone of *that* snapshot is put through
# the same set of tests. (Clone testing can be optionally skipped.)

################################################################

Expand All @@ -56,6 +58,8 @@ PROGNAME=$(basename $0)
ORIGINAL=original-$$
SNAP1=snap1-$$
CLONE1=clone1-$$
SNAP2=snap2-$$
CLONE2=clone2-$$

function err() {
if [ $# -gt 0 ]; then
Expand Down Expand Up @@ -211,20 +215,38 @@ function setup() {
sudo chown ubuntu /sys/bus/rbd/add
sudo chown ubuntu /sys/bus/rbd/remove
fi
# create and fill the original image with some data
create_image "${ORIGINAL}"
map_image "${ORIGINAL}"
fill_original

# create a snapshot of the original
create_image_snap "${ORIGINAL}" "${SNAP1}"
map_image_snap "${ORIGINAL}" "${SNAP1}"
if [ "${TEST_CLONES}" = true ]; then
# create a clone of the original snapshot
create_snap_clone "${ORIGINAL}" "${SNAP1}" "${CLONE1}"
map_image "${CLONE1}"

# create a snapshot of that clone
create_image_snap "${CLONE1}" "${SNAP2}"
map_image_snap "${CLONE1}" "${SNAP2}"

# create a clone of that clone's snapshot
create_snap_clone "${CLONE1}" "${SNAP2}" "${CLONE2}"
map_image "${CLONE2}"
fi
}

function teardown() {
verbose "===== cleaning up ====="
if [ "${TEST_CLONES}" = true ]; then
unmap_image "${CLONE2}" || true
destroy_snap_clone "${CLONE1}" "${SNAP2}" "${CLONE2}" || true

unmap_image_snap "${CLONE1}" "${SNAP2}" || true
destroy_image_snap "${CLONE1}" "${SNAP2}" || true

unmap_image "${CLONE1}" || true
destroy_snap_clone "${ORIGINAL}" "${SNAP1}" "${CLONE1}" || true
fi
Expand Down Expand Up @@ -608,6 +630,8 @@ run_using "${ORIGINAL}"
doit "${ORIGINAL}@${SNAP1}"
if [ "${TEST_CLONES}" = true ]; then
doit "${CLONE1}"
doit "${CLONE1}@${SNAP2}"
doit "${CLONE2}"
fi
rm -rf $(out_data_dir "${ORIGINAL}")

Expand Down

0 comments on commit 7ad5ceb

Please sign in to comment.