[DRBD-cvs] testing by lars; make generic_test.pl more configurable
drbd-user@lists.linbit.com
drbd-user@lists.linbit.com
Thu, 3 Jun 2004 12:00:13 +0200 (CEST)
DRBD CVS committal
Author : lars
Project : drbd
Module : testing
Dir : drbd/testing/CTH
Modified Files:
Tag: rel-0_7-branch
LGE_CTH.pm generic_test.pl
Log Message:
make generic_test.pl more configurable
===================================================================
RCS file: /var/lib/cvs/drbd/drbd/testing/CTH/Attic/LGE_CTH.pm,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -3 -r1.1.2.1 -r1.1.2.2
--- LGE_CTH.pm 27 May 2004 12:44:18 -0000 1.1.2.1
+++ LGE_CTH.pm 3 Jun 2004 10:00:08 -0000 1.1.2.2
@@ -1,5 +1,5 @@
package LGE_CTH;
-# $Id: LGE_CTH.pm,v 1.1.2.1 2004/05/27 12:44:18 lars Exp $
+# $Id: LGE_CTH.pm,v 1.1.2.2 2004/06/03 10:00:08 lars Exp $
use strict;
use warnings;
use Carp;
@@ -109,7 +109,8 @@
use LGE_CTH::Configure (
logfile => "some.file.log",
logprefix => "test_run_name",
- config-file => "some.config.file";
+ config_file => "some.config.file";
+ FIXME add missing...
);
___
sub Configure {
@@ -132,9 +133,10 @@
unless defined $logprefix;
die "config_file missing from argument list\n$usage"
unless defined $config_file;
- unlink $logname;
+ # unlink $logname;
+ -e $logname and warn ("appending log to '$logname'\n");
# FIXME LOG -=> $logfile = IO::Handle ...
- sysopen(LOG,$logname,O_WRONLY|O_APPEND|O_CREAT) or die "open logfile: $!";
+ sysopen(LOG,$logname,O_WRONLY|O_APPEND|O_CREAT) or die "open logfile '$logname': $!";
syswrite(LOG,"\n\n-- \n\n") or die "syswrite>LOG: $!";
$srand = unpack "L", `head -c4 /dev/urandom` if not defined $srand;
@@ -144,7 +146,13 @@
$SIG{__WARN__} = sub { print STDERR "@_"; Log(@_); };
$SIG{__DIE__} = sub { warn @_; exit 255 unless $died++ or $exiting; };
- warn("New Start $0 @ARGV\nrand_seed = $srand\nmove_res = $move_resource_prob\n");
+ warn(<<___);
+New Start $0 @ARGV
+rand_seed = $srand
+sleeptime = $sleeptime
+move_res = $move_resource_prob
+config_file = $config_file
+___
$SIG{CHLD} = \&__reap;
$SIG{INT} = sub { $SIG{INT} = 'DEFAULT'; warn("SIGINT caught, exiting"); $pending = -1; };
@@ -193,7 +201,7 @@
@Resource = grep { $_->isa('LGE_CTH::Resource') and $_->{_refcnt} == 0; } @ALL_OBJ;
die "No Resource configured in $config_file??\n" unless @Resource;
- print "Services:\n", map { "\t$_->{_id}\n" } @Resource;
+ print "Services:\n", map { "\t" . $_->as_string . "\n" } @Resource;
boot_nodes;
@@ -314,7 +322,7 @@
END {
if ($$ == $mpid and not $exiting) {
$exiting = 1;
- warn("\n.\n#\n#\tEXITING\n#\n");
+ warn("\n.\n#\n#\tEXITING\n#\n") if $configured;
#print STDERR "$$ removing semaphore\n";
$CRM->stop_all if $clean_exit;
my $pid;
===================================================================
RCS file: /var/lib/cvs/drbd/drbd/testing/CTH/Attic/generic_test.pl,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -3 -r1.1.2.1 -r1.1.2.2
--- generic_test.pl 27 May 2004 12:44:18 -0000 1.1.2.1
+++ generic_test.pl 3 Jun 2004 10:00:08 -0000 1.1.2.2
@@ -1,40 +1,45 @@
-package main;
-# $Id: generic_test.pl,v 1.1.2.1 2004/05/27 12:44:18 lars Exp $
+#!/usr/bin/perl
+# $Id: generic_test.pl,v 1.1.2.2 2004/06/03 10:00:08 lars Exp $
use strict;
use warnings;
use LGE_CTH;
+use Pod::Usage;
+use Getopt::Long;
-sub show_usage() {
- print <<___;
-Usage: $0 test_name
-where currently supported tests are:
- wbtest
- tiobench
- dummy (does only touch one file, and sleep, in a loop)
-since the path to ./functions.sh is still hardcoded, you have to start
-this in the directory where it lives, or copy functions.sh over to the
-current directory...
-
-to tune which "HW" parts may fail, or what config file to use
-or which file system you like best, or where to mount them,
-you still have to edit this file...
-
-to add more tests, you have to edit this file, and you need to add bash
-functions named <your_test>_start, and maybe <your_test>_stop if the
-generic_test_stop does not fit, to functions.sh.
-
-there currently is no paranoia implemented about whether the needed
-programs exist on the target box.
-___
-}
-
-show_usage and exit 1
-unless $ARGV[0] =~ /^(wbtest|tiobench|dummy)$/
- and -e "./functions.sh";
+my $logfile = 'tmp.log';
+my $logprefix = 'test0';
+my $test_name = 'wbtest';
+my $config_file = 'NONE';
+my $sleeptime = 30;
+my $move_prob = 50;
+my $rand_seed;
+my $help;
+
+GetOptions(
+ "h" => \$help,
+ "help" => sub { $help = 2 },
+ "rand_seed=i" => \$rand_seed,
+ "test_name=s" => \$test_name,
+ "logfile=s" => \$logfile,
+ "logprefix=s" => \$logprefix,
+ "config=s" => \$config_file,
+ "sleep=i" => \$sleeptime,
+ "move=i" => \$move_prob,
+) or pod2usage(2);
+
+while(not $help) {
+ $test_name =~ /^(wbtest|tiobench|dummy)$/
+ or warn("unknown testname '$test_name'\n"), $help++, last;
+ $config_file and -e $config_file
+ or warn("config file ($config_file) not found\n"), $help++, last;
+ -e "./functions.sh" or warn("./functions.sh not found\n"), $help++, last;
+ last;
+};
-my $which = $ARGV[0];
+pod2usage(-exitstatus => 0, -verbose => 2) if $help > 1;
+pod2usage(1) if $help;
our (
$left,$right,$link,
@@ -42,17 +47,13 @@
);
# CHANGE
-# sleeptime, move_res, logfile
-# logfile gets OVERWRITTEN with each run !!
Configure(
- rand_seed => 1234567890,
- logfile => "tmp.out",
- logprefix => "test0",
- config_file => "uml-minna.conf",
- # config_file => "bloodymary.conf",
- # config_file => "chipdale.conf",
- sleeptime => 30,
- move_res => 50, # probability (percent) of moving resources when $FAILED == 0
+ rand_seed => $rand_seed,
+ logfile => $logfile,
+ logprefix => $logprefix,
+ config_file => $config_file,
+ sleeptime => $sleeptime,
+ move_res => $move_prob,
);
@@ -63,15 +64,58 @@
new LGE_CTH::GenericTest {
fs => $fs0,
- which => $which,
+ which => $test_name,
};
new LGE_CTH::GenericTest {
fs => $fs1,
- which => $which,
+ which => $test_name,
};
Run;
die "NOT REACHED ??";
+
+__END__
+
+=head1 NAME
+
+Generic test script.
+
+=head1 SYNOPSIS
+
+ -h short help
+ -help more verbose help
+ -rand_seed set random seed
+ -test_name select which test to run; currently supported:
+ wbtest, tiobench, dummy
+ -logfile where to log to
+ -logprefix used to tag log lines of this run
+ -config config file to use
+ -sleep min time between two events
+ -move probability (percent) to move resources
+ instead of failing some HW component
+
+=head1 DESCRIPTION
+
+ <config_file> should look like bloodymary.conf or chipdale.conf
+ <test_name> currently supported tests are:
+ wbtest
+ tiobench
+ dummy (does only touch one file, and sleep, in a loop)
+
+since the path to ./functions.sh is still hardcoded, you have to start
+this in the directory where it lives, or copy functions.sh over to the
+current directory...
+
+to tune which "HW" parts may fail, or what config file to use
+or which file system you like best, or where to mount them,
+you still have to change your config file...
+
+to add more tests, you have to edit this file, and you need to add bash
+functions named <your_test>_start, and maybe <your_test>_stop if the
+generic_test_stop does not fit, to functions.sh.
+
+there currently is no paranoia implemented about whether the needed
+programs exist on the target box.