# HG changeset patch # User Shabe Razvi # Date 1242741104 -3600 # Node ID 2c7b53b5228f66927232005477c33fad408d3ce9 # Parent aa585d28e58404863a929a76d232e8bd68583537 Add ATS test client target to default configuration. Default is off. diff -r aa585d28e584 -r 2c7b53b5228f common/build.xml --- a/common/build.xml Mon May 18 11:39:37 2009 +0100 +++ b/common/build.xml Tue May 19 14:51:44 2009 +0100 @@ -420,21 +420,43 @@ - + - - - + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + + + - + - - + + @@ -461,9 +483,7 @@ - - - + diff -r aa585d28e584 -r 2c7b53b5228f common/common_props.ant.xml --- a/common/common_props.ant.xml Mon May 18 11:39:37 2009 +0100 +++ b/common/common_props.ant.xml Tue May 19 14:51:44 2009 +0100 @@ -68,11 +68,15 @@ - - + + + + + - - + + + diff -r aa585d28e584 -r 2c7b53b5228f common/tools/ats/ats3_testdrop.pl --- a/common/tools/ats/ats3_testdrop.pl Mon May 18 11:39:37 2009 +0100 +++ b/common/tools/ats/ats3_testdrop.pl Tue May 19 14:51:44 2009 +0100 @@ -1,5 +1,6 @@ #!/usr/bin/perl +#curl "http://sym-build01:8080/ats3/XTestRunExecute.do?username=admin&password=admin&testrunpath=D:\smoketests\test_drops\9.zip use strict; use Getopt::Long; use File::Copy; @@ -13,6 +14,7 @@ my $local_drop_path; my $local_test_pkg; my $help; +my $dev_null = $^O =~ /^MSWin/ ? "nul" : "/dev/null"; sub usage($); sub help(); @@ -44,11 +46,12 @@ usage_error(), unless (defined($host) && defined($local_test_pkg) && defined($local_drop_path) && defined($host_drop_path)); -my $cscript_help = `cscript /?`; -die("Need command \"cscript\". Not in found"), if ($?); -die("Need VB script wshTestRunX.vbs. Not found"), unless ( -f "wshTestRunX.vbs"); +my $curl_version = $^O =~ /^MSWin/ ? `curl --version 1> $dev_null 2>&1` : `curl --version 1> $dev_null 2>&1`; +die("Need program \"curl\". Not found"), if ($?); die("Test drop path \"$local_drop_path\" not found"), unless ( -d "$local_drop_path"); +$host .= ":8080", unless ($host =~ /:\d+$/); + my ($vol,$dir,$pkg); my $local_test_drop; my $host_test_drop; @@ -62,27 +65,30 @@ die("Test package file \"$local_test_pkg\" not found"), unless ( -f "$local_test_pkg"); ($vol,$dir,$pkg) = File::Spec->splitpath($local_test_pkg); $local_test_drop = File::Spec->catfile($local_drop_path,$pkg); - my $lc_local_test_drop = lc($local_test_drop); - my $lc_local_test_pkg = lc($local_test_pkg); - if ("$lc_local_test_drop" ne "$lc_local_test_pkg") { - if (unlink($local_test_drop) == 0) { - die("Can't delete stale testdrop \"$local_test_drop\". $!"); + if ( -f "$local_test_drop") { + my $cmp_local_test_drop = $local_test_drop; + my $cmp_local_test_pkg = $local_test_pkg; + if ($^O =~ /^MSWin/) { + $cmp_local_test_drop = lc($local_test_drop); + $cmp_local_test_pkg = lc($local_test_pkg); + } + if ("$cmp_local_test_drop" eq "$cmp_local_test_pkg") { + if (unlink($local_test_drop) == 0) { + die("Can't delete stale test drop \"$local_test_drop\". $!"); + } + else { + print("A stale test drop \"$local_test_drop\" existed. Deleted\n"); + } } - else { - print("A stale testtop \"$local_test_drop\" existed. Deleted\n"); - } - copy("$local_test_pkg","$local_test_drop") - or die("Cannot copy \"$local_test_pkg\" -> \"$local_test_drop\". $!"); - } + } + copy("$local_test_pkg","$local_test_drop") + or die("Cannot copy \"$local_test_pkg\" -> \"$local_test_drop\". $!"); } $host_test_drop = File::Spec->catfile($host_drop_path,$pkg); - -$ENV{'ats3.host'} = $host; -$ENV{'ats3.pathToDrop'} = $host_test_drop; -$ENV{'ats3.username'} = $username; -$ENV{'ats3.password'} = $password; -$ENV{'ats3.schedule'} = $schedule, if defined($schedule); -system("cscript wshTestRunX.vbs"); +my $url ="http://$host/ats3/XTestRunExecute.do?username=$username&password=$password&testrunpath=$host_test_drop"; +$url .= "&schedule=$schedule", if (defined($schedule)); +my $curl_cmd = "curl \"$url\""; +system("$curl_cmd"); die("\nTest drop failed: $!"), if ($?); print("\nTest drop done"); diff -r aa585d28e584 -r 2c7b53b5228f common/tools/ats/make_junction.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/common/tools/ats/make_junction.pl Tue May 19 14:51:44 2009 +0100 @@ -0,0 +1,117 @@ +#!/usr/bin/perl + +use strict; +use Getopt::Long; +use File::Spec; + +my $link; +my $target; +my $help; +my $force = 0; + +sub usage($); +sub help(); +sub usage_error(); + +my %optmap = ( 'link' => \$link, + 'target' => \$target, + 'force' => \$force, + 'help' => \$help); + +GetOptions(\%optmap, + 'link=s', + 'target=s', + 'force!', + 'help!') + or usage_error(); + +if ($help) { + help(); +} + +usage_error(), unless (defined($link) && defined($target)); + +my $junction_help = `junction /?`; +die("Need command \"junction\". Not found\n"), if ($junction_help =~ /is not recognised/); +die("Directory \"$target\" not found\n"), unless -d "$target"; + +my ($vol,$dir,$file) = File::Spec->splitpath($target); +my @subst_lines = `subst`; + +foreach (@subst_lines) { + my $line = $_; + chomp($line); + $line =~ /^(.:)\\: => (.*)$/; + die("Cannot parse output of 'subst'. Bailing out confused."), unless (defined($1) and defined($2)); + my $subst_drive = $1; + my $subst_targ = $2; + if (lc($subst_drive) eq lc($vol)) { + print("Target $target is in a substituted drive: $line\n"); + $target = File::Spec->catfile(($subst_targ,$dir),$file); + print("Target $target will be used\n"); + last; + } +} + + +if ( -e "$link") { + print("\"$link\" already exists. "); + if (!$force) { + my $choice; + while($choice ne 'y' and $choice ne 'n') { + print "Delete? (y/n)? "; + $choice = ; + chomp($choice); + $choice = lc($choice); + } + $force = $choice eq 'y'; + } + if ($force) { + system("junction -d \"$link\" > nul"); + if ($?) { + die("Cannot delete \"$link\": $!\n"); + } + else { + print "Deleted \"$link\"\n"; + } + } +} + +system("junction \"$link\" \"$target\" > nul"); +if ($?) { + die("Cannot cteate junction \"$link\" -> \"$target\": $!\n"); +} +else { + print("Created junction \"$link\" -> \"$target\"\n"); +} +exit 0; + +sub usage($) +{ + my $error = shift; + my $fh = $error == 0 ? *STDOUT : *STDERR; + print $fh "make_junction.pl\n" . + "Create a Windows junction (a.k.a symbolic link)\n" . + "usage:\n" . + " make_junction.pl --help\n" . + " make_junction.pl --link=LINKDIR --target=TARGDIR\n " . + "options:\n" . + " --help Display this help and exit\n" . + " --link=LINKDIR LINKDIR specifies the junction to be created. Last component is the junction. The rest must exist\n" . + " --target=TARGDIR TARGDIR is directory to which the junction will point.\n" . + " If TARGDIR is in a substed drive, the real path will be used.\n"; + exit $error; +} + +sub help() +{ + usage(0); +} + +sub usage_error() +{ + usage(1); +} + +# EOF + \ No newline at end of file diff -r aa585d28e584 -r 2c7b53b5228f common/tools/ats/tester.bat --- a/common/tools/ats/tester.bat Mon May 18 11:39:37 2009 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -perl ats3_testdrop.pl --host=172.16.11.11 --local-test-pkg=...9.zip --local-drop-path=D:\ATS3\TestDrops --host-drop-path=T:\TestDrops - diff -r aa585d28e584 -r 2c7b53b5228f common/tools/ats/wshTestRunX.vbs --- a/common/tools/ats/wshTestRunX.vbs Mon May 18 11:39:37 2009 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,78 +0,0 @@ -' -' WScript that will invoke the test run execute functionality at ATS3 web server without installing any ATS3 -' specific programs on the local PC. -' -' Password must be given in encrypted format and the path to test drop must be in URLEncoded -' -' Usage cscript wshRunX.vbs -' - -' Get the command line arguments -set args = WScript.Arguments - -' Check that all arguments have been specified -Set objShell = WScript.CreateObject("WScript.Shell") -Set env = objShell.Environment("Process") -checkEnvVars(env) - -' Invoke the web application and write the result to stdOut -WScript.StdOut.Write doTestRunX(env("ats3.username"), env("ats3.password"), env("ats3.host"), URLEncode( env("ats3.pathToDrop") ), URLEncode( env("ats3.schedule") )) - -' Quit the script -Wscript.Quit - -Function checkEnvVars(env) - if env("ats3.username") = "" then - WScript.Echo "Environment variable ats3.username not specified" - WScript.Quit 1 - elseif env("ats3.password") = "" then - WScript.Echo "Environment variable ats3.password not specified" - WScript.Quit 1 - elseif env("ats3.host") = "" then - WScript.Echo "Environment variable ats3.host not specified" - WScript.Quit 1 - elseif env("ats3.pathToDrop") = "" then - WScript.Echo "Environment variable ats3.pathToDrop not specified" - WScript.Quit 1 - end if -End Function - -' Invoke the ATS3 web application in given host with the specified username, password and file path -Function doTestRunX(uname, password, hostName, pathToDrop, schedule) - On Error Resume Next - - 'If the given hostname contain port, use it otherwise use the default 8080 - if(InStr(1, hostName, ":", VBTEXTCOMPARE) = 0) then - hostName = hostName & ":8080" - end if - - Set objxmlHTTP = CreateObject("Microsoft.XMLHTTP") - Call objxmlHTTP.open("GET", "http://" & hostName & "/ats3/XTestRunExecute.do?username=" & uname & "&password=" & password & "&testrunpath=" & pathToDrop & "&schedule=" & schedule, False) - objxmlHTTP.Send() - If Err.Number <> 0 Then - WScript.Echo "Error sending data to server: " + hostName - WScript.Quit 1 - End if - - if objxmlHTTP.status = 200 then - doTestRunX = objxmlHTTP.ResponseText - else - WScript.Echo "Error importing test run: " + objxmlHTTP.ResponseText - WScript.Quit 1 - end if -End Function - -Function URLEncode(data) - data = replace(data,"\","/") - data = replace(data,"$","%24") - data = replace(data,"&","%26") - data = replace(data,"+","%2B") - data = replace(data,",","%2C") - data = replace(data,"/","%2F") - data = replace(data,":","%3A") - data = replace(data,";","%3B") - data = replace(data,"=","%3D") - data = replace(data,"?","%3F") - data = replace(data,"@","%40") - URLEncode = data -End Function \ No newline at end of file