summaryrefslogtreecommitdiffstats
path: root/dvm/764802/testcase
blob: f0a344a83738638cae8f74f934eb4846363492dd (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/bash

source $cwd/regression_helpers

BRICK1=$(hostname):$EXPORT_DIR/$global_bug_id/brick1
BRICK2=$(hostname):$EXPORT_DIR/$global_bug_id/brick2

$GLUSTERFSDIR/gluster volume create $global_bug_id $BRICK1 1>/dev/null 2>/dev/null

$GLUSTERFSDIR/gluster volume start $global_bug_id 2>/dev/null 1>/dev/null
sleep 5

mount_glusterfs $global_bug_id

cd $FUSE_MOUNT

for i in {1..10}
do
    touch $i
done


# Capture the GFIDs of all the files
cd $EXPORT_DIR/$global_bug_id/brick1

for i in {1..10}
do
    GFID_ARR[$i]=$(getfattr -d -e hex -n trusted.gfid -m . $i | grep trusted.gfid| cut -d "=" -f2)
done

$GLUSTERFSDIR/gluster volume add-brick $global_bug_id $BRICK2 1>/dev/null 2>/dev/null
$GLUSTERFSDIR/gluster volume rebalance $global_bug_id start 1>/dev/null 2>/dev/null
sleep 2

status=0
time_out=0

while [[ $status -ne 1 && $time_out -le 300 ]]
do
    status=$($GLUSTERFSDIR/gluster volume rebalance $global_bug_id status| grep 'rebalance completed'|wc -l)
    time_out=$(( $time_out + 1))
    sleep 1
done


# for some reason rebalance is hung so we errout
# assuming 300 is fairly enough for rebalancing
# 10 files
if [ $time_out -gt 300 ]; then
    exit 1
fi


# now compare the GFIDs of all the files
# with the previously stored
for i in {1..10}
do
   if [  -f "$EXPORT_DIR/$global_bug_id/brick1/$i" ] ; then

        GFID_ARR2[$i]=$(getfattr -d -e hex -n trusted.gfid -m . $EXPORT_DIR/$global_bug_id/brick1/$i 2>/dev/null\
                                              | grep trusted.gfid | cut -d "=" -f2)


        if [ ${GFID_ARR[$i]} != ${GFID_ARR2[$i]} ]; then
            exit 1
        fi
   elif [ -f "$EXPORT_DIR/$global_bug_id/brick2/$i" ]; then

         GFID_ARR2[$i]=$(getfattr -d -e hex -n trusted.gfid -m . $EXPORT_DIR/$global_bug_id/brick2/$i 2>/dev/null\
                                               | grep trusted.gfid | cut -d "=" -f2)

         if [ ${GFID_ARR[$i]} != ${GFID_ARR2[$i]} ]; then
             exit 1
         fi
   else
        echo "file not found"
        exit 1
   fi
done


exit 0