forked from accelazh/ceph-allinone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-osd.sh
executable file
·74 lines (63 loc) · 2.06 KB
/
test-osd.sh
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
#!/bin/bash
########################################
# This file tests whether OSD services
# are properly installed and running
########################################
BASEDIR=$(dirname $0)
. ${BASEDIR}/config.sh
. ${BASEDIR}/file_path.sh
. ${BASEDIR}/functions.sh
common_init
mon_ip_array=($mon_ip_list)
mon_port_array=($mon_port_list)
TMP_OBJECT_FILE=/tmp/object-to-test-osd.data
TMP_OBJECT_GET_FILE=/tmp/object-to-test-osd-get.data
OBJECT_NAME="test-osd-$(uuidgen)"
echo "checking whether ceph-osd process exists ..."
proc_exist="$(ps cax | grep ceph-osd)"
if [ -z "$proc_exist" ]; then
echo "OSD processes is not running"
exit 1
fi
echo "grep ceph log to find errors ..."
if [ "$(has_log_error)" != "0" ]; then
echo "log file has errors!"
exit 1
fi
echo "Testing by ceph status ..."
ceph status -c ${CONF_FILE} -m "${mon_ip_array}:${mon_port_array}"
if [ $? != 0 ]; then
echo "can not get ceph status!"
exit 1
fi
# check object put and get
rm -rf ${TMP_OBJECT_FILE}
rm -rf ${TMP_OBJECT_GET_FILE}
uuidgen > ${TMP_OBJECT_FILE}
if [ -z "$(cat ${TMP_OBJECT_FILE})" ]; then
echo "Failed to generate object file ${TMP_OBJECT_FILE} to test OSD."
exit 1
fi
echo "*********** Below may stuck for a while or with 'wrong node' messages, please wait patiently ... ************"
rados -c ${CONF_FILE} -m "${mon_ip_array}:${mon_port_array}" put ${OBJECT_NAME} ${TMP_OBJECT_FILE} --pool=data
if [ $? != 0 ]; then
echo "Failed to write object to RADOS pool."
exit 1
fi
echo "*********** Below may stuck for a while or with 'wrong node' messages, please wait patiently ... ************"
rados -c ${CONF_FILE} -m "${mon_ip_array}:${mon_port_array}" get ${OBJECT_NAME} ${TMP_OBJECT_GET_FILE} --pool=data
if [ $? != 0 ]; then
echo "Failed to get object from RADOS pool."
exit 1
fi
if [ "$(cat ${TMP_OBJECT_GET_FILE})" != "$(cat ${TMP_OBJECT_FILE})" ]; then
echo "Retrieved object has unmatched content."
exit 1
fi
# redo the log check again
echo "grep ceph log to find errors ..."
if [ "$(has_log_error)" != "0" ]; then
echo "log file has errors!"
exit 1
fi
echo "Successfully passed tests."