]> git.proxmox.com Git - ceph.git/blame - ceph/src/test/osd/safe-to-destroy.sh
import 15.2.0 Octopus source
[ceph.git] / ceph / src / test / osd / safe-to-destroy.sh
CommitLineData
11fdf7f2
TL
1#!/usr/bin/env bash
2
3source $CEPH_ROOT/qa/standalone/ceph-helpers.sh
4
5set -e
6
7function run() {
8 local dir=$1
9 shift
10
11 export CEPH_MON="127.0.0.1:$(get_unused_port)"
12 export CEPH_ARGS
13 CEPH_ARGS+="--fsid=$(uuidgen) --auth-supported=none "
14 CEPH_ARGS+="--mon-host=$CEPH_MON "
15 set -e
16
17 local funcs=${@:-$(set | sed -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')}
18 for func in $funcs ; do
19 setup $dir || return 1
20 $func $dir || return 1
21 teardown $dir || return 1
22 done
23}
24
25function TEST_safe_to_destroy() {
26 local dir=$1
27
28 run_mon $dir a
29 run_mgr $dir x
30 run_osd $dir 0
31 run_osd $dir 1
32 run_osd $dir 2
33 run_osd $dir 3
34
35 flush_pg_stats
36
37 ceph osd safe-to-destroy 0
38 ceph osd safe-to-destroy 1
39 ceph osd safe-to-destroy 2
40 ceph osd safe-to-destroy 3
41
42 ceph osd pool create foo 128
43 sleep 2
44 flush_pg_stats
45 wait_for_clean
46
9f95a23c 47 expect_failure $dir 'pgs currently' ceph osd safe-to-destroy 0
11fdf7f2
TL
48 expect_failure $dir 'pgs currently' ceph osd safe-to-destroy 1
49 expect_failure $dir 'pgs currently' ceph osd safe-to-destroy 2
50 expect_failure $dir 'pgs currently' ceph osd safe-to-destroy 3
51
52 ceph osd out 0
53 sleep 2
54 flush_pg_stats
55 wait_for_clean
56
57 ceph osd safe-to-destroy 0
58
59 # even osds without osd_stat are ok if all pgs are active+clean
60 id=`ceph osd create`
61 ceph osd safe-to-destroy $id
62}
63
64function TEST_ok_to_stop() {
65 local dir=$1
66
67 run_mon $dir a
68 run_mgr $dir x
69 run_osd $dir 0
70 run_osd $dir 1
71 run_osd $dir 2
72 run_osd $dir 3
73
74 ceph osd pool create foo 128
75 ceph osd pool set foo size 3
76 ceph osd pool set foo min_size 2
77 sleep 1
78 flush_pg_stats
79 wait_for_clean
80
81 ceph osd ok-to-stop 0
82 ceph osd ok-to-stop 1
83 ceph osd ok-to-stop 2
84 ceph osd ok-to-stop 3
85 expect_failure $dir degraded ceph osd ok-to-stop 0 1
86
87 ceph osd pool set foo min_size 1
88 sleep 1
89 flush_pg_stats
90 wait_for_clean
91 ceph osd ok-to-stop 0 1
92 ceph osd ok-to-stop 1 2
93 ceph osd ok-to-stop 2 3
94 ceph osd ok-to-stop 3 4
95 expect_failure $dir degraded ceph osd ok-to-stop 0 1 2
96 expect_failure $dir degraded ceph osd ok-to-stop 0 1 2 3
97}
98
99main safe-to-destroy "$@"