Whamcloud - gitweb
LU-10059 tests: sanityn 32a error messages
[fs/lustre-release.git] / lustre / tests / oos2.sh
1 #!/bin/bash
2
3 set -e
4
5 LUSTRE=${LUSTRE:-$(dirname $0)/..}
6 . $LUSTRE/tests/test-framework.sh
7 init_test_env $@
8
9 MOUNT=${MOUNT:-$1}
10 MOUNT=${MOUNT:-/mnt/lustre}
11 MOUNT2=${MOUNT2:-$2}
12 MOUNT2=${MOUNT2:-${MOUNT}2}
13 OOS=$MOUNT/oosfile
14 OOS2=$MOUNT2/oosfile2
15 LOG=$TMP/$(basename $0 .sh).log
16 LOG2=${LOG}2
17
18 SUCCESS=1
19
20 rm -f $OOS $OOS2 $LOG $LOG2
21
22 sync; sleep 1; sync     # to ensure we get up-to-date statfs info
23
24 STRIPECOUNT=$($LCTL get_param -n lov.*.activeobd | head -n 1)
25 ORIGFREE=$($LCTL get_param -n llite.*.kbytesavail | head -n 1)
26 MAXFREE=${MAXFREE:-$((400000 * $STRIPECOUNT))}
27 echo STRIPECOUNT=$STRIPECOUNT ORIGFREE=$ORIGFREE MAXFREE=$MAXFREE
28 if [ $ORIGFREE -gt $MAXFREE ]; then
29         skip "$0: ${ORIGFREE}kB free gt MAXFREE ${MAXFREE}kB, increase $MAXFREE (or reduce test fs size) to proceed"
30         exit 0
31 fi
32
33 export LANG=C LC_LANG=C # for "No space left on device" message
34
35 # make sure we stripe over all OSTs to avoid OOS on only a subset of OSTs
36 $LFS setstripe $OOS -c $STRIPECOUNT
37 $LFS setstripe $OOS2 -c $STRIPECOUNT
38 dd if=/dev/zero of=$OOS count=$((3 * $ORIGFREE / 4 + 100)) bs=1k 2>> $LOG &
39 DDPID=$!
40 if dd if=/dev/zero of=$OOS2 count=$((3*$ORIGFREE/4 + 100)) bs=1k 2>> $LOG2; then
41         echo "ERROR: dd2 did not fail"
42         SUCCESS=0
43 fi
44 if wait $DDPID; then
45         echo "ERROR: dd did not fail"
46         SUCCESS=0
47 fi
48
49 [ ! -s "$LOG" ] && error "LOG file is empty!"
50 [ ! -s "$LOG2" ] && error "LOG2 file is empty!"
51
52 if [ "`cat $LOG $LOG2 | grep -c 'No space left on device'`" -ne 2 ]; then
53         echo "ERROR: dd not return ENOSPC"
54         SUCCESS=0
55 fi
56
57 # flush cache to OST(s) so avail numbers are correct
58 sync; sleep 1 ; sync
59
60 if ! oos_full; then
61         echo "no OSTs are close to full"
62         SUCCESS=0
63 fi
64
65 RECORDSOUT=$((`grep "records out" $LOG | cut -d+ -f 1` + \
66               `grep "records out" $LOG2 | cut -d+ -f 1`))
67
68 FILESIZE=$((`ls -l $OOS | awk '{print $5}'` + `ls -l $OOS2 | awk '{print $5}'`))
69 if [ "$RECORDSOUT" -ne $(($FILESIZE / 1024)) ]; then
70         echo "ERROR: blocks written by dd not equal to the size of file"
71         SUCCESS=0
72 fi
73
74 echo LOG LOG2 file
75 cat $LOG $LOG2
76
77 rm -f $OOS $OOS2
78 sync; sleep 1; sync
79
80 if [ $SUCCESS -eq 1 ]; then
81         echo "Success!"
82         rm -f $LOG $LOG2
83 else
84         exit 1
85 fi