parallel: Partial Reuse licensing support.
[parallel.git] / testsuite / tests-to-run / parallel-local-ssh9.sh
blobd66533a20cd7e0feb0b1ee7953848a05d6f66593
1 #!/bin/bash
3 # SPDX-FileCopyrightText: 2021 Ole Tange, http://ole.tange.dk and Free Software and Foundation, Inc.
5 # SPDX-License-Identifier: GPL-3.0-or-later
7 par_ash_embed() {
8 myscript=$(cat <<'_EOF'
9 echo '--embed'
10 parallel --embed | tac | perl -pe '
11 /^parallel/ and not $seen++ and s{^}{
12 echo \$b
13 parset a,b,c echo ::: ParsetOK ParsetOK ParsetOK
14 env_parallel echo ::: env_parallel_OK
15 env_parallel --env myvar echo {} --env \\\$myvar ::: env_parallel
16 myvar=OK
17 parallel echo ::: parallel_OK
18 PATH=/usr/sbin:/usr/bin:/sbin:/bin
19 # Do not look for parallel in /usr/local/bin
20 #. \`which env_parallel.ash\`
22 ' | tac > parallel-embed
23 chmod +x parallel-embed
24 ./parallel-embed
25 rm parallel-embed
26 _EOF
28 ssh ash@lo "$myscript"
31 par_bash_embed() {
32 myscript=$(cat <<'_EOF'
33 echo '--embed'
34 parallel --embed | tac | perl -pe '
35 /^parallel/ and not $seen++ and s{^}{
36 echo \${a[1]}
37 parset a echo ::: ParsetOK ParsetOK ParsetOK
38 env_parallel echo ::: env_parallel_OK
39 env_parallel --env myvar echo {} --env \\\$myvar ::: env_parallel
40 myvar=OK
41 parallel echo ::: parallel_OK
42 PATH=/usr/sbin:/usr/bin:/sbin:/bin
43 # Do not look for parallel in /usr/local/bin
44 #. \`which env_parallel.bash\`
46 ' | tac > parallel-embed
47 chmod +x parallel-embed
48 ./parallel-embed
49 rm parallel-embed
50 _EOF
52 ssh bash@lo "$myscript"
55 par_csh_embed() {
56 echo Not implemented
59 par_fish_embed() {
60 echo Not implemented
63 par_ksh_embed() {
64 myscript=$(cat <<'_EOF'
65 echo '--embed'
66 parallel --embed | tac | perl -pe '
67 /^parallel/ and not $seen++ and s{^}{
68 echo \${a[1]}
69 parset a echo ::: ParsetOK ParsetOK ParsetOK
70 env_parallel echo ::: env_parallel_OK
71 env_parallel --env myvar echo {} --env \\\$myvar ::: env_parallel
72 myvar=OK
73 parallel echo ::: parallel_OK
74 PATH=/usr/sbin:/usr/bin:/sbin:/bin
75 # Do not look for parallel in /usr/local/bin
76 #. \`which env_parallel.ksh\`
78 ' | tac > parallel-embed
79 chmod +x parallel-embed
80 ./parallel-embed
81 rm parallel-embed
82 _EOF
84 ssh ksh@lo "$myscript"
87 par_sh_embed() {
88 myscript=$(cat <<'_EOF'
89 echo '--embed'
90 parallel --embed | tac | perl -pe '
91 /^parallel/ and not $seen++ and s{^}{
92 echo \$b
93 parset a,b,c echo ::: ParsetOK ParsetOK ParsetOK
94 env_parallel echo ::: env_parallel_OK
95 env_parallel --env myvar echo {} --env \\\$myvar ::: env_parallel
96 myvar=OK
97 parallel echo ::: parallel_OK
98 PATH=/usr/sbin:/usr/bin:/sbin:/bin
99 # Do not look for parallel in /usr/local/bin
100 #. \`which env_parallel.sh\`
102 ' | tac > parallel-embed
103 chmod +x parallel-embed
104 ./parallel-embed
105 rm parallel-embed
106 _EOF
108 ssh sh@lo "$myscript"
111 par_tcsh_embed() {
112 echo Not implemented
115 par_zsh_embed() {
116 myscript=$(cat <<'_EOF'
117 echo '--embed'
118 parallel --embed | tac | perl -pe '
119 /^parallel/ and not $seen++ and s{^}{
120 echo \${a[1]}
121 parset a echo ::: ParsetOK ParsetOK ParsetOK
122 env_parallel echo ::: env_parallel_OK
123 env_parallel --env myvar echo {} --env \\\$myvar ::: env_parallel
124 myvar=OK
125 parallel echo ::: parallel_OK
126 PATH=/usr/sbin:/usr/bin:/sbin:/bin
127 # Do not look for parallel in /usr/local/bin
129 ' | tac > parallel-embed
130 chmod +x parallel-embed
131 ./parallel-embed
132 rm parallel-embed
133 _EOF
135 ssh zsh@lo "$myscript" 2>&1 |
136 grep -v .zshenv:.:1
139 par_propagate_env() {
140 echo '### bug #41805: Idea: propagate --env for parallel --number-of-cores'
141 echo '** test_zsh'
142 FOO=test_zsh parallel --env FOO,HOME -S zsh@lo -N0 env ::: "" |sort|egrep 'FOO|^HOME'
143 echo '** test_zsh_filter'
144 FOO=test_zsh_filter parallel --filter-hosts --env FOO,HOME -S zsh@lo -N0 env ::: "" |sort|egrep 'FOO|^HOME'
145 echo '** test_csh'
146 FOO=test_csh parallel --env FOO,HOME -S csh@lo -N0 env ::: "" |sort|egrep 'FOO|^HOME'
147 echo '** test_csh_filter'
148 FOO=test_csh_filter parallel --filter-hosts --env FOO,HOME -S csh@lo -N0 env ::: "" |sort|egrep 'FOO|^HOME'
149 echo '** bug #41805 done'
152 par_env_parallel_big_env() {
153 echo '### bug #54128: command too long when exporting big env'
154 . `which env_parallel.bash`
155 a=`rand | perl -pe 's/\0//g'| head -c 70000`
156 env_parallel -Slo echo should not ::: fail 2>&1
157 a=`rand | perl -pe 's/\0//g'| head -c 80000`
158 env_parallel -Slo echo should ::: fail 2>/dev/null || echo OK
161 par_no_route_to_host() {
162 echo '### no route to host with | and -j0 causes inf loop'
163 # Broken in parallel-20121122 .. parallel-20181022
164 # parallel-20181022 -j0 -S 185.75.195.218 echo ::: {1..11}
165 via_parallel() {
166 seq 11 | stdout parallel -j0 -S $1 echo
168 export -f via_parallel
169 raw() {
170 stdout ssh $1 echo
172 export -f raw
174 # Random hosts
175 findhosts() {
176 ip='$(($RANDOM%256)).$(($RANDOM%256)).$(($RANDOM%256)).$(($RANDOM%256))'
177 seq 10000 | parallel -N0 echo $ip
180 # See if the hosts fail fast
181 filterhosts() {
182 stdout parallel --timeout 2 -j5 ssh -o PasswordAuthentication=no {} echo |
183 perl -ne 's/ssh:.* host (\d+\.\d+\.\d+\.\d+) .* No route .*/$1/ and print; $|=1'
187 # Cache a list of hosts that fail fast with 'No route'
188 # Filter the list 5 times to make sure to get good hosts
189 export -f findhosts
190 export -f filterhosts
191 nice bash -c '
192 findhosts | filterhosts | filterhosts | filterhosts |
193 filterhosts | filterhosts | head > /tmp/filtered.$$
194 mv /tmp/filtered.$$ /tmp/filtered.hosts
198 # We just need one of each to complete
199 stdout parallel --halt now,done=1 -j0 raw :::: /tmp/filtered.hosts
200 stdout parallel --halt now,done=1 -j0 via_parallel :::: /tmp/filtered.hosts
201 ) | perl -pe 's/(\d+\.\d+\.\d+\.\d+)/i.p.n.r/' | puniq
204 par_PARALLEL_SSHLOGIN_SSHHOST() {
205 echo '### bug #56554: Introduce $PARALLEL_SSHLOGIN $PARALLEL_SSHHOST'
206 (echo lo; echo zsh@lo; echo /usr/bin/ssh csh@lo; echo 1/sh@lo;
207 echo 1//usr/bin/ssh tcsh@lo) |
208 parallel -k --tag --nonall -S - 'whoami;echo $PARALLEL_SSHLOGIN $PARALLEL_SSHHOST' |
209 LANG=C sort
212 export -f $(compgen -A function | grep par_)
213 #compgen -A function | grep par_ | sort | parallel --delay $D -j$P --tag -k '{} 2>&1'
214 #compgen -A function | grep par_ | sort |
215 compgen -A function | grep par_ | LANG=C sort -ri |
216 # parallel --joblog /tmp/jl-`basename $0` --delay $D -j$P --tag -k '{} 2>&1'
217 parallel --joblog /tmp/jl-`basename $0` --delay 0.1 -j200% --tag -k '{} 2>&1' |
218 perl -pe 's/line \d\d\d+:/line XXX:/' |
219 perl -pe 's/\[\d\d\d+\]:/[XXX]:/'