summaryrefslogtreecommitdiffstats
path: root/tests/bugs/glusterd/bug-1595320.t
blob: 3a289f386def5e12fa2c74a20008c20f0525231e (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
#!/bin/bash

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

cleanup

function count_up_bricks {
        $CLI --xml volume status $V0 | grep '<status>1' | wc -l
}

function count_brick_processes {
        pgrep glusterfsd | wc -l
}

# Setup 3 LVMS
LVM_PREFIX="test"
TEST init_n_bricks 3
TEST setup_lvm 3

# Start glusterd
TEST glusterd
TEST pidof glusterd

# Create volume and enable brick multiplexing
TEST $CLI volume create $V0 $H0:$L1 $H0:$L2 $H0:$L3
TEST $CLI v set all cluster.brick-multiplex on

# Start the volume
TEST $CLI volume start $V0
EXPECT_WITHIN $PROCESS_UP_TIMEOUT 3 count_up_bricks
EXPECT 1 count_brick_processes

# Kill volume ungracefully
brick_pid=`pgrep glusterfsd`

# Make sure every brick root should be consumed by a brick process
n=`ls -lrth /proc/$brick_pid/fd | grep -iw $L1 | grep -v ".glusterfs" | wc -l`
TEST [ $n -eq 1 ]
n=`ls -lrth /proc/$brick_pid/fd | grep -iw $L2 | grep -v ".glusterfs" | wc -l`
TEST [ $n -eq 1 ]
n=`ls -lrth /proc/$brick_pid/fd | grep -iw $L3 | grep -v ".glusterfs" | wc -l`
TEST [ $n -eq 1 ]

b1_pid_file=$(ls $GLUSTERD_PIDFILEDIR/vols/$V0/*d-backends-1*.pid)
b2_pid_file=$(ls $GLUSTERD_PIDFILEDIR/vols/$V0/*d-backends-2*.pid)
b3_pid_file=$(ls $GLUSTERD_PIDFILEDIR/vols/$V0/*d-backends-3*.pid)

kill -9 $brick_pid
EXPECT 0 count_brick_processes

# Unmount 3rd brick root from node
brick_root=$L3
_umount_lv 3

# Start the volume only 2 brick should be start
TEST $CLI volume start $V0 force
EXPECT_WITHIN $PROCESS_UP_TIMEOUT 2 count_up_bricks
EXPECT 1 count_brick_processes

brick_pid=`pgrep glusterfsd`

# Make sure only two brick root should be consumed by a brick process
n=`ls -lrth /proc/$brick_pid/fd | grep -iw $L1 | grep -v ".glusterfs" | wc -l`
TEST [ $n -eq 1 ]
n=`ls -lrth /proc/$brick_pid/fd | grep -iw $L2 | grep -v ".glusterfs" | wc -l`
TEST [ $n -eq 1 ]
n=`ls -lrth /proc/$brick_pid/fd | grep -iw $L3 | grep -v ".glusterfs" | wc -l`
TEST [ $n -eq 0 ]

# Mount the brick root
TEST mkdir -p $brick_root
TEST mount -t xfs -o nouuid  /dev/test_vg_3/brick_lvm $brick_root

# Replace brick_pid file to test brick_attach code
TEST cp $b1_pid_file $b3_pid_file

# Start the volume all brick should be up
TEST $CLI volume start $V0 force

EXPECT_WITHIN $PROCESS_UP_TIMEOUT 3 count_up_bricks
EXPECT 1 count_brick_processes

# Make sure every brick root should be consumed by a brick process
n=`ls -lrth /proc/$brick_pid/fd | grep -iw $L1 | grep -v ".glusterfs" | wc -l`
TEST [ $n -eq 1 ]
n=`ls -lrth /proc/$brick_pid/fd | grep -iw $L2 | grep -v ".glusterfs" | wc -l`
TEST [ $n -eq 1 ]
n=`ls -lrth /proc/$brick_pid/fd | grep -iw $L3 | grep -v ".glusterfs" | wc -l`
TEST [ $n -eq 1 ]

cleanup