]>
Commit | Line | Data |
---|---|---|
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 | ||
20 | source $CEPH_ROOT/qa/standalone/ceph-helpers.sh | |
21 | ||
22 | function 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 | ||
39 | PGID= | |
40 | ||
41 | function test_log_size() | |
42 | { | |
43 | local PGID=$1 | |
44 | local EXPECTED=$2 | |
1e59de90 | 45 | local DUPS_EXPECTED=${3:-0} |
94b18763 FG |
46 | ceph tell osd.\* flush_pg_stats |
47 | sleep 3 | |
48 | ceph pg $PGID query | jq .info.stats.log_size | |
49 | ceph pg $PGID query | jq .info.stats.log_size | grep "${EXPECTED}" | |
1e59de90 TL |
50 | ceph pg $PGID query | jq .info.stats.log_dups_size |
51 | ceph pg $PGID query | jq .info.stats.log_dups_size | grep "${DUPS_EXPECTED}" | |
94b18763 FG |
52 | } |
53 | ||
54 | function setup_log_test() { | |
55 | local dir=$1 | |
56 | local which=$2 | |
57 | ||
58 | run_mon $dir a || return 1 | |
59 | run_mgr $dir x || return 1 | |
60 | run_osd $dir 0 || return 1 | |
61 | run_osd $dir 1 || return 1 | |
62 | run_osd $dir 2 || return 1 | |
63 | ||
64 | ceph osd pool create test 1 1 || true | |
65 | POOL_ID=$(ceph osd dump --format json | jq '.pools[] | select(.pool_name == "test") | .pool') | |
66 | PGID="${POOL_ID}.0" | |
67 | ||
9f95a23c TL |
68 | # With 1 PG setting entries per osd 20 results in a target log of 20 |
69 | ceph tell osd.\* injectargs -- --osd_target_pg_log_entries_per_osd 20 || return 1 | |
94b18763 FG |
70 | ceph tell osd.\* injectargs -- --osd-min-pg-log-entries 20 || return 1 |
71 | ceph tell osd.\* injectargs -- --osd-max-pg-log-entries 30 || return 1 | |
72 | ceph tell osd.\* injectargs -- --osd-pg-log-trim-min 10 || return 1 | |
1e59de90 | 73 | ceph tell osd.\* injectargs -- --osd_pg_log_dups_tracked 20 || return 1 |
94b18763 | 74 | |
1adf2230 | 75 | touch $dir/foo |
94b18763 FG |
76 | for i in $(seq 1 20) |
77 | do | |
1adf2230 | 78 | rados -p test put foo $dir/foo || return 1 |
94b18763 FG |
79 | done |
80 | ||
81 | test_log_size $PGID 20 || return 1 | |
82 | ||
83 | rados -p test rm foo || return 1 | |
84 | ||
85 | # generate error entries | |
86 | for i in $(seq 1 20) | |
87 | do | |
88 | rados -p test rm foo | |
89 | done | |
90 | ||
91 | # log should have been trimmed down to min_entries with one extra | |
92 | test_log_size $PGID 21 || return 1 | |
93 | } | |
94 | ||
95 | function TEST_repro_long_log1() | |
96 | { | |
97 | local dir=$1 | |
98 | ||
99 | setup_log_test $dir || return 1 | |
100 | # regular write should trim the log | |
1adf2230 | 101 | rados -p test put foo $dir/foo || return 1 |
94b18763 FG |
102 | test_log_size $PGID 22 || return 1 |
103 | } | |
104 | ||
105 | function TEST_repro_long_log2() | |
106 | { | |
107 | local dir=$1 | |
108 | ||
109 | setup_log_test $dir || return 1 | |
110 | local PRIMARY=$(ceph pg $PGID query | jq '.info.stats.up_primary') | |
111 | kill_daemons $dir TERM osd.$PRIMARY || return 1 | |
1e59de90 | 112 | CEPH_ARGS="--osd-max-pg-log-entries=2 --osd-pg-log-dups-tracked=3 --no-mon-config" ceph-objectstore-tool --data-path $dir/$PRIMARY --pgid $PGID --op trim-pg-log || return 1 |
9f95a23c | 113 | activate_osd $dir $PRIMARY || return 1 |
94b18763 | 114 | wait_for_clean || return 1 |
1e59de90 | 115 | test_log_size $PGID 21 18 || return 1 |
94b18763 FG |
116 | } |
117 | ||
118 | function TEST_trim_max_entries() | |
119 | { | |
120 | local dir=$1 | |
121 | ||
122 | setup_log_test $dir || return 1 | |
123 | ||
9f95a23c TL |
124 | ceph tell osd.\* injectargs -- --osd_target_pg_log_entries_per_osd 2 || return 1 |
125 | ceph tell osd.\* injectargs -- --osd-min-pg-log-entries 2 | |
94b18763 FG |
126 | ceph tell osd.\* injectargs -- --osd-pg-log-trim-min 2 |
127 | ceph tell osd.\* injectargs -- --osd-pg-log-trim-max 4 | |
1e59de90 | 128 | ceph tell osd.\* injectargs -- --osd_pg_log_dups_tracked 0 |
94b18763 FG |
129 | |
130 | # adding log entries, should only trim 4 and add one each time | |
131 | rados -p test rm foo | |
9f95a23c | 132 | test_log_size $PGID 18 || return 1 |
94b18763 | 133 | rados -p test rm foo |
9f95a23c | 134 | test_log_size $PGID 15 || return 1 |
94b18763 | 135 | rados -p test rm foo |
9f95a23c | 136 | test_log_size $PGID 12 || return 1 |
94b18763 | 137 | rados -p test rm foo |
9f95a23c | 138 | test_log_size $PGID 9 || return 1 |
94b18763 | 139 | rados -p test rm foo |
9f95a23c | 140 | test_log_size $PGID 6 || return 1 |
94b18763 | 141 | rados -p test rm foo |
9f95a23c | 142 | test_log_size $PGID 3 || return 1 |
94b18763 FG |
143 | |
144 | # below trim_min | |
145 | rados -p test rm foo | |
9f95a23c | 146 | test_log_size $PGID 4 || return 1 |
94b18763 | 147 | rados -p test rm foo |
9f95a23c | 148 | test_log_size $PGID 3 || return 1 |
94b18763 | 149 | rados -p test rm foo |
9f95a23c | 150 | test_log_size $PGID 4 || return 1 |
28e407b8 | 151 | rados -p test rm foo |
9f95a23c | 152 | test_log_size $PGID 3 || return 1 |
94b18763 FG |
153 | } |
154 | ||
1e59de90 TL |
155 | function TEST_trim_max_entries_with_dups() |
156 | { | |
157 | local dir=$1 | |
158 | ||
159 | setup_log_test $dir || return 1 | |
160 | ||
161 | ceph tell osd.\* injectargs -- --osd_target_pg_log_entries_per_osd 2 || return 1 | |
162 | ceph tell osd.\* injectargs -- --osd-min-pg-log-entries 2 | |
163 | ceph tell osd.\* injectargs -- --osd-pg-log-trim-min 2 | |
164 | ceph tell osd.\* injectargs -- --osd-pg-log-trim-max 4 | |
165 | ceph tell osd.\* injectargs -- --osd_pg_log_dups_tracked 20 || return 1 | |
166 | ||
167 | # adding log entries, should only trim 4 and add one each time | |
168 | # dups should be trimmed to 1 | |
169 | rados -p test rm foo | |
170 | test_log_size $PGID 18 2 || return 1 | |
171 | rados -p test rm foo | |
172 | test_log_size $PGID 15 6 || return 1 | |
173 | rados -p test rm foo | |
174 | test_log_size $PGID 12 10 || return 1 | |
175 | rados -p test rm foo | |
176 | test_log_size $PGID 9 14 || return 1 | |
177 | rados -p test rm foo | |
178 | test_log_size $PGID 6 18 || return 1 | |
179 | rados -p test rm foo | |
180 | test_log_size $PGID 3 20 || return 1 | |
181 | ||
182 | # below trim_min | |
183 | rados -p test rm foo | |
184 | test_log_size $PGID 4 20 || return 1 | |
185 | rados -p test rm foo | |
186 | test_log_size $PGID 3 20 || return 1 | |
187 | rados -p test rm foo | |
188 | test_log_size $PGID 4 20 || return 1 | |
189 | rados -p test rm foo | |
190 | test_log_size $PGID 3 20 || return 1 | |
191 | } | |
192 | ||
94b18763 FG |
193 | main repro-long-log "$@" |
194 | ||
195 | # Local Variables: | |
196 | # compile-command: "cd ../.. ; make -j4 && ../qa/run-standalone.sh repro_long_log.sh" | |
197 | # End: |