randgen team mailing list archive
-
randgen team
-
Mailing list archive
-
Message #00085
[Merge] lp:~bernt-johnsen/randgen/newLogging into lp:randgen
Bernt M Johnsen has proposed merging lp:~bernt-johnsen/randgen/newLogging into lp:randgen.
Requested reviews:
Random Query Generator Team (randgen)
For more details, see:
https://code.launchpad.net/~bernt-johnsen/randgen/newLogging/+merge/55925
--
https://code.launchpad.net/~bernt-johnsen/randgen/newLogging/+merge/55925
Your team Random Query Generator Team is requested to review the proposed merge of lp:~bernt-johnsen/randgen/newLogging into lp:randgen.
=== modified file 'gentest.pl'
--- gentest.pl 2010-11-29 20:48:33 +0000
+++ gentest.pl 2011-04-01 12:57:29 +0000
@@ -1,7 +1,7 @@
#!/usr/bin/perl
-# Copyright (C) 2008-2010 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
+# Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights
+# reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -28,6 +28,14 @@
use GenTest::Constants;
use GenTest::App::GenTest;
+my $logger;
+eval
+{
+ require Log::Log4perl;
+ Log::Log4perl->import();
+ $logger = Log::Log4perl->get_logger('randgen.gentest');
+};
+
my $DEFAULT_THREADS = 10;
my $DEFAULT_QUERIES = 1000;
my $DEFAULT_DURATION = 3600;
@@ -72,7 +80,10 @@
'valgrind',
'valgrind-xml',
'notnull',
- 'debug');
+ 'debug',
+ 'logfile=s',
+ 'logconf=s',
+ 'report-tt-logdir=s');
backwardCompatability($options);
my $config = GenTest::Properties->new(
options => $options,
@@ -112,11 +123,22 @@
'valgrind',
'valgrind-xml',
'sqltrace',
- 'notnull'],
+ 'notnull',
+ 'logfile',
+ 'logconf',
+ 'report-tt-logdir'],
help => \&help);
help() if !$opt_result || $config->help;
+if (defined $config->logfile && defined $logger) {
+ setLoggingToFile($config->logfile);
+} else {
+ if (defined $config->logconf && defined $logger) {
+ setLogConf($config->logconf);
+ }
+}
+
say("Starting \n $0 \\ \n ".join(" \\ \n ", @ARGV_saved));
$ENV{RQG_DEBUG} = 1 if defined $config->debug;
=== modified file 'lib/DBServer/DBServer.pm'
--- lib/DBServer/DBServer.pm 2010-08-11 19:40:07 +0000
+++ lib/DBServer/DBServer.pm 2011-04-01 12:57:29 +0000
@@ -1,5 +1,5 @@
-# Copyright (C) 2008-2010 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
+# Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights
+# reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -29,6 +29,14 @@
use POSIX;
use Carp;
+my $logger;
+eval
+{
+ require Log::Log4perl;
+ Log::Log4perl->import();
+ $logger = Log::Log4perl->get_logger('randgen.dbserver');
+};
+
use constant DBSTATUS_OK => 0;
use constant DBSTATUS_FAILURE => 1;
@@ -88,14 +96,22 @@
sub say {
my $text = shift;
-
- if ($text =~ m{[\r\n]}sio) {
- foreach my $line (split (m{[\r\n]}, $text)) {
- print "# ".isoTimestamp()." $line\n";
- }
- } else {
- print "# ".isoTimestamp()." $text\n";
- }
+ defaultLogging();
+ if ($text =~ m{[\r\n]}sio) {
+ foreach my $line (split (m{[\r\n]}, $text)) {
+ if (defined $logger) {
+ $logger->info($line);
+ } else {
+ print "# ".isoTimestamp()." $line\n";
+ }
+ }
+ } else {
+ if (defined $logger) {
+ $logger->info($text);
+ } else {
+ print "# ".isoTimestamp()." $text\n";
+ }
+ }
}
sub sayFile {
@@ -166,8 +182,23 @@
my $datetime = shift;
my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = defined $datetime ? gmtime($datetime) : gmtime();
- return sprintf("%04d-%02d-%02dT%02d:%02d:%02dZ", $year+1900, $mon+1 ,$mday ,$hour, $min, $sec);
+ return sprintf("%04d-%02d-%02dT%02d:%02d:%02d", $year+1900, $mon+1 ,$mday ,$hour, $min, $sec);
}
+sub defaultLogging {
+ if (defined $logger) {
+ if (not Log::Log4perl::initialized()) {
+ my $logconf = q(
+log4perl.rootLogger = INFO, STDOUT
+log4perl.appender.STDOUT=Log::Log4perl::Appender::Screen
+log4perl.appender.STDOUT.layout=PatternLayout
+log4perl.appender.STDOUT.layout.ConversionPattern=# %d{yyyy-MM-dd'T'HH:mm:ss} %m%n
+);
+ Log::Log4perl::init( \$logconf );
+ say("Using Log::Log4perl");
+ }
+ }
+}
+
1;
=== modified file 'lib/GenTest.pm'
--- lib/GenTest.pm 2010-08-11 19:40:07 +0000
+++ lib/GenTest.pm 2011-04-01 12:57:29 +0000
@@ -1,5 +1,5 @@
-# Copyright (C) 2008-2010 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
+# Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights
+# reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -20,7 +20,9 @@
@EXPORT = ('say', 'sayFile', 'tmpdir', 'safe_exit',
'osWindows', 'osLinux', 'osSolaris', 'osMac',
- 'isoTimestamp', 'isoUTCTimestamp', 'rqg_debug', 'unix2winPath');
+ 'isoTimestamp', 'isoUTCTimestamp', 'isoUTCSimpleTimestamp',
+ 'rqg_debug', 'unix2winPath',
+ 'setLoggingToFile','setLogConf');
use strict;
@@ -28,6 +30,14 @@
use POSIX;
use Carp;
+my $logger;
+eval
+{
+ require Log::Log4perl;
+ Log::Log4perl->import();
+ $logger = Log::Log4perl->get_logger('randgen.gentest');
+};
+
my $tmpdir;
1;
@@ -84,14 +94,22 @@
sub say {
my $text = shift;
-
- if ($text =~ m{[\r\n]}sio) {
- foreach my $line (split (m{[\r\n]}, $text)) {
- print "# ".isoTimestamp()." $line\n";
- }
- } else {
- print "# ".isoTimestamp()." $text\n";
- }
+ defaultLogging();
+ if ($text =~ m{[\r\n]}sio) {
+ foreach my $line (split (m{[\r\n]}, $text)) {
+ if (defined $logger) {
+ $logger->info($line);
+ } else {
+ print "# ".isoTimestamp()." $line\n";
+ }
+ }
+ } else {
+ if (defined $logger) {
+ $logger->info($text);
+ } else {
+ print "# ".isoTimestamp()." $text\n";
+ }
+ }
}
sub sayFile {
@@ -155,16 +173,22 @@
my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = defined $datetime ? localtime($datetime) : localtime();
return sprintf("%04d-%02d-%02dT%02d:%02d:%02d", $year+1900, $mon+1 ,$mday ,$hour, $min, $sec);
-
}
sub isoUTCTimestamp {
my $datetime = shift;
my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = defined $datetime ? gmtime($datetime) : gmtime();
- return sprintf("%04d-%02d-%02dT%02d:%02d:%02dZ", $year+1900, $mon+1 ,$mday ,$hour, $min, $sec);
+ return sprintf("%04d-%02d-%02dT%02d:%02d:%02d", $year+1900, $mon+1 ,$mday ,$hour, $min, $sec);
+}
+
+sub isoUTCSimpleTimestamp {
+ my $datetime = shift;
+
+ my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = defined $datetime ? gmtime($datetime) : gmtime();
+ return sprintf("%04d%02d%02dT%02d%02d%02d", $year+1900, $mon+1 ,$mday ,$hour, $min, $sec);
+}
-}
# unix2winPath:
# Converts the given file path from unix style to windows native style
@@ -183,4 +207,45 @@
}
}
+sub defaultLogging {
+ if (defined $logger) {
+ if (not Log::Log4perl::initialized()) {
+ my $logconf = q(
+log4perl.rootLogger = INFO, STDOUT
+log4perl.appender.STDOUT=Log::Log4perl::Appender::Screen
+log4perl.appender.STDOUT.layout=PatternLayout
+log4perl.appender.STDOUT.layout.ConversionPattern=# %d{yyyy-MM-dd'T'HH:mm:ss} %m%n
+);
+ Log::Log4perl::init( \$logconf );
+ say("Using Log::Log4perl");
+ }
+ }
+}
+
+
+sub setLoggingToFile {
+ my $logfile = shift;
+ my $logconf = {
+ 'log4perl.logger.randgen' => 'INFO, STDOUT, FILE',
+
+ 'log4perl.appender.STDOUT' => 'Log::Log4perl::Appender::Screen',
+ 'log4perl.appender.STDOUT.layout'=>'PatternLayout',
+ 'log4perl.appender.STDOUT.layout.ConversionPattern'=>"# %d{yyyy-MM-dd'T'HH:mm:ss} %m%n",
+
+ 'log4perl.appender.FILE'=>'Log::Log4perl::Appender::File',
+ 'log4perl.appender.FILE.filename'=>$logfile,
+ 'log4perl.appender.FILE.mode'=>'append',
+ 'log4perl.appender.FILE.layout'=>'PatternLayout',
+ 'log4perl.appender.FILE.layout.ConversionPattern'=>"# %d{yyyy-MM-dd'T'HH:mm:ss} %m%n"
+ };
+ Log::Log4perl::init($logconf);
+ say("Logging to stdout and $logfile");
+}
+
+sub setLogConf {
+ my $logfile = shift;
+ Log::Log4perl::init($logfile);
+ say("Logging defined by $logfile");
+}
+
1;
=== modified file 'lib/GenTest/App/GenTest.pm'
--- lib/GenTest/App/GenTest.pm 2011-02-19 21:27:26 +0000
+++ lib/GenTest/App/GenTest.pm 2011-04-01 12:57:29 +0000
@@ -155,15 +155,15 @@
my @executors;
foreach my $i (0..2) {
next if $self->config->dsn->[$i] eq '';
- my $executor = GenTest::Executor->newFromDSN($self->config->dsn->[$i], osWindows() ? undef : $channel);
+ my $executor = GenTest::Executor->newFromDSN($self->config->dsn->[$i], osWindows() ? undef : $channel);
$executor->sqltrace($self->config->sqltrace);
- $executor->setId($i+1);
+ $executor->setId($i+1);
push @executors, $executor;
- if ($executor->type() == DB_MYSQL) {
- my $metadata_executor = GenTest::Executor->newFromDSN($self->config->dsn->[$i], osWindows() ? undef : $channel);
- $metadata_executor->init();
- $metadata_executor->cacheMetaData() if defined $metadata_executor->dbh();
- }
+ if ($executor->type() == DB_MYSQL) {
+ my $metadata_executor = GenTest::Executor->newFromDSN($self->config->dsn->[$i], osWindows() ? undef : $channel);
+ $metadata_executor->init();
+ $metadata_executor->cacheMetaData() if defined $metadata_executor->dbh();
+ }
}
my $drizzle_only = $executors[0]->type == DB_DRIZZLE;
@@ -264,10 +264,13 @@
$test_suite_name = "rqg_no_name";
}
}
-
+
+ my $logdir = $test_suite_name.isoUTCSimpleTimestamp;
+
my $test = GenTest::XML::Test->new(
id => time(),
name => $test_suite_name, # NOTE: Consider changing to test (or test case) name when suites are supported.
+ logdir => $self->config->property('report-tt-logdir').'/'.$logdir,
attributes => {
engine => $self->config->engine,
gendata => $self->config->gendata,
@@ -462,6 +465,10 @@
if ($result != STATUS_OK) {
croak("Error from XML Transporter: $result");
}
+ if (defined $self->config->logfile && defined
+ $self->config->property('report-tt-logdir')) {
+ $self->copyLogFiles($logdir, \@executors);
+ }
}
if ($total_status == STATUS_OK) {
@@ -474,9 +481,9 @@
} elsif ($process_type == PROCESS_TYPE_PERIODIC) {
## Periodic does not use channel
$channel->close();
- my $killed = 0;
- local $SIG{TERM} = sub { $killed = 1 };
-
+ my $killed = 0;
+ local $SIG{TERM} = sub { $killed = 1 };
+
while (1) {
my $reporter_status = $reporter_manager->monitor(REPORTER_TYPE_PERIODIC);
$self->stop_child($reporter_status) if $reporter_status > STATUS_CRITICAL_FAILURE;
@@ -557,4 +564,39 @@
}
}
+sub copyLogFiles {
+ my ($self,$ld, $executors) = @_;
+ ## Won't copy log files on windows (yet)
+ ## And do this only when tt-logging is enabled
+ if (!osWindows() && -e $self->config->property('report-tt-logdir')) {
+ ## Only for unices
+ my $logdir = $self->config->property('report-tt-logdir')."/".$ld;
+ mkdir $logdir if ! -e $logdir;
+
+ foreach my $exe (@$executors) {
+ my $dbh = DBI->connect($exe->dsn(), undef, undef, {
+ PrintError => 1,
+ RaiseError => 0,
+ AutoCommit => 1,
+ mysql_multi_statements => 1
+ } );
+ my $sth = $dbh->prepare("show variables like '%log_file'");
+ $sth->execute();
+ while (my $row = $sth->fetchrow_arrayref()) {
+ copyFileToDir(@{$row}[1], $logdir) if -e @{$row}[1];
+ }
+ }
+ copyFileToDir($self->config->logfile,$logdir);
+ }
+}
+
+sub copyFileToDir {
+ ## Not ported to windows. But then again TT-reporing with scp does
+ ## not work on Windows either...
+ my ($from, $todir) = @_;
+ say("Copying '$from' to '$todir'");
+ system("cp ".$from." ".$todir);
+}
+
1;
+
=== modified file 'lib/GenTest/Incident.pm'
--- lib/GenTest/Incident.pm 2010-05-06 14:39:18 +0000
+++ lib/GenTest/Incident.pm 2011-04-01 12:57:29 +0000
@@ -63,7 +63,7 @@
debugs => INCIDENT_DEBUGS
}, @_);
- $incident->[INCIDENT_TIMESTAMP] = isoTimestamp() if not defined $incident->[INCIDENT_TIMESTAMP];
+ $incident->[INCIDENT_TIMESTAMP] = isoUTCTimestamp() if not defined $incident->[INCIDENT_TIMESTAMP];
$incident->[INCIDENT_ID] = $id++ if not defined $incident->[INCIDENT_ID];
return $incident;
=== modified file 'lib/GenTest/Properties.pm'
--- lib/GenTest/Properties.pm 2010-02-15 09:23:41 +0000
+++ lib/GenTest/Properties.pm 2011-04-01 12:57:29 +0000
@@ -1,5 +1,5 @@
-# Copyright (C) 2009-2010 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
+# Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights
+# reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -165,10 +165,10 @@
my $message;
$message .= "The following properties are not legal: ".
- join(", ", map {"'--".$_."'"} sort @illegal). ". " if defined @illegal;
+ join(", ", map {"'--".$_."'"} sort @illegal). ". " if $#illegal >= 0;
$message .= "The following required properties are missing: ".
- join(", ", map {"'--".$_."'"} sort @missing). ". " if defined @missing;
+ join(", ", map {"'--".$_."'"} sort @missing). ". " if $#missing >= 0;
if (defined $message) {
$props->_help();
=== modified file 'lib/GenTest/XML/Report.pm'
--- lib/GenTest/XML/Report.pm 2010-04-22 14:28:59 +0000
+++ lib/GenTest/XML/Report.pm 2011-04-01 12:57:29 +0000
@@ -35,7 +35,6 @@
use constant XMLREPORT_TESTS => 2;
use constant XMLREPORT_ENVIRONMENT => 3;
use constant XMLREPORT_NAME => 4;
-
1;
sub new {
@@ -49,7 +48,7 @@
name => XMLREPORT_NAME
}, @_);
- $report->[XMLREPORT_DATE] = isoTimestamp() if not defined $report->[XMLREPORT_DATE];
+ $report->[XMLREPORT_DATE] = isoUTCTimestamp() if not defined $report->[XMLREPORT_DATE];
$report->[XMLREPORT_ENVIRONMENT] = GenTest::XML::Environment->new() if not defined $report->[XMLREPORT_ENVIRONMENT];
return $report;
@@ -78,12 +77,9 @@
);
$writer->dataElement('date', $report->[XMLREPORT_DATE]);
- if (osLinux() || osSolaris())
- {
+ if (osLinux() || osSolaris()) {
$writer->dataElement('operator', $ENV{'LOGNAME'});
- }
- else
- {
+ } else {
$writer->dataElement('operator', $ENV{'USERNAME'});
}
@@ -95,7 +91,7 @@
$writer->dataElement('name', $report->[XMLREPORT_NAME]);
$writer->dataElement('environment_id', 0);
$writer->dataElement('starttime', $report->[XMLREPORT_DATE]);
- $writer->dataElement('endtime', isoTimestamp());
+ $writer->dataElement('endtime', isoUTCTimestamp());
$writer->dataElement('description', 'http://forge.mysql.com/wiki/RQG');
# TODO (if applicable):
# test-suite specific descriptions (once we have defined testsuites)?
=== modified file 'lib/GenTest/XML/Transporter.pm'
--- lib/GenTest/XML/Transporter.pm 2010-04-12 13:22:56 +0000
+++ lib/GenTest/XML/Transporter.pm 2011-04-01 12:57:29 +0000
@@ -1,5 +1,5 @@
-# Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
-# Use is subject to license terms.
+# Copyright (c) 2010,2011 Oracle and/or its affiliates. All rights
+# reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -29,9 +29,10 @@
use constant XMLTRANSPORT_TYPE => 0; # which transport type to use
-use constant XMLTRANSPORT_TYPE_MYSQL => 1; # db connections
-use constant XMLTRANSPORT_TYPE_SCP => 2; # secure copy
-use constant XMLTRANSPORT_TYPES => 3; # collection of types
+use constant XMLTRANSPORT_TYPE_NONE => 1; # Noop. Does nothing
+use constant XMLTRANSPORT_TYPE_MYSQL => 2; # db connections
+use constant XMLTRANSPORT_TYPE_SCP => 3; # secure copy
+use constant XMLTRANSPORT_TYPES => 4; # collection of types
# Defaults:
use constant XML_DEFAULT_TRANSPORT_TYPE => XMLTRANSPORT_TYPE_SCP;
@@ -76,6 +77,8 @@
} elsif ($self->[XMLTRANSPORT_TYPE] =~ m{mysql}io) {
# string match for "mysql" (case insensitive)
$self->[XMLTRANSPORT_TYPE] = XMLTRANSPORT_TYPE_MYSQL;
+ } elsif ($self->[XMLTRANSPORT_TYPE] =~ m{none}io) {
+ $self->[XMLTRANSPORT_TYPE] = XMLTRANSPORT_TYPE_NONE;
}
#${$self}[XMLTRANSPORT_TYPES] = ();
@@ -123,7 +126,10 @@
sub sendXML {
my ($self, $xml, $dest) = @_;
- if ($self->type == XMLTRANSPORT_TYPE_MYSQL) {
+ if ($self->type == XMLTRANSPORT_TYPE_NONE) {
+ say("XML Transport type: NONE");
+ return STATUS_OK;
+ } elsif ($self->type == XMLTRANSPORT_TYPE_MYSQL) {
say("XML Transport type: MySQL database connection");
$dest = XML_MYSQL_DEFAULT_DSN if not defined $dest;
return $self->mysql($xml, $dest);
@@ -187,7 +193,7 @@
# TODO: The scp command is interactive if keys and hosts are not set up.
# This may cause hangs in automated environments. Find a way to
# always run non-interactively, or kill the command after a timeout.
- my $result == system($cmd);
+ my $result = system($cmd);
if ($result != STATUS_OK) {
warn('XML Transport: scp failed. Command was: '.$cmd);
}
=== modified file 'runall-new.pl'
--- runall-new.pl 2010-10-25 11:15:59 +0000
+++ runall-new.pl 2011-04-01 12:57:29 +0000
@@ -1,7 +1,7 @@
#!/usr/bin/perl
-# Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
-# Use is subject to license terms.
+# Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights
+# reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -31,6 +31,14 @@
use DBServer::MySQL::MySQLd;
use DBServer::MySQL::ReplMySQLd;
+my $logger;
+eval
+{
+ require Log::Log4perl;
+ Log::Log4perl->import();
+ $logger = Log::Log4perl->get_logger('randgen.gentest');
+};
+
$| = 1;
if (osWindows()) {
$SIG{CHLD} = "IGNORE";
@@ -58,7 +66,7 @@
$varchar_len, $xml_output, $valgrind, @valgrind_options, $views,
$start_dirty, $filter, $build_thread, $sqltrace, $testname,
$report_xml_tt, $report_xml_tt_type, $report_xml_tt_dest,
- $notnull);
+ $notnull, $logfile, $logconf, $report_tt_logdir);
my $gendata=''; ## default simple gendata
@@ -110,9 +118,20 @@
'start-dirty' => \$start_dirty,
'filter=s' => \$filter,
'mtr-build-thread=i' => \$build_thread,
- 'sqltrace' => \$sqltrace
+ 'sqltrace' => \$sqltrace,
+ 'logfile=s' => \$logfile,
+ 'logconf=s' => \$logconf,
+ 'report-tt-logdir=s' => \$report_tt_logdir
);
+if (defined $logfile && defined $logger) {
+ setLoggingToFile($logfile);
+} else {
+ if (defined $logconf && defined $logger) {
+ setLogConf($logconf);
+ }
+}
+
if (!$opt_result || $help || $basedirs[0] eq '' || not defined $grammar_file) {
help();
exit($help ? 0 : 1);
@@ -317,7 +336,10 @@
'sqltrace',
'report-xml-tt',
'report-xml-tt-type',
- 'report-xml-tt-dest']
+ 'report-xml-tt-dest',
+ 'logfile',
+ 'logconf',
+ 'report-tt-logdir']
);
my @gentest_options;
@@ -357,6 +379,9 @@
$gentestProps->valgrind(1) if $valgrind;
$gentestProps->sqltrace(1) if $sqltrace;
$gentestProps->testname($testname) if $testname;
+$gentestProps->logfile($logfile) if defined $logfile;
+$gentestProps->logconf($logconf) if defined $logconf;
+$gentestProps->property('report-tt-logdir',$report_tt_logdir) if defined $report_tt_logdir;
$gentestProps->property('report-xml-tt', 1) if defined $report_xml_tt;
$gentestProps->property('report-xml-tt-type', $report_xml_tt_type) if defined $report_xml_tt_type;
$gentestProps->property('report-xml-tt-dest', $report_xml_tt_dest) if defined $report_xml_tt_dest;
=== modified file 'runall.pl'
--- runall.pl 2011-02-16 09:30:59 +0000
+++ runall.pl 2011-04-01 12:57:29 +0000
@@ -1,7 +1,7 @@
#!/usr/bin/perl
-# Copyright (c) 2008, 2010 Oracle and/or its affiliates. All rights reserved.
-# Use is subject to license terms.
+# Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights
+# reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -31,6 +31,14 @@
use strict;
use GenTest;
+my $logger;
+eval
+{
+ require Log::Log4perl;
+ Log::Log4perl->import();
+ $logger = Log::Log4perl->get_logger('randgen.gentest');
+};
+
$| = 1;
if (osWindows()) {
$SIG{CHLD} = "IGNORE";
@@ -55,9 +63,10 @@
my ($gendata, @basedirs, @mysqld_options, @vardirs, $rpl_mode,
$engine, $help, $debug, $validators, $reporters, $grammar_file,
$redefine_file, $seed, $mask, $mask_level, $no_mask, $mem, $rows,
- $varchar_len, $xml_output, $valgrind, $valgrind_xml, $views, $start_dirty,
- $filter, $build_thread, $testname, $report_xml_tt, $report_xml_tt_type,
- $report_xml_tt_dest, $notnull, $sqltrace, $lcov);
+ $varchar_len, $xml_output, $valgrind, $valgrind_xml, $views,
+ $start_dirty, $filter, $build_thread, $testname, $report_xml_tt,
+ $report_xml_tt_type, $report_xml_tt_dest, $notnull, $sqltrace,
+ $lcov, $logfile, $logconf, $report_tt_logdir);
my $threads = my $default_threads = 10;
my $queries = my $default_queries = 1000;
@@ -107,9 +116,21 @@
'filter=s' => \$filter,
'mtr-build-thread=i' => \$build_thread,
'testname=s' => \$testname,
- 'lcov' => \$lcov
+ 'lcov' => \$lcov,
+ 'logfile=s' => \$logfile,
+ 'logconf=s' => \$logconf,
+ 'report-tt-logdir=s' => \$report_tt_logdir
);
+if (defined $logfile && defined $logger) {
+ setLoggingToFile($logfile);
+} else {
+ if (defined $logconf && defined $logger) {
+ setLogConf($logconf);
+ }
+}
+
+
$ENV{RQG_DEBUG} = 1 if defined $debug;
$validators = join(',', @$validators) if defined $validators;
@@ -380,6 +401,9 @@
push @gentest_options, "--valgrind-xml" if defined $valgrind_xml;
push @gentest_options, "--testname=$testname" if defined $testname;
push @gentest_options, "--sqltrace" if defined $sqltrace;
+push @gentest_options, "--logfile=$logfile" if defined $logfile;
+push @gentest_options, "--logconf=$logconf" if defined $logconf;
+push @gentest_options, "--report-tt-logdir=$report_tt_logdir" if defined $report_tt_logdir;
# Push the number of "worker" threads into the environment.
# lib/GenTest/Generator/FromGrammar.pm will generate a corresponding grammar element.
=== modified file 'unit/Suite.pm'
--- unit/Suite.pm 2010-10-28 09:47:30 +0000
+++ unit/Suite.pm 2011-04-01 12:57:29 +0000
@@ -1,5 +1,5 @@
-# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
-# Use is subject to license terms.
+# Copyright (c) 2010,2011 Oracle and/or its affiliates. All rights
+# reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -34,6 +34,7 @@
IPC
TestMySQLServer
TestReplServer
+TestTT
) }
1;
=== added file 'unit/TestTT.pm'
--- unit/TestTT.pm 1970-01-01 00:00:00 +0000
+++ unit/TestTT.pm 2011-04-01 12:57:29 +0000
@@ -0,0 +1,65 @@
+# Copyright (c) 2011 Oracle and/or its affiliates. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+# USA
+
+# Do a simple run of scripts to see that they're sound
+#
+package TestTT;
+use base qw(Test::Unit::TestCase);
+use lib 'lib';
+use GenTest;
+use Cwd;
+
+sub new {
+ my $self = shift()->SUPER::new(@_);
+ # your state for fixture here
+ return $self;
+}
+
+my $generator;
+sub set_up {
+}
+
+sub tear_down {
+ # clean up after test
+}
+
+sub test_xml_runall {
+ my $portbase = $ENV{TEST_PORTBASE}>0?int($ENV{TEST_PORTBASE}):22120;
+ my $pb = int(($portbase - 10000) / 10);
+ my $self = shift;
+ ## This test requires RQG_MYSQL_BASE to point to a in source Mysql database
+ if ($ENV{RQG_MYSQL_BASE}) {
+ $ENV{LD_LIBRARY_PATH}=join(":",map{"$ENV{RQG_MYSQL_BASE}".$_}("/libmysql/.libs","/libmysql","/lib/mysql"));
+ my $status = system("perl -MCarp=verbose ./runall.pl --mtr-build-thread=$pb --grammar=conf/examples/example.yy --gendata=conf/examples/example.zz --queries=3 --threads=3 --report-xml-tt --report-xml-tt-type=none --xml-output=unit/test1.xml --logfile=unit/foo1.log --report-tt-logdir=unit --basedir=".$ENV{RQG_MYSQL_BASE});
+ $self->assert_equals(0, $status);
+ }
+}
+
+sub test_xml_runall_new {
+ my $self = shift;
+ ## This test requires RQG_MYSQL_BASE to point to a Mysql database (in source, out of source or installed)
+ my $portbase = 10 + ($ENV{TEST_PORTBASE}>0?int($ENV{TEST_PORTBASE}):22120);
+ my $pb = int(($portbase - 10000) / 10);
+
+
+ if ($ENV{RQG_MYSQL_BASE}) {
+ $ENV{LD_LIBRARY_PATH}=join(":",map{"$ENV{RQG_MYSQL_BASE}".$_}("/libmysql/.libs","/libmysql","/lib/mysql"));
+ my $status = system("perl -MCarp=verbose ./runall-new.pl --mtr-build-thread=$pb --grammar=conf/examples/example.yy --gendata=conf/examples/example.zz --queries=3 --threads=3 --report-xml-tt --report-xml-tt-type=none --xml-output=unit/test2.xml --logfile=unit/foo2.log --report-tt-logdir=unit --basedir=".$ENV{RQG_MYSQL_BASE}." --vardir=".cwd()."/unit/tmp");
+ $self->assert_equals(0, $status);
+ }
+}
+
+1;