From e9b3387a7b2415f22071b8bd650a7932e5888f60 Mon Sep 17 00:00:00 2001 From: Ole Tange Date: Thu, 13 Nov 2014 04:19:33 +0100 Subject: [PATCH] Test suite for --hostgroup. --- doc/release_new_version | 4 +- src/parallel | 8 ++- src/parallel.pod | 8 ++- testsuite/tests-to-run/parallel-local-ssh1.sh | 6 +- testsuite/tests-to-run/parallel-local-ssh3.sh | 27 ++++++++ testsuite/tests-to-run/parallel-remote1.sh | 5 ++ testsuite/wanted-results/parallel-local-ssh1 | 5 -- testsuite/wanted-results/parallel-local-ssh3 | 62 +++++++++++++++++++ testsuite/wanted-results/parallel-remote1 | 5 ++ 9 files changed, 112 insertions(+), 18 deletions(-) create mode 100644 testsuite/tests-to-run/parallel-local-ssh3.sh create mode 100644 testsuite/wanted-results/parallel-local-ssh3 diff --git a/doc/release_new_version b/doc/release_new_version index 50e53952..1e6ff6b1 100644 --- a/doc/release_new_version +++ b/doc/release_new_version @@ -226,9 +226,9 @@ cc:Tim Cuthbertson , Ryoichiro Suzuki , Jesse Alama -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: diff --git a/src/parallel b/src/parallel index 9c90450b..965c23e4 100755 --- a/src/parallel +++ b/src/parallel @@ -723,7 +723,7 @@ sub options_hash { "cat" => \$opt::cat, "fifo" => \$opt::fifo, "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 { # Returns: N/A # Defaults: - $Global::version = 20141107; + $Global::version = 20141111; $Global::progname = 'parallel'; $Global::infinity = 2**31; $Global::debug = 0; @@ -7457,7 +7457,9 @@ sub new { ::warning("No such hostgroup (@hostgroups)\n"); @hostgroups = (keys %Global::hostgroups); } - } + } else { + @hostgroups = (keys %Global::hostgroups); + } } return bless { 'orig' => $orig, diff --git a/src/parallel.pod b/src/parallel.pod index 8db65f36..d6e8c785 100644 --- a/src/parallel.pod +++ b/src/parallel.pod @@ -740,10 +740,12 @@ Example: parallel --hostgroups \ --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 may be run on either B or B, but -B will only be run on B. +B may be run on either B or B, +B may be run on either B or B, +but B will only be run on B. =item B<-I> I diff --git a/testsuite/tests-to-run/parallel-local-ssh1.sh b/testsuite/tests-to-run/parallel-local-ssh1.sh index 4a946cd2..8ab3acfa 100644 --- a/testsuite/tests-to-run/parallel-local-ssh1.sh +++ b/testsuite/tests-to-run/parallel-local-ssh1.sh @@ -1,15 +1,11 @@ #!/bin/bash +# SSH only allowed to localhost/lo rm -rf tmp mkdir tmp cd tmp 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' stdout parallel --filter-hosts -S no-such.host echo ::: 1 diff --git a/testsuite/tests-to-run/parallel-local-ssh3.sh b/testsuite/tests-to-run/parallel-local-ssh3.sh new file mode 100644 index 00000000..958c9bc4 --- /dev/null +++ b/testsuite/tests-to-run/parallel-local-ssh3.sh @@ -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 diff --git a/testsuite/tests-to-run/parallel-remote1.sh b/testsuite/tests-to-run/parallel-remote1.sh index e5be7fd0..83c1e14d 100644 --- a/testsuite/tests-to-run/parallel-remote1.sh +++ b/testsuite/tests-to-run/parallel-remote1.sh @@ -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 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' parallel --nonall --filter-hosts -S localhost,NoUser@localhost,154.54.72.206,"ssh 5.5.5.5" hostname diff --git a/testsuite/wanted-results/parallel-local-ssh1 b/testsuite/wanted-results/parallel-local-ssh1 index c2f5150a..1a87138e 100644 --- a/testsuite/wanted-results/parallel-local-ssh1 +++ b/testsuite/wanted-results/parallel-local-ssh1 @@ -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' ### 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 diff --git a/testsuite/wanted-results/parallel-local-ssh3 b/testsuite/wanted-results/parallel-local-ssh3 new file mode 100644 index 00000000..303f4a9a --- /dev/null +++ b/testsuite/wanted-results/parallel-local-ssh3 @@ -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 diff --git a/testsuite/wanted-results/parallel-remote1 b/testsuite/wanted-results/parallel-remote1 index 0b6c4bd2..4d8002b9 100644 --- a/testsuite/wanted-results/parallel-remote1 +++ b/testsuite/wanted-results/parallel-remote1 @@ -100,6 +100,11 @@ TODO test ssh with > 9 simultaneous 98 99 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' ### --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