summaryrefslogtreecommitdiffstats
path: root/tests/basic/quorum.t
blob: b8fc9cf3acaa5ff6ba53ba901e85865a3606ce3b (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
#!/bin/bash

# Test *very basic* NSR functionality - startup, mount, simplest possible file
# write.

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

function get_rep_count {
	v=$(getfattr --only-values -e text -n trusted.nsr.rep-count $1 2> /dev/null)
	#echo $v > /dev/tty
	echo $v
}

function kill_a_brick {
	for r in /var/lib/glusterd/vols/${V0}/run/*-recon.pid; do
		rpid=$(cat $r)
		#echo "recon PID = $rpid" > /dev/tty
		b=$(echo $r | sed '/\(.*\):\(.*\)-recon.pid/s//\1\2.pid/')
		bpid=$(cat $b)
		#echo "brick PID = $bpid" > /dev/tty
		kill -9 $bpid $rpid
		return 0
	done

	# No bricks?!?
	return 1
}

cleanup

TEST glusterd
TEST pidof glusterd
TEST $CLI volume info

TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{1,2}

EXPECT "$V0" volinfo_field $V0 'Volume Name'
EXPECT 'Created' volinfo_field $V0 'Status'
EXPECT '2' brick_count $V0

TEST $CLI volume set $V0 cluster.nsr on
TEST $CLI volume set $V0 cluster.nsr.recon on

TEST $CLI volume start $V0
EXPECT 'Started' volinfo_field $V0 'Status'

## Mount FUSE with caching disabled (read-only)
TEST glusterfs --entry-timeout=0 --attribute-timeout=0 -s $H0 --volfile-id $V0 $M0

# Give the bricks a chance to connect to each other.
EXPECT_WITHIN 10 "2" get_rep_count $M0

TEST kill_a_brick
EXPECT_WITHIN 10 "1" get_rep_count $M0

# Make sure writes fail while degraded.
tmpfile=$(mktemp)
trap "rm $tmpfile" EXIT
dd if=/dev/urandom of=$M0/probe bs=4k count=100 status=none 2> $tmpfile
TEST [ x"$?" != x"0" ]
TEST grep -qs 'Read-only file system' $tmpfile

cleanup