#!/usr/bin/perl ############################################################################## # # Name: rantest # # Description: This script is a test driver script capable of running tests # individually or from a file. There are many facilities for # specifying input and options to this program - see the usage # and help subroutines for clues. Basically you can run rantest # by itself and it will interactively prompt you for what to do # and what information or options it needs. Additionally you can # set options in the environment such as RANTEST_VIEW or # RANTEST_UNIT to serve as defaults. Or you can use -view or # -type, for example, at the command line to supply such parms. # If rantest still doesn't have all it needs it will prompts. # # Note that options and/or test cases can be specified in config # files specified by RANTEST_FILE or -file. Embedded in the # config file can be additional options in the form of: # # b2_l3_rnc_irt_001.test: # ---------------------- # view: p6258c_SIMCQ00000100_intview # type: rnc # unit: 4 # exec: tc CN_SIM/TC_CN_Simulation_RANAP_Setup.profile -timeout 60 # exec: tc CN_SIM/TC_CN_Simulation.profile -timeout -1 -pause 5 # exec: tc RBS_SIM/TC_RBS_Sim_Cell_Setup.profile -timeout 180 # exec: tc l3_rnc/irt/TC_b2_l3_rnc_irt_001.profile -timeout 180 # # Above we've set view, type and unit for the test run # and defined test steps of tc # CN_SIM/TC_CN_Simulation_RANAP_Setup.profile, # CN_SIM/TC_CN_Simulation.profile, # RBS_SIM/TC_RBS_Sim_Cell_Setup.profile and # l3_rnc/irt/TC_b2_l3_rnc_irt_001.profile # # Note that you can specify optional additional # parameters after the test name like -timeout and a # bunch of other parameters as described in the "Command # Line in East" document. # # This would be run as so: # # $ rantest -file b2_l3_rnc_irt_001.test # # Suite files, those ending in .suite, are different # from .test files in that they merely contain a list of # .test files (relative to /vobs/simdev/test) to # execute for this suite. Note that parameters can be # added after the suite file name: # # nightly.suite: # -------------- # # RNC IRT tests # b2_l3_rnc_irt_007.test -unit 4 # b2_l3_rnc_irt_014.test # # # RNC SCH tests # b2_l3_rnc_sch_001.test -view official_view # b2_l3_rnc_sch_003a.test # # Author: Andrew@ClearSCM.com # # Copyright (c) 2008, 2009 General Dynamics # # All rights reserved except as subject to DFARS 252.227-7014 of contract # number CP02H8901N issued under prime contract N00039-04-C-2009. # # Warning: This document contains technical data whose export is restricted # by the Arms Export Control Act (Title 22, U.S.C., Sec 2751, et seq.) or the # Export Administration Act of 1979, as amended, Title, 50, U.S.C., App. 2401 # et seq. Violations of these export laws are subject to severe criminal # penalties. Disseminate in accordance with provisions of DoD Directive # 5230.25. # ############################################################################## use strict; use warnings; use File::Basename; use File::Glob ':glob'; use File::Path; use FindBin; use Getopt::Long; use Net::Domain qw (hostname); use Term::ANSIColor qw (:constants); use Term::ReadLine; use Term::ReadLine::Gnu; # Use the SDE Tools libraries. Sorry for this long path. I didn't come # up with it! #use lib "/cleartrig/ent/SNSD/muos/ccadm_tools/vobs/ranccadm/scripts/lib"; use lib "$FindBin::Bin/../lib"; use DateUtils; use Display; use Utils; use GetConfig; use Logger; error "$FindBin::Script only runs on seast1", 1 unless hostname eq "seast1"; use lib "$FindBin::Bin/../lib"; use GD::RantestDB; use GD::Nethawk::East; use constant VERSION_NBR=> "1.2.5"; use constant VERSION => BOLD GREEN VERSION_NBR; use constant PROMPT => BOLD YELLOW "$FindBin::Script>"; use constant DESC => BOLD RED "$FindBin::Script", RESET "Version", VERSION . RESET ": " . BOLD CYAN "RAN T" . RESET "ool for " . BOLD CYAN "E" . RESET "xecution of " . BOLD CYAN "S" . RESET "ystem " . BOLD CYAN "T" . RESET "ests"; use constant HISTORY_FILE => "$ENV{HOME}/.rantest_hist"; use constant LOGBASE => "$ENV{MNT_DIR}/testlogs"; ############################################################################ # Globals ############################################################################ my $_east; my $_connected = 0; my $_debugging; my $_log; my $_term; my $_rantestdb; my $_testNbr = 0; my $_validationNbr = 0; my %_stats; my %_executionResults; my (%_opts, %_cmdline_opts); # Seed opts from the environment. $_opts{eastview} = $ENV{RANTEST_EASTVIEW} if $ENV{RANTEST_EASTVIEW}; $_opts{eastview} = $ENV{RANTEST_VIEW} if $ENV{RANTEST_VIEW} && !$_opts{eastview}; $_opts{tm500view} = $ENV{RANTEST_TM500VIEW} if $ENV{RANTEST_TM500VIEW}; $_opts{nmsview} = $ENV{RANTEST_NMSVIEW} if $ENV{RANTEST_NMSVIEW}; $_opts{type} = $ENV{RANTEST_TYPE} if $ENV{RANTEST_TYPE}; $_opts{class} = $ENV{RANTEST_CLASS} if $ENV{RANTEST_CLASS}; $_opts{unit} = $ENV{RANTEST_UNIT} if $ENV{RANTEST_UNIT}; $_opts{test} = $ENV{RANTEST_TEST} if $ENV{RANTEST_TEST}; $_opts{file} = $ENV{RANTEST_FILE} if $ENV{RANTEST_FILE}; $_opts{rfr} = $ENV{RANTEST_RFR} if $ENV{RANTEST_RFR}; $_opts{checkin_on_error}= $ENV{CHECKIN_ON_ERROR} if $ENV{CHECKIN_ON_ERROR}; $_opts{feature} = $ENV{RANTEST_FEATURE} if $ENV{RANTEST_FEATURE}; $_opts{regression} = $ENV{RANTEST_REGRESSION} if $ENV{RANTEST_REGRESSION}; $_opts{secure} = $ENV{RANTEST_SECURE} if $ENV{RANTEST_SECURE}; # Explicitly default secure to either $ENV{RANTEST_SECURE}, if defined, otherwise 1 $_opts{secure} = $ENV{RANTEST_SECURE} ? $ENV{RANTEST_SECURE} : 1; sub usage (;$) { my ($msg) = @_; my $usage = "ERROR: $msg\n\n" if $msg; $usage .= <] [-tm500view ] [-nmsview ] [-type ] [-class ] [-rfr ] [-checkin_on_error] [-unit ] [-test ] [-file ] [-feature ] [-[no]s|ecure] Where: -us|age: Display usage -ve|rbose: Turn on verbose mode -d|ebug: Turn on debug mode -[ea|st]view View tag to run test(s) under -tm|500view TM 500 view to set into the environment for test -nm|sview NMS view to set into the environment for test -ty|pe Type of unit to test (i.e. rbs | rnc) -c|lass Class of test (i.e. one of the following): Load LoadTCRunner Pool RegressionLoadRunner TC RegressionRunner TS RegressionTSRunner Manual Manual test -un|it Unit number to test on -te|st Name of test (Optional: If not specific you will be prompted for test case names) -f|ile File containing a list of tests to execute (Optional: Contains a file of test classes and names to test) -rfr Run for record: ID is the test case ID to store results under -checkin_on_error Checks in rfr log files even if a test(s) fails -regression Run regression tests. These tests will log there results. -feature If specified then FEATURE will be set into the environment on the blade before calling start_east_auto. -[no]s|ecure Indicates whether or not to secure the node before attempting to connect to it. (Default: secure). NOTE: Set ANSI_COLORS_DISABLED to turn off colors If you specify -file you cannot specify -test nor -class. -class'es are read from -file. Additionally, options above can be specified in the environment by preceeding the environment variable with \"RANTEST_\". For example, \$ export RANTEST_TYPE=rbs \$ export RANTEST_UNIT=2 \$ rantest Also such options can be specified in the -file: unit: 5 executionlevel: 2 ts ts1.profile -timeout -1 -pause 5 ts ts2.profile -displaylevel 3 ts ts3.profile -activecalls 10 Options after test profile name are passed directory to EAST's command line. The exceptions are -timeout and -pause: -timeout Specifies the timeout for this test's execution. If negative the test will be placed in the background. No result is recovered from background tests nor are any logfiles analysed or stored. If positive then this sets the timeout period for this test in seconds. -pause Used in conjunction with -timeout. If test is backgrounded then $FindBin::Script will wait pause seconds before returning control from this test. This allows the backgrounded test time to start. -name Names a test. Used in conditional execution. -if ( ) Run this test if the named test returned where is one of . Success . Failure . In Progress . Timed out . Failed to execute . Rendezvous . Failed to rendezvous Note: Required options not supplied will be prompted for. END my $pager = $ENV{PAGER} ? $ENV{PAGER} : "more"; system "echo \"$usage\" | $pager"; exit 1 if $msg; } # usage sub help () { display DESC . RESET; display < Execute the contents of set