summaryrefslogtreecommitdiffstats
path: root/tests/bugs/shard/bug-1251824.t
blob: 71bfdc7fdae3a7b84aee10905f13836ea30b3cd2 (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
#!/bin/bash

. $(dirname $0)/../../include.rc

cleanup;

TEST glusterd
TEST pidof glusterd
TEST $CLI volume create $V0 $H0:$B0/${V0}{0,1}
TEST $CLI volume set $V0 features.shard on
TEST $CLI volume start $V0

TEST $GFS --volfile-id=$V0 --volfile-server=$H0 $M0
TEST useradd -M test_user 2>/dev/null

# Create 3 files as root.
TEST touch $M0/foo
TEST touch $M0/bar
TEST touch $M0/baz

# Change ownership to non-root on foo and bar.
TEST chown test_user:test_user $M0/foo
TEST chown test_user:test_user $M0/bar

# Write 6M of data on foo as non-root, 2M overflowing into block-1.
su -m test_user -c "dd if=/dev/zero of=$M0/foo bs=1M count=6"

# Ensure owner and group are same on the shard as the main file.
gfid_foo=`getfattr -n glusterfs.gfid.string $M0/foo 2>/dev/null \
          | grep glusterfs.gfid.string | cut -d '"' -f 2`

EXPECT "test_user" echo `find $B0 -name $gfid_foo.1 | xargs stat -c %U`
EXPECT "test_user" echo `find $B0 -name $gfid_foo.1 | xargs stat -c %G`

# Write 6M of data on bar as root.
TEST dd if=/dev/zero of=$M0/bar bs=1M count=6

# Ensure owner and group are same on the shard as the main file.
gfid_bar=`getfattr -n glusterfs.gfid.string $M0/bar 2>/dev/null \
          | grep glusterfs.gfid.string | cut -d '"' -f 2`

EXPECT "test_user" echo `find $B0 -name $gfid_bar.1 | xargs stat -c %U`
EXPECT "test_user" echo `find $B0 -name $gfid_bar.1 | xargs stat -c %G`

# Write 6M of data on baz as root.
TEST dd if=/dev/zero of=$M0/baz bs=1M count=6

# Ensure owner andgroup are same on the shard as the main file.
gfid_baz=`getfattr -n glusterfs.gfid.string $M0/baz 2>/dev/null \
          | grep glusterfs.gfid.string | cut -d '"' -f 2`

EXPECT "root" echo `find $B0 -name $gfid_baz.1 | xargs stat -c %U`
EXPECT "root" echo `find $B0 -name $gfid_baz.1 | xargs stat -c %G`
userdel test_user

TEST umount $M0

TEST $CLI volume stop $V0
TEST $CLI volume delete $V0

cleanup;