]>
git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/ocf/tests/functional/tests/security/test_management_fuzzy.py
2 # Copyright(c) 2019 Intel Corporation
3 # SPDX-License-Identifier: BSD-3-Clause-Clear
8 from pyocf
.types
.cache
import Cache
, CacheMode
, CleaningPolicy
, AlruParams
, AcpParams
9 from pyocf
.types
.core
import Core
10 from pyocf
.types
.volume
import Volume
11 from pyocf
.utils
import Size
as S
12 from tests
.utils
import generate_random_numbers
13 from pyocf
.types
.shared
import OcfError
, CacheLineSize
, SeqCutOffPolicy
20 @pytest.mark
.parametrize("cm", CacheMode
)
21 @pytest.mark
.parametrize("cls", CacheLineSize
)
23 def test_neg_change_cache_mode(pyocf_ctx
, cm
, cls
):
25 Test whether it is possible to change cache mode to invalid value.
26 :param pyocf_ctx: basic pyocf context fixture
27 :param cm: cache mode we start with
28 :param cls: cache line size we start with
31 cache_device
= Volume(S
.from_MiB(30))
32 cache
= Cache
.start_on_device(
33 cache_device
, cache_mode
=cm
, cache_line_size
=cls
36 # Change cache mode to invalid one and check if failed
37 for i
in generate_random_numbers(c_uint32
):
38 if i
in [item
.value
for item
in CacheMode
]:
40 with pytest
.raises(OcfError
, match
="Error changing cache mode"):
41 cache
.change_cache_mode(i
)
44 @pytest.mark
.parametrize("cm", CacheMode
)
45 @pytest.mark
.parametrize("cls", CacheLineSize
)
47 def test_neg_set_cleaning_policy(pyocf_ctx
, cm
, cls
):
49 Test whether it is possible to change cleaning policy to invalid value
50 :param pyocf_ctx: basic pyocf context fixture
51 :param cm: cache mode we start with
52 :param cls: cache line size we start with
56 cache_device
= Volume(S
.from_MiB(30))
57 cache
= Cache
.start_on_device(
58 cache_device
, cache_mode
=cm
, cache_line_size
=cls
61 # Set cleaning policy to invalid one and check if failed
62 for i
in generate_random_numbers(c_uint32
):
63 if i
in [item
.value
for item
in CleaningPolicy
]:
65 with pytest
.raises(OcfError
, match
="Error changing cleaning policy"):
66 cache
.set_cleaning_policy(i
)
69 @pytest.mark
.parametrize("cm", CacheMode
)
70 @pytest.mark
.parametrize("cls", CacheLineSize
)
72 def test_neg_attach_cls(pyocf_ctx
, cm
, cls
):
74 Test whether it is possible to change cache line size to
75 invalid value while attaching cache device
76 :param pyocf_ctx: basic pyocf context fixture
77 :param cm: cache mode we start with
78 :param cls: cache line size we start with
82 cache_device
= Volume(S
.from_MiB(30))
83 cache
= Cache(owner
=cache_device
.owner
, cache_mode
=cm
, cache_line_size
=cls
)
86 # Check whether it is possible to attach cache device with invalid cache line size
87 for i
in generate_random_numbers(c_uint64
):
88 if i
in [item
.value
for item
in CacheLineSize
]:
90 with pytest
.raises(OcfError
, match
="Attaching cache device failed"):
91 cache
.attach_device(cache_device
, cache_line_size
=i
)
94 @pytest.mark
.parametrize("cm", CacheMode
)
95 @pytest.mark
.parametrize("cls", CacheLineSize
)
97 def test_neg_cache_set_seq_cut_off_policy(pyocf_ctx
, cm
, cls
):
99 Test whether it is possible to change cache seq cut-off policy to invalid value
100 :param pyocf_ctx: basic pyocf context fixture
101 :param cm: cache mode we start with
102 :param cls: cache line size we start with
106 cache_device
= Volume(S
.from_MiB(30))
107 cache
= Cache
.start_on_device(
108 cache_device
, cache_mode
=cm
, cache_line_size
=cls
111 # Create 2 core devices
112 core_device1
= Volume(S
.from_MiB(10))
113 core1
= Core
.using_device(core_device1
)
114 core_device2
= Volume(S
.from_MiB(10))
115 core2
= Core
.using_device(core_device2
)
118 cache
.add_core(core1
)
119 cache
.add_core(core2
)
121 # Change cache seq cut off policy to invalid one and check if failed
122 for i
in generate_random_numbers(c_uint32
):
123 if i
in [item
.value
for item
in SeqCutOffPolicy
]:
125 with pytest
.raises(OcfError
, match
="Error setting cache seq cut off policy"):
126 cache
.set_seq_cut_off_policy(i
)
129 @pytest.mark
.parametrize("cm", CacheMode
)
130 @pytest.mark
.parametrize("cls", CacheLineSize
)
131 @pytest.mark
.security
132 def test_neg_core_set_seq_cut_off_policy(pyocf_ctx
, cm
, cls
):
134 Test whether it is possible to change core seq cut-off policy to invalid value
135 :param pyocf_ctx: basic pyocf context fixture
136 :param cm: cache mode we start with
137 :param cls: cache line size we start with
141 cache_device
= Volume(S
.from_MiB(30))
142 cache
= Cache
.start_on_device(
143 cache_device
, cache_mode
=cm
, cache_line_size
=cls
147 core_device
= Volume(S
.from_MiB(10))
148 core
= Core
.using_device(core_device
)
153 # Change core seq cut off policy to invalid one and check if failed
154 for i
in generate_random_numbers(c_uint32
):
155 if i
in [item
.value
for item
in SeqCutOffPolicy
]:
157 with pytest
.raises(OcfError
, match
="Error setting core seq cut off policy"):
158 core
.set_seq_cut_off_policy(i
)
161 @pytest.mark
.parametrize("cm", CacheMode
)
162 @pytest.mark
.parametrize("cls", CacheLineSize
)
163 @pytest.mark
.security
164 def test_neg_set_alru_param(pyocf_ctx
, cm
, cls
):
166 Test whether it is possible to set invalid param for alru cleaning policy
167 :param pyocf_ctx: basic pyocf context fixture
168 :param cm: cache mode we start with
169 :param cls: cache line size we start with
173 cache_device
= Volume(S
.from_MiB(30))
174 cache
= Cache
.start_on_device(
175 cache_device
, cache_mode
=cm
, cache_line_size
=cls
178 # Change invalid alru param and check if failed
179 for i
in generate_random_numbers(c_uint32
):
180 if i
in [item
.value
for item
in AlruParams
]:
182 with pytest
.raises(OcfError
, match
="Error setting cleaning policy param"):
183 cache
.set_cleaning_policy_param(CleaningPolicy
.ALRU
, i
, 1)
186 @pytest.mark
.parametrize("cm", CacheMode
)
187 @pytest.mark
.parametrize("cls", CacheLineSize
)
188 @pytest.mark
.security
189 def test_neg_set_acp_param(pyocf_ctx
, cm
, cls
):
191 Test whether it is possible to set invalid param for acp cleaning policy
192 :param pyocf_ctx: basic pyocf context fixture
193 :param cm: cache mode we start with
194 :param cls: cache line size we start with
198 cache_device
= Volume(S
.from_MiB(30))
199 cache
= Cache
.start_on_device(
200 cache_device
, cache_mode
=cm
, cache_line_size
=cls
203 # Change invalid acp param and check if failed
204 for i
in generate_random_numbers(c_uint32
):
205 if i
in [item
.value
for item
in AcpParams
]:
207 with pytest
.raises(OcfError
, match
="Error setting cleaning policy param"):
208 cache
.set_cleaning_policy_param(CleaningPolicy
.ALRU
, i
, 1)