Whamcloud - gitweb
LU-10048 osd: async truncate
[fs/lustre-release.git] / lustre / tests / dne_sanity.sh
1 #!/bin/bash
2 #
3 # run tests on different directories at the same time
4 #
5
6 set -e
7
8 SRCDIR=$(cd $(dirname $0); echo $PWD)
9 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
10
11 SAVE_PWD=$PWD
12
13 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
14 . $LUSTRE/tests/test-framework.sh
15 init_test_env $@
16 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
17 init_logging
18
19 PARALLEL_RUNS=${PARALLEL_RUNS:-2}
20 FAIL_ON_ERROR=false
21
22 check_and_setup_lustre
23
24 build_test_filter
25
26 DIR=${DIR:-$MOUNT}
27
28 ORIGIN_DIR=$DIR
29
30 prepare_running_directories()
31 {
32         local mdtidx
33         local rc=0
34         local i
35
36         for i in $(seq $PARALLEL_RUNS); do
37                 rm -rf $ORIGIN_DIR/dir$i
38                 if [ $MDSCOUNT -gt 1 ]; then
39                         mdtidx=$((i % MDSCOUNT))
40                         $LFS mkdir -i $mdtidx $ORIGIN_DIR/dir$i || rc=$?
41                 else
42                         mkdir -p $ORIGIN_DIR/dir$i
43                 fi
44
45                 if [ $rc != 0 ]; then
46                         echo "can not create dir$i"
47                         break
48                 fi
49         done
50
51         return $rc
52 }
53
54 prepare_running_directories || error "Can not create running directories"
55
56 cleanup_running_directories()
57 {
58         local i
59         local rc=0
60
61         for i in $(seq $PARALLEL_RUNS); do
62                 rm -rf $ORIGIN_DIR/dir$i || rc=$?
63         done
64
65         return $rc
66 }
67
68 test_sanity()
69 {
70         [ ! -f sanity.sh ] && skip_env "No sanity.sh skipping" && return
71
72         local index
73         local pid
74         local rpids
75         local rc=0
76         local rrc=0
77
78         for index in $(seq $PARALLEL_RUNS); do
79                 DIR=$ORIGIN_DIR/dir${index} PARALLEL=yes \
80                 EXT2_DEV="$TMP/SANITY.LOOP_${index}" \
81                 LOGDIR="${LOGDIR}_${index}" YAML_LOG="" sh sanity.sh &
82                 pid=$!
83                 echo start sanity: $pid
84                 rpids="$rpids $pid"
85         done
86
87         echo sanity pids: $rpids
88         for pid in $rpids; do
89                 wait $pid
90                 rc=$?
91                 echo "pid=$pid rc=$rc"
92                 if [ $rc != 0 ]; then
93                         rrc=$((rrc + 1))
94                 fi
95         done
96         return $rrc
97 }
98
99 run_test sanity "Run sanity parallel on different directories at the same time"
100
101 cleanup_running_directories || error "unlink running directories"
102
103 complete $SECONDS
104 check_and_cleanup_lustre
105 exit_status