summaryrefslogtreecommitdiffstats
path: root/tests/bugs/bug-884597.t
blob: 0d3495a6597b511356b18becfa7cf7841697a0f1 (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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/bin/bash
. $(dirname $0)/../include.rc
. $(dirname $0)/../dht.rc

cleanup;
BRICK_COUNT=3
function uid_gid_compare()
{
        val=1

        if [ "$1" == "$3" ]
        then
                if [ "$2" == "$4" ]
                        then
                                val=0
                fi
        fi
        echo "$val"
}


TEST glusterd
TEST pidof glusterd

TEST $CLI volume create $V0 $H0:$B0/${V0}0 $H0:$B0/${V0}1 $H0:$B0/${V0}2
TEST $CLI volume start $V0

## Mount FUSE
TEST glusterfs --attribute-timeout=0 --entry-timeout=0 -s $H0 --volfile-id $V0 $M0;

i=1
NEW_UID=36
NEW_GID=36

TEST touch $M0/$i

chown $NEW_UID:$NEW_GID $M0/$i
## rename till file gets a linkfile

while [ $i -ne 0 ]
do
        TEST mv $M0/$i $M0/$(( $i+1 ))
        let i++
        file_has_linkfile $i
        has_link=$?
        if [ $has_link -eq 2 ]
        then
                break;
        fi
done

get_hashed_brick $i
cached=$?

# check if uid/gid on linkfile is created with correct uid/gid
BACKEND_UID=`stat --printf=%u $B0/${V0}$cached/$i`;
BACKEND_GID=`stat --printf=%g $B0/${V0}$cached/$i`;

EXPECT "0" uid_gid_compare $NEW_UID $NEW_GID $BACKEND_UID $BACKEND_GID

# remove linkfile from backend, and trigger a lookup heal. uid/gid should match
rm -rf $B0/${V0}$cached/$i

# without a unmount, we are not able to trigger a lookup based heal

TEST umount $M0

## Mount FUSE
TEST glusterfs --attribute-timeout=0 --entry-timeout=0 -s $H0 --volfile-id $V0 $M0;

lookup=`ls -l $M0/$i 2>/dev/null`

# check if uid/gid on linkfile is created with correct uid/gid
BACKEND_UID=`stat --printf=%u $B0/${V0}$cached/$i`;
BACKEND_GID=`stat --printf=%g $B0/${V0}$cached/$i`;

EXPECT "0" uid_gid_compare $NEW_UID $NEW_GID $BACKEND_UID $BACKEND_GID
# create hardlinks. Make sure a linkfile gets created

i=1
NEW_UID=36
NEW_GID=36

TEST touch $M0/file
chown $NEW_UID:$NEW_GID $M0/file;

## ln till file gets a linkfile

while [ $i -ne 0 ]
do
        TEST ln $M0/file $M0/link$i

        file_has_linkfile link$i
        has_link=$?
        if [ $has_link -eq 2 ]
        then
                break;
        fi
        let i++
done

get_hashed_brick link$i
cached=$?

# check if uid/gid on linkfile is created with correct uid/gid
BACKEND_UID=`stat --printf=%u $B0/${V0}$cached/link$i`;
BACKEND_GID=`stat --printf=%g $B0/${V0}$cached/link$i`;

EXPECT "0" uid_gid_compare $NEW_UID $NEW_GID $BACKEND_UID $BACKEND_GID