|
| 1 | +#!/usr/bin/env bash |
| 2 | +# |
| 3 | +# Copyright (C) 2022 Red Hat <[email protected]> |
| 4 | +# |
| 5 | +# Author: Prashant D <[email protected]> |
| 6 | +# |
| 7 | +# This program is free software; you can redistribute it and/or modify |
| 8 | +# it under the terms of the GNU Library Public License as published by |
| 9 | +# the Free Software Foundation; either version 2, or (at your option) |
| 10 | +# any later version. |
| 11 | +# |
| 12 | +# This program is distributed in the hope that it will be useful, |
| 13 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | +# GNU Library Public License for more details. |
| 16 | +# |
| 17 | + |
| 18 | +source $CEPH_ROOT/qa/standalone/ceph-helpers.sh |
| 19 | + |
| 20 | +function run() { |
| 21 | + local dir=$1 |
| 22 | + shift |
| 23 | + |
| 24 | + export CEPH_MON="127.0.0.1:7156" # git grep '\<7156\>' : there must be only one |
| 25 | + export CEPH_ARGS |
| 26 | + CEPH_ARGS+="--fsid=$(uuidgen) --auth-supported=none " |
| 27 | + CEPH_ARGS+="--mon-host=$CEPH_MON " |
| 28 | + |
| 29 | + local funcs=${@:-$(set | sed -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')} |
| 30 | + for func in $funcs ; do |
| 31 | + setup $dir || return 1 |
| 32 | + $func $dir || return 1 |
| 33 | + teardown $dir || return 1 |
| 34 | + done |
| 35 | +} |
| 36 | + |
| 37 | +function TEST_cluster_log_level() { |
| 38 | + local dir=$1 |
| 39 | + |
| 40 | + run_mon $dir a || return 1 |
| 41 | + run_mgr $dir x || return 1 |
| 42 | + run_osd $dir 0 || return 1 |
| 43 | + |
| 44 | + ceph config set mon.a mon_cluster_log_level debug |
| 45 | + ceph osd pool create replicated1 8 8 |
| 46 | + ceph osd pool set replicated1 size 1 --yes-i-really-mean-it |
| 47 | + ceph osd pool set replicated1 min_size 1 |
| 48 | + |
| 49 | + WAIT_FOR_CLEAN_TIMEOUT=60 wait_for_clean |
| 50 | + ERRORS=0 |
| 51 | + truncate $dir/log -s 0 |
| 52 | + ceph pg deep-scrub 1.0 |
| 53 | + search_str="cluster [[]DBG[]] 1.0 deep-scrub" |
| 54 | + TIMEOUT=60 wait_for_string $dir/log "$search_str" |
| 55 | + grep -q "$search_str" $dir/log |
| 56 | + return_code=$? |
| 57 | + if [ $return_code -ne 0 ]; then |
| 58 | + echo "Failed : Could not find DBG log in the cluster log file" |
| 59 | + ERRORS=$(($ERRORS + 1)) |
| 60 | + fi |
| 61 | + |
| 62 | + ceph osd down 0 |
| 63 | + TIMEOUT=20 wait_for_osd up 0 || return 1 |
| 64 | + grep -q "cluster [[]INF[]] osd.0.*boot" $dir/log |
| 65 | + return_code=$? |
| 66 | + if [ $return_code -ne 0 ]; then |
| 67 | + echo "Failed : Could not find INF log in the cluster log file" |
| 68 | + ERRORS=$(($ERRORS + 1)) |
| 69 | + fi |
| 70 | + |
| 71 | + ceph config set mon.a mon_cluster_log_level info |
| 72 | + ceph pg deep-scrub 1.1 |
| 73 | + search_str="cluster [[]DBG[]] 1.1 deep-scrub" |
| 74 | + TIMEOUT=60 wait_for_string $dir/log "$search_str" |
| 75 | + grep -q "$search_str" $dir/log |
| 76 | + return_code=$? |
| 77 | + if [ $return_code -eq 0 ]; then |
| 78 | + echo "Failed : Found DBG log in the cluster log file" |
| 79 | + ERRORS=$(($ERRORS + 1)) |
| 80 | + fi |
| 81 | + |
| 82 | + ceph config set mon.a mon_cluster_log_level warn |
| 83 | + ceph osd set noup |
| 84 | + ceph osd down osd.0 |
| 85 | + ceph osd unset noup |
| 86 | + TIMEOUT=60 wait_for_osd up 0 || return 1 |
| 87 | + search_str="cluster [[]WRN[]] Health check failed: noup flag(s) set (OSDMAP_FLAGS)" |
| 88 | + grep -q "$search_str" $dir/log |
| 89 | + return_code=$? |
| 90 | + if [ $return_code -ne 0 ]; then |
| 91 | + echo "Failed : No WRN entries found in the cluster log file" |
| 92 | + ERRORS=$(($ERRORS + 1)) |
| 93 | + fi |
| 94 | + |
| 95 | + ceph osd out 0 |
| 96 | + ceph osd in 0 |
| 97 | + WAIT_FOR_CLEAN_TIMEOUT=60 wait_for_clean |
| 98 | + search_str="cluster [[]INF[]] Client client.admin marked osd.0 out, while it was still marked up" |
| 99 | + ceph log last 1000 | grep -q "$search_str" || return 1 |
| 100 | + TIMEOUT=60 wait_for_string $dir/log "$search_str" |
| 101 | + grep -q "$search_str" $dir/log |
| 102 | + return_code=$? |
| 103 | + if [ $return_code -eq 0 ]; then |
| 104 | + echo "Failed : Found INF log in the cluster log file" |
| 105 | + ERRORS=$(($ERRORS + 1)) |
| 106 | + fi |
| 107 | + |
| 108 | + if [ $ERRORS -gt 0 ]; then |
| 109 | + echo "TEST FAILED WITH $ERRORS ERRORS" |
| 110 | + return 1 |
| 111 | + fi |
| 112 | + |
| 113 | + echo "TEST PASSED" |
| 114 | + return 0 |
| 115 | +} |
| 116 | + |
| 117 | +function TEST_journald_cluster_log_level() { |
| 118 | + local dir=$1 |
| 119 | + |
| 120 | + run_mon $dir a || return 1 |
| 121 | + run_mgr $dir x || return 1 |
| 122 | + run_osd $dir 0 || return 1 |
| 123 | + |
| 124 | + ceph config set mon.a mon_cluster_log_level debug |
| 125 | + ceph osd pool create replicated1 8 8 |
| 126 | + ceph osd pool set replicated1 size 1 --yes-i-really-mean-it |
| 127 | + ceph osd pool set replicated1 min_size 1 |
| 128 | + |
| 129 | + WAIT_FOR_CLEAN_TIMEOUT=60 wait_for_clean |
| 130 | + ERRORS=0 |
| 131 | + ceph config set mon.a mon_cluster_log_to_journald true |
| 132 | + |
| 133 | + ceph pg deep-scrub 1.0 |
| 134 | + search_str="1.0 deep-scrub" |
| 135 | + TIMEOUT=60 |
| 136 | + sleep $TIMEOUT |
| 137 | + journalctl _COMM=ceph-mon CEPH_CHANNEL=cluster PRIORITY=7 --output=json-pretty --since "60 seconds ago" |jq '.MESSAGE' > $dir/journal.log |
| 138 | + grep -q "$search_str" $dir/journal.log |
| 139 | + return_code=$? |
| 140 | + if [ $return_code -ne 0 ]; then |
| 141 | + echo "Failed : Could not find DBG log in the journalctl log file" |
| 142 | + ERRORS=$(($ERRORS + 1)) |
| 143 | + fi |
| 144 | + |
| 145 | + ceph osd down 0 |
| 146 | + TIMEOUT=20 wait_for_osd up 0 || return 1 |
| 147 | + search_str="osd.0.*boot" |
| 148 | + journalctl _COMM=ceph-mon CEPH_CHANNEL=cluster PRIORITY=6 --output=json-pretty --since "60 seconds ago" |jq '.MESSAGE' > $dir/journal.log |
| 149 | + grep -q "$search_str" $dir/journal.log |
| 150 | + return_code=$? |
| 151 | + if [ $return_code -ne 0 ]; then |
| 152 | + echo "Failed : Could not find INF log in the journalctl log file" |
| 153 | + ERRORS=$(($ERRORS + 1)) |
| 154 | + fi |
| 155 | + |
| 156 | + ceph config set mon.a mon_cluster_log_level info |
| 157 | + ceph pg deep-scrub 1.1 |
| 158 | + TIMEOUT=60 |
| 159 | + sleep $TIMEOUT |
| 160 | + search_str="1.1 deep-scrub" |
| 161 | + journalctl _COMM=ceph-mon CEPH_CHANNEL=cluster PRIORITY=7 --output=json-pretty --since "60 seconds ago" |jq '.MESSAGE' > $dir/journal.log |
| 162 | + grep -q "$search_str" $dir/journal.log |
| 163 | + return_code=$? |
| 164 | + if [ $return_code -eq 0 ]; then |
| 165 | + echo "Failed : Found $clog_entries DBG log entries in the journalctl log file" |
| 166 | + ERRORS=$(($ERRORS + 1)) |
| 167 | + fi |
| 168 | + |
| 169 | + ceph config set mon.a mon_cluster_log_level warn |
| 170 | + ceph osd set noup |
| 171 | + ceph osd down osd.0 |
| 172 | + ceph osd unset noup |
| 173 | + TIMEOUT=60 wait_for_osd up 0 || return 1 |
| 174 | + search_str="Health check failed: noup flag(s) set (OSDMAP_FLAGS)" |
| 175 | + journalctl _COMM=ceph-mon CEPH_CHANNEL=cluster PRIORITY=4 --output=json-pretty --since "60 seconds ago" |jq '.MESSAGE' > $dir/journal.log |
| 176 | + grep -q "$search_str" $dir/journal.log |
| 177 | + return_code=$? |
| 178 | + if [ $return_code -ne 0 ]; then |
| 179 | + echo "Failed : No WRN entries found in the journalctl log file" |
| 180 | + ERRORS=$(($ERRORS + 1)) |
| 181 | + fi |
| 182 | + |
| 183 | + ceph osd out 0 |
| 184 | + ceph osd in 0 |
| 185 | + WAIT_FOR_CLEAN_TIMEOUT=60 wait_for_clean |
| 186 | + search_str="Client client.admin marked osd.0 out, while it was still marked up" |
| 187 | + ceph log last | grep -q "$search_str" || return 1 |
| 188 | + journalctl _COMM=ceph-mon CEPH_CHANNEL=cluster PRIORITY=6 --output=json-pretty --since "60 seconds ago" |jq '.MESSAGE' > $dir/journal.log |
| 189 | + grep -q "$search_str" $dir/journal.log |
| 190 | + return_code=$? |
| 191 | + if [ $return_code -eq 0 ]; then |
| 192 | + echo "Failed : Found $clog_entries INF log entries in the journalctl log file" |
| 193 | + ERRORS=$(($ERRORS + 1)) |
| 194 | + fi |
| 195 | + |
| 196 | + if [ $ERRORS -gt 0 ]; then |
| 197 | + echo "TEST FAILED WITH $ERRORS ERRORS" |
| 198 | + return 1 |
| 199 | + fi |
| 200 | + |
| 201 | + echo "TEST PASSED" |
| 202 | + return 0 |
| 203 | +} |
| 204 | + |
| 205 | +main mon-cluster-log "$@" |
0 commit comments