summaryrefslogtreecommitdiffstats
path: root/debian/tests/pacemaker-basic-resource.sh
blob: de2a4c4936c84903008ba9e108f5b28a9d52a7c6 (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
#!/bin/sh

set -ex

DAEMON_TIMEOUT=60
CRM_TIMEOUT=5
RSC_NAME="test"
rsc_check()
{
	if crm status | grep "$RSC_NAME[[:space:]][(]ocf::\?heartbeat:IPv6addr[)]:[[:space:]].*$1" >/dev/null; then
		return 0
	else
		return 1
	fi
}

# https://bugs.launchpad.net/bugs/1828228
ulimit -H -l unlimited 2>/dev/null || {
	echo "test disabled for unprivileged namespaces"
	exit 77
}

#
# daemons start
#

service corosync start
service pacemaker start
sleep $DAEMON_TIMEOUT

#
# disable stonith and quorum
#

crm configure property stonith-enabled="false"
crm configure property no-quorum-policy="ignore"
sleep $CRM_TIMEOUT

#
# creation & start
#

crm configure primitive $RSC_NAME \
	ocf:heartbeat:IPv6addr \
		params ipv6addr="fe00::200" \
		cidr_netmask="64" \
		nic="lo"
sleep $CRM_TIMEOUT
crm resource start $RSC_NAME
sleep $CRM_TIMEOUT
if rsc_check "Started" ; then
	: INFO resource creation and start OK
else
	: ERROR failed to start resource
	exit 1
fi

#
# restart
#

crm resource restart $RSC_NAME
sleep $CRM_TIMEOUT
if rsc_check "Started" ; then
	: INFO resource restart OK
else
	: ERROR failed to restart resource
	exit 1
fi

#
# stop
#

crm resource stop $RSC_NAME
sleep $CRM_TIMEOUT
if rsc_check "Stopped" ; then
	: INFO resource stop OK
else
	: ERROR failed to stop resource
	exit 1
fi

#
# delete
#

crm configure delete $RSC_NAME
sleep $CRM_TIMEOUT
if ! rsc_check "Stopped" ; then
	: INFO resource delete OK
else
	: ERROR failed to delete resource
	exit 1
fi

: INFO all tests OK
exit 0