]> git.proxmox.com Git - ceph.git/blame - ceph/qa/workunits/rados/test_cache_pool.sh
update sources to v12.1.2
[ceph.git] / ceph / qa / workunits / rados / test_cache_pool.sh
CommitLineData
7c673cae
FG
1#!/bin/bash -x
2
3set -e
4
5expect_false()
6{
7 set -x
8 if "$@"; then return 1; else return 0; fi
9}
10
11# create pools, set up tier relationship
12ceph osd pool create base_pool 2
c07f9fc5 13ceph osd pool application enable base_pool rados
7c673cae
FG
14ceph osd pool create partial_wrong 2
15ceph osd pool create wrong_cache 2
16ceph osd tier add base_pool partial_wrong
17ceph osd tier add base_pool wrong_cache
18
19# populate base_pool with some data
20echo "foo" > foo.txt
21echo "bar" > bar.txt
22echo "baz" > baz.txt
23rados -p base_pool put fooobj foo.txt
24rados -p base_pool put barobj bar.txt
25# fill in wrong_cache backwards so we can tell we read from it
26rados -p wrong_cache put fooobj bar.txt
27rados -p wrong_cache put barobj foo.txt
28# partial_wrong gets barobj backwards so we can check promote and non-promote
29rados -p partial_wrong put barobj foo.txt
30
31# get the objects back before setting a caching pool
32rados -p base_pool get fooobj tmp.txt
33diff -q tmp.txt foo.txt
34rados -p base_pool get barobj tmp.txt
35diff -q tmp.txt bar.txt
36
37# set up redirect and make sure we get backwards results
38ceph osd tier set-overlay base_pool wrong_cache
39ceph osd tier cache-mode wrong_cache writeback
40rados -p base_pool get fooobj tmp.txt
41diff -q tmp.txt bar.txt
42rados -p base_pool get barobj tmp.txt
43diff -q tmp.txt foo.txt
44
45# switch cache pools and make sure we're doing promote
46ceph osd tier remove-overlay base_pool
47ceph osd tier set-overlay base_pool partial_wrong
48ceph osd tier cache-mode partial_wrong writeback
49rados -p base_pool get fooobj tmp.txt
50diff -q tmp.txt foo.txt # hurray, it promoted!
51rados -p base_pool get barobj tmp.txt
52diff -q tmp.txt foo.txt # yep, we read partial_wrong's local object!
53
54# try a nonexistent object and make sure we get an error
55expect_false rados -p base_pool get bazobj tmp.txt
56
57# drop the cache entirely and make sure contents are still the same
58ceph osd tier remove-overlay base_pool
59rados -p base_pool get fooobj tmp.txt
60diff -q tmp.txt foo.txt
61rados -p base_pool get barobj tmp.txt
62diff -q tmp.txt bar.txt
63
64# create an empty cache pool and make sure it has objects after reading
65ceph osd pool create empty_cache 2
66
67touch empty.txt
68rados -p empty_cache ls > tmp.txt
69diff -q tmp.txt empty.txt
70
71ceph osd tier add base_pool empty_cache
72ceph osd tier set-overlay base_pool empty_cache
73ceph osd tier cache-mode empty_cache writeback
74rados -p base_pool get fooobj tmp.txt
75rados -p base_pool get barobj tmp.txt
76expect_false rados -p base_pool get bazobj tmp.txt
77
78rados -p empty_cache ls > tmp.txt
79expect_false diff -q tmp.txt empty.txt
80
81# cleanup
82ceph osd tier remove-overlay base_pool
83ceph osd tier remove base_pool wrong_cache
84ceph osd tier remove base_pool partial_wrong
85ceph osd tier remove base_pool empty_cache
86ceph osd pool delete base_pool base_pool --yes-i-really-really-mean-it
87ceph osd pool delete empty_cache empty_cache --yes-i-really-really-mean-it
88ceph osd pool delete wrong_cache wrong_cache --yes-i-really-really-mean-it
89ceph osd pool delete partial_wrong partial_wrong --yes-i-really-really-mean-it
90
91## set of base, cache
92ceph osd pool create base 8
c07f9fc5 93ceph osd pool application enable base rados
7c673cae
FG
94ceph osd pool create cache 8
95
96ceph osd tier add base cache
97ceph osd tier cache-mode cache writeback
98ceph osd tier set-overlay base cache
99
100# cache-flush, cache-evict
101rados -p base put foo /etc/passwd
102expect_false rados -p base cache-evict foo
103expect_false rados -p base cache-flush foo
104expect_false rados -p cache cache-evict foo
105rados -p cache cache-flush foo
106rados -p cache cache-evict foo
107rados -p cache ls - | wc -l | grep 0
108
109# cache-try-flush, cache-evict
110rados -p base put foo /etc/passwd
111expect_false rados -p base cache-evict foo
112expect_false rados -p base cache-flush foo
113expect_false rados -p cache cache-evict foo
114rados -p cache cache-try-flush foo
115rados -p cache cache-evict foo
116rados -p cache ls - | wc -l | grep 0
117
118# cache-flush-evict-all
119rados -p base put bar /etc/passwd
120rados -p cache ls - | wc -l | grep 1
121expect_false rados -p base cache-flush-evict-all
122rados -p cache cache-flush-evict-all
123rados -p cache ls - | wc -l | grep 0
124
125# cache-try-flush-evict-all
126rados -p base put bar /etc/passwd
127rados -p cache ls - | wc -l | grep 1
128expect_false rados -p base cache-flush-evict-all
129rados -p cache cache-try-flush-evict-all
130rados -p cache ls - | wc -l | grep 0
131
132# cache flush/evit when clone objects exist
133rados -p base put testclone /etc/passwd
134rados -p cache ls - | wc -l | grep 1
135ceph osd pool mksnap base snap
136rados -p base put testclone /etc/hosts
137rados -p cache cache-flush-evict-all
138rados -p cache ls - | wc -l | grep 0
139
140ceph osd tier cache-mode cache forward --yes-i-really-mean-it
141rados -p base -s snap get testclone testclone.txt
142diff -q testclone.txt /etc/passwd
143rados -p base get testclone testclone.txt
144diff -q testclone.txt /etc/hosts
145
146# test --with-clones option
147ceph osd tier cache-mode cache writeback
148rados -p base put testclone2 /etc/passwd
149rados -p cache ls - | wc -l | grep 1
150ceph osd pool mksnap base snap1
151rados -p base put testclone2 /etc/hosts
152expect_false rados -p cache cache-flush testclone2
153rados -p cache cache-flush testclone2 --with-clones
154expect_false rados -p cache cache-evict testclone2
155rados -p cache cache-evict testclone2 --with-clones
156rados -p cache ls - | wc -l | grep 0
157
158rados -p base -s snap1 get testclone2 testclone2.txt
159diff -q testclone2.txt /etc/passwd
160rados -p base get testclone2 testclone2.txt
161diff -q testclone2.txt /etc/hosts
162
163# cleanup
164ceph osd tier remove-overlay base
165ceph osd tier remove base cache
166
167ceph osd pool delete cache cache --yes-i-really-really-mean-it
168ceph osd pool delete base base --yes-i-really-really-mean-it
169
170echo OK