Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / qa / standalone / mon / mon-created-time.sh
1 #!/bin/bash
2 #
3 # Copyright (C) 2015 SUSE LINUX GmbH
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU Library Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
8 # any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU Library Public License for more details.
14 #
15 source $CEPH_ROOT/qa/standalone/ceph-helpers.sh
16
17 function run() {
18     local dir=$1
19     shift
20
21     export CEPH_MON="127.0.0.1:7125" # git grep '\<7125\>' : there must be only one
22     export CEPH_ARGS
23     CEPH_ARGS+="--fsid=$(uuidgen) --auth-supported=none "
24     CEPH_ARGS+="--mon-host=$CEPH_MON "
25
26     local funcs=${@:-$(set | sed -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')}
27     for func in $funcs ; do
28         setup $dir || return 1
29         $func $dir || return 1
30         teardown $dir || return 1
31     done
32 }
33
34 function TEST_mon_created_time() {
35     local dir=$1
36
37     run_mon $dir a || return 1
38
39     ceph mon dump || return 1
40
41     if test "$(ceph mon dump 2>/dev/null | sed -n '/created/p' | awk '{print $NF}')"x = ""x ; then
42         return 1
43     fi
44
45     if test "$(ceph mon dump 2>/dev/null | sed -n '/created/p' | awk '{print $NF}')"x = "0.000000"x ; then
46         return 1
47     fi
48 }
49
50 main mon-created-time "$@"
51
52 # Local Variables:
53 # compile-command: "cd ../.. ; make -j4 && test/mon/mon-created-time.sh"
54 # End: