2013-03-24 16:24:59 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2024-01-24 01:02:07 +00:00
|
|
|
# SPDX-FileCopyrightText: 2021-2024 Ole Tange, http://ole.tange.dk and Free Software and Foundation, Inc.
|
2021-03-22 20:16:35 +00:00
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2017-01-06 18:10:20 +00:00
|
|
|
SERVER1=parallel-server1
|
2023-07-21 02:33:22 +00:00
|
|
|
SERVER2=parallel-server2
|
2020-08-07 20:20:30 +00:00
|
|
|
SERVER3=parallel-server3
|
|
|
|
SSHUSER1=vagrant
|
|
|
|
SSHUSER2=vagrant
|
|
|
|
SSHUSER3=vagrant
|
2021-02-17 14:49:47 +00:00
|
|
|
export SSHLOGIN1=$SSHUSER1@$SERVER1
|
|
|
|
export SSHLOGIN2=$SSHUSER2@$SERVER2
|
|
|
|
export SSHLOGIN3=$SSHUSER3@$SERVER3
|
2020-08-07 20:20:30 +00:00
|
|
|
|
|
|
|
#SERVER1=parallel-server1
|
|
|
|
#SERVER2=lo
|
|
|
|
#SSHLOGIN1=parallel@parallel-server1
|
|
|
|
#SSHLOGIN2=parallel@lo
|
|
|
|
#SSHLOGIN3=parallel@parallel-server2
|
2013-03-24 16:24:59 +00:00
|
|
|
|
2023-07-21 02:33:22 +00:00
|
|
|
par_force_number_of_cpu() {
|
|
|
|
echo '### Check forced number of CPUs being respected'
|
|
|
|
echo 'ssh is slow, so should only get 7. : should get the rest'
|
|
|
|
seq 1 20 |
|
|
|
|
stdout parallel -k -j+0 -S 1/:,7/$SSHLOGIN1 "hostname; echo {} >/dev/null" |
|
|
|
|
sort | uniq -c | sort | field 1
|
|
|
|
}
|
|
|
|
|
2021-02-17 14:49:47 +00:00
|
|
|
par_special_ssh() {
|
|
|
|
echo '### Test use special ssh'
|
|
|
|
echo 'TODO test ssh with > 9 simultaneous'
|
|
|
|
echo 'ssh "$@"; echo "$@" >>/tmp/myssh1-run' >/tmp/myssh1
|
|
|
|
echo 'ssh "$@"; echo "$@" >>/tmp/myssh2-run' >/tmp/myssh2
|
|
|
|
chmod 755 /tmp/myssh1 /tmp/myssh2
|
|
|
|
seq 1 100 | parallel --sshdelay 0.03 --retries 10 --sshlogin "/tmp/myssh1 $SSHLOGIN1,/tmp/myssh2 $SSHLOGIN2" -k echo
|
|
|
|
}
|
2015-02-01 20:46:06 +00:00
|
|
|
|
2023-07-21 02:33:22 +00:00
|
|
|
par__filter_hosts_different_errors() {
|
2021-02-17 14:49:47 +00:00
|
|
|
echo '### --filter-hosts - OK, non-such-user, connection refused, wrong host'
|
2023-07-21 02:33:22 +00:00
|
|
|
hostname=$(hostname)
|
2021-02-17 14:49:47 +00:00
|
|
|
stdout parallel --nonall --filter-hosts -S localhost,NoUser@localhost,154.54.72.206,"ssh 5.5.5.5" hostname |
|
2023-07-21 02:33:22 +00:00
|
|
|
grep -v 'parallel: Warning: Removed' |
|
|
|
|
perl -pe "s/$hostname/myhostname/g"
|
2021-02-17 14:49:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
par_timeout_retries() {
|
|
|
|
echo '### test --timeout --retries'
|
2024-03-31 21:29:30 +00:00
|
|
|
# 8.8.8.8 is up but does not allow login - should timeout
|
|
|
|
# 8.8.8.9 is down - should timeout
|
|
|
|
# 192.168.1.197 is down but on our subnet - should not timeout
|
2024-05-22 20:55:05 +00:00
|
|
|
stdout parallel -j0 --timeout 8 --retries 3 -k ssh {} echo {} \
|
2024-03-31 21:29:30 +00:00
|
|
|
::: 192.168.1.197 8.8.8.8 8.8.8.9 $SSHLOGIN1 $SSHLOGIN2 $SSHLOGIN3 |
|
2023-07-21 02:33:22 +00:00
|
|
|
grep -v 'Warning: Permanently added' | puniq
|
2021-02-17 14:49:47 +00:00
|
|
|
}
|
|
|
|
|
2023-07-21 02:33:22 +00:00
|
|
|
par__filter_hosts_no_ssh_nxserver() {
|
2021-02-17 14:49:47 +00:00
|
|
|
echo '### test --filter-hosts with server w/o ssh, non-existing server'
|
2024-03-31 21:29:30 +00:00
|
|
|
stdout parallel -S 192.168.1.197,8.8.8.8,8.8.8.9,$SSHLOGIN1,$SSHLOGIN2,$SSHLOGIN3 --filter-hosts --nonall -k --tag echo |
|
2021-02-17 14:49:47 +00:00
|
|
|
grep -v 'parallel: Warning: Removed'
|
|
|
|
}
|
|
|
|
|
|
|
|
par_controlmaster_is_faster() {
|
|
|
|
echo '### bug #41964: --controlmaster not seems to reuse OpenSSH connections to the same host'
|
2022-03-09 22:03:26 +00:00
|
|
|
echo '-M should finish first - eventhough there are 2x jobs'
|
2023-01-30 21:51:56 +00:00
|
|
|
export SSHLOGIN1=sh@lo
|
2023-02-19 13:49:30 +00:00
|
|
|
nl="$(printf "\n\n.")"
|
|
|
|
export TMPDIR="/tmp/ctrl_master/$nl'$nl"
|
|
|
|
mkdir -p "$TMPDIR"
|
2021-02-17 14:49:47 +00:00
|
|
|
(parallel -S $SSHLOGIN1 true ::: {1..20};
|
|
|
|
echo No --controlmaster - finish last) &
|
2022-03-09 22:03:26 +00:00
|
|
|
(parallel -M -S $SSHLOGIN1 true ::: {1..40};
|
2021-02-17 14:49:47 +00:00
|
|
|
echo With --controlmaster - finish first) &
|
|
|
|
wait
|
2023-02-19 13:49:30 +00:00
|
|
|
rm -r "/tmp/ctrl_master"
|
2021-02-17 14:49:47 +00:00
|
|
|
}
|
2015-02-01 20:46:06 +00:00
|
|
|
|
2021-02-17 14:49:47 +00:00
|
|
|
par_workdir_in_HOME() {
|
|
|
|
echo '### test --workdir . in $HOME'
|
|
|
|
cd && mkdir -p parallel-test && cd parallel-test &&
|
2021-09-22 21:37:24 +00:00
|
|
|
echo OK > testfile &&
|
|
|
|
stdout parallel --workdir . --transfer -S $SSHLOGIN1 cat {} ::: testfile |
|
|
|
|
grep -v 'Permanently added'
|
2021-02-17 14:49:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export -f $(compgen -A function | grep par_)
|
|
|
|
compgen -A function | grep par_ | LC_ALL=C sort |
|
2023-07-21 02:33:22 +00:00
|
|
|
parallel --timeout 3000% -j6 --tag -k --joblog /tmp/jl-`basename $0` '{} 2>&1' |
|
2021-02-17 14:49:47 +00:00
|
|
|
perl -pe 's:/usr/bin:/bin:g'
|
|
|
|
|
|
|
|
|
|
|
|
cat <<'EOF' | sed -e s/\$SERVER1/$SERVER1/\;s/\$SERVER2/$SERVER2/\;s/\$SSHLOGIN1/$SSHLOGIN1/\;s/\$SSHLOGIN2/$SSHLOGIN2/\;s/\$SSHLOGIN3/$SSHLOGIN3/ | parallel -vj3 -k -L1 -r
|
2013-08-16 11:11:35 +00:00
|
|
|
|
2014-11-14 00:00:56 +00:00
|
|
|
|
2013-08-17 16:24:51 +00:00
|
|
|
|
2013-11-28 15:05:25 +00:00
|
|
|
|
2015-08-04 05:54:40 +00:00
|
|
|
echo '### TODO: test --filter-hosts proxied through the one host'
|
|
|
|
|
2013-11-28 15:05:25 +00:00
|
|
|
|
2013-08-19 09:15:39 +00:00
|
|
|
EOF
|
2015-02-01 20:46:06 +00:00
|
|
|
rm /tmp/myssh1 /tmp/myssh2 /tmp/myssh1-run /tmp/myssh2-run
|
|
|
|
|