From 9e547ab506679392bd33beae55d77073b696e169 Mon Sep 17 00:00:00 2001 From: wuzhenwei Date: Tue, 27 Nov 2018 20:07:27 +0800 Subject: [PATCH] fix torque.test --- t/01_torque_install.t | 2 +- t/05_serial_jobs.t | 7 +++++-- t/06_parallel_jobs.t | 7 +++++-- t/07_job_arrays.t | 12 +++++++----- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/t/01_torque_install.t b/t/01_torque_install.t index 0a8bc6b733..46172c3eef 100755 --- a/t/01_torque_install.t +++ b/t/01_torque_install.t @@ -16,7 +16,7 @@ ok(defined $qstat, 'Client Tools') or # version - TORQUE version my $version = `qstat --version 2>&1`; - $version =~ /^version:\s*([\d.]+)\s*$/i; + $version =~ /Version:\s+(\d+\.\d+\.\d+)/; $version = $1 || undef; ok(defined $version, 'TORQUE Version') or BAIL_OUT('Cannot determine TORQUE version'); diff --git a/t/05_serial_jobs.t b/t/05_serial_jobs.t index 05b1bc012d..39b67284b5 100755 --- a/t/05_serial_jobs.t +++ b/t/05_serial_jobs.t @@ -30,7 +30,9 @@ ok($job =~ /^\d+\S*\s*$/, 'Job Submission') or BAIL_OUT("Unable to submit job to TORQUE as '$testuser' - see TORQUE docs, Section 2.1"); # Job In Queue -$job =~ s/\D//g; +# shouldn't use global match lest hostname should contain figures +$job =~ s/\d+//; +$job = $&; sleep 1; my $qstat = `qstat | grep $job` || undef; ok(defined $qstat, 'Job in Queue') or @@ -60,7 +62,8 @@ ok($running, 'Job Running') or BAIL_OUT("Submitted job has failed to start within $waittime seconds - check scheduler - see TORQUE docs, Section 5.1"); # Check Output Files -my $remaining = $joblength - $timer + 1; +# giving more remaining time so that output files could have been created +my $remaining = $joblength - $timer + 2; my $outputfile = "STDIN.o$job"; my $errorfile = "STDIN.e$job"; sleep $remaining if ($remaining > 0); diff --git a/t/06_parallel_jobs.t b/t/06_parallel_jobs.t index 0fca954b31..1ba71ba171 100755 --- a/t/06_parallel_jobs.t +++ b/t/06_parallel_jobs.t @@ -35,7 +35,8 @@ foreach my $line (split /[\r\n]+/, $pbsnodes) $nodes{$node} += $1 - 1 if ($line =~ /^\s+np = (\d+)/) and defined $node; } -map { $proccount += $_ } (values %nodes); +# As far as I know, Torque cann't start a job on every processor when proccount are different among nodes +map { $proccount += 1 } (values %nodes); ok($proccount, 'Processor Count') or BAIL_OUT('TORQUE reported 0 processors'); @@ -64,7 +65,9 @@ sub submit_job ($) BAIL_OUT("Unable to submit job to TORQUE as '$testuser' - see TORQUE docs, Section 2.1"); ok($job =~ /^\d+\S*\s*$/, 'Job Submission') or BAIL_OUT("Unable to submit job to TORQUE as '$testuser' - see TORQUE docs, Section 2.1"); - $job =~ s/\D//g; + # shouldn't use global match lest hostname should contain figures + $job =~ s/\d+//; + $job = $&; return $job; } # diff --git a/t/07_job_arrays.t b/t/07_job_arrays.t index d34e338f48..03a6fbacb6 100755 --- a/t/07_job_arrays.t +++ b/t/07_job_arrays.t @@ -60,7 +60,8 @@ SKIP: if ($line =~ /^\s+np = (\d+)/) and defined $node; } - map { $proccount += $_ } (values %nodes); + # As far as I know, Torque cann't start a job on every processor when proccount are different among nodes + map { $proccount += 1 } (values %nodes); $Jobcount = 2 * $proccount; ok($proccount, 'Processor Count') or BAIL_OUT('TORQUE reported 0 processors'); @@ -72,12 +73,13 @@ SKIP: { my $walltime = 1.1 * $Joblength; my $baseid = `su $Testuser -c 'echo "sleep $Joblength" | qsub -k oe -l nodes=1,walltime=$walltime -t 0-$Jobcount'` || undef; - $baseid =~ s/\D//g if defined $baseid; + $baseid =~ s/\d+//; + $baseid = $& if defined $baseid; ok(defined $baseid, "Job Submission") or BAIL_OUT("Unable to submit job to TORQUE as '$Testuser' - see TORQUE docs, Section 2.1"); ok($baseid =~ /^\d+\S*\s*$/, "Job Submission") or BAIL_OUT("Unable to submit job to TORQUE as '$Testuser' - see TORQUE docs, Section 2.1"); - @Jobs = map { "$baseid-$_" } (0..$Jobcount); + @Jobs = map { "$baseid\[$_\]" } (0..$Jobcount); } # Jobs In Queue @@ -177,14 +179,14 @@ sub qstat_info { my %data; # Gather Information - my $qstat = `qstat` || undef; + my $qstat = `qstat -t` || undef; ok(defined $qstat, 'qstat Results') or BAIL_OUT('Cannot gather information from qstat'); foreach my $line (split /[\r\n]+/, $qstat) { next unless $line =~ /^ - (\d+-\d+)\S*\s+ # Job ID + (\d+\[\d+\])\S*\s+ # Job ID \S+\s+ # Name \S+\s+ # User \S+\s+ # Time Use