Bug #41611 mysql-test-run calling mysql-stress-test.pl as executable causes problems
Submitted: 19 Dec 2008 2:04 Modified: 23 Nov 2011 14:15
Reporter: Elena Stepanova Email Updates:
Status: Closed Impact on me:
None 
Category:Tools: MTR / mysql-test-run Severity:S3 (Non-critical)
Version:5.0, 5.1, 6.0 OS:Any
Assigned to: Bjørn Munch CPU Architecture:Any

[19 Dec 2008 2:04] Elena Stepanova
Description:
mysql-test-run.pl with --stress option does not work on Windows boxes and on *nix boxes with non-default configuration.

mysql-test-run in stress mode calls run_stress_test() subroutine from lib/mtr_stress.pl.
run_stress_test calls mtr_run with mysql-stress-test.pl as the first parameter, and with a bunch of arguments; mtr_run calls spawn_impl in the same fashion, and spawn_impl calls exec with path to mysql-stress-test.pl as a pathname and with an array of arguments.

Thus, mysql-stress-test.pl is called via exec() as an executable, not as an argument (script name) for perl. 

One general problem is that construction 
exec( "<perl script pathname>", @args" ) 
does not work on Windows when @args is not empty, while construction 
exec( "perl", ( "<perl script pathname>", @args ) 
does. 
It happens even if .pl extension are associated with perl interpreter, etc.
Checked with ActivePerl build 1004 and Strawberry Perl 5.10.0, so it is not single-version-related.

Besides that, there are some more specific cases when such call of mysql-stress-test does not work. 

Examples:

- (*nix) if /usr/bin/perl exists, but does not support threads -- this is now the case on our Solaris test boxes, where Perl with threads has different location;

- (Windows, even in case of empty @args) If .pl extension is not associated with perl interpreter;

- (*nix) if /usr/bin/perl, which is given in #!, does not exist;

- (*nix) if mysql-stress-test.pl does not have execution permissions on whatever reason;

etc.

How to repeat:
In a system with at least one pre-condition from the list above (depending on which error you want to reproduce);
- cd to <mysql-basedir>/mysql-test;
- make sure that the folder contains mysql-stress-test.pl (see bug:41546);
- run perl ./mysql-test-run.pl with some stress parameters, e.g. taken from bug:35322.

In case of not supported threads or non-existing perl on *nix systems, there will be a corresponding error message. In case of the Windows problem, no visible errors are produced -- stdout will contain only "Starting stress testing" and immediately "Stopping All Servers".

Suggested fix:
A simple fix is to call exec with 'perl' (without absolute path) as the 1st argument, and pass the script name as the first element of the args array. This will eliminate some problems and will allow a user to influence the execution by setting correct PATH. 

A more complicated solution could be taking path to perl as an option, and pre-configuring it on per-system basis for auto-testing according to our common configurations of Solaris, Linux and Windows boxes.
[19 Jun 2009 10:34] Bjørn Munch
This should be mine....
[23 Nov 2011 14:15] Bjørn Munch
--stress has been re-implemented in MTR v2, closing this as v1 is no longer supported (and problem does not apply to v2).