Test suite for --hostgroup.

This commit is contained in:
Ole Tange 2014-11-13 04:19:33 +01:00
parent fb3c148050
commit e9b3387a7b
9 changed files with 112 additions and 18 deletions

View file

@ -226,9 +226,9 @@ cc:Tim Cuthbertson <tim3d.junk@gmail.com>,
Ryoichiro Suzuki <ryoichiro.suzuki@gmail.com>, Ryoichiro Suzuki <ryoichiro.suzuki@gmail.com>,
Jesse Alama <jesse.alama@gmail.com> Jesse Alama <jesse.alama@gmail.com>
Subject: GNU Parallel 20141122 ('') released Subject: GNU Parallel 20141122 ('Rosetta') released
GNU Parallel 20141122 ('') has been released. It is available for download at: http://ftp.gnu.org/gnu/parallel/ GNU Parallel 20141122 ('Rosetta') has been released. It is available for download at: http://ftp.gnu.org/gnu/parallel/
Haiku of the month: Haiku of the month:

View file

@ -723,7 +723,7 @@ sub options_hash {
"cat" => \$opt::cat, "cat" => \$opt::cat,
"fifo" => \$opt::fifo, "fifo" => \$opt::fifo,
"pipepart|pipe-part" => \$opt::pipepart, "pipepart|pipe-part" => \$opt::pipepart,
"hostgroup|hostgroups" => \$opt::hostgroups, "hgrp|hostgroup|hostgroups" => \$opt::hostgroups,
); );
} }
@ -772,7 +772,7 @@ sub get_options_from_array {
sub parse_options { sub parse_options {
# Returns: N/A # Returns: N/A
# Defaults: # Defaults:
$Global::version = 20141107; $Global::version = 20141111;
$Global::progname = 'parallel'; $Global::progname = 'parallel';
$Global::infinity = 2**31; $Global::infinity = 2**31;
$Global::debug = 0; $Global::debug = 0;
@ -7457,6 +7457,8 @@ sub new {
::warning("No such hostgroup (@hostgroups)\n"); ::warning("No such hostgroup (@hostgroups)\n");
@hostgroups = (keys %Global::hostgroups); @hostgroups = (keys %Global::hostgroups);
} }
} else {
@hostgroups = (keys %Global::hostgroups);
} }
} }
return bless { return bless {

View file

@ -740,10 +740,12 @@ Example:
parallel --hostgroups \ parallel --hostgroups \
--sshlogin @grp1/myserver1 -S @grp1+grp2/myserver2 \ --sshlogin @grp1/myserver1 -S @grp1+grp2/myserver2 \
echo ::: my_grp1_arg@grp1 arg_for_grp2@grp2 --sshlogin @grp3/myserver3 \
echo ::: my_grp1_arg@grp1 arg_for_grp2@grp2 third_arg@grp1+grp3
B<my_grp1_arg> may be run on either B<myserver1> or B<myserver2>, but B<my_grp1_arg> may be run on either B<myserver1> or B<myserver2>,
B<arg_for_grp2> will only be run on B<myserver2>. B<third_arg> may be run on either B<myserver1> or B<myserver3>,
but B<arg_for_grp2> will only be run on B<myserver2>.
=item B<-I> I<replace-str> =item B<-I> I<replace-str>

View file

@ -1,15 +1,11 @@
#!/bin/bash #!/bin/bash
# SSH only allowed to localhost/lo
rm -rf tmp rm -rf tmp
mkdir tmp mkdir tmp
cd tmp cd tmp
cat <<'EOF' | sed -e s/\$SERVER1/$SERVER1/\;s/\$SERVER2/$SERVER2/ | stdout parallel -vj5 -k -L1 cat <<'EOF' | sed -e s/\$SERVER1/$SERVER1/\;s/\$SERVER2/$SERVER2/ | stdout parallel -vj5 -k -L1
echo '### bug #41964: --controlmaster not seems to reuse OpenSSH connections to the same host'
(parallel -S redhat9.tange.dk true ::: {1..20}; echo No --controlmaster - finish last) &
(parallel -M -S redhat9.tange.dk true ::: {1..20}; echo With --controlmaster - finish first) &
wait
echo '### Stop if all hosts are filtered and there are no hosts left to run on' echo '### Stop if all hosts are filtered and there are no hosts left to run on'
stdout parallel --filter-hosts -S no-such.host echo ::: 1 stdout parallel --filter-hosts -S no-such.host echo ::: 1

View file

@ -0,0 +1,27 @@
#!/bin/bash
# SSH only allowed to localhost/lo
cat <<'EOF' | sed -e s/\$SERVER1/$SERVER1/\;s/\$SERVER2/$SERVER2/ | stdout parallel -vj2 -k -L1
echo '### --hostgroup force ncpu'
parallel --delay 0.1 --hgrp -S @g1/1/parallel@lo -S @g2/3/lo whoami\;sleep 0.{} ::: {1..8} | sort
echo '### --hostgroup two group arg'
parallel -k --delay 0.1 --hgrp -S @g1/1/parallel@lo -S @g2/3/lo whoami\;sleep 0.{} ::: {1..8}@g1+g2 | sort
echo '### --hostgroup one group arg'
parallel --delay 0.1 --hgrp -S @g1/1/parallel@lo -S @g2/3/lo whoami\;sleep 0.{} ::: {1..8}@g2
echo '### --hostgroup multiple group arg + unused group'
parallel --delay 0.1 --hgrp -S @g1/1/parallel@lo -S @g1/3/lo -S @g3/100/tcsh@lo whoami\;sleep 0.{} ::: {1..8}@g1+g2 | sort
echo '### --hostgroup two groups @'
parallel -k --hgrp -S @g1/parallel@lo -S @g2/lo --tag whoami\;echo ::: parallel@g1 tange@g2
echo '### --hostgroup'
parallel -k --hostgroup -S @grp1/lo echo ::: no_group explicit_group@grp1 implicit_group@lo
echo '### --hostgroup --sshlogin with @'
parallel -k --hostgroups -S parallel@lo echo ::: no_group implicit_group@parallel@lo
EOF

View file

@ -14,6 +14,11 @@ chmod 755 /tmp/myssh1 /tmp/myssh2
seq 1 100 | parallel --sshdelay 0.05 --sshlogin "/tmp/myssh1 $SSHLOGIN1,/tmp/myssh2 $SSHLOGIN2" -k echo seq 1 100 | parallel --sshdelay 0.05 --sshlogin "/tmp/myssh1 $SSHLOGIN1,/tmp/myssh2 $SSHLOGIN2" -k echo
cat <<'EOF' | sed -e s/\$SERVER1/$SERVER1/\;s/\$SERVER2/$SERVER2/\;s/\$SSHLOGIN1/$SSHLOGIN1/\;s/\$SSHLOGIN2/$SSHLOGIN2/\;s/\$SSHLOGIN3/$SSHLOGIN3/ | parallel -vj2 -k -L1 cat <<'EOF' | sed -e s/\$SERVER1/$SERVER1/\;s/\$SERVER2/$SERVER2/\;s/\$SSHLOGIN1/$SSHLOGIN1/\;s/\$SSHLOGIN2/$SSHLOGIN2/\;s/\$SSHLOGIN3/$SSHLOGIN3/ | parallel -vj2 -k -L1
echo '### bug #41964: --controlmaster not seems to reuse OpenSSH connections to the same host'
(parallel -S redhat9.tange.dk true ::: {1..20}; echo No --controlmaster - finish last) &
(parallel -M -S redhat9.tange.dk true ::: {1..20}; echo With --controlmaster - finish first) &
wait
echo '### --filter-hosts - OK, non-such-user, connection refused, wrong host' echo '### --filter-hosts - OK, non-such-user, connection refused, wrong host'
parallel --nonall --filter-hosts -S localhost,NoUser@localhost,154.54.72.206,"ssh 5.5.5.5" hostname parallel --nonall --filter-hosts -S localhost,NoUser@localhost,154.54.72.206,"ssh 5.5.5.5" hostname

View file

@ -1,8 +1,3 @@
echo '### bug #41964: --controlmaster not seems to reuse OpenSSH connections to the same host'
### bug #41964: --controlmaster not seems to reuse OpenSSH connections to the same host
(parallel -S redhat9.tange.dk true ::: {1..20}; echo No --controlmaster - finish last) & (parallel -M -S redhat9.tange.dk true ::: {1..20}; echo With --controlmaster - finish first) & wait
With --controlmaster - finish first
No --controlmaster - finish last
echo '### Stop if all hosts are filtered and there are no hosts left to run on' echo '### Stop if all hosts are filtered and there are no hosts left to run on'
### Stop if all hosts are filtered and there are no hosts left to run on ### Stop if all hosts are filtered and there are no hosts left to run on
stdout parallel --filter-hosts -S no-such.host echo ::: 1 stdout parallel --filter-hosts -S no-such.host echo ::: 1

View file

@ -0,0 +1,62 @@
echo '### --hostgroup force ncpu'
### --hostgroup force ncpu
parallel --delay 0.1 --hgrp -S @g1/1/parallel@lo -S @g2/3/lo whoami\;sleep 0.{} ::: {1..8} | sort
parallel
parallel
tange
tange
tange
tange
tange
tange
echo '### --hostgroup two group arg'
### --hostgroup two group arg
parallel -k --delay 0.1 --hgrp -S @g1/1/parallel@lo -S @g2/3/lo whoami\;sleep 0.{} ::: {1..8}@g1+g2 | sort
parallel
parallel
tange
tange
tange
tange
tange
tange
echo '### --hostgroup one group arg'
### --hostgroup one group arg
parallel --delay 0.1 --hgrp -S @g1/1/parallel@lo -S @g2/3/lo whoami\;sleep 0.{} ::: {1..8}@g2
tange
tange
tange
tange
tange
tange
tange
tange
echo '### --hostgroup multiple group arg + unused group'
### --hostgroup multiple group arg + unused group
parallel --delay 0.1 --hgrp -S @g1/1/parallel@lo -S @g1/3/lo -S @g3/100/tcsh@lo whoami\;sleep 0.{} ::: {1..8}@g1+g2 | sort
parallel
parallel
tange
tange
tange
tange
tange
tange
echo '### --hostgroup two groups @'
### --hostgroup two groups @
parallel -k --hgrp -S @g1/parallel@lo -S @g2/lo --tag whoami\;echo ::: parallel@g1 tange@g2
parallel parallel
parallel parallel
tange tange
tange tange
echo '### --hostgroup'
### --hostgroup
parallel -k --hostgroup -S @grp1/lo echo ::: no_group explicit_group@grp1 implicit_group@lo
no_group
explicit_group
implicit_group
echo '### --hostgroup --sshlogin with @'
### --hostgroup --sshlogin with @
parallel -k --hostgroups -S parallel@lo echo ::: no_group implicit_group@parallel@lo
no_group
implicit_group

View file

@ -100,6 +100,11 @@ TODO test ssh with > 9 simultaneous
98 98
99 99
100 100
echo '### bug #41964: --controlmaster not seems to reuse OpenSSH connections to the same host'
### bug #41964: --controlmaster not seems to reuse OpenSSH connections to the same host
(parallel -S redhat9.tange.dk true ::: {1..20}; echo No --controlmaster - finish last) & (parallel -M -S redhat9.tange.dk true ::: {1..20}; echo With --controlmaster - finish first) & wait
With --controlmaster - finish first
No --controlmaster - finish last
echo '### --filter-hosts - OK, non-such-user, connection refused, wrong host' echo '### --filter-hosts - OK, non-such-user, connection refused, wrong host'
### --filter-hosts - OK, non-such-user, connection refused, wrong host ### --filter-hosts - OK, non-such-user, connection refused, wrong host
parallel --nonall --filter-hosts -S localhost,NoUser@localhost,154.54.72.206,"ssh 5.5.5.5" hostname parallel --nonall --filter-hosts -S localhost,NoUser@localhost,154.54.72.206,"ssh 5.5.5.5" hostname