#!/usr/software/bin/perl # $Id: //depot/prod/test/main/storage/hdd/NADQ_SEA/NDATE_NVMe/NADQ02_NVMe_Compliance.thpl#1 $ # ## @summary Mode ## Disk Firmware Download in background/foreground mode # ## ## @description ## Verify that the drive can download disk firmware in foreground and background mode properly ## using the method available in the NetApp system. ## ## @Test Mode ## File system mode ## ## @Test bed setup ## FC : Cluster Fabric ## SATA : Cluster ## SAS : Cluster ## ## @usage ## The test can be run independently or with other tests as part of STEST. ## ## @dependencies ## Disk firmwares should be copied to ~/NDATE/FIRMWARE/DISKFW/HIGH folder for foreground ## ## @steps ## The test will execute steps mentioned below: ## ## ## @status Automated ######################################## ### Library functions ########################################## use strict; use Storage::NVMe_Common_Lib; use Storage::Tahiti_Common_Lib; use Storage::Common_Lib; use NACL::C::Statistics; use NACL::MTask::EventLogDetector; ######################################### ######################################### ### Initialization/declaration ######################################### ##### # Global parameters use vars qw( $FILER $MODE $FILER_CONN $TEST_CONFIG $TEST_SETUP $FILER_PROMPT $LOGDIR $EOE $TEST_WAIT_TIME $BOOT_MODE $BOOT_TYPE $SSD $EMAIL $MAIL_TO $MAIL_FROM $FILER_TYPE $FIRMWARE $RUNID $ARMADILLO $USER_LOOPS ); my $params = NATE::ParamSet->new( global => 1 ); $FILER = $params->get( 'FILER', default => 'Filer' ); $TEST_CONFIG = $params->get( 'TEST_CONFIG', default => 'E' ); $TEST_WAIT_TIME = $params->get( 'TEST_WAIT_TIME', default => '3' ); $LOGDIR = $params->get( 'LOGDIR', default => undef ); $EOE = $params->get( 'EOE', default => 1 ); $EMAIL = $params->get( 'EMAIL', default => 'y' ); $MAIL_TO = $params->get( 'MAIL_TO', default => 'Email to' ); $MAIL_FROM = $params->get( 'MAIL_FROM', default => 'Email from' ); $TEST_SETUP = $params->get( 'TEST_SETUP', default => 'SAS' ); $BOOT_MODE = $params->get( 'BOOT_MODE', default => '1' ); $BOOT_TYPE = $params->get( 'BOOT_TYPE', default => 'A' ); $RUNID = $params->get( 'RUNID', default => undef ); $SSD = $params->get( 'SSD', default => 'no' ); $ARMADILLO = $params->get( 'ARMADILLO', default => '2' ); $FILER_TYPE = $params->get( 'FILER_TYPE', default => 'BR' ); $FIRMWARE = $params->get( 'FIRMWARE', default => 'Firmware file not entered' ); $USER_LOOPS = $params->get( 'LOOPS', default => '10' ); ################ # Testcase name ################ my $TC_name; $TC_name = "101_NADQ02_NVMe_Th_Maint_Enum"; #Common variable declaration my ( $email_subject, $email_body ); my @Nodes; my $filer_names; my $Mode; my $test_status = 0; my %nodes_filer; my $firmware_hash = {}; my @firmware_list; my $cnt = 1; my $disk_show_v; my %test_details; my $Home = $ENV{HOME}; my $test_wait_time = 12 * 3600; #12 Hrs test if ( $TEST_WAIT_TIME == 1 ) { $test_wait_time = ( $test_wait_time / 10 ); } elsif ( $TEST_WAIT_TIME == 2 ) { $test_wait_time = ( $test_wait_time / 2 ); } elsif ( $TEST_WAIT_TIME == 4 ) { $test_wait_time = ( ($test_wait_time) * (.95) ); } ######################################### # Test case available for execution ######################################### my @Testcases = ( Th_Drive_Enum => "Tahiti - Apollo - NVMe Drive Enumeration in maintenance mode." ); &main(); sub main { # Debug break point $DB::single = 2; # Create Test Case Driver object $Test = new TCD( -testcases => [@Testcases] ); if ( $Test->error ) { $Test->log( $Test->errmsg ); $test_status = 1; $email_subject = "$TC_name : Test FAILED: FAIL"; $email_body = "Failed to instantiate Test object.\nLog Location : $LOGDIR\n"; send_message( mail_subject => $email_subject, mail_body => $email_body, MAIL_FROM => $MAIL_FROM, MAIL_TO => $MAIL_TO, EOE => $EOE, EMAIL => $EMAIL ); return $TCD::FAIL; } # Performs method callbacks $Test->run_test(); if ( $Test->error ) { $Test->log( $Test->errmsg ); return $TCD::FAIL; } exit(0); } ## end sub main ########## INIT ################################################### # This init subroutine will initialise the filer. #################################################################### sub init() { $Test->description(" Initialising all required variables and filer connections "); $filer_names = $Test->get_param("FILER"); # Capturing Filer names from the param(Test_Suite) ##Check for duplicate node object and push unique node object in Nodes array. my @temp_nodes = NACL::C::Node->find(); # Find Nodes/Filers used in the test, Based on FILER param. foreach my $Node (@temp_nodes) { my $FILER_C = $Node->name(); $nodes_filer{$FILER_C} = $Node; } @Nodes = values(%nodes_filer); # Contains Node object used for test execution. sort(@Nodes); $Mode = $Nodes[0]->mode(); logcomment("Checking for execution mode"); logcomment( "FILER- $filer_names : $TC_name : started, expected max completion time 30 Min : " . scalar( localtime() ) ); logcomment( "FILER- $filer_names : Log file for this test case: \n $LOGDIR/$TC_name" . ".log " . scalar( localtime() ) ); return $TCD::PASS; } ########## SETUP ################################################### # setup automatically called before executing tests #################################################################### sub setup() { $Test->description("Setup the environment for the test execution "); logcomment("Mode of filer $filer_names : $Mode"); my $node_ref = \@Nodes; version_test( node_present => $node_ref, tc_name => $TC_name ); foreach my $Node (@Nodes) { my $FILER_C = $Node->name(); logcomment("Check filer State : $FILER_C"); my $Transit_obj = NACL::Transit->new( name => $FILER_C ); my $filer_state = $Transit_obj->get_state( 'timeout' => 3600, 'get_state_timeout' => 7200 ); logcomment("$FILER_C : is in $filer_state state "); logcomment("Halt Filer : $FILER_C "); $Transit_obj->change_state( to => "FIRMWARE" ); logcomment("Check Filer State : $FILER_C"); my $filer_state = $Transit_obj->get_state( 'timeout' => 3600, 'get_state_timeout' => 7200 ); logcomment("$FILER_C : is in $filer_state state "); } return $TCD::PASS; } sub Th_Drive_Enum { my @subtests; my $status = 0; logcomment( "Number of nodes are " . scalar @Nodes . " and the filer are $filer_names" ); foreach my $Node (@Nodes) { my $FILER_C = $Node->name(); push( @subtests, subtest( \&halt_boot_check, -runid, "halt_boot_check_dr_$FILER_C", -bg, "--", $Node ) ); } Subtest::wait_finish( subtest => [@subtests] ); my $status = status_return( subtest_ref => [@subtests] ); logcomment("Total test status is : $status"); if ( $status == 0 ) { return $TCD::PASS; } else { return $TCD::FAIL; } } sub halt_boot_check { $Test->description("Executing in Sequence - Halt Node , Boot Maintenance - Check failed Drive "); my $Home = $ENV{HOME}; my $drv_result = {}; my $tahiti_drvs = {}; my @nv_drv; my @tahiti_drv; my $Node = shift(@_); my $FILER_C = $Node->name(); my $Host = host($FILER_C); logcomment("FILER : $FILER_C - Executing "); logcomment( "Filer passed to the subtest :: " . $Node->name() ); logcomment("User Selected Loop count : $USER_LOOPS"); logcomment("Sequence will be execute $USER_LOOPS times"); for ( my $i = 1 ; $i <= $USER_LOOPS ; $i++ ) { logcomment("$FILER_C : Loop $i Start "); #STEP 1 tahiti_eye_catcher( Test => $Test, string => "STEP 1 of 3: Halt Filer $FILER_C" ); logcomment("Check filer State : $FILER_C"); my $Transit_obj = NACL::Transit->new( name => $FILER_C ); my $filer_state = $Transit_obj->get_state( 'timeout' => 3600, 'get_state_timeout' => 7200 ); logcomment("$FILER_C : is in $filer_state state "); logcomment("Halt Filer : $FILER_C "); $Transit_obj->change_state( to => "FIRMWARE" ); sleep 10; logcomment("Check filer State "); my $filer_state = $Transit_obj->get_state( 'timeout' => 3600, 'get_state_timeout' => 7200 ); logcomment("$FILER_C : is in $filer_state state "); if ( $filer_state =~ /FIRMWARE/i ) { logcomment("$FILER_C: is in LOADER "); } else { logcomment("**NO_RUN** : Filer $FILER_C cannot be halted, Check Connection"); return 1; } #STEP 2 : tahiti_eye_catcher( Test => $Test, string => "STEP 2 of 3: Boot in maintenance mode and check for init failed" ); logcomment("Filer password : Boot $FILER_C in maintenance mode"); my $Transit_obj = NACL::Transit->new( name => $FILER_C ); eye_catcher( Test => $Test, string => "MAINT_BOOT : START " ); my $maint_out = $Transit_obj->change_state( to => "MAINT" ); my $Host = host($FILER_C); my $Api_Set_ObjMM = NACL::APISet->new( hostobj => $Host, category => "Node", interface => "CLI", set => "Maintenance" ); my $filer_state = $Transit_obj->get_state( 'timeout' => 3600, 'get_state_timeout' => 7200 ); logcomment("$FILER_C : is in $filer_state state "); eye_catcher( Test => $Test, string => "MAINT_BOOT : END " ); logcomment("LOG DIR : $LOGDIR"); my $log_name = "halt_boot_check_dr_$FILER_C" . ".log"; my $log2read = "$LOGDIR/$log_name"; logcomment( "FILER- $FILER_C Log file for this test case: \n $log2read " . scalar( localtime() ) ); open( H_LOGFILE, "<$log2read" ) || logresult( "FAIL", "CANNOT READ LOG FILE $log2read" ); foreach my $line () { chomp($line); if ( $line =~ /disk\.init\.failure\.error/ ) { logcomment("**FATAL** : disk.init.failure.error FOUND !!! in Loop $i"); } if ( $line =~ /failed initialization/ ) { logcomment("**FATAL** : Drive FAILED Initialization !!! in Loop $i"); } } logcomment("Booted in Maintenance mode "); #STEP 3 tahiti_eye_catcher( Test => $Test, string => "STEP 3 of 3: check for all drives " ); my $output = $Api_Set_ObjMM->execute_command( 'command' => 'sysconfig -v', 'timeout' => 6000 ); foreach my $line ( split( /\n/, $output ) ) { if ( $line =~ /init failed/ ) { logcomment("**FATAL** : Drive init failed"); } if ( $line =~ /failed/i ) { logcomment("**FATAL** : FAILED Drive present"); } } my $disk_out = $Api_Set_ObjMM->execute_command( 'command' => 'disk show', 'timeout' => 6000 ); foreach my $line ( split( /\n/, $output ) ) { if ( $line =~ /init failed/ ) { logcomment("**FATAL** : Drive init failed"); } if ( $line =~ /failed/i ) { logcomment("**FATAL** : FAILED Drive present"); } } logcomment("$FILER_C : Loop $i Completed "); } logresult( "INFO", msg => $test_status ); } # End of sub_exe ##################################################################### # Cleanup - Post Process ##################################################################### sub cleanup() { $Test->nlog(" $filer_names - Clean up and post test process"); @Nodes = node_new_obj( node_array => [@Nodes] ); my $node_ref = \@Nodes; return $TCD::PASS; }