]> git.proxmox.com Git - ceph.git/blame - ceph/qa/standalone/osd/repro_long_log.sh
update sources to 12.2.7
[ceph.git] / ceph / qa / standalone / osd / repro_long_log.sh
CommitLineData
94b18763
FG
1#!/usr/bin/env bash
2#
3# Copyright (C) 2014 Cloudwatt <libre.licensing@cloudwatt.com>
4# Copyright (C) 2018 Red Hat <contact@redhat.com>
5#
6# Author: Josh Durgin <jdurgin@redhat.com>
7# Author: David Zafman <dzafman@redhat.com>
8#
9# This program is free software; you can redistribute it and/or modify
10# it under the terms of the GNU Library Public License as published by
11# the Free Software Foundation; either version 2, or (at your option)
12# any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU Library Public License for more details.
18#
19
20source $CEPH_ROOT/qa/standalone/ceph-helpers.sh
21
22function run() {
23 local dir=$1
24 shift
25
26 export CEPH_MON="127.0.0.1:7100" # git grep '\<7100\>' : there must be only one
27 export CEPH_ARGS
28 CEPH_ARGS+="--fsid=$(uuidgen) --auth-supported=none "
29 CEPH_ARGS+="--mon-host=$CEPH_MON "
30
31 local funcs=${@:-$(set | sed -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')}
32 for func in $funcs ; do
33 setup $dir || return 1
34 $func $dir || return 1
35 teardown $dir || return 1
36 done
37}
38
39PGID=
40
41function test_log_size()
42{
43 local PGID=$1
44 local EXPECTED=$2
45 ceph tell osd.\* flush_pg_stats
46 sleep 3
47 ceph pg $PGID query | jq .info.stats.log_size
48 ceph pg $PGID query | jq .info.stats.log_size | grep "${EXPECTED}"
49}
50
51function setup_log_test() {
52 local dir=$1
53 local which=$2
54
55 run_mon $dir a || return 1
56 run_mgr $dir x || return 1
57 run_osd $dir 0 || return 1
58 run_osd $dir 1 || return 1
59 run_osd $dir 2 || return 1
60
61 ceph osd pool create test 1 1 || true
62 POOL_ID=$(ceph osd dump --format json | jq '.pools[] | select(.pool_name == "test") | .pool')
63 PGID="${POOL_ID}.0"
64
65 ceph tell osd.\* injectargs -- --osd-min-pg-log-entries 20 || return 1
66 ceph tell osd.\* injectargs -- --osd-max-pg-log-entries 30 || return 1
67 ceph tell osd.\* injectargs -- --osd-pg-log-trim-min 10 || return 1
68 ceph tell osd.\* injectargs -- --osd-pg-log-dups-tracked 10 || return 1
69
70 touch foo
71 for i in $(seq 1 20)
72 do
73 rados -p test put foo foo || return 1
74 done
75
76 test_log_size $PGID 20 || return 1
77
78 rados -p test rm foo || return 1
79
80 # generate error entries
81 for i in $(seq 1 20)
82 do
83 rados -p test rm foo
84 done
85
86 # log should have been trimmed down to min_entries with one extra
87 test_log_size $PGID 21 || return 1
88}
89
90function TEST_repro_long_log1()
91{
92 local dir=$1
93
94 setup_log_test $dir || return 1
95 # regular write should trim the log
96 rados -p test put foo foo || return 1
97 test_log_size $PGID 22 || return 1
98}
99
100function TEST_repro_long_log2()
101{
102 local dir=$1
103
104 setup_log_test $dir || return 1
105 local PRIMARY=$(ceph pg $PGID query | jq '.info.stats.up_primary')
106 kill_daemons $dir TERM osd.$PRIMARY || return 1
107 CEPH_ARGS="--osd-max-pg-log-entries=2 --no-mon-config" ceph-objectstore-tool --data-path $dir/$PRIMARY --pgid $PGID --op trim-pg-log || return 1
108 run_osd $dir $PRIMARY || return 1
109 wait_for_clean || return 1
110 test_log_size $PGID 2 || return 1
111}
112
113function TEST_trim_max_entries()
114{
115 local dir=$1
116
117 setup_log_test $dir || return 1
118
119 ceph tell osd.\* injectargs -- --osd-min-pg-log-entries 1
120 ceph tell osd.\* injectargs -- --osd-pg-log-trim-min 2
121 ceph tell osd.\* injectargs -- --osd-pg-log-trim-max 4
122
123 # adding log entries, should only trim 4 and add one each time
124 rados -p test rm foo
125 test_log_size $PGID 17
126 rados -p test rm foo
127 test_log_size $PGID 14
128 rados -p test rm foo
129 test_log_size $PGID 11
130 rados -p test rm foo
131 test_log_size $PGID 8
132 rados -p test rm foo
133 test_log_size $PGID 5
134 rados -p test rm foo
135 test_log_size $PGID 2
136
137 # below trim_min
138 rados -p test rm foo
139 test_log_size $PGID 3
140 rados -p test rm foo
28e407b8 141 test_log_size $PGID 3
94b18763 142 rados -p test rm foo
28e407b8
AA
143 test_log_size $PGID 3
144 rados -p test rm foo
145 test_log_size $PGID 3
94b18763
FG
146}
147
148main repro-long-log "$@"
149
150# Local Variables:
151# compile-command: "cd ../.. ; make -j4 && ../qa/run-standalone.sh repro_long_log.sh"
152# End: