Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / qa / workunits / mon / rbd_snaps_ops.sh
1 #!/bin/bash
2
3 # attempt to trigger #6047
4
5
6 cmd_no=0
7 expect()
8 {
9   cmd_no=$(($cmd_no+1))
10   cmd="$1"
11   expected=$2
12   echo "[$cmd_no] $cmd"
13   eval  $cmd
14   ret=$?
15   if [[ $ret -ne $expected ]]; then
16     echo "[$cmd_no] unexpected return '$ret', expected '$expected'"
17     exit 1
18   fi
19 }
20
21 ceph osd pool delete test test --yes-i-really-really-mean-it || true
22 expect 'ceph osd pool create test 256 256' 0
23 expect 'rbd --pool=test pool init' 0
24 expect 'ceph osd pool mksnap test snapshot' 0
25 expect 'ceph osd pool rmsnap test snapshot' 0
26
27 expect 'rbd --pool=test --rbd_validate_pool=false create --size=102400 image' 0
28 expect 'rbd --pool=test snap create image@snapshot' 22
29
30 expect 'ceph osd pool delete test test --yes-i-really-really-mean-it' 0
31 expect 'ceph osd pool create test 256 256' 0
32 expect 'rbd --pool=test pool init' 0
33 expect 'rbd --pool=test create --size=102400 image' 0
34 expect 'rbd --pool=test snap create image@snapshot' 0
35 expect 'rbd --pool=test snap ls image' 0
36 expect 'rbd --pool=test snap rm image@snapshot' 0
37
38 expect 'ceph osd pool mksnap test snapshot' 22
39
40 expect 'ceph osd pool delete test test --yes-i-really-really-mean-it' 0
41
42 # reproduce 7210 and expect it to be fixed
43 # basically create such a scenario where we end up deleting what used to
44 # be an unmanaged snapshot from a not-unmanaged pool
45
46 ceph osd pool delete test-foo test-foo --yes-i-really-really-mean-it || true
47 expect 'rados mkpool test-foo' 0
48 expect 'rbd pool init test-foo'
49 expect 'rbd --pool test-foo create --size 1024 image' 0
50 expect 'rbd --pool test-foo snap create image@snapshot' 0
51
52 ceph osd pool delete test-bar test-bar --yes-i-really-really-mean-it || true
53 expect 'rados mkpool test-bar' 0
54 expect 'rbd pool init test-bar'
55 expect 'rados cppool test-foo test-bar --yes-i-really-mean-it' 0
56 expect 'rbd --pool test-bar snap rm image@snapshot' 95
57 expect 'ceph osd pool delete test-foo test-foo --yes-i-really-really-mean-it' 0
58 expect 'ceph osd pool delete test-bar test-bar --yes-i-really-really-mean-it' 0
59
60
61 echo OK