Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / qa / workunits / ceph-disk / ceph-disk.sh
1 #!/bin/bash
2 if [ -f $(dirname $0)/../ceph-helpers-root.sh ]; then
3     source $(dirname $0)/../ceph-helpers-root.sh
4 else
5     echo "$(dirname $0)/../ceph-helpers-root.sh does not exist."
6     exit 1
7 fi
8
9 install python-pytest || true
10 install pytest || true
11
12 # complete the cluster setup done by the teuthology ceph task
13 sudo chown $(id -u) /etc/ceph/ceph.conf
14 if ! test -f /etc/ceph/ceph.client.admin.keyring ; then
15     sudo cp /etc/ceph/ceph.keyring /etc/ceph/ceph.client.admin.keyring
16 fi
17 if ! sudo test -f /var/lib/ceph/bootstrap-osd/ceph.keyring ; then
18     sudo ceph-create-keys --id a
19 fi
20 sudo ceph osd crush rm osd.0 || true
21 sudo ceph osd crush rm osd.1 || true
22
23 sudo cp $(dirname $0)/60-ceph-by-partuuid.rules /lib/udev/rules.d
24 sudo udevadm control --reload
25
26 perl -pi -e 's|pid file.*|pid file = /var/run/ceph/\$cluster-\$name.pid|' /etc/ceph/ceph.conf
27
28 PATH=$(dirname $0):$(dirname $0)/..:$PATH
29
30 : ${PYTHON:=python}
31 PY_VERSION=$($PYTHON --version 2>&1)
32
33 if ! ${PYTHON} -m pytest --version > /dev/null 2>&1; then
34     echo "py.test not installed for ${PY_VERSION}"
35     exit 1
36 fi
37
38 sudo env PATH=$(dirname $0):$(dirname $0)/..:$PATH PYTHONWARNINGS=ignore ${PYTHON} -m pytest -s -v $(dirname $0)/ceph-disk-test.py
39 result=$?
40
41 sudo rm -f /lib/udev/rules.d/60-ceph-by-partuuid.rules
42 # own whatever was created as a side effect of the py.test run
43 # so that it can successfully be removed later on by a non privileged
44 # process
45 sudo chown -R $(id -u) $(dirname $0)
46 exit $result