From 7c8d3d053afb4ab5521f4e7c32f064d2e1b26454 Mon Sep 17 00:00:00 2001 From: tamil Date: Mon, 11 Feb 2013 17:24:50 -0800 Subject: [PATCH] added new cli tests Signed-off-by: tamil --- qa/qa_scripts/RbdLib.pm | 54 ++++++++++++++++++++++++---- qa/qa_scripts/rbd_cli_tests.pl | 66 +++++++++++++++++++++++++++++++++- 2 files changed, 113 insertions(+), 7 deletions(-) diff --git a/qa/qa_scripts/RbdLib.pm b/qa/qa_scripts/RbdLib.pm index a7d957b3fe5cd..f203b8ac08419 100755 --- a/qa/qa_scripts/RbdLib.pm +++ b/qa/qa_scripts/RbdLib.pm @@ -9,7 +9,7 @@ package RbdLib; use Cwd; use Exporter; @ISA = 'Exporter'; -@EXPORT_OK = qw(perform_action create_image resize_image rename_image copy_image list_image info_image export_image import_image remove_image create_snapshots rollback_snapshots purge_snapshots list_snapshots remove_snapshot rbd_map rbd_unmap rbd_showmapped display_result _pre_clean_up _post_clean_up _create_rados_pool display_ceph_os_info $RADOS_LS $RADOS_MKPOOL $RADOS_RMPOOL $RBD_CREATE $RBD_RESIZE $RBD_INFO $RBD_REMOVE $RBD_RENAME $RBD_MV $RBD_LS $RBD_LIST $RBD_CLONE $RBD_EXPORT $RBD_IMPORT $RBD_CP $RBD_COPY $SNAP_CREATE $SNAP_LS $SNAP_LIST $SNAP_ROLLBACK $SNAP_PURGE $SNAP_REMOVE $POOL_RM_SUCCESS $POOL_MK_SUCCESS $RBD_EXISTS_ERR $RBD_WATCH $RBD_MAP $RBD_UNMAP $RBD_SHOWMAPPED get_command_output verify_action debug_msg tpass tfail log_results display_func_result $CLI_FLAG); +@EXPORT_OK = qw(perform_action create_image resize_image rename_image copy_image list_image info_image export_image import_image remove_image create_snapshots protect_snapshot clone_image unprotect_snapshot rollback_snapshots purge_snapshots list_snapshots remove_snapshot rbd_map rbd_unmap rbd_showmapped display_result _pre_clean_up _post_clean_up _create_rados_pool display_ceph_os_info $RADOS_LS $RADOS_MKPOOL $RADOS_RMPOOL $RBD_CREATE $RBD_RESIZE $RBD_INFO $RBD_REMOVE $RBD_RENAME $RBD_MV $RBD_LS $RBD_LIST $RBD_CLONE $RBD_EXPORT $RBD_IMPORT $RBD_CP $RBD_COPY $SNAP_CREATE $SNAP_LS $SNAP_LIST $SNAP_ROLLBACK $SNAP_PURGE $SNAP_REMOVE $RBD_CHILDREN $RBD_FLATTEN $POOL_RM_SUCCESS $POOL_MK_SUCCESS $RBD_EXISTS_ERR $RBD_WATCH $RBD_MAP $RBD_UNMAP $RBD_SHOWMAPPED $RBD_FLATTEN $SNAP_PROTECT $SNAP_UNPROTECT get_command_output verify_action debug_msg tpass tfail log_results display_func_result $CLI_FLAG ); use Pod::Usage(); use Getopt::Long(); @@ -50,6 +50,11 @@ our $RBD_MAP = "sudo rbd map"; our $RBD_UNMAP = "sudo rbd unmap"; our $RBD_SHOWMAPPED = "rbd showmapped"; our $RADOS_LS = "rados ls"; +our $SNAP_PROTECT = "rbd snap protect"; +our $SNAP_UNPROTECT = "rbd snap unprotect"; +our $RBD_CHILDREN = "rbd children"; +our $RBD_FLATTEN = "rbd flatten"; + #====Error messages======================== our $RBD_CREATE_ERR = "size must be >= 0"; @@ -72,8 +77,20 @@ our $RBD_IMP_ERR = "import failed"; our $RBD_MAP_ERR = "add failed"; our $RBD_UNMAP_ERR = "remove failed"; our $RBD_INFO_SNAP_ERR = "error setting snapshot context"; -our $RBD_SIZE_ERR = "must specify size in MB"; - +our $SNAP_PROTECT_ERR = "Device or resource busy"; +our $SNAP_PROTECT_RM_ERR = "protected from removal"; +our $SNAP_PROTECT_ERR1 = "No such file or directory"; +our $SNAP_UNPROT_ERR = "snap_unprotect: image must support layering"; +our $SNAP_UNPROT_ERR1 = "snap_unprotect: can't unprotect"; +#our $SNAP_UNPROTECT_ERR - bug # 4045 +our $SNAP_PROT_ERR = "snap_protect: image must support layering"; +our $CLONE_UNPROTECT_ERR = "parent snapshot must be protected"; +our $CLONE_ARG_ERR = "destination image name was not specified"; +our $CLONE_PARENT_ERR = "error opening parent image"; +our $CLONE_PF_ERR = "parent image must be in new format"; +our $FLATTEN_ERR = "librbd: parent snapshot must be protected"; +our $FLATTEN_IMG_ERR = "librbd: image has no parent"; + #=======Success messages======================= our $POOL_MK_SUCCESS = "successfully created pool"; @@ -85,6 +102,7 @@ our $RBD_EXP_SUCCESS = "Exporting image: 100%"; our $RBD_IMP_SUCCESS = "Importing image: 100%"; our $SNAP_ROLLBACK_SUCCESS = "Rolling back to snapshot: 100%"; our $SNAP_PURGE_SUCCESS = "Removing all snapshots: 100%"; +our $RBD_FLATTEN_SUCCESS = "Image flatten: 100% complete"; #===========Variables used in the script======== @@ -371,6 +389,18 @@ sub validate_cmd_output { elsif ( ( $act =~ /$RBD_MAP/ ) && ( $cmd_op !~ /./ ) ) { pass("$act $args passed"); } + elsif ( ( $act =~ /$SNAP_PROTECT/ ) && ( $cmd_op !~ /./ ) ) { + pass("$act $args passed"); + } + elsif ( ( $act =~ /$SNAP_UNPROTECT/ ) && ( $cmd_op !~ /./ ) ) { + pass("$act $args passed"); + } + elsif ( ( $act =~ /$RBD_CLONE/ ) && ( $cmd_op !~ /./ ) ) { + pass("$act $args passed"); + } + elsif ( ( $act =~ /$RBD_FLATTEN/ ) && ( $cmd_op =~ /$RBD_FLATTEN_SUCCESS/ ) ) { + pass("$act $args passed"); + } elsif ( ( $act =~ /$RBD_UNMAP/ ) && ( $cmd_op !~ /$RBD_UNMAP_ERR/ ) ) { pass("$act $args passed"); } @@ -409,7 +439,18 @@ sub validate_cmd_output { || ( $cmd_op =~ /$RBD_CREATE_ERR/ ) || ( $cmd_op =~ /$RBD_EXTRA_ERR/ ) || ( $cmd_op =~ /$RBD_REQ_ERR/ ) - || ( $cmd_op =~ /$RBD_SIZE_ERR/ ) + || ( $cmd_op =~ /$SNAP_PROTECT_ERR/ ) + || ( $cmd_op =~ /$SNAP_PROTECT_ERR1/ ) + || ( $cmd_op =~ /$SNAP_PROTECT_RM_ERR/ ) + || ( $cmd_op =~ /$SNAP_PROT_ERR/ ) + || ( $cmd_op =~ /$SNAP_UNPROT_ERR/ ) + || ( $cmd_op =~ /$SNAP_UNPROT_ERR1/ ) + || ( $cmd_op =~ /$CLONE_UNPROTECT_ERR/ ) + || ( $cmd_op =~ /$CLONE_ARG_ERR/ ) + || ( $cmd_op =~ /$CLONE_PARENT_ERR/ ) + || ( $cmd_op =~ /$CLONE_PF_ERR/ ) + || ( $cmd_op =~ /$FLATTEN_ERR/ ) + || ( $cmd_op =~ /$FLATTEN_IMG_ERR/ ) || ( $cmd_op =~ /$RBD_INFO_SNAP_ERR/ ) ) ) { @@ -480,8 +521,9 @@ sub ceph_os_info sub display_ceph_os_info { my ($vceph, $vos) = ceph_os_info(); - my $msg = "The Tests are running on"; - debug_msg ( "$msg\n$vos$vceph",1 ); + my $dat = get_command_output ( "date" ); + my $msg = "The Tests were executed on $dat"; + debug_msg ( "$msg\n$vos$vceph\n",1 ); open( TC, '>>log.txt' ); print TC "[Log] $vceph\n"; close (TC); diff --git a/qa/qa_scripts/rbd_cli_tests.pl b/qa/qa_scripts/rbd_cli_tests.pl index 854089e5ce687..4c8b5a9afa530 100755 --- a/qa/qa_scripts/rbd_cli_tests.pl +++ b/qa/qa_scripts/rbd_cli_tests.pl @@ -42,7 +42,7 @@ For Example,for "nova" user, 'export CEPH_ARGS="--keyring /etc/ceph/ceph.keyring =cut use Cwd; -use RbdLib qw(perform_action create_image resize_image rename_image copy_image list_image info_image export_image import_image remove_image create_snapshots rollback_snapshots purge_snapshots list_snapshots remove_snapshot rbd_map rbd_unmap rbd_showmapped display_result _pre_clean_up _post_clean_up _create_rados_pool display_ceph_os_info $RADOS_MKPOOL $RADOS_RMPOOL $RBD_CREATE $RBD_RESIZE $RBD_INFO $RBD_REMOVE $RBD_RENAME $RBD_MV $RBD_LS $RBD_LIST $RBD_CLONE $RBD_EXPORT $RBD_IMPORT $RBD_CP $RBD_COPY $SNAP_CREATE $SNAP_LS $SNAP_LIST $SNAP_ROLLBACK $SNAP_PURGE $SNAP_REMOVE $POOL_RM_SUCCESS $POOL_MK_SUCCESS $RBD_EXISTS_ERR $RBD_WATCH $RBD_MAP $RBD_UNMAP $RBD_SHOWMAPPED get_command_output debug_msg $CLI_FLAG); +use RbdLib qw(perform_action create_image resize_image rename_image copy_image list_image info_image export_image import_image remove_image create_snapshots protect_snapshot unprotect_snapshot clone_image rollback_snapshots purge_snapshots list_snapshots remove_snapshot rbd_map rbd_unmap rbd_showmapped display_result _pre_clean_up _post_clean_up _create_rados_pool display_ceph_os_info $RADOS_MKPOOL $RADOS_RMPOOL $RBD_CREATE $RBD_RESIZE $RBD_INFO $RBD_REMOVE $RBD_RENAME $RBD_MV $RBD_LS $RBD_LIST $RBD_CLONE $RBD_EXPORT $RBD_IMPORT $RBD_CP $RBD_COPY $SNAP_CREATE $SNAP_PROTECT $SNAP_UNPROTECT $SNAP_LS $SNAP_LIST $SNAP_ROLLBACK $SNAP_PURGE $SNAP_REMOVE $POOL_RM_SUCCESS $POOL_MK_SUCCESS $RBD_EXISTS_ERR $RBD_WATCH $RBD_MAP $RBD_UNMAP $RBD_SHOWMAPPED $RBD_CHILDREN $RBD_FLATTEN get_command_output debug_msg $CLI_FLAG); use Pod::Usage(); use Getopt::Long(); @@ -67,6 +67,12 @@ our $snap_name = "snap1"; our $snap_name2 = "snap2"; our $snap_name3 = "snap3"; our $snap_name4 = "snap4"; +our $snap_name5 = "snap5"; +our $snap_new = "snap_new"; +our $clone_new = "clone_new"; +our $clone_new1 = "clone_new1"; +our $clone_new2 = "clone_new2"; +our $snap_test = "snap_test"; our $new_rbd_img = "new_rbd_img"; our $non_existing_img = "rbdimage"; our $cp_new = "newest"; @@ -128,6 +134,58 @@ sub create_snapshots { 0 ); perform_action( $SNAP_CREATE, "--snap $snap_name4 $pool_name\/$img_name", 0 ); + perform_action( $SNAP_CREATE, "--snap $snap_new $pool_name\/$new_img_name", + 0 ); +} + +# Tests to protect snapshot +sub protect_snapshot { + perform_action( $SNAP_PROTECT, "--snap $snap_new $pool_name\/$new_img_name", + 0 ); + perform_action( $SNAP_PROTECT, "--snap $snap_new $pool_name\/$new_img_name", + 2 ); + perform_action( $SNAP_PROTECT, "--snap $snap_name4 $pool_name\/$img_name", + 2 ); + perform_action( $SNAP_PROTECT, "--snap $snap_test $pool_name\/$img_name", + 2 ); +} + +# Tests to unprotect snapshot +sub unprotect_snapshot { + perform_action( $SNAP_UNPROTECT, "--snap $snap_new $pool_name\/$new_img_name", + 0 ); + perform_action( $SNAP_UNPROTECT, "--snap $snap_new $pool_name\/$new_img_name", + 2 ); + perform_action( $SNAP_UNPROTECT, "--snap $snap_name4 $pool_name\/$img_name", + 2 ); + perform_action( $SNAP_UNPROTECT, "--snap $snap_test $pool_name\/$img_name", + 2 ); +} + +# clone protected snapshot +sub clone_image { + perform_action( $RBD_CLONE, "$pool_name\/$new_img_name\@$snap_new $pool_name\/$clone_new", + 0 ); + perform_action( $RBD_CLONE, "$pool_name\/$new_img_name\@$snap_new $pool_name\/$clone_new", + 1 ); + perform_action( $RBD_CLONE, "$pool_name\/$new_img_name\@$snap_name5 $pool_name\/$clone_new1", + 2 ); + perform_action( $RBD_CLONE, "$pool_name\/$img_name\@$snap_test $pool_name\/$clone_new1", + 2 ); + perform_action( $RBD_CLONE, "$pool_name\/$img_name\@$snap_name5 $pool_name\/$clone_new2", + 2 ); + perform_action( $RBD_CLONE, "$pool_name\/$img_name\@$snap_new", + 2 ); + perform_action( $RBD_CLONE, "$pool_name\/$img_name", + 2 ); +} + +#flatten image +sub rbd_flatten { + perform_action( $RBD_FLATTEN, "$pool_name\/$clone_new", 0); + perform_action( $RBD_FLATTEN, "$pool_name\/$clone_new", 2); + perform_action( $RBD_FLATTEN, "$pool_name\/$clone_new2", 2); + perform_action( $RBD_FLATTEN, "$pool_name\/$new_img_name", 2); } # Tests to rollback snapshot @@ -144,6 +202,7 @@ sub rollback_snapshot { sub purge_snapshots { perform_action( $SNAP_PURGE, "$pool_name\/$img_name", 0 ); perform_action( $SNAP_PURGE, "$pool_name\/$new_rbd_img", 2 ); + perform_action( $SNAP_PURGE, "$pool_name\/$new_img_name", 2 ); } # Tests to list snapshots for an image @@ -154,6 +213,7 @@ sub list_snapshots { # Tests for remove snapshots sub remove_snapshot { perform_action( $SNAP_REMOVE, "$pool_name\/$img_name\@$snap_name", 0 ); + perform_action( $SNAP_REMOVE, "$pool_name\/$new_img_name\@$snap_new", 2 ); perform_action( $SNAP_REMOVE, "$non_pool_name\/$img_name\@$snap_name3", 2 ); perform_action( $SNAP_REMOVE, "$pool_name\/$img_name\@$snap_name2", 0 ); perform_action( $SNAP_REMOVE, "$pool_name\/$non_existing_img", 2 ); @@ -309,12 +369,16 @@ rename_image(); resize_image(); info_image(); create_snapshots(); +protect_snapshot(); export_image(); import_image(); list_snapshots(); rollback_snapshot(); remove_snapshot(); purge_snapshots(); +clone_image(); +rbd_flatten(); +unprotect_snapshot(); copy_image(); remove_image(); display_result(); -- 2.39.5