]> git.proxmox.com Git - ceph.git/blob - ceph/qa/workunits/mon/test_noautoscale_flag.sh
e1a45a4d87a5e67047e7127a09edead6a5529cd6
[ceph.git] / ceph / qa / workunits / mon / test_noautoscale_flag.sh
1 #!/bin/bash -ex
2
3 unset CEPH_CLI_TEST_DUP_COMMAND
4
5 NUM_POOLS=$(ceph osd pool ls | wc -l)
6
7 if [ "$NUM_POOLS" -gt 0 ]; then
8 echo "test requires no preexisting pools"
9 exit 1
10 fi
11
12 ceph osd pool set noautoscale
13
14 ceph osd pool create pool_a
15
16 echo 'pool_a autoscale_mode:' $(ceph osd pool autoscale-status | grep pool_a | grep -o -m 1 'on\|off')
17
18 NUM_POOLS=$[NUM_POOLS+1]
19
20 sleep 2
21
22 # Count the number of Pools with AUTOSCALE `off`
23
24 RESULT1=$(ceph osd pool autoscale-status | grep -oe 'off' | wc -l)
25
26 # number of Pools with AUTOSCALE `off` should equal to $NUM_POOLS
27
28 test "$RESULT1" -eq "$NUM_POOLS"
29
30 ceph osd pool unset noautoscale
31
32 echo $(ceph osd pool get noautoscale)
33
34
35 ceph osd pool create pool_b
36
37 echo 'pool_a autoscale_mode:' $(ceph osd pool autoscale-status | grep pool_a | grep -o -m 1 'on\|off')
38
39 echo 'pool_b autoscale_mode:' $(ceph osd pool autoscale-status | grep pool_b | grep -o -m 1 'on\|off')
40
41
42 NUM_POOLS=$[NUM_POOLS+1]
43
44 sleep 2
45
46 # Count the number of Pools with AUTOSCALE `on`
47
48 RESULT2=$(ceph osd pool autoscale-status | grep -oe 'on' | wc -l)
49
50 # number of Pools with AUTOSCALE `on` should equal to 3
51
52 test "$RESULT2" -eq "$[NUM_POOLS-1]"
53
54 ceph osd pool set noautoscale
55
56 ceph osd pool create pool_c
57
58 echo 'pool_a autoscale_mode:' $(ceph osd pool autoscale-status | grep pool_a | grep -o -m 1 'on\|off')
59
60 echo 'pool_b autoscale_mode:' $(ceph osd pool autoscale-status | grep pool_b | grep -o -m 1 'on\|off')
61
62 echo 'pool_c autoscale_mode:' $(ceph osd pool autoscale-status | grep pool_c | grep -o -m 1 'on\|off')
63
64
65 NUM_POOLS=$[NUM_POOLS+1]
66
67 sleep 2
68
69 # Count the number of Pools with AUTOSCALE `off`
70
71 RESULT3=$(ceph osd pool autoscale-status | grep -oe 'off' | wc -l)
72
73 # number of Pools with AUTOSCALE `off` should equal to 4
74
75 test "$RESULT3" -eq "$NUM_POOLS"
76
77 # Now we test if we retain individual pool state of autoscale mode
78 # when we set and unset the noautoscale flag.
79
80 ceph osd pool unset noautoscale
81
82 ceph osd pool set pool_a pg_autoscale_mode on
83
84 ceph osd pool set pool_b pg_autoscale_mode warn
85
86 ceph osd pool set noautoscale
87
88 ceph osd pool unset noautoscale
89
90 RESULT4=$(ceph osd pool autoscale-status | grep pool_a | grep -o -m 1 'on\|off\|warn')
91 RESULT5=$(ceph osd pool autoscale-status | grep pool_b | grep -o -m 1 'on\|off\|warn')
92 RESULT6=$(ceph osd pool autoscale-status | grep pool_c | grep -o -m 1 'on\|off\|warn')
93
94 test "$RESULT4" == 'on'
95 test "$RESULT5" == 'warn'
96 test "$RESULT6" == 'off'
97
98 ceph osd pool rm pool_a pool_a --yes-i-really-really-mean-it
99
100 ceph osd pool rm pool_b pool_b --yes-i-really-really-mean-it
101
102 ceph osd pool rm pool_c pool_c --yes-i-really-really-mean-it
103
104 echo OK