mirror of
https://git.savannah.gnu.org/git/parallel.git
synced 2024-12-26 06:37:56 +00:00
parallel: test added for --onall
This commit is contained in:
parent
78824429c8
commit
b84663bac8
|
@ -4,21 +4,8 @@
|
|||
|
||||
One jobqueue per sshlogin.
|
||||
|
||||
parallel '(echo {3} {2}) | awk \{print\ \$2}' ::: a b c ::: 1 2 3
|
||||
|
||||
# Should work:
|
||||
parallel --onall -S eos,iris '(echo {3} {2}) | awk \{print\ \$2}' ::: a b c ::: 1 2 3
|
||||
|
||||
parallel -S eos '(echo {3} {2}) | awk \{print\ \$2}' ::: a b c ::: 1 2 3
|
||||
parallel -S iris '(echo {3} {2}) | awk \{print\ \$2}' ::: a b c ::: 1 2 3
|
||||
|
||||
parallel -a /tmp/abc -a /tmp/123 -S eos '(echo {3} {2}) | awk \{print\ \$2}'
|
||||
parallel -a /tmp/abc -a /tmp/123 -S iris '(echo {3} {2}) | awk \{print\ \$2}'
|
||||
|
||||
cat | parallel --onall -S eos,iris '(echo {3} {2}) | awk \{print\ \$2}' :::: - ::: a b c ::: 1 2 3
|
||||
|
||||
|
||||
|
||||
vmstat\ 1\ 2\ \|\ tail\ -n1\ \|\ awk\ \{print\\\ \\\$7*\\\$8\}
|
||||
|
||||
|
||||
|
|
51
src/parallel
51
src/parallel
|
@ -61,15 +61,23 @@ if($::opt_nonall or $::opt_onall) {
|
|||
}
|
||||
# for each sshlogin do:
|
||||
# parallel -S $sshlogin $command :::: @argfiles
|
||||
open(PARALLEL,"| parallel -j $::opt_P") || die;
|
||||
#
|
||||
# Pass some of the options to the sub-parallels, not all of them as
|
||||
# -P should only go to the first, and -S should not be copied at all.
|
||||
my $options =
|
||||
((defined $::opt_u) ? "-u" : " ") .
|
||||
((defined $::opt_g) ? "-g" : " ") .
|
||||
"";
|
||||
::debug("| parallel $options");
|
||||
open(PARALLEL,"| parallel $options -P $::opt_P") || die;
|
||||
for my $sshlogin (values %Global::host) {
|
||||
print PARALLEL "parallel -j1 -S ".
|
||||
print PARALLEL "parallel $options -j1 -S ".
|
||||
shell_quote_scalar($sshlogin->string())." ".
|
||||
shell_quote_scalar($command)." :::: @argfiles\n";
|
||||
}
|
||||
close PARALLEL;
|
||||
unlink(@argfiles);
|
||||
exit;
|
||||
wait_and_exit(min(undef_as_zero($Global::exitstatus),254));
|
||||
}
|
||||
|
||||
$Global::JobQueue = JobQueue->new(
|
||||
|
@ -316,22 +324,9 @@ sub acquire_semaphore {
|
|||
return $sem;
|
||||
}
|
||||
|
||||
sub get_options_from_array {
|
||||
# Run GetOptions on @array
|
||||
# Returns:
|
||||
# true if parsing worked
|
||||
# false if parsing failed
|
||||
# @array is changed
|
||||
my $array_ref = shift;
|
||||
# A bit of shuffling of @ARGV needed as GetOptionsFromArray is not
|
||||
# supported everywhere
|
||||
my @save_argv;
|
||||
my $this_is_ARGV = (\@::ARGV == $array_ref);
|
||||
if(not $this_is_ARGV) {
|
||||
@save_argv = @::ARGV;
|
||||
@::ARGV = @{$array_ref};
|
||||
}
|
||||
my @retval = GetOptions
|
||||
sub options_hash {
|
||||
# Returns a hash of the GetOptions config
|
||||
return
|
||||
("debug|D" => \$::opt_D,
|
||||
"xargs|m" => \$::opt_m,
|
||||
"X" => \$::opt_X,
|
||||
|
@ -421,6 +416,24 @@ sub get_options_from_array {
|
|||
"Y|shebang|hashbang" => \$::opt_shebang,
|
||||
"skip-first-line" => \$::opt_skip_first_line,
|
||||
);
|
||||
}
|
||||
|
||||
sub get_options_from_array {
|
||||
# Run GetOptions on @array
|
||||
# Returns:
|
||||
# true if parsing worked
|
||||
# false if parsing failed
|
||||
# @array is changed
|
||||
my $array_ref = shift;
|
||||
# A bit of shuffling of @ARGV needed as GetOptionsFromArray is not
|
||||
# supported everywhere
|
||||
my @save_argv;
|
||||
my $this_is_ARGV = (\@::ARGV == $array_ref);
|
||||
if(not $this_is_ARGV) {
|
||||
@save_argv = @::ARGV;
|
||||
@::ARGV = @{$array_ref};
|
||||
}
|
||||
my @retval = GetOptions(options_hash());
|
||||
if(not $this_is_ARGV) {
|
||||
@{$array_ref} = @::ARGV;
|
||||
@::ARGV = @save_argv;
|
||||
|
|
|
@ -621,13 +621,16 @@ See also B<-X> for context replace. If in doubt use B<-X> as that will
|
|||
most likely do what is needed.
|
||||
|
||||
|
||||
=item B<--onall> (unimplemented)
|
||||
=item B<--onall> (alpha testing)
|
||||
|
||||
Run all the jobs on all computers given with B<--sshlogin>. GNU
|
||||
B<parallel> will log into B<--jobs> number of computers in parallel
|
||||
and run one job at a time on the computer. The order of the jobs will
|
||||
not be changed, but some computers may finish before others.
|
||||
|
||||
When using B<--group> the output will be grouped by each server, so
|
||||
all the output from one server will be grouped together.
|
||||
|
||||
|
||||
=item B<--output-as-files>
|
||||
|
||||
|
|
13
testsuite/tests-to-run/test60.sh
Normal file
13
testsuite/tests-to-run/test60.sh
Normal file
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
|
||||
SERVER1=parallel-server3
|
||||
SERVER2=parallel-server2
|
||||
|
||||
echo '### Test --onall'
|
||||
parallel --onall -S parallel@$SERVER2,$SERVER1 '(echo {3} {2}) | awk \{print\ \$2}' ::: a b c ::: 1 2 3
|
||||
parallel --onall -S parallel@$SERVER2,$SERVER1 -u '(echo {3} {2}) | awk \{print\ \$2}' ::: a b c ::: 1 2 3
|
||||
|
||||
echo '### Test --nonall'
|
||||
parallel --nonall -S parallel@$SERVER2,$SERVER1 'hostname'
|
||||
parallel --nonall -S parallel@$SERVER2,$SERVER1 -u 'hostname;sleep 2;hostname'
|
||||
|
44
testsuite/wanted-results/test60
Normal file
44
testsuite/wanted-results/test60
Normal file
|
@ -0,0 +1,44 @@
|
|||
### Test --onall
|
||||
1
|
||||
2
|
||||
3
|
||||
1
|
||||
2
|
||||
3
|
||||
1
|
||||
2
|
||||
3
|
||||
1
|
||||
2
|
||||
3
|
||||
1
|
||||
2
|
||||
3
|
||||
1
|
||||
2
|
||||
3
|
||||
1
|
||||
1
|
||||
2
|
||||
3
|
||||
2
|
||||
1
|
||||
3
|
||||
2
|
||||
3
|
||||
1
|
||||
1
|
||||
2
|
||||
2
|
||||
3
|
||||
3
|
||||
1
|
||||
2
|
||||
3
|
||||
### Test --nonall
|
||||
nlv.pi.dk
|
||||
vh2.pi.dk
|
||||
nlv.pi.dk
|
||||
vh2.pi.dk
|
||||
nlv.pi.dk
|
||||
vh2.pi.dk
|
Loading…
Reference in a new issue