Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / qa / workunits / rbd / test_rbdmap_RBDMAPFILE.sh
1 #!/bin/sh
2 #
3 # Regression test for http://tracker.ceph.com/issues/14984
4 #
5 # When the bug is present, starting the rbdmap service causes
6 # a bogus log message to be emitted to the log because the RBDMAPFILE
7 # environment variable is not set.
8 #
9 # When the bug is not present, starting the rbdmap service will emit 
10 # no log messages, because /etc/ceph/rbdmap does not contain any lines 
11 # that require processing.
12 #
13 set -ex
14
15 which ceph-detect-init >/dev/null || exit 1
16 [ "$(ceph-detect-init)" = "systemd" ] || exit 0
17
18 echo "TEST: save timestamp for use later with journalctl --since"
19 TIMESTAMP=$(date +%Y-%m-%d\ %H:%M:%S)
20
21 echo "TEST: assert that rbdmap has not logged anything since boot"
22 journalctl -b 0 -t rbdmap | grep 'rbdmap\[[[:digit:]]' && exit 1
23 journalctl -b 0 -t init-rbdmap | grep 'rbdmap\[[[:digit:]]' && exit 1
24
25 echo "TEST: restart the rbdmap.service"
26 sudo systemctl restart rbdmap.service
27
28 echo "TEST: ensure that /usr/bin/rbdmap runs to completion"
29 until sudo systemctl status rbdmap.service | grep 'active (exited)' ; do 
30     sleep 0.5
31 done
32
33 echo "TEST: assert that rbdmap has not logged anything since TIMESTAMP"
34 journalctl --since "$TIMESTAMP" -t rbdmap  | grep 'rbdmap\[[[:digit:]]' && exit 1
35 journalctl --since "$TIMESTAMP" -t init-rbdmap | grep 'rbdmap\[[[:digit:]]' && exit 1
36
37 exit 0