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