summaryrefslogtreecommitdiffstats
path: root/debian/tests/delay
blob: ad0af03cce48d30ada6f7829139a4e1280aac4c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/sh

set -e

DEFAULT_ARGS='delay=10\n login=test\n passwd=test\n ipaddr=127.0.0.1\n port=1\n managed=1\n devices=test\n session_url=http://127.0.0.1\n email=test@test.te\n ping_targets=localhost'
OUTPUT=$AUTOPKGTEST_TMP/delay
mkdir -p $OUTPUT

for agent in /usr/sbin/fence_*; do
  [ "$agent" = "/usr/sbin/fence_ack_manual" ] && continue
  [ "$agent" = "/usr/sbin/fence_kdump" ] && continue

  ARGS="$DEFAULT_ARGS"
  if [ "$agent" = "/usr/sbin/fence_cisco_mds" ]; then
    ARGS=$(echo "$ARGS" | sed 's#port=1#port=fc1/1#')
  fi
  LOG="$OUTPUT/$(basename $agent)"

  (
    TIME=$(/usr/bin/time -p sh -c "printf '$ARGS' | $agent " 2>&1 | awk -F"[. ]" -vOFS= '/real/ {print $2,$3}')
    if [ "$TIME" -lt 1000 ]; then
      echo "$agent delay too low: $TIME" | tee $LOG
    else
      echo "$agent delay ok: $TIME" | tee $LOG
    fi
  ) &
  pids="$pids $!"
done

wait $pids

if grep -qr 'delay too low' $OUTPUT; then
  exit 1
fi