# Hey emacs, this is basically -*- perl -*- # $Id$ # # Copyright (c) 2011 Network Appliance, Inc. # All rights reserved. # ## @summary Example Script illustrating VerifyVolID Task. ## ## @description ## Because this test script is executed using the TCD.pm ## package, we will always execute methods in the following ## order: init(), setup(), , cleanup(), ## uninit() ## ## @description Objective: ## Automate the TestCase - WAFL075-02 using NACL Task VerifyVolID. ## ## Test Control Parameters ## ## @param TESTCASES ## Optional: List of test cases to execute. This can be "all", a ## comma separated list of test cases, or the index/id of test cases. ## The user can include switches and multipliers as well. See the ## documentation for the TCD lib for a full description of this ## parameter. By default all test cases will be executed one time. ## ## @param LISTTESTCASES ## Optional: If this is set to yes, the script will not execute the ## test cases, but instead will print a list of the test cases ## and their descriptions that correspond to the other input ## parameters. Default is 0. ## Test Case Specific Parameters ## ## Test Case Specific Parameters ## ## @param NODES ## Required: Comma separated list of filer hostrec ## ## @param VSERVER ## Optional: vserver of the Filer ## Default : vs0 ## ## @param FILER_VOL ## Optional: Test volume to run test ## Default: testvol_flex ## ## @param FILER_AGGR ## Optional: Test Aggr to run test ## Default: testaggr_flex ## ## @param FLEX_SIZE ## Optional: Size of the volume that will be created ## Default : 20m ## ## @param VOL_NEWNAME ## Optional: A new name that would be assigned to the test volume ## Default : vol_new_name ## ## @param AGGR_NEWNAME ## Optional: A new name that would be assigned to the test aggregate ## Default : aggr_new_name ## ## @param CLEANUP ## Optional: Type of cleanup to be done at the end ## Default : test ## ## The following test cases can be executed by supplying ## the TESTCASES parameters with either the test name or id value(s) ## on the command ## line. Please see the TCD.pm POD documentation for other command ## line options. ## ## ID Test Case ## -- ------------------ ## 1 WAFL075_002 ## ## @dependencies Filer ## 1. If running on a CMode filer, Vserver is expected to be created already ## ## @synopsis ## ntest NODES=hostspec of node ## [VSERVER=vservername] ## [FILER_VOL=testvol] ## [FILER_AGGR=testaggr] ## [FLEX_SIZE=size-of-volume] ## [CLEANUP= none|test] ## [VOL_NEWNAME=vol_new_name] ## [AGGR_NEWNAME=aggr_new_name] ## tc_verifyvolid.thpl ## ## @example ## Run tc_verifyvolid.thpl ## ## # run all the test cases ## ntest NODES=wqa-gx76 -noconsole tc_verifyvolid.thpl ## ## # list of test cases to execute - used by nip ## ntest NODES=wqa-gx76 -noconsole tc_verifyvolid.thpl \ ## LISTTESTCASES=1 ## ## # run all the test cases use -q "quiet" so you don't get STDOUT output ## ntest NODES=wqa-gx76 -noconsole tc_verifyvolid.thpl\ ## TESTCASES="-q,all" ## ## # run specific test cases ## ntest NODES=wqa-gx76 -noconsole tc_verifyvolid.thpl \ ## TESTCASES=WAFL0075_002 ## ## # run test cases that begin with "testcase" using the "%" wild card ## ntest NODES=wqa-gx76 -noconsole tc_verifyvolid.thpl \ ## TESTCASES=WAFL075% ## ## # execute test case testcase_1 50 times ## ntest NODES=wqa-gx76 -noconsole tc_verifyvolid.thpl \ ## TESTCASES=WAFL0075_002*50 ## ## # execute specific tests and skipover setup and cleanup ## # (-nsc=no setup or cleanup and overrides testcase specific params) ## ntest NODES=wqa-gx76 -noconsole tc_verifyvolid.thpl \ ## TESTCASES=-nsc,WAFL0075_002 ## ## @keywords {VerifyVolID Example-TestCase} ## ## @attributes listtestcases=yes ## ## @status Review ## ## @author hemamalini.rengarajan@netapp.com ## ## @change 2011-03-29 author: Original template created use strict; use warnings; # ============================================================= # Module import. # ============================================================= use TCD; use Tharn qw($Log); use NACL::MTask::VerifyVolID; use NACL::STask::Aggregate; use NACL::STask::Volume; use NACL::C::Node; use FS::commonParams; # ============================================================= # Declare Global Variables # ============================================================= our ( $AGGR_CREATION_TIME, $VSERVER, $VOL_NEWNAME, $AGGR_NEWNAME ); param( "VSERVER", '-default', 'vs0' ); param( "FLEX_SIZE", '-default', '20m' ); param( "FILER_AGGR", '-default', 'testaggr_flex' ); param( "VOL_NEWNAME", '-default', 'vol_new_name' ); param( "AGGR_NEWNAME", '-default', 'aggr_new_name' ); FS::commonParams->new( set_legacy_defaults => 1 ); my ( @TC_LIST, $Test, $Node, $Testdata, $Vvid_task, $Aggr_task, $Vol_task ); $Testdata = { Aggregate => [ { 'aggregate' => $FILER_AGGR, 'diskcount' => '3', 'volume-style' => "flex", 'voltype' => 'flex' } ], Volume => [ { 'aggregate' => $FILER_AGGR, 'volume' => $FILER_VOL, 'size' => $FLEX_SIZE, 'vserver' => $VSERVER }, ] }; # ============================================================= # Test cases to execute # ============================================================= @TC_LIST = ( 'WAFL075_002' => 'WAFL075-002 Rename aggr and flex vols and verify Vol IDs' ); # Run program &main(); # ============================================================= # MAIN # ============================================================= sub main { # Standard break point for debugging - don't remove $DB::single = 2; # The new method takes an optional argument called # options. It's for TCD options and it's been added # so that users can add them into their scritps without # the user having to include them in the TESTCASES # Format: Comma separated list of TCD Options. # Examples: -q -rsc -ns -nc -nsc -cl -e -st -l -h # Create Test Case Object $Test = new TCD( -testcases => \@TC_LIST ); if ( $Test->error() ) { $Test->log( $Test->errmsg ); return $TCD::FAIL; } # Performs method callbacks. If LISTTESTCASES is set, all # run_test() will do is parse the TESTCASES param and list the test cases. $Test->run_test(); if ( $Test->error() ) { $Test->log( $Test->errmsg ); return $TCD::FAIL; } exit(0); } # end main() # ============================================================= # INIT # init() is automatically called before executing tests to get # test parameters and to create any needed resources # ============================================================= sub init() { my ( @node_list, $ret_code ); try { $Test->description( "Retrieve variables from the test harness and\n " . "instantiate objects needed for test execution" ); # Initialize the return value here $ret_code = $TCD::PASS; # Identify the command interface & Mode to execute the commands @node_list = NACL::C::Node->find(); $Node = $node_list[0]; } ## End of try block catch NATE::BaseException with { my $exception_object = shift; $Log->comment( "Error: " . $exception_object->text() ); $ret_code = $TCD::CONFIG; }; return $ret_code; } # end init() # ============================================================= # SETUP # setup() is automatically called before executing tests # ============================================================= sub setup() { my ( $ret_code, $input_params ); try { $Test->description("Set up for the Test Case"); # Initialize the return value here $ret_code = $TCD::PASS; # Create Aggregate $Test->step("Create the test aggregate $FILER_AGGR "); $input_params = $Testdata->{'Aggregate'}->[0]; $Aggr_task = NACL::STask::Aggregate->create( command_interface => $Node, if_exists => 'die', %$input_params ); ## Create Volume $Test->step("Create the test volume $FILER_VOL "); $Vol_task = NACL::STask::Volume->create( command_interface => $Node, if_exists => 'die', %{ $Testdata->{'Volume'}->[0] } ); ## Create VVerifyVolID Task object handle $Log->comment("Creating VerifyVolID Task object handle "); $Vvid_task = NACL::MTask::VerifyVolID->new( command_interface => $Node, volumes => [$Vol_task], vserver => $VSERVER, require_provenance => 1, id_pairs_match => 1, ); } ## End of try block catch NATE::BaseException with { my $exception_object = shift; $Log->comment( "Error: " . $exception_object->text() ); $ret_code = $TCD::CONFIG; }; return $ret_code; } # end setup() # ============================================================= # CLEANUP # cleanup() is automatically called after executing tests # ============================================================= sub cleanup() { $Test->description("Cleanup"); if ( $CLEANUP ne 'none' ) { try { $Test->step("Deleting the volume $FILER_VOL "); $Vol_task->purge(); } catch NATE::BaseException with { my $exception_object = shift; $Log->warn( "Problem while renaming/deleting volume " . $Vol_task->volume() ); $Log->comment( "Problem:" . $exception_object->text() ); }; try { $Test->step("Deleting the aggregate $FILER_AGGR"); $Aggr_task->purge(); } catch NATE::BaseException with { my $exception_object = shift; $Log->warn("Problem while renaming/deleting Aggregate $FILER_AGGR "); $Log->comment( "Problem:" . $exception_object->text() ); }; } ## end if ( $CLEANUP ne 'none') return $TCD::PASS; } ## end sub cleanup() # ============================================================= # UNINIT # uninit() is automatically called after executing tests # ============================================================= sub uninit() { $Test->description("uninit()"); undef $Vvid_task; undef $Aggr_task; undef $Vol_task; return $TCD::PASS; } ## end sub uninit() sub WAFL075_002 { $Test->description( "WAFL075-002 Rename aggr and flex vols and verify Vol IDs"); my ($ret_code); $ret_code = $TCD::PASS; try { ## Rename the volume here $Test->step("Rename the volume from $FILER_VOL to $VOL_NEWNAME"); $Vol_task->rename( newname => $VOL_NEWNAME ); ## Verify the Volid using the Task handle created here $Test->step("Verify the volid is the same after volume-rename "); $Vvid_task->verify(); ## Rename the aggregate now $Test->step("Rename the aggregate from $FILER_AGGR to $AGGR_NEWNAME"); $Aggr_task->rename( newname => $AGGR_NEWNAME ); ## Verify the Volid using the Task handle created here $Test->step("Verify the volid is the same after aggregate-rename "); $Vvid_task->verify(); } catch NATE::BaseException with { my $exception_object = shift; $Log->comment( "Error: " . $exception_object->text() ); $ret_code = $TCD::FAIL; }; return $ret_code; }