]>
Commit | Line | Data |
---|---|---|
11fdf7f2 TL |
1 | import io |
2 | import time | |
3 | import sys | |
4 | import random | |
5 | import signal | |
6 | import subprocess | |
7 | import pprint | |
8 | import socket | |
9 | import threading | |
10 | import os | |
11 | ||
12 | from errno import ESRCH | |
13 | from os import kill, path, unlink, path, listdir, remove | |
14 | from rpc_commands_lib import Commands_Rpc | |
15 | from time import sleep | |
16 | from uuid import uuid4 | |
17 | ||
18 | ||
19 | MEGABYTE = 1024 * 1024 | |
20 | ||
21 | ||
22 | current_fio_pid = -1 | |
23 | ||
9f95a23c TL |
24 | # ## Objective |
25 | # The purpose of these tests is to verify the possibility of using lvol configuration in SPDK. | |
26 | # | |
27 | # ## Methodology | |
28 | # Configuration in test is to be done using example stub application. | |
29 | # All management is done using RPC calls, including logical volumes management. | |
30 | # All tests are performed using malloc backends. | |
31 | # One exception to malloc backends are tests for logical volume | |
32 | # tasting - these require persistent merory like NVMe backend. | |
33 | # | |
34 | # Tests will be executed as scenarios - sets of smaller test step | |
35 | # in which return codes from RPC calls is validated. | |
36 | # Some configuration calls may also be validated by use of | |
37 | # "get_*" RPC calls, which provide additional information for verifying | |
38 | # results. | |
39 | # | |
40 | # Tests with thin provisioned lvol bdevs, snapshots and clones are using nbd devices. | |
41 | # Before writing/reading to lvol bdev, bdev is installed with rpc start_nbd_disk. | |
42 | # After finishing writing/reading, rpc stop_nbd_disk is used. | |
43 | ||
11fdf7f2 TL |
44 | |
45 | def is_process_alive(pid): | |
46 | try: | |
47 | os.kill(pid, 0) | |
48 | except Exception as e: | |
49 | return 1 | |
50 | ||
51 | return 0 | |
52 | ||
53 | ||
54 | def get_fio_cmd(nbd_disk, offset, size, rw, pattern, extra_params=""): | |
55 | fio_template = "fio --name=fio_test --filename=%(file)s --offset=%(offset)s --size=%(size)s"\ | |
56 | " --rw=%(rw)s --direct=1 %(extra_params)s %(pattern)s" | |
57 | pattern_template = "" | |
58 | if pattern: | |
59 | pattern_template = "--do_verify=1 --verify=pattern --verify_pattern=%s"\ | |
60 | " --verify_state_save=0" % pattern | |
61 | fio_cmd = fio_template % {"file": nbd_disk, "offset": offset, "size": size, | |
62 | "rw": rw, "pattern": pattern_template, | |
63 | "extra_params": extra_params} | |
64 | ||
65 | return fio_cmd | |
66 | ||
67 | ||
68 | def run_fio(fio_cmd, expected_ret_value): | |
69 | global current_fio_pid | |
70 | try: | |
71 | proc = subprocess.Popen([fio_cmd], shell=True) | |
72 | current_fio_pid = proc.pid | |
73 | proc.wait() | |
74 | rv = proc.returncode | |
75 | except Exception as e: | |
76 | print("ERROR: Fio test ended with unexpected exception.") | |
77 | rv = 1 | |
78 | if expected_ret_value == rv: | |
79 | return 0 | |
80 | ||
81 | if rv == 0: | |
82 | print("ERROR: Fio test ended with unexpected success") | |
83 | else: | |
84 | print("ERROR: Fio test ended with unexpected failure") | |
85 | return 1 | |
86 | ||
87 | ||
88 | class FioThread(threading.Thread): | |
89 | def __init__(self, nbd_disk, offset, size, rw, pattern, expected_ret_value, | |
90 | extra_params=""): | |
91 | super(FioThread, self).__init__() | |
92 | self.fio_cmd = get_fio_cmd(nbd_disk, offset, size, rw, pattern, | |
93 | extra_params=extra_params) | |
94 | self.rv = 1 | |
95 | self.expected_ret_value = expected_ret_value | |
96 | ||
97 | def run(self): | |
98 | print("INFO: Starting fio") | |
99 | self.rv = run_fio(self.fio_cmd, self.expected_ret_value) | |
100 | print("INFO: Fio test finished") | |
101 | ||
102 | ||
103 | def test_counter(): | |
104 | ''' | |
105 | :return: the number of tests | |
106 | ''' | |
107 | return ['test_case' in i for i in dir(TestCases)].count(True) | |
108 | ||
109 | ||
110 | def case_message(func): | |
111 | def inner(*args, **kwargs): | |
112 | test_name = { | |
9f95a23c | 113 | # construct_lvol_store - positive tests |
11fdf7f2 | 114 | 1: 'construct_lvs_positive', |
9f95a23c | 115 | # construct_lvol_bdev - positive tests |
11fdf7f2 TL |
116 | 50: 'construct_logical_volume_positive', |
117 | 51: 'construct_multi_logical_volumes_positive', | |
118 | 52: 'construct_lvol_bdev_using_name_positive', | |
119 | 53: 'construct_lvol_bdev_duplicate_names_positive', | |
9f95a23c | 120 | # construct_lvol_bdev - negative tests |
11fdf7f2 TL |
121 | 100: 'construct_logical_volume_nonexistent_lvs_uuid', |
122 | 101: 'construct_lvol_bdev_on_full_lvol_store', | |
123 | 102: 'construct_lvol_bdev_name_twice', | |
9f95a23c | 124 | # resize_lvol_store - positive tests |
11fdf7f2 | 125 | 150: 'resize_lvol_bdev_positive', |
9f95a23c | 126 | # resize lvol store - negative tests |
11fdf7f2 TL |
127 | 200: 'resize_logical_volume_nonexistent_logical_volume', |
128 | 201: 'resize_logical_volume_with_size_out_of_range', | |
9f95a23c | 129 | # destroy_lvol_store - positive tests |
11fdf7f2 TL |
130 | 250: 'destroy_lvol_store_positive', |
131 | 251: 'destroy_lvol_store_use_name_positive', | |
132 | 252: 'destroy_lvol_store_with_lvol_bdev_positive', | |
133 | 253: 'destroy_multi_logical_volumes_positive', | |
134 | 254: 'destroy_after_resize_lvol_bdev_positive', | |
135 | 255: 'delete_lvol_store_persistent_positive', | |
9f95a23c | 136 | # destroy_lvol_store - negative tests |
11fdf7f2 TL |
137 | 300: 'destroy_lvol_store_nonexistent_lvs_uuid', |
138 | 301: 'delete_lvol_store_underlying_bdev', | |
9f95a23c | 139 | # construct_lvol_store - negative tests |
11fdf7f2 TL |
140 | 450: 'construct_lvs_nonexistent_bdev', |
141 | 451: 'construct_lvs_on_bdev_twice', | |
142 | 452: 'construct_lvs_name_twice', | |
9f95a23c | 143 | # nested construct_lvol_bdev - test negative |
11fdf7f2 TL |
144 | 500: 'nested_construct_lvol_bdev_on_full_lvol_store', |
145 | 550: 'delete_bdev_positive', | |
146 | 551: 'delete_lvol_bdev', | |
147 | 552: 'destroy_lvol_store_with_clones', | |
148 | 553: 'unregister_lvol_bdev', | |
149 | 600: 'construct_lvol_store_with_cluster_size_max', | |
150 | 601: 'construct_lvol_store_with_cluster_size_min', | |
9f95a23c TL |
151 | 602: 'construct_lvol_store_with_all_clear_methods', |
152 | # Provisioning | |
11fdf7f2 TL |
153 | 650: 'thin_provisioning_check_space', |
154 | 651: 'thin_provisioning_read_empty_bdev', | |
9f95a23c | 155 | 652: 'thin_provisioning_data_integrity_test', |
11fdf7f2 TL |
156 | 653: 'thin_provisioning_resize', |
157 | 654: 'thin_overprovisioning', | |
158 | 655: 'thin_provisioning_filling_disks_less_than_lvs_size', | |
9f95a23c | 159 | # logical volume tasting tests |
11fdf7f2 TL |
160 | 700: 'tasting_positive', |
161 | 701: 'tasting_lvol_store_positive', | |
162 | 702: 'tasting_positive_with_different_lvol_store_cluster_size', | |
9f95a23c | 163 | # snapshot and clone |
11fdf7f2 TL |
164 | 750: 'snapshot_readonly', |
165 | 751: 'snapshot_compare_with_lvol_bdev', | |
166 | 752: 'snapshot_during_io_traffic', | |
167 | 753: 'snapshot_of_snapshot', | |
168 | 754: 'clone_bdev_only', | |
169 | 755: 'clone_writing_clone', | |
170 | 756: 'clone_and_snapshot_consistency', | |
171 | 757: 'clone_inflate', | |
172 | 758: 'decouple_parent', | |
173 | 759: 'decouple_parent_rw', | |
9f95a23c TL |
174 | 760: 'set_read_only', |
175 | # logical volume rename tests | |
11fdf7f2 TL |
176 | 800: 'rename_positive', |
177 | 801: 'rename_lvs_nonexistent', | |
178 | 802: 'rename_lvs_EEXIST', | |
179 | 803: 'rename_lvol_bdev_nonexistent', | |
180 | 804: 'rename_lvol_bdev_EEXIST', | |
9f95a23c | 181 | # SIGTERM |
11fdf7f2 TL |
182 | 10000: 'SIGTERM', |
183 | } | |
184 | num = int(func.__name__.strip('test_case')[:]) | |
185 | print("************************************") | |
186 | print("START TEST CASE {name}".format(name=test_name[num])) | |
187 | print("************************************") | |
188 | fail_count = func(*args, **kwargs) | |
189 | print("************************************") | |
190 | if not fail_count: | |
191 | print("END TEST CASE {name} PASS".format(name=test_name[num])) | |
192 | else: | |
193 | print("END TEST CASE {name} FAIL".format(name=test_name[num])) | |
194 | print("************************************") | |
195 | return fail_count | |
196 | return inner | |
197 | ||
198 | ||
199 | class TestCases(object): | |
200 | ||
201 | def __init__(self, rpc_py, total_size, block_size, base_dir_path, app_path): | |
202 | self.c = Commands_Rpc(rpc_py) | |
203 | self.total_size = total_size | |
204 | self.block_size = block_size | |
205 | self.cluster_size = None | |
206 | self.path = base_dir_path | |
207 | self.app_path = app_path | |
208 | self.lvs_name = "lvs_test" | |
209 | self.lbd_name = "lbd_test" | |
210 | self.vhost_config_path = path.join(path.dirname(sys.argv[0]), 'vhost.conf') | |
211 | ||
212 | def _gen_lvs_uuid(self): | |
213 | return str(uuid4()) | |
214 | ||
215 | def _gen_lvb_uuid(self): | |
216 | return "_".join([str(uuid4()), str(random.randrange(9999999999))]) | |
217 | ||
218 | def compare_two_disks(self, disk1, disk2, expected_ret_value): | |
219 | cmp_cmd = "cmp %s %s" % (disk1, disk2) | |
220 | try: | |
221 | process = subprocess.check_output(cmp_cmd, stderr=subprocess.STDOUT, shell=True) | |
222 | rv = 0 | |
223 | except subprocess.CalledProcessError as ex: | |
224 | rv = 1 | |
225 | except Exception as e: | |
226 | print("ERROR: Cmp ended with unexpected exception.") | |
227 | rv = 1 | |
228 | ||
229 | if expected_ret_value == rv: | |
230 | return 0 | |
231 | elif rv == 0: | |
232 | print("ERROR: Cmp ended with unexpected success") | |
233 | else: | |
234 | print("ERROR: Cmp ended with unexpected failure") | |
235 | ||
236 | return 1 | |
237 | ||
238 | def run_fio_test(self, nbd_disk, offset, size, rw, pattern, expected_ret_value=0): | |
239 | fio_cmd = get_fio_cmd(nbd_disk, offset, size, rw, pattern) | |
240 | return run_fio(fio_cmd, expected_ret_value) | |
241 | ||
242 | def _stop_vhost(self, pid_path): | |
243 | with io.open(pid_path, 'r') as vhost_pid: | |
244 | pid = int(vhost_pid.readline()) | |
245 | if pid: | |
246 | try: | |
247 | kill(pid, signal.SIGTERM) | |
248 | for count in range(30): | |
249 | sleep(1) | |
250 | kill(pid, 0) | |
251 | except OSError as err: | |
252 | if err.errno == ESRCH: | |
253 | pass | |
254 | else: | |
255 | return 1 | |
256 | else: | |
257 | return 1 | |
258 | else: | |
259 | return 1 | |
260 | return 0 | |
261 | ||
262 | def _start_vhost(self, vhost_path, pid_path): | |
263 | subprocess.call("{app} -f " | |
264 | "{pid} &".format(app=vhost_path, | |
265 | pid=pid_path), shell=True) | |
266 | for timeo in range(10): | |
267 | if timeo == 9: | |
268 | print("ERROR: Timeout on waiting for app start") | |
269 | return 1 | |
270 | if not path.exists(pid_path): | |
271 | print("Info: Waiting for PID file...") | |
272 | sleep(1) | |
273 | continue | |
274 | else: | |
275 | break | |
276 | ||
277 | # Wait for RPC to open | |
278 | sock = socket.socket(socket.AF_UNIX) | |
279 | for timeo in range(30): | |
280 | if timeo == 29: | |
281 | print("ERROR: Timeout on waiting for RPC start") | |
282 | return 1 | |
283 | try: | |
284 | sock.connect("/var/tmp/spdk.sock") | |
285 | break | |
286 | except socket.error as e: | |
287 | print("Info: Waiting for RPC Unix socket...") | |
288 | sleep(1) | |
289 | continue | |
290 | else: | |
291 | sock.close() | |
292 | break | |
293 | ||
294 | with io.open(pid_path, 'r') as vhost_pid: | |
295 | pid = int(vhost_pid.readline()) | |
296 | if not pid: | |
297 | return 1 | |
298 | return 0 | |
299 | ||
300 | def get_lvs_size(self, lvs_name="lvs_test"): | |
301 | lvs = self.c.get_lvol_stores(lvs_name)[0] | |
302 | return int(int(lvs['free_clusters'] * lvs['cluster_size']) / MEGABYTE) | |
303 | ||
304 | def get_lvs_divided_size(self, split_num, lvs_name="lvs_test"): | |
305 | # Actual size of lvol bdevs on creation is rounded up to multiple of cluster size. | |
306 | # In order to avoid over provisioning, this function returns | |
307 | # lvol store size in MB divided by split_num - rounded down to multiple of cluster size." | |
308 | lvs = self.c.get_lvol_stores(lvs_name)[0] | |
309 | return int(int(lvs['free_clusters'] / split_num) * lvs['cluster_size'] / MEGABYTE) | |
310 | ||
311 | def get_lvs_cluster_size(self, lvs_name="lvs_test"): | |
312 | lvs = self.c.get_lvol_stores(lvs_name)[0] | |
313 | return int(int(lvs['cluster_size']) / MEGABYTE) | |
314 | ||
315 | # positive tests | |
316 | @case_message | |
317 | def test_case1(self): | |
9f95a23c TL |
318 | """ |
319 | construct_lvs_positive | |
320 | ||
321 | Positive test for constructing a new lvol store. | |
322 | Call construct_lvol_store with correct base bdev name. | |
323 | """ | |
324 | # Create malloc bdev | |
11fdf7f2 TL |
325 | base_name = self.c.construct_malloc_bdev(self.total_size, |
326 | self.block_size) | |
9f95a23c | 327 | # Construct_lvol_store on correct, exisitng malloc bdev |
11fdf7f2 TL |
328 | uuid_store = self.c.construct_lvol_store(base_name, |
329 | self.lvs_name) | |
9f95a23c | 330 | # Check correct uuid values in response get_lvol_stores command |
11fdf7f2 TL |
331 | fail_count = self.c.check_get_lvol_stores(base_name, uuid_store, |
332 | self.cluster_size) | |
333 | self.c.destroy_lvol_store(uuid_store) | |
334 | self.c.delete_malloc_bdev(base_name) | |
335 | if self.c.check_get_lvol_stores("", "", "") == 1: | |
336 | fail_count += 1 | |
9f95a23c TL |
337 | |
338 | # Expected result | |
339 | # - call successful, return code = 0, uuid printed to stdout | |
340 | # - get_lvol_stores: backend used for construct_lvol_store has uuid | |
341 | # field set with the same uuid as returned from RPC call | |
342 | # - no other operation fails | |
11fdf7f2 TL |
343 | return fail_count |
344 | ||
345 | @case_message | |
346 | def test_case50(self): | |
9f95a23c TL |
347 | """ |
348 | construct_logical_volume_positive | |
349 | ||
350 | Positive test for constructing a new logical volume. | |
351 | Call construct_lvol_bdev with correct lvol store UUID and size in MiB for this bdev | |
352 | """ | |
353 | # Create malloc bdev | |
11fdf7f2 TL |
354 | base_name = self.c.construct_malloc_bdev(self.total_size, |
355 | self.block_size) | |
9f95a23c | 356 | # Create lvol store on correct, exisitng malloc bdev |
11fdf7f2 TL |
357 | uuid_store = self.c.construct_lvol_store(base_name, |
358 | self.lvs_name) | |
9f95a23c | 359 | # Check correct uuid values in response get_lvol_stores command |
11fdf7f2 TL |
360 | fail_count = self.c.check_get_lvol_stores(base_name, uuid_store, |
361 | self.cluster_size) | |
362 | ||
363 | lvs_size = self.get_lvs_size() | |
9f95a23c | 364 | # Construct lvol bdev on correct lvs_uuid and size |
11fdf7f2 TL |
365 | uuid_bdev = self.c.construct_lvol_bdev(uuid_store, |
366 | self.lbd_name, | |
367 | lvs_size) | |
9f95a23c | 368 | # Check correct uuid values in response get_bdevs command |
11fdf7f2 TL |
369 | fail_count += self.c.check_get_bdevs_methods(uuid_bdev, |
370 | lvs_size) | |
371 | self.c.destroy_lvol_bdev(uuid_bdev) | |
372 | self.c.destroy_lvol_store(uuid_store) | |
373 | self.c.delete_malloc_bdev(base_name) | |
9f95a23c TL |
374 | |
375 | # Expected result: | |
376 | # - call successful, return code = 0 | |
377 | # - get_lvol_store: backend used for construct_lvol_bdev has name | |
378 | # field set with the same name as returned from RPC call for all repeat | |
379 | # - no other operation fails | |
11fdf7f2 TL |
380 | return fail_count |
381 | ||
382 | @case_message | |
383 | def test_case51(self): | |
9f95a23c TL |
384 | """ |
385 | construct_multi_logical_volumes_positive | |
386 | ||
387 | Positive test for constructing a multi logical volumes. | |
388 | Call construct_lvol_bdev with correct lvol store UUID and | |
389 | size is equal one quarter of the this bdev size. | |
390 | """ | |
391 | # Create malloc bdev | |
11fdf7f2 TL |
392 | base_name = self.c.construct_malloc_bdev(self.total_size, |
393 | self.block_size) | |
9f95a23c | 394 | # Construct lvol store on correct, exisitng malloc bdev |
11fdf7f2 TL |
395 | uuid_store = self.c.construct_lvol_store(base_name, |
396 | self.lvs_name) | |
9f95a23c | 397 | # Verify lvol store was created correctly |
11fdf7f2 TL |
398 | fail_count = self.c.check_get_lvol_stores(base_name, uuid_store, |
399 | self.cluster_size) | |
400 | size = self.get_lvs_divided_size(4) | |
401 | ||
9f95a23c TL |
402 | # Repeat two times: |
403 | # - construct four lvol bdevs with 25% size of lvs size | |
404 | # - verify if every lvol bdev was created correctly | |
405 | # - delete four lvol bdevs | |
11fdf7f2 TL |
406 | for j in range(2): |
407 | uuid_bdevs = [] | |
408 | for i in range(4): | |
409 | uuid_bdev = self.c.construct_lvol_bdev(uuid_store, | |
410 | self.lbd_name + str(i), | |
411 | size) | |
412 | uuid_bdevs.append(uuid_bdev) | |
413 | fail_count += self.c.check_get_bdevs_methods(uuid_bdev, size) | |
414 | ||
415 | for uuid_bdev in uuid_bdevs: | |
416 | self.c.destroy_lvol_bdev(uuid_bdev) | |
417 | ||
418 | self.c.destroy_lvol_store(uuid_store) | |
419 | self.c.delete_malloc_bdev(base_name) | |
9f95a23c TL |
420 | |
421 | # Expected result: | |
422 | # - calls successful, return code = 0 | |
423 | # - no other operation fails | |
11fdf7f2 TL |
424 | return fail_count |
425 | ||
426 | @case_message | |
427 | def test_case52(self): | |
9f95a23c TL |
428 | """ |
429 | construct_lvol_bdev_using_name_positive | |
430 | ||
431 | Positive test for constructing a logical volume using friendly names. | |
432 | Verify that logical volumes can be created by using a friendly name | |
433 | instead of uuid when referencing to lvol store. | |
434 | """ | |
435 | # Create malloc bdev | |
11fdf7f2 TL |
436 | base_name = self.c.construct_malloc_bdev(self.total_size, |
437 | self.block_size) | |
9f95a23c | 438 | # Construct lvol store |
11fdf7f2 TL |
439 | uuid_store = self.c.construct_lvol_store(base_name, |
440 | self.lvs_name) | |
9f95a23c | 441 | # Check correct uuid values in response get_lvol_stores command |
11fdf7f2 TL |
442 | fail_count = self.c.check_get_lvol_stores(base_name, uuid_store, |
443 | self.cluster_size) | |
444 | lvs_size = self.get_lvs_size() | |
9f95a23c TL |
445 | # Create logical volume on lvol store by using a friendly name |
446 | # as a reference | |
11fdf7f2 TL |
447 | uuid_bdev = self.c.construct_lvol_bdev(self.lvs_name, |
448 | self.lbd_name, | |
449 | lvs_size) | |
9f95a23c | 450 | # Verify logical volume was correctly created |
11fdf7f2 TL |
451 | fail_count += self.c.check_get_bdevs_methods(uuid_bdev, |
452 | lvs_size) | |
453 | ||
454 | fail_count += self.c.destroy_lvol_bdev(uuid_bdev) | |
455 | fail_count += self.c.destroy_lvol_store(uuid_store) | |
456 | fail_count += self.c.delete_malloc_bdev(base_name) | |
9f95a23c TL |
457 | |
458 | # Expected result: | |
459 | # - calls successful, return code = 0 | |
460 | # - no other operation fails | |
11fdf7f2 TL |
461 | return fail_count |
462 | ||
463 | @case_message | |
464 | def test_case53(self): | |
9f95a23c TL |
465 | """ |
466 | construct_lvol_bdev_duplicate_names_positive | |
467 | ||
468 | Positive test for constructing a logical volumes using friendly names. | |
469 | Verify that logical volumes can use the same argument for friendly names | |
470 | if they are created on separate logical volume stores. | |
471 | """ | |
472 | # Construct two malloc bdevs | |
11fdf7f2 TL |
473 | base_name_1 = self.c.construct_malloc_bdev(self.total_size, |
474 | self.block_size) | |
475 | base_name_2 = self.c.construct_malloc_bdev(self.total_size, | |
476 | self.block_size) | |
9f95a23c | 477 | # Create logical volume stores on created malloc bdevs |
11fdf7f2 TL |
478 | uuid_store_1 = self.c.construct_lvol_store(base_name_1, |
479 | self.lvs_name + "1") | |
480 | uuid_store_2 = self.c.construct_lvol_store(base_name_2, | |
481 | self.lvs_name + "2") | |
9f95a23c | 482 | # Verify stores were created correctly |
11fdf7f2 TL |
483 | fail_count = self.c.check_get_lvol_stores(base_name_1, uuid_store_1, |
484 | self.cluster_size) | |
485 | fail_count = self.c.check_get_lvol_stores(base_name_2, uuid_store_2, | |
486 | self.cluster_size) | |
487 | ||
488 | lvs_size = self.get_lvs_size(self.lvs_name + "1") | |
9f95a23c | 489 | # Create logical volume on first lvol store |
11fdf7f2 TL |
490 | uuid_bdev_1 = self.c.construct_lvol_bdev(uuid_store_1, |
491 | self.lbd_name, | |
492 | lvs_size) | |
9f95a23c TL |
493 | # Using the same friendly name argument create logical volume on second |
494 | # lvol store | |
11fdf7f2 TL |
495 | uuid_bdev_2 = self.c.construct_lvol_bdev(uuid_store_2, |
496 | self.lbd_name, | |
497 | lvs_size) | |
9f95a23c | 498 | # Verify two lvol bdevs were correctly created |
11fdf7f2 TL |
499 | fail_count += self.c.check_get_bdevs_methods(uuid_bdev_1, lvs_size) |
500 | fail_count += self.c.check_get_bdevs_methods(uuid_bdev_2, lvs_size) | |
501 | ||
502 | fail_count += self.c.destroy_lvol_bdev(uuid_bdev_1) | |
503 | fail_count += self.c.destroy_lvol_bdev(uuid_bdev_2) | |
504 | fail_count += self.c.destroy_lvol_store(uuid_store_1) | |
505 | fail_count += self.c.destroy_lvol_store(uuid_store_2) | |
506 | fail_count += self.c.delete_malloc_bdev(base_name_1) | |
507 | fail_count += self.c.delete_malloc_bdev(base_name_2) | |
9f95a23c TL |
508 | |
509 | # Expected result: | |
510 | # - calls successful, return code = 0 | |
511 | # - no other operation fails | |
11fdf7f2 TL |
512 | return fail_count |
513 | ||
514 | @case_message | |
515 | def test_case100(self): | |
9f95a23c TL |
516 | """ |
517 | construct_logical_volume_nonexistent_lvs_uuid | |
518 | ||
519 | Negative test for constructing a new logical_volume. | |
520 | Call construct_lvol_bdev with lvs_uuid which does not | |
521 | exist in configuration. | |
522 | """ | |
11fdf7f2 | 523 | fail_count = 0 |
9f95a23c | 524 | # Try to call construct_lvol_bdev with lvs_uuid which does not exist |
11fdf7f2 TL |
525 | if self.c.construct_lvol_bdev(self._gen_lvs_uuid(), |
526 | self.lbd_name, | |
527 | 32) == 0: | |
528 | fail_count += 1 | |
9f95a23c TL |
529 | |
530 | # Expected result: | |
531 | # - return code != 0 | |
532 | # - ENODEV response printed to stdout | |
11fdf7f2 TL |
533 | return fail_count |
534 | ||
535 | @case_message | |
536 | def test_case101(self): | |
9f95a23c TL |
537 | """ |
538 | construct_lvol_bdev_on_full_lvol_store | |
539 | ||
540 | Negative test for constructing a new lvol bdev. | |
541 | Call construct_lvol_bdev on a full lvol store. | |
542 | """ | |
543 | # Create malloc bdev | |
11fdf7f2 TL |
544 | base_name = self.c.construct_malloc_bdev(self.total_size, |
545 | self.block_size) | |
9f95a23c | 546 | # Create logical volume store on malloc bdev |
11fdf7f2 TL |
547 | uuid_store = self.c.construct_lvol_store(base_name, |
548 | self.lvs_name) | |
9f95a23c | 549 | # Check correct uuid values in response from get_lvol_stores command |
11fdf7f2 TL |
550 | fail_count = self.c.check_get_lvol_stores(base_name, uuid_store, |
551 | self.cluster_size) | |
552 | lvs_size = self.get_lvs_size() | |
9f95a23c | 553 | # Construct lvol bdev on correct lvs_uuid |
11fdf7f2 TL |
554 | uuid_bdev = self.c.construct_lvol_bdev(uuid_store, |
555 | self.lbd_name, | |
556 | lvs_size) | |
9f95a23c | 557 | # Verify if lvol bdev was correctly created |
11fdf7f2 TL |
558 | fail_count += self.c.check_get_bdevs_methods(uuid_bdev, |
559 | lvs_size) | |
9f95a23c TL |
560 | # Try construct lvol bdev on the same lvs_uuid as in last step |
561 | # This call should fail as lvol store space is taken by previously | |
562 | # created bdev | |
11fdf7f2 TL |
563 | if self.c.construct_lvol_bdev(uuid_store, |
564 | self.lbd_name + "_1", | |
565 | lvs_size) == 0: | |
566 | fail_count += 1 | |
567 | ||
568 | self.c.destroy_lvol_bdev(uuid_bdev) | |
569 | self.c.destroy_lvol_store(uuid_store) | |
570 | self.c.delete_malloc_bdev(base_name) | |
9f95a23c TL |
571 | |
572 | # Expected result: | |
573 | # - first call successful | |
574 | # - second construct_lvol_bdev call return code != 0 | |
575 | # - EEXIST response printed to stdout | |
576 | # - no other operation fails | |
11fdf7f2 TL |
577 | return fail_count |
578 | ||
579 | @case_message | |
580 | def test_case102(self): | |
9f95a23c TL |
581 | """ |
582 | construct_lvol_bdev_name_twice | |
583 | ||
584 | Negative test for constructing lvol bdev using the same | |
585 | friendly name twice on the same logical volume store. | |
586 | """ | |
587 | # Construct malloc bdev | |
11fdf7f2 TL |
588 | base_name = self.c.construct_malloc_bdev(self.total_size, |
589 | self.block_size) | |
9f95a23c | 590 | # Create logical volume store on malloc bdev |
11fdf7f2 TL |
591 | uuid_store = self.c.construct_lvol_store(base_name, |
592 | self.lvs_name) | |
9f95a23c | 593 | # Using get_lvol_stores verify that logical volume store was correctly created |
11fdf7f2 TL |
594 | fail_count = self.c.check_get_lvol_stores(base_name, uuid_store, |
595 | self.cluster_size) | |
596 | size = self.get_lvs_size() | |
9f95a23c | 597 | # Construct logical volume on lvol store and verify it was correctly created |
11fdf7f2 TL |
598 | uuid_bdev = self.c.construct_lvol_bdev(uuid_store, |
599 | self.lbd_name, | |
600 | size) | |
601 | fail_count += self.c.check_get_bdevs_methods(uuid_bdev, | |
602 | size) | |
9f95a23c TL |
603 | # Try to create another logical volume on the same lvol store using |
604 | # the same friendly name as in previous step | |
605 | # This step should fail | |
11fdf7f2 TL |
606 | if self.c.construct_lvol_bdev(uuid_store, |
607 | self.lbd_name, | |
608 | size) == 0: | |
609 | fail_count += 1 | |
610 | ||
611 | self.c.destroy_lvol_bdev(uuid_bdev) | |
612 | self.c.destroy_lvol_store(uuid_store) | |
613 | self.c.delete_malloc_bdev(base_name) | |
9f95a23c TL |
614 | |
615 | # Expected results: | |
616 | # - creating two logical volumes with the same friendly name within the same | |
617 | # lvol store should not be possible | |
618 | # - no other operation fails | |
11fdf7f2 TL |
619 | return fail_count |
620 | ||
621 | @case_message | |
622 | def test_case150(self): | |
9f95a23c TL |
623 | """ |
624 | resize_logical_volume_positive | |
625 | ||
626 | ||
627 | Positive test for resizing a logical_volume. | |
628 | Call resize_lvol_bdev with correct logical_volumes name and new size. | |
629 | """ | |
630 | # Construct malloc bdev | |
11fdf7f2 TL |
631 | base_name = self.c.construct_malloc_bdev(self.total_size, |
632 | self.block_size) | |
9f95a23c | 633 | # Create lvol store |
11fdf7f2 TL |
634 | uuid_store = self.c.construct_lvol_store(base_name, |
635 | self.lvs_name) | |
9f95a23c | 636 | # Check correct uuid values in response get_lvol_stores command |
11fdf7f2 TL |
637 | fail_count = self.c.check_get_lvol_stores(base_name, uuid_store, |
638 | self.cluster_size) | |
9f95a23c | 639 | # Construct lvol bdev on correct lvs_uuid and |
11fdf7f2 | 640 | # size is equal to one quarter of size malloc bdev |
11fdf7f2 TL |
641 | size = self.get_lvs_divided_size(4) |
642 | uuid_bdev = self.c.construct_lvol_bdev(uuid_store, self.lbd_name, size) | |
9f95a23c | 643 | # Check size of the lvol bdev by rpc command get_bdevs |
11fdf7f2 TL |
644 | fail_count += self.c.check_get_bdevs_methods(uuid_bdev, size) |
645 | ||
9f95a23c | 646 | # Resize lvol bdev on correct lvs_uuid and |
11fdf7f2 TL |
647 | # size is equal to half of size malloc bdev |
648 | size = self.get_lvs_divided_size(2) | |
649 | self.c.resize_lvol_bdev(uuid_bdev, size) | |
9f95a23c | 650 | # Check size of the lvol bdev by rpc command get_bdevs |
11fdf7f2 TL |
651 | fail_count += self.c.check_get_bdevs_methods(uuid_bdev, size) |
652 | ||
9f95a23c | 653 | # Resize lvol bdev on the correct lvs_uuid and |
11fdf7f2 TL |
654 | # size is smaller by 1 cluster |
655 | size = (self.get_lvs_size() - self.get_lvs_cluster_size()) | |
656 | self.c.resize_lvol_bdev(uuid_bdev, size) | |
9f95a23c | 657 | # Check size of the lvol bdev by rpc command get_bdevs |
11fdf7f2 TL |
658 | fail_count += self.c.check_get_bdevs_methods(uuid_bdev, size) |
659 | ||
9f95a23c | 660 | # Resize lvol bdev on the correct lvs_uuid and |
11fdf7f2 TL |
661 | # size is equal 0 MiB |
662 | size = 0 | |
663 | self.c.resize_lvol_bdev(uuid_bdev, size) | |
9f95a23c | 664 | # Check size of the lvol bdev by rpc command get_bdevs |
11fdf7f2 TL |
665 | fail_count += self.c.check_get_bdevs_methods(uuid_bdev, size) |
666 | ||
667 | self.c.destroy_lvol_bdev(uuid_bdev) | |
668 | self.c.destroy_lvol_store(uuid_store) | |
669 | self.c.delete_malloc_bdev(base_name) | |
9f95a23c TL |
670 | # Expected result: |
671 | # - lvol bdev should change size after resize operations | |
672 | # - calls successful, return code = 0 | |
673 | # - no other operation fails | |
11fdf7f2 TL |
674 | return fail_count |
675 | ||
676 | @case_message | |
677 | def test_case200(self): | |
9f95a23c TL |
678 | """ |
679 | resize_logical_volume_nonexistent_logical_volume | |
680 | ||
681 | Negative test for resizing a logical_volume. | |
682 | Call resize_lvol_bdev with logical volume which does not | |
683 | exist in configuration. | |
684 | """ | |
11fdf7f2 | 685 | fail_count = 0 |
9f95a23c | 686 | # Try resize lvol bdev on logical volume which does not exist |
11fdf7f2 TL |
687 | if self.c.resize_lvol_bdev(self._gen_lvb_uuid(), 16) == 0: |
688 | fail_count += 1 | |
9f95a23c TL |
689 | |
690 | # Expected result: | |
691 | # - return code != 0 | |
692 | # - Error code: ENODEV ("No such device") response printed to stdout | |
11fdf7f2 TL |
693 | return fail_count |
694 | ||
695 | @case_message | |
696 | def test_case201(self): | |
9f95a23c TL |
697 | """ |
698 | resize_logical_volume_with_size_out_of_range | |
699 | ||
700 | Negative test for resizing a logical volume. | |
701 | Call resize_lvol_store with size argument bigger than size of base bdev. | |
702 | """ | |
703 | # Create malloc bdev | |
11fdf7f2 TL |
704 | base_name = self.c.construct_malloc_bdev(self.total_size, |
705 | self.block_size) | |
9f95a23c | 706 | # Construct lvol store on created malloc bdev |
11fdf7f2 TL |
707 | uuid_store = self.c.construct_lvol_store(base_name, |
708 | self.lvs_name) | |
9f95a23c | 709 | # Check correct uuid values in response get_lvol_stores command |
11fdf7f2 TL |
710 | fail_count = self.c.check_get_lvol_stores(base_name, uuid_store, |
711 | self.cluster_size) | |
9f95a23c TL |
712 | # Construct_lvol_bdev on correct lvs_uuid and |
713 | # size is equal one quarter of size malloc bdev | |
11fdf7f2 TL |
714 | lvs_size = self.get_lvs_size() |
715 | uuid_bdev = self.c.construct_lvol_bdev(uuid_store, | |
716 | self.lbd_name, | |
717 | lvs_size) | |
718 | fail_count += self.c.check_get_bdevs_methods(uuid_bdev, | |
719 | lvs_size) | |
9f95a23c TL |
720 | # Try resize_lvol_bdev on correct lvs_uuid and size is |
721 | # equal to size malloc bdev + 1MiB; this call should fail | |
11fdf7f2 TL |
722 | if self.c.resize_lvol_bdev(uuid_bdev, self.total_size + 1) == 0: |
723 | fail_count += 1 | |
724 | ||
725 | self.c.destroy_lvol_bdev(uuid_bdev) | |
726 | self.c.destroy_lvol_store(uuid_store) | |
727 | self.c.delete_malloc_bdev(base_name) | |
9f95a23c TL |
728 | |
729 | # Expected result: | |
730 | # - resize_lvol_bdev call return code != 0 | |
731 | # - Error code: ENODEV ("Not enough free clusters left on lvol store") | |
732 | # response printed to stdout | |
733 | # - no other operation fails | |
11fdf7f2 TL |
734 | return fail_count |
735 | ||
736 | @case_message | |
737 | def test_case250(self): | |
9f95a23c TL |
738 | """ |
739 | destroy_lvol_store_positive | |
740 | ||
741 | Positive test for destroying a logical volume store. | |
742 | Call destroy_lvol_store with correct logical_volumes name | |
743 | """ | |
744 | # Construct malloc bdev | |
11fdf7f2 TL |
745 | base_name = self.c.construct_malloc_bdev(self.total_size, |
746 | self.block_size) | |
9f95a23c | 747 | # Create lvol store on created malloc bdev |
11fdf7f2 TL |
748 | uuid_store = self.c.construct_lvol_store(base_name, |
749 | self.lvs_name) | |
9f95a23c | 750 | # check correct uuid values in response get_lvol_stores command |
11fdf7f2 TL |
751 | fail_count = self.c.check_get_lvol_stores(base_name, uuid_store, |
752 | self.cluster_size) | |
9f95a23c | 753 | # Destroy lvol store |
11fdf7f2 | 754 | self.c.destroy_lvol_store(uuid_store) |
9f95a23c | 755 | # Check correct response get_lvol_stores command |
11fdf7f2 TL |
756 | if self.c.check_get_lvol_stores("", "", "") == 1: |
757 | fail_count += 1 | |
758 | self.c.delete_malloc_bdev(base_name) | |
9f95a23c TL |
759 | |
760 | # Expected result: | |
761 | # - calls successful, return code = 0 | |
762 | # - get_lvol_stores: response should be of no value after destroyed lvol store | |
763 | # - no other operation fails | |
11fdf7f2 TL |
764 | return fail_count |
765 | ||
766 | @case_message | |
767 | def test_case251(self): | |
9f95a23c TL |
768 | """ |
769 | destroy_lvol_store_use_name_positive | |
770 | ||
771 | Positive test for destroying a logical volume store using | |
772 | lvol store name instead of uuid for reference. | |
773 | Call destroy_lvol_store with correct logical volume name | |
774 | """ | |
775 | # Create malloc bdev | |
11fdf7f2 TL |
776 | base_name = self.c.construct_malloc_bdev(self.total_size, |
777 | self.block_size) | |
9f95a23c | 778 | # Construct lvol store on created malloc bdev |
11fdf7f2 TL |
779 | uuid_store = self.c.construct_lvol_store(base_name, |
780 | self.lvs_name) | |
9f95a23c | 781 | # Check correct uuid values in response get_lvol_stores command |
11fdf7f2 TL |
782 | fail_count = self.c.check_get_lvol_stores(base_name, uuid_store, |
783 | self.cluster_size) | |
9f95a23c | 784 | # Destroy lvol store |
11fdf7f2 | 785 | fail_count += self.c.destroy_lvol_store(self.lvs_name) |
9f95a23c | 786 | # Check correct response get_lvol_stores command |
11fdf7f2 TL |
787 | if self.c.check_get_lvol_stores("", "", "") == 1: |
788 | fail_count += 1 | |
789 | fail_count += self.c.delete_malloc_bdev(base_name) | |
9f95a23c TL |
790 | |
791 | # Expected result: | |
792 | # - calls successful, return code = 0 | |
793 | # - get_lvol_stores: response should be of no value after destroyed lvol store | |
794 | # - no other operation fails | |
11fdf7f2 TL |
795 | return fail_count |
796 | ||
797 | @case_message | |
798 | def test_case252(self): | |
9f95a23c TL |
799 | """ |
800 | destroy_lvol_store_with_lvol_bdev_positive | |
801 | ||
802 | Positive test for destroying a logical volume store with lvol bdev | |
803 | created on top. | |
804 | Call destroy_lvol_store with correct logical_volumes name | |
805 | """ | |
806 | # Create malloc bdev | |
11fdf7f2 TL |
807 | base_name = self.c.construct_malloc_bdev(self.total_size, |
808 | self.block_size) | |
9f95a23c | 809 | # Construct lvol store on created malloc bdev |
11fdf7f2 TL |
810 | uuid_store = self.c.construct_lvol_store(base_name, |
811 | self.lvs_name) | |
9f95a23c | 812 | # Check correct uuid values in response get_lvol_stores command |
11fdf7f2 TL |
813 | fail_count = self.c.check_get_lvol_stores(base_name, uuid_store, |
814 | self.cluster_size) | |
9f95a23c TL |
815 | # Construct lvol bdev on correct lvs_uuid |
816 | # and size is equal to size malloc bdev | |
11fdf7f2 TL |
817 | lvs_size = self.get_lvs_size() |
818 | uuid_bdev = self.c.construct_lvol_bdev(uuid_store, | |
819 | self.lbd_name, | |
820 | lvs_size) | |
821 | fail_count += self.c.check_get_bdevs_methods(uuid_bdev, | |
822 | lvs_size) | |
9f95a23c | 823 | # Destroy lvol store |
11fdf7f2 TL |
824 | if self.c.destroy_lvol_store(uuid_store) != 0: |
825 | fail_count += 1 | |
826 | ||
9f95a23c | 827 | # Check correct response get_lvol_stores command |
11fdf7f2 TL |
828 | if self.c.check_get_lvol_stores("", "", "") == 1: |
829 | fail_count += 1 | |
830 | self.c.delete_malloc_bdev(base_name) | |
9f95a23c TL |
831 | |
832 | # Expected result: | |
833 | # - calls successful, return code = 0 | |
834 | # - get_lvol_stores: response should be of no value after destroyed lvol store | |
835 | # - no other operation fails | |
11fdf7f2 TL |
836 | return fail_count |
837 | ||
838 | @case_message | |
839 | def test_case253(self): | |
9f95a23c TL |
840 | """ |
841 | Name: destroy_multi_logical_volumes_positive | |
842 | ||
843 | Positive test for destroying a logical volume store with multiple lvol | |
844 | bdevs created on top. | |
845 | Call construct_lvol_bdev with correct lvol store UUID and | |
846 | size is equal to one quarter of the this bdev size. | |
847 | """ | |
848 | # Create malloc bdev | |
11fdf7f2 TL |
849 | base_name = self.c.construct_malloc_bdev(self.total_size, |
850 | self.block_size) | |
9f95a23c | 851 | # Construct lvol store on correct, exisitng malloc bdev |
11fdf7f2 TL |
852 | uuid_store = self.c.construct_lvol_store(base_name, |
853 | self.lvs_name) | |
9f95a23c | 854 | # Check correct uuid values in response get_lvol_stores command |
11fdf7f2 TL |
855 | fail_count = self.c.check_get_lvol_stores(base_name, uuid_store, |
856 | self.cluster_size) | |
857 | size = self.get_lvs_divided_size(4) | |
9f95a23c TL |
858 | # Construct four lvol bdevs on correct lvs_uuid and |
859 | # size is equal to one quarter of the lvol size | |
11fdf7f2 TL |
860 | for i in range(4): |
861 | uuid_bdev = self.c.construct_lvol_bdev(uuid_store, | |
862 | self.lbd_name + str(i), | |
863 | size) | |
864 | fail_count += self.c.check_get_bdevs_methods(uuid_bdev, size) | |
865 | ||
9f95a23c | 866 | # Destroy lvol store |
11fdf7f2 | 867 | self.c.destroy_lvol_store(uuid_store) |
9f95a23c | 868 | # Check correct response get_lvol_stores command |
11fdf7f2 TL |
869 | if self.c.check_get_lvol_stores("", "", "") == 1: |
870 | fail_count += 1 | |
871 | self.c.delete_malloc_bdev(base_name) | |
9f95a23c TL |
872 | |
873 | # Expected result: | |
874 | # - call successful, return code = 0 | |
875 | # - get_lvol_store: backend used for construct_lvol_bdev has name | |
876 | # field set with the same name as returned from RPC call for all repeat | |
877 | # - no other operation fails | |
11fdf7f2 TL |
878 | return fail_count |
879 | ||
880 | @case_message | |
881 | def test_case254(self): | |
9f95a23c TL |
882 | """ |
883 | destroy_resize_logical_volume_positive | |
884 | ||
885 | Positive test for destroying a logical_volume after resizing. | |
886 | Call destroy_lvol_store with correct logical_volumes name. | |
887 | """ | |
888 | # Create malloc bdev | |
11fdf7f2 TL |
889 | base_name = self.c.construct_malloc_bdev(self.total_size, |
890 | self.block_size) | |
9f95a23c | 891 | # Construct lvol store on create malloc bdev |
11fdf7f2 TL |
892 | uuid_store = self.c.construct_lvol_store(base_name, |
893 | self.lvs_name) | |
9f95a23c | 894 | # Check correct uuid values in response get_lvol_stores command |
11fdf7f2 TL |
895 | fail_count = self.c.check_get_lvol_stores(base_name, uuid_store, |
896 | self.cluster_size) | |
897 | size = self.get_lvs_divided_size(4) | |
9f95a23c TL |
898 | # construct_lvol_bdev on correct lvs_uuid and size is |
899 | # equal to one quarter of size malloc bdev | |
11fdf7f2 TL |
900 | uuid_bdev = self.c.construct_lvol_bdev(uuid_store, |
901 | self.lbd_name, | |
902 | size) | |
9f95a23c | 903 | # check size of the lvol bdev |
11fdf7f2 | 904 | fail_count += self.c.check_get_bdevs_methods(uuid_bdev, size) |
11fdf7f2 | 905 | sz = size + 4 |
9f95a23c TL |
906 | # Resize_lvol_bdev on correct lvs_uuid and size is |
907 | # equal to one quarter of size malloc bdev plus 4 MB | |
11fdf7f2 | 908 | self.c.resize_lvol_bdev(uuid_bdev, sz) |
9f95a23c | 909 | # check size of the lvol bdev by command RPC : get_bdevs |
11fdf7f2 | 910 | fail_count += self.c.check_get_bdevs_methods(uuid_bdev, sz) |
9f95a23c TL |
911 | # Resize_lvol_bdev on correct lvs_uuid and size is |
912 | # equal half of size malloc bdev | |
11fdf7f2 TL |
913 | sz = size * 2 |
914 | self.c.resize_lvol_bdev(uuid_bdev, sz) | |
9f95a23c | 915 | # check size of the lvol bdev by command RPC : get_bdevs |
11fdf7f2 | 916 | fail_count += self.c.check_get_bdevs_methods(uuid_bdev, sz) |
9f95a23c TL |
917 | # Resize_lvol_bdev on correct lvs_uuid and size is |
918 | # equal to three quarters of size malloc bdev | |
11fdf7f2 TL |
919 | sz = size * 3 |
920 | self.c.resize_lvol_bdev(uuid_bdev, sz) | |
9f95a23c | 921 | # check size of the lvol bdev by command RPC : get_bdevs |
11fdf7f2 | 922 | fail_count += self.c.check_get_bdevs_methods(uuid_bdev, sz) |
9f95a23c TL |
923 | # Resize_lvol_bdev on correct lvs_uuid and size is |
924 | # equal to size if malloc bdev minus 4 MB | |
11fdf7f2 TL |
925 | sz = (size * 4) - 4 |
926 | self.c.resize_lvol_bdev(uuid_bdev, sz) | |
9f95a23c | 927 | # check size of the lvol bdev by command RPC : get_bdevs |
11fdf7f2 | 928 | fail_count += self.c.check_get_bdevs_methods(uuid_bdev, sz) |
9f95a23c | 929 | # Resize_lvol_bdev on the correct lvs_uuid and size is equal 0 MiB |
11fdf7f2 TL |
930 | sz = 0 |
931 | self.c.resize_lvol_bdev(uuid_bdev, sz) | |
9f95a23c | 932 | # check size of the lvol bdev by command RPC : get_bdevs |
11fdf7f2 TL |
933 | fail_count += self.c.check_get_bdevs_methods(uuid_bdev, sz) |
934 | ||
9f95a23c | 935 | # Destroy lvol store |
11fdf7f2 TL |
936 | self.c.destroy_lvol_store(uuid_store) |
937 | if self.c.check_get_lvol_stores("", "", "") == 1: | |
938 | fail_count += 1 | |
939 | self.c.delete_malloc_bdev(base_name) | |
9f95a23c TL |
940 | |
941 | # Expected result: | |
942 | # - lvol bdev should change size after resize operations | |
943 | # - calls successful, return code = 0 | |
944 | # - no other operation fails | |
945 | # - get_lvol_stores: response should be of no value after destroyed lvol store | |
11fdf7f2 TL |
946 | return fail_count |
947 | ||
948 | @case_message | |
949 | def test_case255(self): | |
9f95a23c TL |
950 | """ |
951 | delete_lvol_store_persistent_positive | |
952 | ||
953 | Positive test for removing lvol store persistently | |
954 | """ | |
11fdf7f2 TL |
955 | base_path = path.dirname(sys.argv[0]) |
956 | base_name = "aio_bdev0" | |
957 | aio_bdev0 = path.join(base_path, "aio_bdev_0") | |
9f95a23c | 958 | # Construct aio bdev |
11fdf7f2 | 959 | self.c.construct_aio_bdev(aio_bdev0, base_name, 4096) |
9f95a23c | 960 | # Create lvol store on created aio bdev |
11fdf7f2 TL |
961 | uuid_store = self.c.construct_lvol_store(base_name, |
962 | self.lvs_name) | |
963 | fail_count = self.c.check_get_lvol_stores(base_name, uuid_store, | |
964 | self.cluster_size) | |
9f95a23c | 965 | # Destroy lvol store |
11fdf7f2 TL |
966 | if self.c.destroy_lvol_store(self.lvs_name) != 0: |
967 | fail_count += 1 | |
968 | ||
9f95a23c | 969 | # Delete aio bdev |
11fdf7f2 | 970 | self.c.delete_aio_bdev(base_name) |
9f95a23c | 971 | # Create aio bdev on the same file |
11fdf7f2 | 972 | self.c.construct_aio_bdev(aio_bdev0, base_name, 4096) |
9f95a23c | 973 | # Wait 1 second to allow time for lvolstore tasting |
11fdf7f2 TL |
974 | sleep(1) |
975 | ||
9f95a23c | 976 | # check if destroyed lvol store does not exist on aio bdev |
11fdf7f2 TL |
977 | ret_value = self.c.check_get_lvol_stores(base_name, uuid_store, |
978 | self.cluster_size) | |
979 | if ret_value == 0: | |
980 | fail_count += 1 | |
981 | self.c.delete_aio_bdev(base_name) | |
9f95a23c TL |
982 | |
983 | # Expected result: | |
984 | # - get_lvol_stores should not report any existsing lvol stores in configuration | |
985 | # after deleting and adding NVMe bdev | |
986 | # - no other operation fails | |
11fdf7f2 TL |
987 | return fail_count |
988 | ||
989 | @case_message | |
990 | def test_case300(self): | |
9f95a23c TL |
991 | """ |
992 | destroy_lvol_store_nonexistent_lvs_uuid | |
993 | ||
994 | Call destroy_lvol_store with nonexistent logical_volumes name | |
995 | exist in configuration. | |
996 | """ | |
11fdf7f2 | 997 | fail_count = 0 |
9f95a23c | 998 | # try to call destroy_lvol_store with lvs_uuid which does not exist |
11fdf7f2 TL |
999 | if self.c.destroy_lvol_store(self._gen_lvs_uuid()) == 0: |
1000 | fail_count += 1 | |
9f95a23c TL |
1001 | |
1002 | # Expected result: | |
1003 | # - return code != 0 | |
1004 | # - Error code response printed to stdout | |
11fdf7f2 TL |
1005 | return fail_count |
1006 | ||
1007 | @case_message | |
1008 | def test_case301(self): | |
9f95a23c TL |
1009 | """ |
1010 | delete_lvol_store_underlying_bdev | |
1011 | ||
1012 | Call destroy_lvol_store after deleting it's base bdev. | |
1013 | Lvol store should be automatically removed on deleting underlying bdev. | |
1014 | """ | |
1015 | # Create malloc bdev | |
11fdf7f2 TL |
1016 | base_name = self.c.construct_malloc_bdev(self.total_size, |
1017 | self.block_size) | |
9f95a23c | 1018 | # Construct lvol store on created malloc bdev |
11fdf7f2 TL |
1019 | uuid_store = self.c.construct_lvol_store(base_name, |
1020 | self.lvs_name) | |
9f95a23c | 1021 | # Check correct uuid values in response get_lvol_stores command |
11fdf7f2 TL |
1022 | fail_count = self.c.check_get_lvol_stores(base_name, uuid_store, |
1023 | self.cluster_size) | |
1024 | ||
9f95a23c | 1025 | # Delete malloc bdev |
11fdf7f2 TL |
1026 | if self.c.delete_malloc_bdev(base_name) != 0: |
1027 | fail_count += 1 | |
1028 | ||
9f95a23c TL |
1029 | # Try to destroy lvol store. This call should fail as lvol store |
1030 | # is no longer present | |
11fdf7f2 TL |
1031 | if self.c.destroy_lvol_store(uuid_store) == 0: |
1032 | fail_count += 1 | |
1033 | ||
9f95a23c TL |
1034 | # Expected result: |
1035 | # - destroy_lvol_store return code != 0 | |
1036 | # - Error code: ENODEV ("No such device") response printed to stdout | |
1037 | # - no other operation fails | |
11fdf7f2 TL |
1038 | return fail_count |
1039 | ||
11fdf7f2 TL |
1040 | # negative tests |
1041 | @case_message | |
1042 | def test_case450(self): | |
9f95a23c TL |
1043 | """ |
1044 | construct_lvs_nonexistent_bdev | |
1045 | ||
1046 | Negative test for constructing a new lvol store. | |
1047 | Call construct_lvol_store with base bdev name which does not | |
1048 | exist in configuration. | |
1049 | """ | |
11fdf7f2 TL |
1050 | fail_count = 0 |
1051 | bad_bdev_id = random.randrange(999999999) | |
9f95a23c | 1052 | # Try construct_lvol_store on bdev which does not exist |
11fdf7f2 TL |
1053 | if self.c.construct_lvol_store(bad_bdev_id, |
1054 | self.lvs_name, | |
1055 | self.cluster_size) == 0: | |
1056 | fail_count += 1 | |
1057 | return fail_count | |
1058 | ||
1059 | @case_message | |
1060 | def test_case451(self): | |
9f95a23c TL |
1061 | """ |
1062 | construct_lvs_on_bdev_twice | |
1063 | ||
1064 | Negative test for constructing a new lvol store. | |
1065 | Call construct_lvol_store with base bdev name twice. | |
1066 | """ | |
1067 | # Create malloc bdev | |
11fdf7f2 TL |
1068 | base_name = self.c.construct_malloc_bdev(self.total_size, |
1069 | self.block_size) | |
9f95a23c | 1070 | # Construct lvol store on created malloc bdev |
11fdf7f2 TL |
1071 | uuid_store = self.c.construct_lvol_store(base_name, |
1072 | self.lvs_name) | |
9f95a23c | 1073 | # Check correct uuid values in response get_lvol_stores command |
11fdf7f2 TL |
1074 | fail_count = self.c.check_get_lvol_stores(base_name, uuid_store, |
1075 | self.cluster_size) | |
9f95a23c TL |
1076 | # Try construct_lvol_store on the same bdev as in last step |
1077 | # This call should fail as base bdev is already claimed by lvol store | |
11fdf7f2 TL |
1078 | if self.c.construct_lvol_store(base_name, |
1079 | self.lvs_name) == 0: | |
1080 | fail_count += 1 | |
1081 | self.c.destroy_lvol_store(uuid_store) | |
1082 | self.c.delete_malloc_bdev(base_name) | |
1083 | return fail_count | |
1084 | ||
1085 | @case_message | |
1086 | def test_case452(self): | |
9f95a23c TL |
1087 | """ |
1088 | construct_lvs_name_twice | |
1089 | ||
1090 | Negative test for constructing a new lvol store using the same | |
1091 | friendly name twice. | |
1092 | """ | |
11fdf7f2 | 1093 | fail_count = 0 |
9f95a23c | 1094 | # Create malloc bdev |
11fdf7f2 TL |
1095 | base_name_1 = self.c.construct_malloc_bdev(self.total_size, |
1096 | self.block_size) | |
9f95a23c | 1097 | # Construct second malloc bdev |
11fdf7f2 TL |
1098 | base_name_2 = self.c.construct_malloc_bdev(self.total_size, |
1099 | self.block_size) | |
9f95a23c | 1100 | # Construct lvol store on first malloc |
11fdf7f2 TL |
1101 | uuid_store_1 = self.c.construct_lvol_store(base_name_1, |
1102 | self.lvs_name) | |
9f95a23c TL |
1103 | # using get_lvol_stores verify that logical volume store was correctly created |
1104 | # and has arguments as provided in step earlier (cluster size, friendly name, base bdev) | |
11fdf7f2 TL |
1105 | fail_count += self.c.check_get_lvol_stores(base_name_1, |
1106 | uuid_store_1, | |
1107 | self.cluster_size) | |
9f95a23c TL |
1108 | # Try to create another logical volume store on second malloc bdev using the |
1109 | # same friendly name as before. This step is expected to fail as lvol stores | |
1110 | # cannot have the same name | |
11fdf7f2 TL |
1111 | if self.c.construct_lvol_store(base_name_2, |
1112 | self.lvs_name) == 0: | |
1113 | fail_count += 1 | |
1114 | ||
1115 | fail_count += self.c.destroy_lvol_store(uuid_store_1) | |
1116 | fail_count += self.c.delete_malloc_bdev(base_name_1) | |
1117 | fail_count += self.c.delete_malloc_bdev(base_name_2) | |
1118 | ||
1119 | return fail_count | |
1120 | ||
9f95a23c | 1121 | @case_message |
11fdf7f2 TL |
1122 | def test_case500(self): |
1123 | """ | |
1124 | nested_construct_lvol_bdev_on_full_lvol_store | |
1125 | ||
1126 | Negative test for constructing a new nested lvol bdev. | |
1127 | Call construct_lvol_bdev on a full lvol store. | |
1128 | """ | |
9f95a23c TL |
1129 | # Create malloc bdev |
1130 | base_name = self.c.construct_malloc_bdev(self.total_size, | |
1131 | self.block_size) | |
1132 | # Construct_lvol_store on correct, exisitng malloc bdev | |
1133 | uuid_store = self.c.construct_lvol_store(base_name, | |
1134 | self.lvs_name) | |
1135 | # Check correct uuid values in response get_lvol_stores command | |
1136 | fail_count = self.c.check_get_lvol_stores(base_name, uuid_store, | |
1137 | self.cluster_size) | |
1138 | # Construct lvol bdev | |
1139 | size = self.get_lvs_size() | |
1140 | uuid_bdev = self.c.construct_lvol_bdev(uuid_store, | |
1141 | self.lbd_name, size) | |
1142 | # Construct nested lvol store on created lvol_bdev | |
1143 | nested_lvs_name = self.lvs_name + "_nested" | |
1144 | nested_lvs_uuid = self.c.construct_lvol_store(uuid_bdev, | |
1145 | nested_lvs_name) | |
1146 | # Check correct uuid values in response get_lvol_stores command | |
1147 | fail_count += self.c.check_get_lvol_stores(uuid_bdev, nested_lvs_uuid, | |
1148 | self.cluster_size) | |
1149 | # Construct nested lvol bdev on previously created nested lvol store | |
1150 | # with size equal to size of nested lvol store | |
1151 | nested_size = self.get_lvs_size(nested_lvs_name) | |
1152 | nested_lbd_name = self.lbd_name + "_nested" | |
1153 | nested_uuid_bdev = self.c.construct_lvol_bdev(nested_lvs_uuid, | |
1154 | nested_lbd_name, nested_size) | |
1155 | fail_count += self.c.check_get_bdevs_methods(nested_uuid_bdev, nested_size) | |
1156 | ||
1157 | # Try construct another lvol bdev as in previous step; this call should fail | |
1158 | # as nested lvol store space is already claimed by lvol bdev | |
1159 | nested_lbd_name = self.lbd_name + "_nested2" | |
1160 | if self.c.construct_lvol_bdev(nested_lvs_uuid, nested_lbd_name, nested_size) == 0: | |
1161 | fail_count += 1 | |
1162 | ||
1163 | fail_count += self.c.delete_malloc_bdev(base_name) | |
1164 | ||
11fdf7f2 TL |
1165 | # Expected result: |
1166 | # - second construct_lvol_bdev call on nested lvol store return code != 0 | |
1167 | # - EEXIST response printed to stdout | |
1168 | # - no other operation fails | |
9f95a23c | 1169 | return fail_count |
11fdf7f2 TL |
1170 | |
1171 | @case_message | |
1172 | def test_case550(self): | |
1173 | """ | |
1174 | delete_bdev_positive | |
1175 | ||
1176 | Positive test for deleting malloc bdev. | |
1177 | Call construct_lvol_store with correct base bdev name. | |
1178 | """ | |
1179 | # Create malloc bdev | |
1180 | base_name = self.c.construct_malloc_bdev(self.total_size, | |
1181 | self.block_size) | |
1182 | # Construct_lvol_store on correct, exisitng malloc bdev | |
1183 | uuid_store = self.c.construct_lvol_store(base_name, | |
1184 | self.lvs_name) | |
1185 | # Check correct uuid values in response get_lvol_stores command | |
1186 | fail_count = self.c.check_get_lvol_stores(base_name, uuid_store, | |
1187 | self.cluster_size) | |
1188 | # Delete malloc bdev | |
1189 | self.c.delete_malloc_bdev(base_name) | |
1190 | # Check response get_lvol_stores command | |
1191 | if self.c.check_get_lvol_stores("", "", "") == 1: | |
1192 | fail_count += 1 | |
1193 | ||
1194 | # Expected result: | |
1195 | # - get_lvol_stores: response should be of no value after destroyed lvol store | |
1196 | # - no other operation fails | |
1197 | return fail_count | |
1198 | ||
1199 | @case_message | |
1200 | def test_case551(self): | |
1201 | """ | |
1202 | destroy_lvol_bdev_ordering | |
1203 | ||
1204 | Test for destroying lvol bdevs in particular order. | |
1205 | Check destroying wrong one is not possible and returns error. | |
1206 | """ | |
1207 | ||
1208 | fail_count = 0 | |
1209 | snapshot_name = "snapshot" | |
1210 | clone_name = "clone" | |
1211 | ||
1212 | # Create malloc bdev | |
1213 | base_name = self.c.construct_malloc_bdev(self.total_size, | |
1214 | self.block_size) | |
1215 | # Construct_lvol_store on correct, exisitng malloc bdev | |
1216 | uuid_store = self.c.construct_lvol_store(base_name, | |
1217 | self.lvs_name, | |
1218 | self.cluster_size) | |
1219 | # Check correct uuid values in response get_lvol_stores command | |
1220 | fail_count = self.c.check_get_lvol_stores(base_name, uuid_store, | |
1221 | self.cluster_size) | |
1222 | lvs = self.c.get_lvol_stores() | |
1223 | size = int(int(lvs[0]['free_clusters'] * lvs[0]['cluster_size']) / 4 / MEGABYTE) | |
1224 | ||
1225 | # Construct thin provisioned lvol bdev | |
1226 | uuid_bdev0 = self.c.construct_lvol_bdev(uuid_store, | |
1227 | self.lbd_name, size, thin=True) | |
1228 | lvol_bdev = self.c.get_lvol_bdev_with_name(uuid_bdev0) | |
1229 | ||
1230 | # Create snapshot of thin provisioned lvol bdev | |
1231 | fail_count += self.c.snapshot_lvol_bdev(lvol_bdev['name'], snapshot_name) | |
1232 | snapshot_bdev = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + snapshot_name) | |
1233 | ||
1234 | # Create clone of snapshot and check if it ends with success | |
1235 | fail_count += self.c.clone_lvol_bdev(self.lvs_name + "/" + snapshot_name, clone_name) | |
1236 | clone_bdev = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + clone_name) | |
1237 | ||
1238 | # Try to destroy snapshot with clones and check if it fails | |
1239 | ret_value = self.c.destroy_lvol_bdev(snapshot_bdev['name']) | |
1240 | if ret_value == 0: | |
1241 | print("ERROR: Delete snapshot should fail but didn't") | |
1242 | fail_count += 1 | |
1243 | ||
1244 | # Destroy clone and then snapshot | |
1245 | fail_count += self.c.destroy_lvol_bdev(lvol_bdev['name']) | |
1246 | fail_count += self.c.destroy_lvol_bdev(clone_bdev['name']) | |
1247 | fail_count += self.c.destroy_lvol_bdev(snapshot_bdev['name']) | |
1248 | ||
1249 | # Destroy lvol store | |
1250 | fail_count += self.c.destroy_lvol_store(uuid_store) | |
1251 | ||
1252 | # Check response get_lvol_stores command | |
1253 | if self.c.check_get_lvol_stores("", "", "") == 1: | |
1254 | fail_count += 1 | |
1255 | ||
1256 | # Delete malloc bdev | |
1257 | self.c.delete_malloc_bdev(base_name) | |
1258 | # Expected result: | |
1259 | # - get_lvol_stores: response should be of no value after destroyed lvol store | |
1260 | # - no other operation fails | |
1261 | return fail_count | |
1262 | ||
1263 | @case_message | |
1264 | def test_case552(self): | |
1265 | """ | |
1266 | destroy_lvol_store_with_clones | |
1267 | ||
1268 | Test for destroying lvol store with clones present, | |
1269 | without removing them first. | |
1270 | """ | |
1271 | ||
1272 | fail_count = 0 | |
1273 | snapshot_name = "snapshot" | |
1274 | snapshot_name2 = "snapshot2" | |
1275 | clone_name = "clone" | |
1276 | ||
1277 | # Create malloc bdev | |
1278 | base_name = self.c.construct_malloc_bdev(self.total_size, | |
1279 | self.block_size) | |
1280 | # Construct_lvol_store on correct, exisitng malloc bdev | |
1281 | uuid_store = self.c.construct_lvol_store(base_name, | |
1282 | self.lvs_name, | |
1283 | self.cluster_size) | |
1284 | # Check correct uuid values in response get_lvol_stores command | |
1285 | fail_count = self.c.check_get_lvol_stores(base_name, uuid_store, | |
1286 | self.cluster_size) | |
1287 | lvs = self.c.get_lvol_stores() | |
1288 | size = int(int(lvs[0]['free_clusters'] * lvs[0]['cluster_size']) / 4 / MEGABYTE) | |
1289 | ||
1290 | # Create lvol bdev, snapshot it, then clone it and then snapshot the clone | |
1291 | uuid_bdev0 = self.c.construct_lvol_bdev(uuid_store, self.lbd_name, size, thin=True) | |
1292 | lvol_bdev = self.c.get_lvol_bdev_with_name(uuid_bdev0) | |
1293 | ||
1294 | fail_count += self.c.snapshot_lvol_bdev(lvol_bdev['name'], snapshot_name) | |
1295 | snapshot_bdev = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + snapshot_name) | |
1296 | ||
1297 | fail_count += self.c.clone_lvol_bdev(self.lvs_name + "/" + snapshot_name, clone_name) | |
1298 | clone_bdev = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + clone_name) | |
1299 | ||
1300 | fail_count += self.c.snapshot_lvol_bdev(clone_bdev['name'], snapshot_name2) | |
1301 | snapshot_bdev2 = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + snapshot_name2) | |
1302 | ||
1303 | # Try to destroy snapshots with clones and check if it fails | |
1304 | ret_value = self.c.destroy_lvol_bdev(snapshot_bdev['name']) | |
1305 | if ret_value == 0: | |
1306 | print("ERROR: Delete snapshot should fail but didn't") | |
1307 | fail_count += 1 | |
1308 | ret_value = self.c.destroy_lvol_bdev(snapshot_bdev2['name']) | |
1309 | if ret_value == 0: | |
1310 | print("ERROR: Delete snapshot should fail but didn't") | |
1311 | fail_count += 1 | |
1312 | ||
1313 | # Destroy lvol store without deleting lvol bdevs | |
1314 | fail_count += self.c.destroy_lvol_store(uuid_store) | |
1315 | ||
1316 | # Check response get_lvol_stores command | |
1317 | if self.c.check_get_lvol_stores("", "", "") == 1: | |
1318 | fail_count += 1 | |
1319 | ||
1320 | # Delete malloc bdev | |
1321 | self.c.delete_malloc_bdev(base_name) | |
1322 | # Expected result: | |
1323 | # - get_lvol_stores: response should be of no value after destroyed lvol store | |
1324 | # - no other operation fails | |
1325 | return fail_count | |
1326 | ||
1327 | @case_message | |
1328 | def test_case553(self): | |
1329 | """ | |
1330 | unregister_lvol_bdev | |
1331 | ||
1332 | Test for unregistering the lvol bdevs. | |
1333 | Removing malloc bdev under an lvol store triggers unregister of | |
1334 | all lvol bdevs. Verify it with clones present. | |
1335 | """ | |
1336 | ||
1337 | fail_count = 0 | |
1338 | snapshot_name = "snapshot" | |
1339 | snapshot_name2 = "snapshot2" | |
1340 | clone_name = "clone" | |
1341 | ||
1342 | # Create malloc bdev | |
1343 | base_name = self.c.construct_malloc_bdev(self.total_size, | |
1344 | self.block_size) | |
1345 | # Construct_lvol_store on correct, exisitng malloc bdev | |
1346 | uuid_store = self.c.construct_lvol_store(base_name, | |
1347 | self.lvs_name, | |
1348 | self.cluster_size) | |
1349 | # Check correct uuid values in response get_lvol_stores command | |
1350 | fail_count = self.c.check_get_lvol_stores(base_name, uuid_store, | |
1351 | self.cluster_size) | |
1352 | lvs = self.c.get_lvol_stores() | |
1353 | size = int(int(lvs[0]['free_clusters'] * lvs[0]['cluster_size']) / 4 / MEGABYTE) | |
1354 | ||
1355 | # Create lvol bdev, snapshot it, then clone it and then snapshot the clone | |
1356 | uuid_bdev0 = self.c.construct_lvol_bdev(uuid_store, self.lbd_name, size, thin=True) | |
1357 | lvol_bdev = self.c.get_lvol_bdev_with_name(uuid_bdev0) | |
1358 | ||
1359 | fail_count += self.c.snapshot_lvol_bdev(lvol_bdev['name'], snapshot_name) | |
1360 | snapshot_bdev = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + snapshot_name) | |
1361 | ||
1362 | fail_count += self.c.clone_lvol_bdev(self.lvs_name + "/" + snapshot_name, clone_name) | |
1363 | clone_bdev = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + clone_name) | |
1364 | ||
1365 | fail_count += self.c.snapshot_lvol_bdev(clone_bdev['name'], snapshot_name2) | |
1366 | snapshot_bdev2 = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + snapshot_name2) | |
1367 | ||
1368 | # Delete malloc bdev | |
1369 | self.c.delete_malloc_bdev(base_name) | |
1370 | ||
1371 | # Check response get_lvol_stores command | |
1372 | if self.c.check_get_lvol_stores("", "", "") == 1: | |
1373 | fail_count += 1 | |
1374 | ||
1375 | # Expected result: | |
1376 | # - get_lvol_stores: response should be of no value after destroyed lvol store | |
1377 | # - no other operation fails | |
1378 | return fail_count | |
1379 | ||
1380 | @case_message | |
1381 | def test_case600(self): | |
1382 | """ | |
1383 | construct_lvol_store_with_cluster_size_max | |
1384 | ||
1385 | Negative test for constructing a new lvol store. | |
1386 | Call construct_lvol_store with cluster size is equal malloc bdev size + 1B. | |
1387 | """ | |
1388 | fail_count = 0 | |
1389 | # Create malloc bdev | |
1390 | base_name = self.c.construct_malloc_bdev(self.total_size, | |
1391 | self.block_size) | |
1392 | # Construct_lvol_store on correct, exisitng malloc bdev and cluster size equal | |
1393 | # malloc bdev size in bytes + 1B | |
1394 | lvol_uuid = self.c.construct_lvol_store(base_name, | |
1395 | self.lvs_name, | |
1396 | (self.total_size * 1024 * 1024) + 1) == 0 | |
1397 | if self.c.check_get_lvol_stores(base_name, lvol_uuid) == 0: | |
1398 | fail_count += 1 | |
1399 | fail_count += self.c.delete_malloc_bdev(base_name) | |
1400 | ||
1401 | # Expected result: | |
1402 | # - return code != 0 | |
1403 | # - Error code response printed to stdout | |
1404 | return fail_count | |
1405 | ||
1406 | @case_message | |
1407 | def test_case601(self): | |
1408 | """ | |
1409 | construct_lvol_store_with_cluster_size_min | |
1410 | ||
1411 | Negative test for constructing a new lvol store. | |
1412 | Call construct_lvol_store with cluster size smaller than minimal value of 8192. | |
1413 | """ | |
1414 | fail_count = 0 | |
1415 | # Create malloc bdev | |
1416 | base_name = self.c.construct_malloc_bdev(self.total_size, | |
1417 | self.block_size) | |
1418 | # Try construct lvol store on malloc bdev with cluster size 8191 | |
1419 | lvol_uuid = self.c.construct_lvol_store(base_name, self.lvs_name, 8191) | |
1420 | # Verify that lvol store was not created | |
1421 | if self.c.check_get_lvol_stores(base_name, lvol_uuid) == 0: | |
1422 | fail_count += 1 | |
1423 | fail_count += self.c.delete_malloc_bdev(base_name) | |
1424 | ||
1425 | # Expected result: | |
1426 | # - construct lvol store return code != 0 | |
1427 | # - Error code response printed to stdout | |
1428 | return fail_count | |
1429 | ||
9f95a23c TL |
1430 | @case_message |
1431 | def test_case602(self): | |
1432 | """ | |
1433 | construct_lvol_store_with_all_clear_methods | |
1434 | ||
1435 | Call construct_lvol_store with all options for clear methods. | |
1436 | """ | |
1437 | fail_count = 0 | |
1438 | # Create malloc bdev | |
1439 | base_name = self.c.construct_malloc_bdev(self.total_size, | |
1440 | self.block_size) | |
1441 | # Construct lvol store with clear method 'none' | |
1442 | lvol_uuid = self.c.construct_lvol_store(base_name, self.lvs_name, clear_method="none") | |
1443 | fail_count += self.c.check_get_lvol_stores(base_name, lvol_uuid) | |
1444 | fail_count += self.c.delete_malloc_bdev(base_name) | |
1445 | ||
1446 | # Create malloc bdev | |
1447 | base_name = self.c.construct_malloc_bdev(self.total_size, | |
1448 | self.block_size) | |
1449 | # Construct lvol store with clear method 'unmap' | |
1450 | lvol_uuid = self.c.construct_lvol_store(base_name, self.lvs_name, clear_method="unmap") | |
1451 | fail_count += self.c.check_get_lvol_stores(base_name, lvol_uuid) | |
1452 | fail_count += self.c.delete_malloc_bdev(base_name) | |
1453 | ||
1454 | # Create malloc bdev | |
1455 | base_name = self.c.construct_malloc_bdev(self.total_size, | |
1456 | self.block_size) | |
1457 | # Construct lvol store with clear method 'write_zeroes' | |
1458 | lvol_uuid = self.c.construct_lvol_store(base_name, self.lvs_name, clear_method="write_zeroes") | |
1459 | fail_count += self.c.check_get_lvol_stores(base_name, lvol_uuid) | |
1460 | fail_count += self.c.delete_malloc_bdev(base_name) | |
1461 | ||
1462 | # Expected result: | |
1463 | # - construct lvol store return code != 0 | |
1464 | # - Error code response printed to stdout | |
1465 | return fail_count | |
1466 | ||
11fdf7f2 TL |
1467 | @case_message |
1468 | def test_case650(self): | |
1469 | """ | |
1470 | thin_provisioning_check_space | |
1471 | ||
1472 | Check if free clusters number on lvol store decreases | |
1473 | if we write to created thin provisioned lvol bdev | |
1474 | """ | |
1475 | # create malloc bdev | |
1476 | base_name = self.c.construct_malloc_bdev(self.total_size, | |
1477 | self.block_size) | |
1478 | # create lvol store on mamloc bdev | |
1479 | uuid_store = self.c.construct_lvol_store(base_name, | |
1480 | self.lvs_name) | |
1481 | fail_count = self.c.check_get_lvol_stores(base_name, uuid_store, | |
1482 | self.cluster_size) | |
1483 | lvs = self.c.get_lvol_stores(self.lvs_name)[0] | |
1484 | free_clusters_start = int(lvs['free_clusters']) | |
1485 | bdev_size = self.get_lvs_size() | |
1486 | # create thin provisioned lvol bdev with size equals to lvol store free space | |
1487 | bdev_name = self.c.construct_lvol_bdev(uuid_store, self.lbd_name, | |
1488 | bdev_size, thin=True) | |
1489 | lvs = self.c.get_lvol_stores(self.lvs_name)[0] | |
1490 | free_clusters_create_lvol = int(lvs['free_clusters']) | |
1491 | # check and save number of free clusters for lvol store | |
1492 | if free_clusters_start != free_clusters_create_lvol: | |
1493 | fail_count += 1 | |
1494 | lvol_bdev = self.c.get_lvol_bdev_with_name(bdev_name) | |
1495 | nbd_name = "/dev/nbd0" | |
1496 | fail_count += self.c.start_nbd_disk(bdev_name, nbd_name) | |
1497 | ||
1498 | size = int(lvs['cluster_size']) | |
1499 | # write data (lvs cluster size) to created lvol bdev starting from offset 0. | |
1500 | fail_count += self.run_fio_test("/dev/nbd0", 0, size, "write", "0xcc") | |
1501 | lvs = self.c.get_lvol_stores(self.lvs_name)[0] | |
1502 | free_clusters_first_fio = int(lvs['free_clusters']) | |
1503 | # check that free clusters on lvol store was decremented by 1 | |
1504 | if free_clusters_start != free_clusters_first_fio + 1: | |
1505 | fail_count += 1 | |
1506 | ||
1507 | size = int(lvs['cluster_size']) | |
1508 | # calculate size of one and half cluster | |
1509 | offset = int((int(lvol_bdev['num_blocks']) * int(lvol_bdev['block_size']) / | |
1510 | free_clusters_create_lvol) * 1.5) | |
1511 | # write data (lvs cluster size) to lvol bdev with offset set to one and half of cluster size | |
1512 | fail_count += self.run_fio_test(nbd_name, offset, size, "write", "0xcc") | |
1513 | lvs = self.c.get_lvol_stores(self.lvs_name)[0] | |
1514 | free_clusters_second_fio = int(lvs['free_clusters']) | |
1515 | # check that free clusters on lvol store was decremented by 2 | |
1516 | if free_clusters_start != free_clusters_second_fio + 3: | |
1517 | fail_count += 1 | |
1518 | ||
1519 | size = (free_clusters_create_lvol - 3) * int(lvs['cluster_size']) | |
1520 | offset = int(int(lvol_bdev['num_blocks']) * int(lvol_bdev['block_size']) / | |
1521 | free_clusters_create_lvol * 3) | |
1522 | # write data to lvol bdev to the end of its size | |
1523 | fail_count += self.run_fio_test(nbd_name, offset, size, "write", "0xcc") | |
1524 | lvs = self.c.get_lvol_stores(self.lvs_name)[0] | |
1525 | free_clusters_third_fio = int(lvs['free_clusters']) | |
1526 | # check that lvol store free clusters number equals to 0 | |
1527 | if free_clusters_third_fio != 0: | |
1528 | fail_count += 1 | |
1529 | ||
1530 | fail_count += self.c.stop_nbd_disk(nbd_name) | |
1531 | # destroy thin provisioned lvol bdev | |
1532 | fail_count += self.c.destroy_lvol_bdev(lvol_bdev['name']) | |
1533 | lvs = self.c.get_lvol_stores(self.lvs_name)[0] | |
1534 | free_clusters_end = int(lvs['free_clusters']) | |
1535 | # check that saved number of free clusters equals to current free clusters | |
1536 | if free_clusters_start != free_clusters_end: | |
1537 | fail_count += 1 | |
1538 | # destroy lvol store | |
1539 | fail_count += self.c.destroy_lvol_store(uuid_store) | |
1540 | # destroy malloc bdev | |
1541 | fail_count += self.c.delete_malloc_bdev(base_name) | |
1542 | # Expected result: | |
1543 | # - calls successful, return code = 0 | |
1544 | # - no other operation fails | |
1545 | return fail_count | |
1546 | ||
1547 | @case_message | |
1548 | def test_case651(self): | |
1549 | """ | |
1550 | thin_provisioning_read_empty_bdev | |
1551 | ||
1552 | Check if we can create thin provisioned bdev on empty lvol store | |
1553 | and check if we can read from this device and it returns zeroes. | |
1554 | """ | |
1555 | # create malloc bdev | |
1556 | base_name = self.c.construct_malloc_bdev(self.total_size, | |
1557 | self.block_size) | |
1558 | # construct lvol store on malloc bdev | |
1559 | uuid_store = self.c.construct_lvol_store(base_name, | |
1560 | self.lvs_name) | |
1561 | fail_count = self.c.check_get_lvol_stores(base_name, uuid_store, | |
1562 | self.cluster_size) | |
1563 | lvs = self.c.get_lvol_stores(self.lvs_name)[0] | |
1564 | free_clusters_start = int(lvs['free_clusters']) | |
1565 | lbd_name0 = self.lbd_name + str("0") | |
1566 | lbd_name1 = self.lbd_name + str("1") | |
1567 | # calculate bdev size in megabytes | |
1568 | bdev_size = self.get_lvs_size() | |
1569 | # create thick provisioned lvol bvdev with size equal to lvol store | |
1570 | bdev_name0 = self.c.construct_lvol_bdev(uuid_store, lbd_name0, | |
1571 | bdev_size, thin=False) | |
1572 | # create thin provisioned lvol bdev with the same size | |
1573 | bdev_name1 = self.c.construct_lvol_bdev(uuid_store, lbd_name1, | |
1574 | bdev_size, thin=True) | |
1575 | lvol_bdev0 = self.c.get_lvol_bdev_with_name(bdev_name0) | |
1576 | lvol_bdev1 = self.c.get_lvol_bdev_with_name(bdev_name1) | |
1577 | nbd_name0 = "/dev/nbd0" | |
1578 | fail_count += self.c.start_nbd_disk(lvol_bdev0['name'], nbd_name0) | |
1579 | nbd_name1 = "/dev/nbd1" | |
1580 | fail_count += self.c.start_nbd_disk(lvol_bdev1['name'], nbd_name1) | |
1581 | ||
1582 | size = bdev_size * MEGABYTE | |
1583 | # fill the whole thick provisioned lvol bdev | |
1584 | fail_count += self.run_fio_test(nbd_name0, 0, size, "write", False) | |
1585 | ||
1586 | size = bdev_size * MEGABYTE | |
1587 | # perform read operations on thin provisioned lvol bdev | |
1588 | # and check if they return zeroes | |
1589 | fail_count += self.run_fio_test(nbd_name1, 0, size, "read", "0x00") | |
1590 | ||
1591 | fail_count += self.c.stop_nbd_disk(nbd_name0) | |
1592 | fail_count += self.c.stop_nbd_disk(nbd_name1) | |
1593 | # destroy thin provisioned lvol bdev | |
1594 | fail_count += self.c.destroy_lvol_bdev(lvol_bdev0['name']) | |
1595 | fail_count += self.c.destroy_lvol_bdev(lvol_bdev1['name']) | |
1596 | # destroy lvol store | |
1597 | fail_count += self.c.destroy_lvol_store(uuid_store) | |
1598 | # destroy malloc bdev | |
1599 | fail_count += self.c.delete_malloc_bdev(base_name) | |
1600 | # Expected result: | |
1601 | # - calls successful, return code = 0 | |
1602 | # - no other operation fails | |
1603 | return fail_count | |
1604 | ||
1605 | @case_message | |
1606 | def test_case652(self): | |
1607 | """ | |
1608 | thin_provisioning_data_integrity_test | |
1609 | ||
1610 | Check if data written to thin provisioned lvol bdev | |
1611 | were properly written (fio test with verification). | |
1612 | """ | |
1613 | # create malloc bdev | |
1614 | base_name = self.c.construct_malloc_bdev(self.total_size, | |
1615 | self.block_size) | |
1616 | # construct lvol store on malloc bdev | |
1617 | uuid_store = self.c.construct_lvol_store(base_name, | |
1618 | self.lvs_name) | |
1619 | fail_count = self.c.check_get_lvol_stores(base_name, uuid_store, | |
1620 | self.cluster_size) | |
1621 | lvs = self.c.get_lvol_stores(self.lvs_name)[0] | |
1622 | free_clusters_start = int(lvs['free_clusters']) | |
1623 | bdev_size = self.get_lvs_size() | |
1624 | # construct thin provisioned lvol bdev with size equal to lvol store | |
1625 | bdev_name = self.c.construct_lvol_bdev(uuid_store, self.lbd_name, | |
1626 | bdev_size, thin=True) | |
1627 | ||
1628 | lvol_bdev = self.c.get_lvol_bdev_with_name(bdev_name) | |
1629 | nbd_name = "/dev/nbd0" | |
1630 | fail_count += self.c.start_nbd_disk(lvol_bdev['name'], nbd_name) | |
1631 | size = bdev_size * MEGABYTE | |
1632 | # on the whole lvol bdev perform write operation with verification | |
1633 | fail_count += self.run_fio_test(nbd_name, 0, size, "write", "0xcc") | |
1634 | ||
1635 | fail_count += self.c.stop_nbd_disk(nbd_name) | |
1636 | # destroy thin provisioned lvol bdev | |
1637 | fail_count += self.c.destroy_lvol_bdev(lvol_bdev['name']) | |
1638 | # destroy lvol store | |
1639 | fail_count += self.c.destroy_lvol_store(uuid_store) | |
1640 | # destroy malloc bdev | |
1641 | fail_count += self.c.delete_malloc_bdev(base_name) | |
1642 | # Expected result: | |
1643 | # - calls successful, return code = 0 | |
1644 | # - verification ends with success | |
1645 | # - no other operation fails | |
1646 | return fail_count | |
1647 | ||
1648 | @case_message | |
1649 | def test_case653(self): | |
1650 | """ | |
1651 | thin_provisioning_resize | |
1652 | ||
9f95a23c | 1653 | Check thin provisioned bdev resize. |
11fdf7f2 | 1654 | """ |
9f95a23c TL |
1655 | # Create malloc bdev |
1656 | base_name = self.c.construct_malloc_bdev(self.total_size, | |
1657 | self.block_size) | |
1658 | # Construct lvol store on malloc bdev | |
1659 | uuid_store = self.c.construct_lvol_store(base_name, self.lvs_name) | |
1660 | fail_count = self.c.check_get_lvol_stores(base_name, uuid_store, | |
1661 | self.cluster_size) | |
1662 | # Construct thin provisioned lvol bdevs on created lvol store | |
11fdf7f2 | 1663 | # with size equal to 50% of lvol store |
9f95a23c TL |
1664 | size = self.get_lvs_divided_size(2) |
1665 | uuid_bdev = self.c.construct_lvol_bdev(uuid_store, | |
1666 | self.lbd_name, size, thin=True) | |
1667 | fail_count += self.c.check_get_bdevs_methods(uuid_bdev, size) | |
1668 | # Fill all free space of lvol bdev with data | |
1669 | nbd_name = "/dev/nbd0" | |
1670 | fail_count += self.c.start_nbd_disk(uuid_bdev, nbd_name) | |
1671 | fail_count += self.run_fio_test(nbd_name, 0, size*MEGABYTE, "write", "0xcc", 0) | |
1672 | fail_count += self.c.stop_nbd_disk(nbd_name) | |
1673 | # Save number of free clusters for lvs | |
1674 | lvs = self.c.get_lvol_stores()[0] | |
1675 | free_clusters_start = int(lvs['free_clusters']) | |
1676 | # Resize bdev to full size of lvs | |
1677 | full_size = int(lvs['total_data_clusters'] * lvs['cluster_size'] / MEGABYTE) | |
1678 | fail_count += self.c.resize_lvol_bdev(uuid_bdev, full_size) | |
1679 | # Check if bdev size changed (total_data_clusters*cluster_size | |
1680 | # equals to num_blocks*block_size) | |
1681 | lvol_bdev = self.c.get_lvol_bdev_with_name(uuid_bdev) | |
1682 | lbd_size = int(lvol_bdev['num_blocks'] * lvol_bdev['block_size'] / MEGABYTE) | |
1683 | if full_size != lbd_size: | |
1684 | fail_count += 1 | |
1685 | # Check if free_clusters on lvs remain unaffected | |
1686 | lvs = self.c.get_lvol_stores()[0] | |
1687 | free_clusters_resize = int(lvs['free_clusters']) | |
1688 | if free_clusters_start != free_clusters_resize: | |
1689 | fail_count += 1 | |
1690 | # Perform write operation with verification | |
11fdf7f2 | 1691 | # to newly created free space of lvol bdev |
9f95a23c TL |
1692 | nbd_name = "/dev/nbd0" |
1693 | fail_count += self.c.start_nbd_disk(uuid_bdev, nbd_name) | |
1694 | fail_count += self.run_fio_test(nbd_name, int(lbd_size * MEGABYTE / 2), | |
1695 | int(lbd_size * MEGABYTE / 2), "write", "0xcc", 0) | |
1696 | fail_count += self.c.stop_nbd_disk(nbd_name) | |
1697 | # Check if free clusters on lvs equals to zero | |
1698 | lvs = self.c.get_lvol_stores()[0] | |
1699 | if int(lvs['free_clusters']) != 0: | |
1700 | fail_count += 1 | |
1701 | # Resize bdev to 25% of lvs and check if it ended with success | |
1702 | size = self.get_lvs_divided_size(4) | |
1703 | fail_count += self.c.resize_lvol_bdev(uuid_bdev, size) | |
1704 | # Check free clusters on lvs | |
1705 | lvs = self.c.get_lvol_stores()[0] | |
1706 | free_clusters_resize2 = int(lvs['free_clusters']) | |
1707 | free_clusters_expected = int((full_size - size) * MEGABYTE / lvs['cluster_size']) | |
1708 | if free_clusters_expected != free_clusters_resize2: | |
1709 | fail_count += 1 | |
1710 | ||
1711 | self.c.destroy_lvol_bdev(uuid_bdev) | |
1712 | self.c.destroy_lvol_store(uuid_store) | |
1713 | self.c.delete_malloc_bdev(base_name) | |
1714 | ||
11fdf7f2 TL |
1715 | # Expected result: |
1716 | # - calls successful, return code = 0 | |
1717 | # - no other operation fails | |
1718 | return fail_count | |
1719 | ||
1720 | @case_message | |
1721 | def test_case654(self): | |
1722 | """ | |
1723 | thin_overprovisioning | |
1724 | ||
1725 | Create two thin provisioned lvol bdevs with max size | |
1726 | and check if writting more than total size of lvol store | |
1727 | will cause failures. | |
1728 | """ | |
1729 | # create malloc bdev | |
1730 | base_name = self.c.construct_malloc_bdev(self.total_size, | |
1731 | self.block_size) | |
1732 | # construct lvol store on malloc bdev | |
1733 | uuid_store = self.c.construct_lvol_store(base_name, self.lvs_name) | |
1734 | fail_count = self.c.check_get_lvol_stores(base_name, uuid_store, | |
1735 | self.cluster_size) | |
1736 | lvs = self.c.get_lvol_stores(self.lvs_name)[0] | |
1737 | free_clusters_start = int(lvs['free_clusters']) | |
1738 | lbd_name0 = self.lbd_name + str("0") | |
1739 | lbd_name1 = self.lbd_name + str("1") | |
1740 | bdev_size = self.get_lvs_size() | |
1741 | # construct two thin provisioned lvol bdevs on created lvol store | |
1742 | # with size equals to free lvs size | |
1743 | bdev_name0 = self.c.construct_lvol_bdev(uuid_store, lbd_name0, | |
1744 | bdev_size, thin=True) | |
1745 | bdev_name1 = self.c.construct_lvol_bdev(uuid_store, lbd_name1, | |
1746 | bdev_size, thin=True) | |
1747 | ||
1748 | lvs = self.c.get_lvol_stores(self.lvs_name)[0] | |
1749 | free_clusters_create_lvol = int(lvs['free_clusters']) | |
1750 | if free_clusters_start != free_clusters_create_lvol: | |
1751 | fail_count += 1 | |
1752 | lvol_bdev0 = self.c.get_lvol_bdev_with_name(bdev_name0) | |
1753 | lvol_bdev1 = self.c.get_lvol_bdev_with_name(bdev_name1) | |
1754 | ||
1755 | nbd_name0 = "/dev/nbd0" | |
1756 | nbd_name1 = "/dev/nbd1" | |
1757 | fail_count += self.c.start_nbd_disk(lvol_bdev0['name'], nbd_name0) | |
1758 | fail_count += self.c.start_nbd_disk(lvol_bdev1['name'], nbd_name1) | |
1759 | ||
1760 | size = "75%" | |
1761 | # fill first bdev to 75% of its space with specific pattern | |
1762 | fail_count += self.run_fio_test(nbd_name0, 0, size, "write", "0xcc") | |
1763 | ||
1764 | size = "75%" | |
1765 | # fill second bdev up to 75% of its space | |
1766 | # check that error message occured while filling second bdev with data | |
1767 | fail_count += self.run_fio_test(nbd_name1, 0, size, "write", "0xee", | |
1768 | expected_ret_value=1) | |
1769 | ||
1770 | size = "75%" | |
1771 | # check if data on first disk stayed unchanged | |
1772 | fail_count += self.run_fio_test(nbd_name0, 0, size, "read", "0xcc") | |
1773 | ||
1774 | size = "25%" | |
1775 | offset = "75%" | |
1776 | fail_count += self.run_fio_test(nbd_name0, offset, size, "read", "0x00") | |
1777 | ||
1778 | fail_count += self.c.stop_nbd_disk(nbd_name0) | |
1779 | fail_count += self.c.stop_nbd_disk(nbd_name1) | |
1780 | # destroy thin provisioned lvol bdev | |
1781 | fail_count += self.c.destroy_lvol_bdev(lvol_bdev0['name']) | |
1782 | fail_count += self.c.destroy_lvol_bdev(lvol_bdev1['name']) | |
1783 | # destroy lvol store | |
1784 | fail_count += self.c.destroy_lvol_store(uuid_store) | |
1785 | # destroy malloc bdev | |
1786 | fail_count += self.c.delete_malloc_bdev(base_name) | |
1787 | # Expected result: | |
1788 | # - calls successful, return code = 0 | |
1789 | # - no other operation fails | |
1790 | return fail_count | |
1791 | ||
1792 | @case_message | |
1793 | def test_case655(self): | |
1794 | """ | |
1795 | thin_provisioning_filling_disks_less_than_lvs_size | |
1796 | ||
1797 | Check if writing to two thin provisioned lvol bdevs | |
1798 | less than total size of lvol store will end with success | |
1799 | """ | |
1800 | # create malloc bdev | |
1801 | base_name = self.c.construct_malloc_bdev(self.total_size, | |
1802 | self.block_size) | |
1803 | # construct lvol store on malloc bdev | |
1804 | uuid_store = self.c.construct_lvol_store(base_name, self.lvs_name) | |
1805 | fail_count = self.c.check_get_lvol_stores(base_name, uuid_store, | |
1806 | self.cluster_size) | |
1807 | lvs = self.c.get_lvol_stores(self.lvs_name)[0] | |
1808 | free_clusters_start = int(lvs['free_clusters']) | |
1809 | lbd_name0 = self.lbd_name + str("0") | |
1810 | lbd_name1 = self.lbd_name + str("1") | |
1811 | lvs_size = self.get_lvs_size() | |
1812 | bdev_size = int(lvs_size * 0.7) | |
1813 | # construct two thin provisioned lvol bdevs on created lvol store | |
1814 | # with size equal to 70% of lvs size | |
1815 | bdev_name0 = self.c.construct_lvol_bdev(uuid_store, lbd_name0, | |
1816 | bdev_size, thin=True) | |
1817 | bdev_name1 = self.c.construct_lvol_bdev(uuid_store, lbd_name1, | |
1818 | bdev_size, thin=True) | |
1819 | ||
1820 | lvol_bdev0 = self.c.get_lvol_bdev_with_name(bdev_name0) | |
1821 | lvol_bdev1 = self.c.get_lvol_bdev_with_name(bdev_name1) | |
1822 | # check if bdevs are available and size of every disk is equal to 70% of lvs size | |
1823 | nbd_name0 = "/dev/nbd0" | |
1824 | nbd_name1 = "/dev/nbd1" | |
1825 | fail_count += self.c.start_nbd_disk(lvol_bdev0['name'], nbd_name0) | |
1826 | fail_count += self.c.start_nbd_disk(lvol_bdev1['name'], nbd_name1) | |
1827 | size = int(int(lvol_bdev0['num_blocks']) * int(lvol_bdev0['block_size']) * 0.7) | |
1828 | # fill first disk with 70% of its size | |
1829 | # check if operation didn't fail | |
1830 | fail_count += self.run_fio_test(nbd_name0, 0, size, "write", "0xcc") | |
1831 | size = int(int(lvol_bdev1['num_blocks']) * int(lvol_bdev1['block_size']) * 0.7) | |
1832 | # fill second disk also with 70% of its size | |
1833 | # check if operation didn't fail | |
1834 | fail_count += self.run_fio_test(nbd_name1, 0, size, "write", "0xee") | |
1835 | ||
1836 | fail_count += self.c.stop_nbd_disk(nbd_name0) | |
1837 | fail_count += self.c.stop_nbd_disk(nbd_name1) | |
1838 | # destroy thin provisioned lvol bdevs | |
1839 | fail_count += self.c.destroy_lvol_bdev(lvol_bdev0['name']) | |
1840 | fail_count += self.c.destroy_lvol_bdev(lvol_bdev1['name']) | |
1841 | # destroy lvol store | |
1842 | fail_count += self.c.destroy_lvol_store(uuid_store) | |
1843 | # destroy malloc bdev | |
1844 | fail_count += self.c.delete_malloc_bdev(base_name) | |
1845 | # Expected result: | |
1846 | # - calls successful, return code = 0 | |
1847 | # - no other operation fails | |
1848 | return fail_count | |
1849 | ||
1850 | @case_message | |
1851 | def test_case700(self): | |
1852 | """ | |
1853 | tasting_positive | |
1854 | ||
1855 | Positive test for tasting a multi lvol bdev configuration. | |
1856 | Create a lvol store with some lvol bdevs on aio bdev and restart vhost app. | |
1857 | After restarting configuration should be automatically loaded and should be exactly | |
1858 | the same as before restarting. | |
1859 | Check that running configuration can be modified after restarting and tasting. | |
1860 | """ | |
1861 | fail_count = 0 | |
1862 | uuid_bdevs = [] | |
1863 | base_name = "aio_bdev0" | |
1864 | ||
1865 | base_path = path.dirname(sys.argv[0]) | |
1866 | vhost_path = path.join(self.app_path, 'vhost') | |
1867 | pid_path = path.join(base_path, 'vhost.pid') | |
1868 | aio_bdev0 = path.join(base_path, 'aio_bdev_0') | |
1869 | ||
1870 | self.c.construct_aio_bdev(aio_bdev0, base_name, 4096) | |
1871 | # Create initial configuration on running vhost instance | |
1872 | # create lvol store, create 5 bdevs | |
1873 | # save info of all lvs and lvol bdevs | |
1874 | uuid_store = self.c.construct_lvol_store(base_name, | |
1875 | self.lvs_name) | |
1876 | fail_count += self.c.check_get_lvol_stores(base_name, | |
1877 | uuid_store, | |
1878 | self.cluster_size) | |
1879 | ||
1880 | size = self.get_lvs_divided_size(10) | |
1881 | ||
1882 | for i in range(5): | |
1883 | uuid_bdev = self.c.construct_lvol_bdev(uuid_store, | |
1884 | self.lbd_name + str(i), | |
1885 | size) | |
1886 | uuid_bdevs.append(uuid_bdev) | |
1887 | # Using get_bdevs command verify lvol bdevs were correctly created | |
1888 | fail_count += self.c.check_get_bdevs_methods(uuid_bdev, size) | |
1889 | ||
1890 | old_bdevs = sorted(self.c.get_lvol_bdevs(), key=lambda x: x["name"]) | |
1891 | old_stores = self.c.get_lvol_stores() | |
1892 | ||
1893 | # Shut down vhost instance and restart with new instance | |
1894 | fail_count += self._stop_vhost(pid_path) | |
1895 | remove(pid_path) | |
1896 | if self._start_vhost(vhost_path, pid_path) != 0: | |
1897 | fail_count += 1 | |
1898 | return fail_count | |
1899 | ||
1900 | self.c.construct_aio_bdev(aio_bdev0, base_name, 4096) | |
1901 | # Check if configuration was properly loaded after tasting | |
1902 | # get all info all lvs and lvol bdevs, compare with previous info | |
1903 | new_bdevs = sorted(self.c.get_lvol_bdevs(), key=lambda x: x["name"]) | |
1904 | new_stores = self.c.get_lvol_stores() | |
1905 | ||
1906 | if old_stores != new_stores: | |
1907 | fail_count += 1 | |
1908 | print("ERROR: old and loaded lvol store is not the same") | |
1909 | print("DIFF:") | |
1910 | print(old_stores) | |
1911 | print(new_stores) | |
1912 | ||
1913 | if len(old_bdevs) != len(new_bdevs): | |
1914 | fail_count += 1 | |
1915 | print("ERROR: old and loaded lvol bdev list count is not equal") | |
1916 | ||
1917 | for o, n in zip(old_bdevs, new_bdevs): | |
1918 | if o != n: | |
1919 | fail_count += 1 | |
1920 | print("ERROR: old and loaded lvol bdev is not the same") | |
1921 | print("DIFF:") | |
1922 | pprint.pprint([o, n]) | |
1923 | ||
1924 | if fail_count != 0: | |
1925 | self.c.delete_aio_bdev(aio_bdev0) | |
1926 | return fail_count | |
1927 | ||
1928 | # Try modifying loaded configuration | |
1929 | # Add some lvol bdevs to existing lvol store then | |
1930 | # remove all lvol configuration and re-create it again | |
1931 | for i in range(5, 10): | |
1932 | uuid_bdev = self.c.construct_lvol_bdev(uuid_store, | |
1933 | self.lbd_name + str(i), | |
1934 | size) | |
1935 | uuid_bdevs.append(uuid_bdev) | |
1936 | fail_count += self.c.check_get_bdevs_methods(uuid_bdev, size) | |
1937 | ||
1938 | for uuid_bdev in uuid_bdevs: | |
1939 | self.c.destroy_lvol_bdev(uuid_bdev) | |
1940 | ||
1941 | if self.c.destroy_lvol_store(uuid_store) != 0: | |
1942 | fail_count += 1 | |
1943 | ||
1944 | uuid_bdevs = [] | |
1945 | ||
1946 | # Create lvol store on aio bdev, create ten lvol bdevs on lvol store and | |
1947 | # verify all configuration call results | |
1948 | uuid_store = self.c.construct_lvol_store(base_name, | |
1949 | self.lvs_name) | |
1950 | fail_count += self.c.check_get_lvol_stores(base_name, | |
1951 | uuid_store, | |
1952 | self.cluster_size) | |
1953 | ||
1954 | for i in range(10): | |
1955 | uuid_bdev = self.c.construct_lvol_bdev(uuid_store, | |
1956 | self.lbd_name + str(i), | |
1957 | size) | |
1958 | uuid_bdevs.append(uuid_bdev) | |
1959 | fail_count += self.c.check_get_bdevs_methods(uuid_bdev, size) | |
1960 | ||
1961 | # Destroy lvol store | |
1962 | if self.c.destroy_lvol_store(uuid_store) != 0: | |
1963 | fail_count += 1 | |
1964 | ||
1965 | self.c.delete_aio_bdev(base_name) | |
1966 | ||
1967 | return fail_count | |
1968 | ||
1969 | @case_message | |
1970 | def test_case701(self): | |
1971 | """ | |
1972 | tasting_lvol_store_positive | |
1973 | ||
1974 | Positive test for tasting lvol store. | |
1975 | """ | |
1976 | base_path = path.dirname(sys.argv[0]) | |
1977 | aio_bdev0 = path.join(base_path, 'aio_bdev_0') | |
1978 | base_name = "aio_bdev0" | |
1979 | ||
1980 | self.c.construct_aio_bdev(aio_bdev0, base_name, 4096) | |
1981 | # construct lvol store on aio bdev | |
1982 | uuid_store = self.c.construct_lvol_store(base_name, | |
1983 | self.lvs_name) | |
1984 | fail_count = self.c.check_get_lvol_stores(base_name, uuid_store, | |
1985 | self.cluster_size) | |
1986 | ||
1987 | self.c.delete_aio_bdev(base_name) | |
1988 | self.c.construct_aio_bdev(aio_bdev0, base_name, 4096) | |
1989 | # wait 1 second to allow time for lvolstore tasting | |
1990 | sleep(1) | |
1991 | # check if lvol store still exists in vhost configuration | |
1992 | if self.c.check_get_lvol_stores(base_name, uuid_store, | |
1993 | self.cluster_size) != 0: | |
1994 | fail_count += 1 | |
1995 | # destroy lvol store from aio bdev | |
1996 | if self.c.destroy_lvol_store(uuid_store) != 0: | |
1997 | fail_count += 1 | |
1998 | ||
1999 | self.c.delete_aio_bdev(base_name) | |
2000 | return fail_count | |
2001 | ||
2002 | @case_message | |
2003 | def test_case702(self): | |
2004 | """ | |
2005 | tasting_positive_with_different_lvol_store_cluster_size | |
2006 | ||
2007 | Positive test for tasting a multi lvol bdev configuration. | |
2008 | Create two lvol stores with different cluster sizes with some lvol bdevs on aio | |
2009 | drive and restart vhost app. | |
2010 | After restarting configuration should be automatically loaded and should be exactly | |
2011 | the same as before restarting. | |
2012 | """ | |
2013 | fail_count = 0 | |
2014 | uuid_bdevs = [] | |
2015 | cluster_size_1M = MEGABYTE | |
2016 | cluster_size_32M = 32 * MEGABYTE | |
2017 | base_name_1M = "aio_bdev0" | |
2018 | base_name_32M = "aio_bdev1" | |
2019 | ||
2020 | base_path = path.dirname(sys.argv[0]) | |
2021 | vhost_path = path.join(self.app_path, 'vhost') | |
2022 | pid_path = path.join(base_path, 'vhost.pid') | |
2023 | aio_bdev0 = path.join(base_path, 'aio_bdev_0') | |
2024 | aio_bdev1 = path.join(base_path, 'aio_bdev_1') | |
2025 | ||
2026 | self.c.construct_aio_bdev(aio_bdev0, base_name_1M, 4096) | |
2027 | self.c.construct_aio_bdev(aio_bdev1, base_name_32M, 4096) | |
2028 | ||
2029 | # Create initial configuration on running vhost instance | |
2030 | # create lvol store, create 5 bdevs | |
2031 | # save info of all lvs and lvol bdevs | |
2032 | uuid_store_1M = self.c.construct_lvol_store(base_name_1M, | |
2033 | self.lvs_name + "_1M", | |
2034 | cluster_size_1M) | |
2035 | ||
2036 | fail_count += self.c.check_get_lvol_stores(base_name_1M, | |
2037 | uuid_store_1M, | |
2038 | cluster_size_1M) | |
2039 | ||
2040 | uuid_store_32M = self.c.construct_lvol_store(base_name_32M, | |
2041 | self.lvs_name + "_32M", | |
2042 | cluster_size_32M) | |
2043 | ||
2044 | fail_count += self.c.check_get_lvol_stores(base_name_32M, | |
2045 | uuid_store_32M, | |
2046 | cluster_size_32M) | |
2047 | ||
2048 | # size = approx 20% of total aio bdev size | |
2049 | size_1M = self.get_lvs_divided_size(5, self.lvs_name + "_1M") | |
2050 | size_32M = self.get_lvs_divided_size(5, self.lvs_name + "_32M") | |
2051 | ||
2052 | for i in range(5): | |
2053 | uuid_bdev = self.c.construct_lvol_bdev(uuid_store_1M, | |
2054 | self.lbd_name + str(i) + "_1M", | |
2055 | size_1M) | |
2056 | uuid_bdevs.append(uuid_bdev) | |
2057 | # Using get_bdevs command verify lvol bdevs were correctly created | |
2058 | fail_count += self.c.check_get_bdevs_methods(uuid_bdev, size_1M) | |
2059 | ||
2060 | for i in range(5): | |
2061 | uuid_bdev = self.c.construct_lvol_bdev(uuid_store_32M, | |
2062 | self.lbd_name + str(i) + "_32M", | |
2063 | size_32M) | |
2064 | uuid_bdevs.append(uuid_bdev) | |
2065 | # Using get_bdevs command verify lvol bdevs were correctly created | |
2066 | fail_count += self.c.check_get_bdevs_methods(uuid_bdev, size_32M) | |
2067 | ||
2068 | old_bdevs = sorted(self.c.get_lvol_bdevs(), key=lambda x: x["name"]) | |
2069 | old_stores = sorted(self.c.get_lvol_stores(), key=lambda x: x["name"]) | |
2070 | ||
2071 | # Shut down vhost instance and restart with new instance | |
2072 | fail_count += self._stop_vhost(pid_path) | |
2073 | remove(pid_path) | |
2074 | if self._start_vhost(vhost_path, pid_path) != 0: | |
2075 | fail_count += 1 | |
2076 | return fail_count | |
2077 | ||
2078 | self.c.construct_aio_bdev(aio_bdev0, base_name_1M, 4096) | |
2079 | self.c.construct_aio_bdev(aio_bdev1, base_name_32M, 4096) | |
2080 | ||
2081 | # Check if configuration was properly loaded after tasting | |
2082 | # get all info all lvs and lvol bdevs, compare with previous info | |
2083 | new_bdevs = sorted(self.c.get_lvol_bdevs(), key=lambda x: x["name"]) | |
2084 | new_stores = sorted(self.c.get_lvol_stores(), key=lambda x: x["name"]) | |
2085 | ||
2086 | if old_stores != new_stores: | |
2087 | fail_count += 1 | |
2088 | print("ERROR: old and loaded lvol store is not the same") | |
2089 | print("DIFF:") | |
2090 | print(old_stores) | |
2091 | print(new_stores) | |
2092 | ||
2093 | if len(old_bdevs) != len(new_bdevs): | |
2094 | fail_count += 1 | |
2095 | print("ERROR: old and loaded lvol bdev list count is not equal") | |
2096 | ||
2097 | for o, n in zip(old_bdevs, new_bdevs): | |
2098 | if o != n: | |
2099 | fail_count += 1 | |
2100 | print("ERROR: old and loaded lvol bdev is not the same") | |
2101 | print("DIFF:") | |
2102 | pprint.pprint([o, n]) | |
2103 | ||
2104 | if fail_count != 0: | |
2105 | self.c.delete_aio_bdev(base_name_1M) | |
2106 | self.c.delete_aio_bdev(base_name_32M) | |
2107 | return fail_count | |
2108 | ||
2109 | for uuid_bdev in uuid_bdevs: | |
2110 | self.c.destroy_lvol_bdev(uuid_bdev) | |
2111 | ||
2112 | if self.c.destroy_lvol_store(uuid_store_1M) != 0: | |
2113 | fail_count += 1 | |
2114 | ||
2115 | if self.c.destroy_lvol_store(uuid_store_32M) != 0: | |
2116 | fail_count += 1 | |
2117 | ||
2118 | self.c.delete_aio_bdev(base_name_1M) | |
2119 | self.c.delete_aio_bdev(base_name_32M) | |
2120 | ||
2121 | return fail_count | |
2122 | ||
2123 | @case_message | |
2124 | def test_case750(self): | |
2125 | """ | |
2126 | snapshot readonly | |
2127 | ||
2128 | Create snaphot of lvol bdev and check if it is readonly. | |
2129 | """ | |
2130 | fail_count = 0 | |
2131 | nbd_name0 = "/dev/nbd0" | |
2132 | snapshot_name = "snapshot0" | |
2133 | # Construct malloc bdev | |
2134 | base_name = self.c.construct_malloc_bdev(self.total_size, | |
2135 | self.block_size) | |
2136 | # Construct lvol store on malloc bdev | |
2137 | uuid_store = self.c.construct_lvol_store(base_name, | |
2138 | self.lvs_name) | |
2139 | fail_count += self.c.check_get_lvol_stores(base_name, uuid_store, | |
2140 | self.cluster_size) | |
2141 | ||
2142 | lvs = self.c.get_lvol_stores()[0] | |
2143 | free_clusters_start = int(lvs['free_clusters']) | |
2144 | bdev_size = self.get_lvs_divided_size(3) | |
2145 | # Create lvol bdev with 33% of lvol store space | |
2146 | bdev_name = self.c.construct_lvol_bdev(uuid_store, self.lbd_name, | |
2147 | bdev_size) | |
2148 | lvol_bdev = self.c.get_lvol_bdev_with_name(bdev_name) | |
2149 | # Create snapshot of lvol bdev | |
2150 | fail_count += self.c.snapshot_lvol_bdev(lvol_bdev['name'], snapshot_name) | |
2151 | snapshot_bdev = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + snapshot_name) | |
2152 | ||
2153 | fail_count += self.c.start_nbd_disk(snapshot_bdev['name'], nbd_name0) | |
2154 | size = bdev_size * MEGABYTE | |
2155 | # Try to perform write operation on created snapshot | |
2156 | # Check if filling snapshot of lvol bdev fails | |
2157 | fail_count += self.run_fio_test(nbd_name0, 0, size, "write", "0xcc", 1) | |
2158 | ||
2159 | fail_count += self.c.stop_nbd_disk(nbd_name0) | |
2160 | # Destroy lvol bdev | |
2161 | fail_count += self.c.destroy_lvol_bdev(lvol_bdev['name']) | |
2162 | # Destroy snapshot | |
2163 | fail_count += self.c.destroy_lvol_bdev(snapshot_bdev['name']) | |
2164 | # Destroy lvol store | |
2165 | fail_count += self.c.destroy_lvol_store(uuid_store) | |
2166 | # Delete malloc bdev | |
2167 | fail_count += self.c.delete_malloc_bdev(base_name) | |
2168 | ||
2169 | # Expected result: | |
2170 | # - calls successful, return code = 0 | |
2171 | # - no other operation fails | |
2172 | return fail_count | |
2173 | ||
2174 | @case_message | |
2175 | def test_case751(self): | |
2176 | """ | |
2177 | snapshot_compare_with_lvol_bdev | |
2178 | ||
2179 | Check if lvol bdevs and snapshots contain the same data. | |
2180 | Check if lvol bdev and snapshot differ when writing to lvol bdev | |
2181 | after creating snapshot. | |
2182 | """ | |
2183 | fail_count = 0 | |
2184 | nbd_name = ["/dev/nbd0", "/dev/nbd1", "/dev/nbd2", "/dev/nbd3"] | |
2185 | snapshot_name0 = "snapshot0" | |
2186 | snapshot_name1 = "snapshot1" | |
2187 | # Construct mallov bdev | |
2188 | base_name = self.c.construct_malloc_bdev(self.total_size, | |
2189 | self.block_size) | |
2190 | # Construct lvol store | |
2191 | uuid_store = self.c.construct_lvol_store(base_name, | |
2192 | self.lvs_name) | |
2193 | fail_count += self.c.check_get_lvol_stores(base_name, uuid_store, | |
2194 | self.cluster_size) | |
2195 | size = self.get_lvs_divided_size(6) | |
2196 | lbd_name0 = self.lbd_name + str(0) | |
2197 | lbd_name1 = self.lbd_name + str(1) | |
2198 | # Create thin provisioned lvol bdev with size less than 25% of lvs | |
2199 | uuid_bdev0 = self.c.construct_lvol_bdev(uuid_store, | |
2200 | lbd_name0, size, thin=True) | |
2201 | # Create thick provisioned lvol bdev with size less than 25% of lvs | |
2202 | uuid_bdev1 = self.c.construct_lvol_bdev(uuid_store, | |
2203 | lbd_name1, size, thin=False) | |
2204 | lvol_bdev0 = self.c.get_lvol_bdev_with_name(uuid_bdev0) | |
2205 | fail_count += self.c.start_nbd_disk(lvol_bdev0['name'], nbd_name[0]) | |
2206 | fill_size = int(size * MEGABYTE / 2) | |
2207 | # Fill thin provisoned lvol bdev with 50% of its space | |
2208 | fail_count += self.run_fio_test(nbd_name[0], 0, fill_size, "write", "0xcc", 0) | |
2209 | lvol_bdev1 = self.c.get_lvol_bdev_with_name(uuid_bdev1) | |
2210 | fail_count += self.c.start_nbd_disk(lvol_bdev1['name'], nbd_name[1]) | |
2211 | fill_size = int(size * MEGABYTE) | |
2212 | # Fill whole thic provisioned lvol bdev | |
2213 | fail_count += self.run_fio_test(nbd_name[1], 0, fill_size, "write", "0xcc", 0) | |
2214 | ||
2215 | # Create snapshots of lvol bdevs | |
2216 | fail_count += self.c.snapshot_lvol_bdev(uuid_bdev0, snapshot_name0) | |
2217 | fail_count += self.c.snapshot_lvol_bdev(uuid_bdev1, snapshot_name1) | |
2218 | fail_count += self.c.start_nbd_disk(self.lvs_name + "/" + snapshot_name0, nbd_name[2]) | |
2219 | fail_count += self.c.start_nbd_disk(self.lvs_name + "/" + snapshot_name1, nbd_name[3]) | |
2220 | # Compare every lvol bdev with corresponding snapshot | |
2221 | # and check that data are the same | |
2222 | fail_count += self.compare_two_disks(nbd_name[0], nbd_name[2], 0) | |
2223 | fail_count += self.compare_two_disks(nbd_name[1], nbd_name[3], 0) | |
2224 | ||
2225 | fill_size = int(size * MEGABYTE / 2) | |
2226 | offset = fill_size | |
2227 | # Fill second half of thin provisioned lvol bdev | |
2228 | fail_count += self.run_fio_test(nbd_name[0], offset, fill_size, "write", "0xaa", 0) | |
2229 | # Compare thin provisioned lvol bdev with its snapshot and check if it fails | |
2230 | fail_count += self.compare_two_disks(nbd_name[0], nbd_name[2], 1) | |
2231 | for nbd in nbd_name: | |
2232 | fail_count += self.c.stop_nbd_disk(nbd) | |
2233 | # Delete lvol bdevs | |
2234 | fail_count += self.c.destroy_lvol_bdev(lvol_bdev0['name']) | |
2235 | fail_count += self.c.destroy_lvol_bdev(lvol_bdev1['name']) | |
2236 | # Delete snapshots | |
2237 | fail_count += self.c.destroy_lvol_bdev(self.lvs_name + "/" + snapshot_name0) | |
2238 | fail_count += self.c.destroy_lvol_bdev(self.lvs_name + "/" + snapshot_name1) | |
2239 | # Destroy snapshot | |
2240 | fail_count += self.c.destroy_lvol_store(uuid_store) | |
2241 | # Delete malloc bdev | |
2242 | fail_count += self.c.delete_malloc_bdev(base_name) | |
2243 | ||
2244 | # Expected result: | |
2245 | # - calls successful, return code = 0 | |
2246 | # - removing snapshot should always end with success | |
2247 | # - no other operation fails | |
2248 | return fail_count | |
2249 | ||
2250 | @case_message | |
2251 | def test_case752(self): | |
2252 | """ | |
2253 | snapshot_during_io_traffic | |
2254 | ||
2255 | Check that when writing to lvol bdev | |
2256 | creating snapshot ends with success | |
2257 | """ | |
2258 | global current_fio_pid | |
2259 | fail_count = 0 | |
2260 | nbd_name = "/dev/nbd0" | |
2261 | snapshot_name = "snapshot" | |
2262 | # Create malloc bdev | |
2263 | base_name = self.c.construct_malloc_bdev(self.total_size, | |
2264 | self.block_size) | |
2265 | # Construct lvol store | |
2266 | uuid_store = self.c.construct_lvol_store(base_name, | |
2267 | self.lvs_name) | |
2268 | fail_count += self.c.check_get_lvol_stores(base_name, uuid_store, | |
2269 | self.cluster_size) | |
2270 | # Create thin provisioned lvol bdev with size equal to 50% of lvs space | |
2271 | size = self.get_lvs_divided_size(2) | |
2272 | uuid_bdev = self.c.construct_lvol_bdev(uuid_store, self.lbd_name, | |
2273 | size, thin=True) | |
2274 | ||
2275 | lvol_bdev = self.c.get_lvol_bdev_with_name(uuid_bdev) | |
2276 | fail_count += self.c.start_nbd_disk(lvol_bdev['name'], nbd_name) | |
2277 | fill_size = int(size * MEGABYTE) | |
2278 | # Create thread that will run fio in background | |
2279 | thread = FioThread(nbd_name, 0, fill_size, "write", "0xcc", 0, | |
2280 | extra_params="--time_based --runtime=8") | |
2281 | # Perform write operation with verification to created lvol bdev | |
2282 | thread.start() | |
2283 | time.sleep(4) | |
2284 | fail_count += is_process_alive(current_fio_pid) | |
2285 | # During write operation create snapshot of created lvol bdev | |
2286 | # and check that snapshot has been created successfully | |
2287 | fail_count += self.c.snapshot_lvol_bdev(lvol_bdev['name'], snapshot_name) | |
2288 | fail_count += is_process_alive(current_fio_pid) | |
2289 | thread.join() | |
2290 | # Check that write operation ended with success | |
2291 | fail_count += thread.rv | |
2292 | fail_count += self.c.stop_nbd_disk(nbd_name) | |
2293 | # Destroy lvol bdev | |
2294 | fail_count += self.c.destroy_lvol_bdev(lvol_bdev['name']) | |
2295 | # Delete snapshot | |
2296 | fail_count += self.c.destroy_lvol_bdev(self.lvs_name + "/" + snapshot_name) | |
2297 | # Destroy lvol store | |
2298 | fail_count += self.c.destroy_lvol_store(uuid_store) | |
2299 | # Delete malloc bdevs | |
2300 | fail_count += self.c.delete_malloc_bdev(base_name) | |
2301 | ||
2302 | # Expected result: | |
2303 | # - calls successful, return code = 0 | |
2304 | # - no other operation fails | |
2305 | return fail_count | |
2306 | ||
2307 | @case_message | |
2308 | def test_case753(self): | |
2309 | """ | |
2310 | snapshot_of_snapshot | |
2311 | ||
2312 | Check that creating snapshot of snapshot will fail | |
2313 | """ | |
2314 | fail_count = 0 | |
2315 | snapshot_name0 = "snapshot0" | |
2316 | snapshot_name1 = "snapshot1" | |
2317 | # Create malloc bdev | |
2318 | base_name = self.c.construct_malloc_bdev(self.total_size, | |
2319 | self.block_size) | |
2320 | # Construct lvol store | |
2321 | uuid_store = self.c.construct_lvol_store(base_name, | |
2322 | self.lvs_name) | |
2323 | fail_count += self.c.check_get_lvol_stores(base_name, uuid_store, | |
2324 | self.cluster_size) | |
2325 | # Create thick provisioned lvol bdev | |
2326 | size = self.get_lvs_divided_size(2) | |
2327 | uuid_bdev = self.c.construct_lvol_bdev(uuid_store, self.lbd_name, | |
2328 | size, thin=False) | |
2329 | ||
2330 | lvol_bdev = self.c.get_lvol_bdev_with_name(uuid_bdev) | |
2331 | # Create snapshot of created lvol bdev | |
2332 | fail_count += self.c.snapshot_lvol_bdev(lvol_bdev['name'], snapshot_name0) | |
2333 | # Create snapshot of previously created snapshot | |
2334 | # and check if operation will fail | |
2335 | if self.c.snapshot_lvol_bdev(snapshot_name0, snapshot_name1) == 0: | |
2336 | print("ERROR: Creating snapshot of snapshot should fail") | |
2337 | fail_count += 1 | |
2338 | # Delete lvol bdev | |
2339 | fail_count += self.c.destroy_lvol_bdev(lvol_bdev['name']) | |
2340 | # Destroy snapshot | |
2341 | fail_count += self.c.destroy_lvol_bdev(self.lvs_name + "/" + snapshot_name0) | |
2342 | # Destroy lvol store | |
2343 | fail_count += self.c.destroy_lvol_store(uuid_store) | |
2344 | # Delete malloc bdev | |
2345 | fail_count += self.c.delete_malloc_bdev(base_name) | |
2346 | ||
2347 | # Expected result: | |
2348 | # - calls successful, return code = 0 | |
2349 | # - creating snapshot of snapshot should fail | |
2350 | # - no other operation fails | |
2351 | return fail_count | |
2352 | ||
2353 | @case_message | |
2354 | def test_case754(self): | |
2355 | """ | |
2356 | clone_bdev_only | |
2357 | ||
2358 | Check that only clone of snapshot can be created. | |
2359 | Creating clone of lvol bdev should fail. | |
2360 | """ | |
2361 | fail_count = 0 | |
2362 | clone_name = "clone" | |
2363 | snapshot_name = "snapshot" | |
2364 | # Create malloc bdev | |
2365 | base_name = self.c.construct_malloc_bdev(self.total_size, | |
2366 | self.block_size) | |
2367 | # Construct lvol store | |
2368 | uuid_store = self.c.construct_lvol_store(base_name, | |
2369 | self.lvs_name) | |
2370 | fail_count += self.c.check_get_lvol_stores(base_name, uuid_store, | |
2371 | self.cluster_size) | |
2372 | lvs = self.c.get_lvol_stores() | |
2373 | # Create thick provisioned lvol bdev with size equal to 50% of lvs space | |
2374 | size = self.get_lvs_divided_size(2) | |
2375 | uuid_bdev = self.c.construct_lvol_bdev(uuid_store, self.lbd_name, | |
2376 | size, thin=False) | |
2377 | ||
2378 | lvol_bdev = self.c.get_lvol_bdev_with_name(uuid_bdev) | |
2379 | # Create clone of lvol bdev and check if it fails | |
2380 | rv = self.c.clone_lvol_bdev(lvol_bdev['name'], clone_name) | |
2381 | if rv == 0: | |
2382 | print("ERROR: Creating clone of lvol bdev ended with unexpected success") | |
2383 | fail_count += 1 | |
2384 | # Create snapshot of lvol bdev | |
2385 | fail_count += self.c.snapshot_lvol_bdev(lvol_bdev['name'], snapshot_name) | |
2386 | # Create again clone of lvol bdev and check if it fails | |
2387 | rv = self.c.clone_lvol_bdev(lvol_bdev['name'], clone_name) | |
2388 | if rv == 0: | |
2389 | print("ERROR: Creating clone of lvol bdev ended with unexpected success") | |
2390 | fail_count += 1 | |
2391 | # Create clone of snapshot and check if it ends with success | |
2392 | rv = self.c.clone_lvol_bdev(self.lvs_name + "/" + snapshot_name, clone_name) | |
2393 | if rv != 0: | |
2394 | print("ERROR: Creating clone of snapshot ended with unexpected failure") | |
2395 | fail_count += 1 | |
2396 | clone_bdev = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + clone_name) | |
2397 | ||
2398 | # Delete lvol bdev | |
2399 | fail_count += self.c.destroy_lvol_bdev(lvol_bdev['name']) | |
2400 | # Destroy clone | |
2401 | fail_count += self.c.destroy_lvol_bdev(clone_bdev['name']) | |
2402 | # Delete snapshot | |
2403 | fail_count += self.c.destroy_lvol_bdev(self.lvs_name + "/" + snapshot_name) | |
2404 | # Delete lvol store | |
2405 | fail_count += self.c.destroy_lvol_store(uuid_store) | |
2406 | # Destroy malloc bdev | |
2407 | fail_count += self.c.delete_malloc_bdev(base_name) | |
2408 | ||
2409 | # Expected result: | |
2410 | # - calls successful, return code = 0 | |
2411 | # - cloning thick provisioned lvol bdev should fail | |
2412 | # - no other operation fails | |
2413 | return fail_count | |
2414 | ||
2415 | @case_message | |
2416 | def test_case755(self): | |
2417 | """ | |
2418 | clone_writing_to_clone | |
2419 | ||
2420 | ||
2421 | """ | |
2422 | fail_count = 0 | |
2423 | nbd_name = ["/dev/nbd0", "/dev/nbd1", "/dev/nbd2", "/dev/nbd3"] | |
2424 | snapshot_name = "snapshot" | |
2425 | clone_name0 = "clone0" | |
2426 | clone_name1 = "clone1" | |
2427 | # Create malloc bdev | |
2428 | base_name = self.c.construct_malloc_bdev(self.total_size, | |
2429 | self.block_size) | |
2430 | # Create lvol store | |
2431 | uuid_store = self.c.construct_lvol_store(base_name, | |
2432 | self.lvs_name) | |
2433 | fail_count += self.c.check_get_lvol_stores(base_name, uuid_store, | |
2434 | self.cluster_size) | |
2435 | size = self.get_lvs_divided_size(6) | |
2436 | lbd_name0 = self.lbd_name + str(0) | |
2437 | # Construct thick provisioned lvol bdev | |
2438 | uuid_bdev0 = self.c.construct_lvol_bdev(uuid_store, | |
2439 | lbd_name0, size, thin=False) | |
2440 | lvol_bdev = self.c.get_lvol_bdev_with_name(uuid_bdev0) | |
2441 | # Install lvol bdev on /dev/nbd0 | |
2442 | fail_count += self.c.start_nbd_disk(lvol_bdev['name'], nbd_name[0]) | |
2443 | fill_size = size * MEGABYTE | |
2444 | # Fill lvol bdev with 100% of its space | |
2445 | fail_count += self.run_fio_test(nbd_name[0], 0, fill_size, "write", "0xcc", 0) | |
2446 | ||
2447 | # Create snapshot of thick provisioned lvol bdev | |
2448 | fail_count += self.c.snapshot_lvol_bdev(lvol_bdev['name'], snapshot_name) | |
2449 | snapshot_bdev = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + snapshot_name) | |
2450 | # Create two clones of created snapshot | |
2451 | fail_count += self.c.clone_lvol_bdev(snapshot_bdev['name'], clone_name0) | |
2452 | fail_count += self.c.clone_lvol_bdev(snapshot_bdev['name'], clone_name1) | |
2453 | ||
2454 | lvol_clone0 = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + clone_name0) | |
2455 | fail_count += self.c.start_nbd_disk(lvol_clone0['name'], nbd_name[1]) | |
2456 | fill_size = int(size * MEGABYTE / 2) | |
2457 | # Perform write operation to first clone | |
2458 | # Change first half of its space | |
2459 | fail_count += self.run_fio_test(nbd_name[1], 0, fill_size, "write", "0xaa", 0) | |
2460 | fail_count += self.c.start_nbd_disk(self.lvs_name + "/" + snapshot_name, nbd_name[2]) | |
2461 | lvol_clone1 = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + clone_name1) | |
2462 | fail_count += self.c.start_nbd_disk(lvol_clone1['name'], nbd_name[3]) | |
2463 | # Compare snapshot with second clone. Data on both bdevs should be the same | |
2464 | time.sleep(1) | |
2465 | fail_count += self.compare_two_disks(nbd_name[2], nbd_name[3], 0) | |
2466 | ||
2467 | for nbd in nbd_name: | |
2468 | fail_count += self.c.stop_nbd_disk(nbd) | |
2469 | # Destroy lvol bdev | |
2470 | fail_count += self.c.destroy_lvol_bdev(lvol_bdev['name']) | |
2471 | # Destroy two clones | |
2472 | fail_count += self.c.destroy_lvol_bdev(lvol_clone0['name']) | |
2473 | fail_count += self.c.destroy_lvol_bdev(lvol_clone1['name']) | |
2474 | # Delete snapshot | |
2475 | fail_count += self.c.destroy_lvol_bdev(snapshot_bdev['name']) | |
2476 | # Destroy lvol store | |
2477 | fail_count += self.c.destroy_lvol_store(uuid_store) | |
2478 | # Delete malloc | |
2479 | fail_count += self.c.delete_malloc_bdev(base_name) | |
2480 | ||
2481 | # Expected result: | |
2482 | # - calls successful, return code = 0 | |
2483 | # - no other operation fails | |
2484 | return fail_count | |
2485 | ||
2486 | @case_message | |
2487 | def test_case756(self): | |
2488 | """ | |
2489 | clone_and_snapshot_relations | |
2490 | ||
2491 | Check if relations between clones and snapshots | |
2492 | are properly set in configuration | |
2493 | """ | |
2494 | fail_count = 0 | |
2495 | snapshot_name = 'snapshot' | |
2496 | clone_name0 = 'clone1' | |
2497 | clone_name1 = 'clone2' | |
2498 | lbd_name = clone_name1 | |
2499 | ||
2500 | # Create malloc bdev | |
2501 | base_name = self.c.construct_malloc_bdev(self.total_size, | |
2502 | self.block_size) | |
2503 | # Create lvol store | |
2504 | uuid_store = self.c.construct_lvol_store(base_name, | |
2505 | self.lvs_name) | |
2506 | fail_count += self.c.check_get_lvol_stores(base_name, uuid_store, | |
2507 | self.cluster_size) | |
2508 | size = self.get_lvs_divided_size(6) | |
2509 | ||
2510 | # Construct thick provisioned lvol bdev | |
2511 | uuid_bdev = self.c.construct_lvol_bdev(uuid_store, | |
2512 | lbd_name, size, thin=False) | |
2513 | lvol_bdev = self.c.get_lvol_bdev_with_name(uuid_bdev) | |
2514 | ||
2515 | # Create snapshot of thick provisioned lvol bdev | |
2516 | fail_count += self.c.snapshot_lvol_bdev(lvol_bdev['name'], snapshot_name) | |
2517 | snapshot_bdev = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + snapshot_name) | |
2518 | ||
2519 | # Create clone of created snapshot | |
2520 | fail_count += self.c.clone_lvol_bdev(snapshot_bdev['name'], clone_name0) | |
2521 | ||
2522 | # Get current bdevs configuration | |
2523 | snapshot_bdev = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + snapshot_name) | |
2524 | lvol_clone0 = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + clone_name0) | |
2525 | lvol_clone1 = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + clone_name1) | |
2526 | ||
2527 | # Check snapshot consistency | |
2528 | snapshot_lvol = snapshot_bdev['driver_specific']['lvol'] | |
2529 | if snapshot_lvol['snapshot'] is not True: | |
2530 | fail_count += 1 | |
2531 | if snapshot_lvol['clone'] is not False: | |
2532 | fail_count += 1 | |
2533 | if sorted([clone_name0, clone_name1]) != sorted(snapshot_lvol['clones']): | |
2534 | fail_count += 1 | |
2535 | ||
2536 | # Check first clone consistency | |
2537 | lvol_clone0_lvol = lvol_clone0['driver_specific']['lvol'] | |
2538 | if lvol_clone0_lvol['snapshot'] is not False: | |
2539 | fail_count += 1 | |
2540 | if lvol_clone0_lvol['clone'] is not True: | |
2541 | fail_count += 1 | |
2542 | if lvol_clone0_lvol['base_snapshot'] != 'snapshot': | |
2543 | fail_count += 1 | |
2544 | ||
2545 | # Check second clone consistency | |
2546 | lvol_clone1_lvol = lvol_clone1['driver_specific']['lvol'] | |
2547 | if lvol_clone1_lvol['snapshot'] is not False: | |
2548 | fail_count += 1 | |
2549 | if lvol_clone1_lvol['clone'] is not True: | |
2550 | fail_count += 1 | |
2551 | if lvol_clone1_lvol['base_snapshot'] != 'snapshot': | |
2552 | fail_count += 1 | |
2553 | ||
2554 | # Destroy first clone and check if it is deleted from snapshot | |
2555 | fail_count += self.c.destroy_lvol_bdev(lvol_clone0['name']) | |
2556 | snapshot_bdev = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + snapshot_name) | |
2557 | if [clone_name1] != snapshot_bdev['driver_specific']['lvol']['clones']: | |
2558 | fail_count += 1 | |
2559 | ||
2560 | # Destroy second clone | |
2561 | fail_count += self.c.destroy_lvol_bdev(lvol_clone1['name']) | |
2562 | ||
2563 | # Delete snapshot | |
2564 | fail_count += self.c.destroy_lvol_bdev(snapshot_bdev['name']) | |
2565 | ||
2566 | # Destroy lvol store | |
2567 | fail_count += self.c.destroy_lvol_store(uuid_store) | |
2568 | ||
2569 | # Delete malloc | |
2570 | fail_count += self.c.delete_malloc_bdev(base_name) | |
2571 | ||
2572 | # Expected result: | |
2573 | # - calls successful, return code = 0 | |
2574 | # - no other operation fails | |
2575 | return fail_count | |
2576 | ||
2577 | @case_message | |
2578 | def test_case757(self): | |
2579 | """ | |
2580 | clone_inflate | |
2581 | ||
2582 | ||
2583 | Test inflate rpc method | |
2584 | """ | |
2585 | fail_count = 0 | |
2586 | snapshot_name = "snapshot" | |
2587 | nbd_name = "/dev/nbd0" | |
2588 | ||
2589 | # Create malloc bdev | |
2590 | base_name = self.c.construct_malloc_bdev(self.total_size, | |
2591 | self.block_size) | |
2592 | ||
2593 | # Create lvol store | |
2594 | uuid_store = self.c.construct_lvol_store(base_name, | |
2595 | self.lvs_name) | |
2596 | fail_count += self.c.check_get_lvol_stores(base_name, uuid_store, | |
2597 | self.cluster_size) | |
2598 | size = self.get_lvs_divided_size(4) | |
2599 | ||
2600 | # Construct thick provisioned lvol bdev | |
2601 | uuid_bdev0 = self.c.construct_lvol_bdev(uuid_store, | |
2602 | self.lbd_name, size, thin=False) | |
2603 | lvol_bdev = self.c.get_lvol_bdev_with_name(uuid_bdev0) | |
2604 | ||
2605 | # Fill bdev with data of knonw pattern | |
2606 | fail_count += self.c.start_nbd_disk(lvol_bdev['name'], nbd_name) | |
2607 | fill_size = size * MEGABYTE | |
2608 | fail_count += self.run_fio_test(nbd_name, 0, fill_size, "write", "0xcc", 0) | |
2609 | self.c.stop_nbd_disk(nbd_name) | |
2610 | ||
2611 | # Create snapshot of thick provisioned lvol bdev | |
2612 | fail_count += self.c.snapshot_lvol_bdev(lvol_bdev['name'], snapshot_name) | |
2613 | snapshot_bdev = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + snapshot_name) | |
2614 | ||
2615 | # Create two clones of created snapshot | |
2616 | lvol_clone = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + self.lbd_name) | |
2617 | if lvol_clone['driver_specific']['lvol']['thin_provision'] is not True: | |
2618 | fail_count += 1 | |
2619 | ||
2620 | # Fill part of clone with data of known pattern | |
2621 | fail_count += self.c.start_nbd_disk(lvol_clone['name'], nbd_name) | |
2622 | first_fill = 0 | |
2623 | second_fill = int(size * 3 / 4) | |
2624 | fail_count += self.run_fio_test(nbd_name, first_fill * MEGABYTE, | |
2625 | MEGABYTE, "write", "0xdd", 0) | |
2626 | fail_count += self.run_fio_test(nbd_name, second_fill * MEGABYTE, | |
2627 | MEGABYTE, "write", "0xdd", 0) | |
2628 | self.c.stop_nbd_disk(nbd_name) | |
2629 | ||
2630 | # Do inflate | |
2631 | fail_count += self.c.inflate_lvol_bdev(lvol_clone['name']) | |
2632 | lvol_clone = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + self.lbd_name) | |
2633 | if lvol_clone['driver_specific']['lvol']['thin_provision'] is not False: | |
2634 | fail_count += 1 | |
2635 | ||
2636 | # Delete snapshot | |
2637 | fail_count += self.c.destroy_lvol_bdev(snapshot_bdev['name']) | |
2638 | ||
2639 | # Check data consistency | |
2640 | fail_count += self.c.start_nbd_disk(lvol_clone['name'], nbd_name) | |
2641 | fail_count += self.run_fio_test(nbd_name, first_fill * MEGABYTE, | |
2642 | MEGABYTE, "read", "0xdd") | |
2643 | fail_count += self.run_fio_test(nbd_name, (first_fill + 1) * MEGABYTE, | |
2644 | (second_fill - first_fill - 1) * MEGABYTE, | |
2645 | "read", "0xcc") | |
2646 | fail_count += self.run_fio_test(nbd_name, (second_fill) * MEGABYTE, | |
2647 | MEGABYTE, "read", "0xdd") | |
2648 | fail_count += self.run_fio_test(nbd_name, (second_fill + 1) * MEGABYTE, | |
2649 | (size - second_fill - 1) * MEGABYTE, | |
2650 | "read", "0xcc") | |
2651 | self.c.stop_nbd_disk(nbd_name) | |
2652 | ||
2653 | # Destroy lvol bdev | |
2654 | fail_count += self.c.destroy_lvol_bdev(lvol_bdev['name']) | |
2655 | ||
2656 | # Destroy lvol store | |
2657 | fail_count += self.c.destroy_lvol_store(uuid_store) | |
2658 | ||
2659 | # Delete malloc | |
2660 | fail_count += self.c.delete_malloc_bdev(base_name) | |
2661 | ||
2662 | # Expected result: | |
2663 | # - calls successful, return code = 0 | |
2664 | # - no other operation fails | |
2665 | return fail_count | |
2666 | ||
2667 | @case_message | |
2668 | def test_case758(self): | |
2669 | """ | |
2670 | clone_decouple_parent | |
2671 | ||
2672 | Detach parent from clone and check if parent can be safely removed. | |
2673 | Check data consistency. | |
2674 | """ | |
2675 | ||
2676 | fail_count = 0 | |
2677 | snapshot_name = "snapshot" | |
2678 | nbd_name = "/dev/nbd0" | |
2679 | ||
2680 | # Create malloc bdev | |
2681 | base_name = self.c.construct_malloc_bdev(self.total_size, | |
2682 | self.block_size) | |
2683 | ||
2684 | # Create lvol store | |
2685 | uuid_store = self.c.construct_lvol_store(base_name, | |
2686 | self.lvs_name) | |
2687 | fail_count += self.c.check_get_lvol_stores(base_name, uuid_store, | |
2688 | self.cluster_size) | |
2689 | size = self.get_lvs_divided_size(4) | |
2690 | ||
2691 | # Construct thin provisioned lvol bdev | |
2692 | uuid_bdev0 = self.c.construct_lvol_bdev(uuid_store, | |
2693 | self.lbd_name, size, thin=True) | |
2694 | lvol_bdev = self.c.get_lvol_bdev_with_name(uuid_bdev0) | |
2695 | ||
2696 | # Decouple parent lvol bdev and check if it fails | |
2697 | ret_value = self.c.decouple_parent_lvol_bdev(lvol_bdev['name']) | |
2698 | if ret_value == 0: | |
2699 | print("ERROR: Decouple parent on bdev without parent should " | |
2700 | "fail but didn't") | |
2701 | fail_count += 1 | |
2702 | ||
2703 | # Create snapshot of thin provisioned lvol bdev | |
2704 | fail_count += self.c.snapshot_lvol_bdev(lvol_bdev['name'], snapshot_name) | |
2705 | snapshot_bdev = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + snapshot_name) | |
2706 | ||
2707 | # Try to destroy snapshot and check if it fails | |
2708 | ret_value = self.c.destroy_lvol_bdev(snapshot_bdev['name']) | |
2709 | if ret_value == 0: | |
2710 | print("ERROR: Delete snapshot should fail but didn't") | |
2711 | fail_count += 1 | |
2712 | ||
2713 | # Decouple parent lvol bdev | |
2714 | fail_count += self.c.decouple_parent_lvol_bdev(lvol_bdev['name']) | |
2715 | lvol_bdev = self.c.get_lvol_bdev_with_name(uuid_bdev0) | |
2716 | snapshot_bdev = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + snapshot_name) | |
2717 | if lvol_bdev['driver_specific']['lvol']['thin_provision'] is not True: | |
2718 | fail_count += 1 | |
2719 | if lvol_bdev['driver_specific']['lvol']['clone'] is not False: | |
2720 | fail_count += 1 | |
2721 | if lvol_bdev['driver_specific']['lvol']['snapshot'] is not False: | |
2722 | fail_count += 1 | |
2723 | if snapshot_bdev['driver_specific']['lvol']['clone'] is not False: | |
2724 | fail_count += 1 | |
2725 | ||
2726 | # Destroy snapshot | |
2727 | fail_count += self.c.destroy_lvol_bdev(snapshot_bdev['name']) | |
2728 | ||
2729 | # Destroy lvol bdev | |
2730 | fail_count += self.c.destroy_lvol_bdev(lvol_bdev['name']) | |
2731 | ||
2732 | # Destroy lvol store | |
2733 | fail_count += self.c.destroy_lvol_store(uuid_store) | |
2734 | ||
2735 | # Delete malloc | |
2736 | fail_count += self.c.delete_malloc_bdev(base_name) | |
2737 | ||
2738 | # Expected result: | |
2739 | # - calls successful, return code = 0 | |
2740 | # - no other operation fails | |
2741 | return fail_count | |
2742 | ||
2743 | @case_message | |
2744 | def test_case759(self): | |
2745 | """ | |
2746 | clone_decouple_parent_rw | |
2747 | ||
2748 | Create tree level snaphot-snapshot2-clone structure. | |
2749 | Detach snapshot2 from clone. Check if snapshot2 can be safely removed. | |
2750 | Each time check consistency of snapshot-clone relations and written data. | |
2751 | """ | |
2752 | fail_count = 0 | |
2753 | snapshot_name = "snapshot" | |
2754 | snapshot_name2 = "snapshot2" | |
2755 | nbd_name = "/dev/nbd0" | |
2756 | ||
2757 | # Create malloc bdev | |
2758 | base_name = self.c.construct_malloc_bdev(self.total_size, | |
2759 | self.block_size) | |
2760 | ||
2761 | # Create lvol store | |
2762 | uuid_store = self.c.construct_lvol_store(base_name, | |
2763 | self.lvs_name) | |
2764 | fail_count += self.c.check_get_lvol_stores(base_name, uuid_store, | |
2765 | self.cluster_size) | |
2766 | lvs = self.c.get_lvol_stores() | |
2767 | size = int(5 * lvs[0]['cluster_size'] / MEGABYTE) | |
2768 | ||
2769 | # Construct thin provisioned lvol bdev | |
2770 | uuid_bdev0 = self.c.construct_lvol_bdev(uuid_store, | |
2771 | self.lbd_name, size, thin=True) | |
2772 | lvol_bdev = self.c.get_lvol_bdev_with_name(uuid_bdev0) | |
2773 | ||
2774 | # Fill first four out of 5 culsters of clone with data of known pattern | |
2775 | fail_count += self.c.start_nbd_disk(lvol_bdev['name'], nbd_name) | |
2776 | begin_fill = 0 | |
2777 | end_fill = int(size * 4 / 5) | |
2778 | fail_count += self.run_fio_test(nbd_name, begin_fill * MEGABYTE, | |
2779 | end_fill * MEGABYTE, "write", "0xdd", 0) | |
2780 | ||
2781 | # Create snapshot of thin provisioned lvol bdev | |
2782 | fail_count += self.c.snapshot_lvol_bdev(lvol_bdev['name'], snapshot_name) | |
2783 | snapshot_bdev = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + snapshot_name) | |
2784 | ||
2785 | # Fill second and fourth cluster of clone with data of known pattern | |
2786 | start_fill = int(size / 5) | |
2787 | fill_range = int(size / 5) | |
2788 | fail_count += self.run_fio_test(nbd_name, start_fill * MEGABYTE, | |
2789 | fill_range * MEGABYTE, "write", "0xcc", 0) | |
2790 | start_fill = int(size * 3 / 5) | |
2791 | fail_count += self.run_fio_test(nbd_name, start_fill * MEGABYTE, | |
2792 | fill_range * MEGABYTE, "write", "0xcc", 0) | |
2793 | ||
2794 | # Create second snapshot of thin provisioned lvol bdev | |
2795 | fail_count += self.c.snapshot_lvol_bdev(lvol_bdev['name'], snapshot_name2) | |
2796 | snapshot_bdev2 = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + snapshot_name2) | |
2797 | ||
2798 | # Fill second cluster of clone with data of known pattern | |
2799 | start_fill = int(size / 5) | |
2800 | fail_count += self.run_fio_test(nbd_name, start_fill * MEGABYTE, | |
2801 | fill_range * MEGABYTE, "write", "0xee", 0) | |
2802 | ||
2803 | # Check data consistency | |
2804 | pattern = ["0xdd", "0xee", "0xdd", "0xcc", "0x00"] | |
2805 | for i in range(0, 5): | |
2806 | begin_fill = int(size * i / 5) | |
2807 | fail_count += self.run_fio_test(nbd_name, begin_fill * MEGABYTE, | |
2808 | fill_range * MEGABYTE, "read", pattern[i]) | |
2809 | ||
2810 | # Delete snapshot and check if it fails | |
2811 | ret_value = self.c.destroy_lvol_bdev(snapshot_bdev2['name']) | |
2812 | if ret_value == 0: | |
2813 | print("ERROR: Delete snapshot should fail but didn't") | |
2814 | fail_count += 1 | |
2815 | ||
2816 | # Decouple parent | |
2817 | fail_count += self.c.decouple_parent_lvol_bdev(lvol_bdev['name']) | |
2818 | lvol_bdev = self.c.get_lvol_bdev_with_name(uuid_bdev0) | |
2819 | ||
2820 | # Check data consistency | |
2821 | for i in range(0, 5): | |
2822 | begin_fill = int(size * i / 5) | |
2823 | fail_count += self.run_fio_test(nbd_name, begin_fill * MEGABYTE, | |
2824 | fill_range * MEGABYTE, "read", pattern[i]) | |
2825 | ||
2826 | # Delete second snapshot | |
2827 | ret_value = self.c.destroy_lvol_bdev(snapshot_bdev2['name']) | |
2828 | ||
2829 | # Check data consistency | |
2830 | for i in range(0, 5): | |
2831 | begin_fill = int(size * i / 5) | |
2832 | fail_count += self.run_fio_test(nbd_name, begin_fill * MEGABYTE, | |
2833 | fill_range * MEGABYTE, "read", pattern[i]) | |
2834 | ||
2835 | # Destroy lvol bdev | |
2836 | fail_count += self.c.destroy_lvol_bdev(lvol_bdev['name']) | |
2837 | ||
2838 | # Destroy snapshot | |
2839 | fail_count += self.c.destroy_lvol_bdev(snapshot_bdev['name']) | |
2840 | ||
2841 | # Destroy lvol store | |
2842 | fail_count += self.c.destroy_lvol_store(uuid_store) | |
2843 | ||
2844 | # Delete malloc | |
2845 | fail_count += self.c.delete_malloc_bdev(base_name) | |
2846 | ||
2847 | # Expected result: | |
2848 | # - calls successful, return code = 0 | |
2849 | # - no other operation fails | |
2850 | return fail_count | |
2851 | ||
9f95a23c TL |
2852 | @case_message |
2853 | def test_case760(self): | |
2854 | """ | |
2855 | set read only | |
2856 | ||
2857 | Set lvol bdev as read only and perform clone on it. | |
2858 | """ | |
2859 | fail_count = 0 | |
2860 | nbd_name0 = "/dev/nbd0" | |
2861 | nbd_name1 = "/dev/nbd1" | |
2862 | clone_name = "clone0" | |
2863 | # Construct malloc bdev | |
2864 | base_name = self.c.construct_malloc_bdev(self.total_size, | |
2865 | self.block_size) | |
2866 | # Construct lvol store on malloc bdev | |
2867 | uuid_store = self.c.construct_lvol_store(base_name, | |
2868 | self.lvs_name) | |
2869 | fail_count += self.c.check_get_lvol_stores(base_name, uuid_store, | |
2870 | self.cluster_size) | |
2871 | ||
2872 | # Create lvol bdev with 50% of lvol store space | |
2873 | lvs = self.c.get_lvol_stores()[0] | |
2874 | free_clusters_start = int(lvs['free_clusters']) | |
2875 | bdev_size = self.get_lvs_divided_size(2) | |
2876 | bdev_name = self.c.construct_lvol_bdev(uuid_store, self.lbd_name, | |
2877 | bdev_size) | |
2878 | # Set lvol bdev as read only | |
2879 | lvol_bdev = self.c.get_lvol_bdev_with_name(bdev_name) | |
2880 | fail_count += self.c.set_read_only_lvol_bdev(lvol_bdev['name']) | |
2881 | ||
2882 | # Try to perform write operation on lvol marked as read only | |
2883 | fail_count += self.c.start_nbd_disk(lvol_bdev['name'], nbd_name0) | |
2884 | size = bdev_size * MEGABYTE | |
2885 | fail_count += self.run_fio_test(nbd_name0, 0, size, "write", "0xcc", 1) | |
2886 | ||
2887 | # Create clone of lvol set to read only | |
2888 | rv = self.c.clone_lvol_bdev(lvol_bdev['name'], clone_name) | |
2889 | if rv != 0: | |
2890 | print("ERROR: Creating clone of snapshot ended with unexpected failure") | |
2891 | fail_count += 1 | |
2892 | clone_bdev = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + clone_name) | |
2893 | ||
2894 | # Try to perform write operation on lvol clone | |
2895 | fail_count += self.c.start_nbd_disk(clone_bdev['name'], nbd_name1) | |
2896 | size = bdev_size * MEGABYTE | |
2897 | fail_count += self.run_fio_test(nbd_name1, 0, size, "write", "0xcc", 0) | |
2898 | ||
2899 | # Stop nbd disks | |
2900 | fail_count += self.c.stop_nbd_disk(nbd_name0) | |
2901 | fail_count += self.c.stop_nbd_disk(nbd_name1) | |
2902 | # Destroy clone lvol bdev | |
2903 | fail_count += self.c.destroy_lvol_bdev(clone_bdev['name']) | |
2904 | # Destroy lvol bdev | |
2905 | fail_count += self.c.destroy_lvol_bdev(lvol_bdev['name']) | |
2906 | # Destroy lvol store | |
2907 | fail_count += self.c.destroy_lvol_store(uuid_store) | |
2908 | # Delete malloc bdev | |
2909 | fail_count += self.c.delete_malloc_bdev(base_name) | |
2910 | ||
2911 | # Expected result: | |
2912 | # - calls successful, return code = 0 | |
2913 | # - no other operation fails | |
2914 | return fail_count | |
2915 | ||
11fdf7f2 TL |
2916 | @case_message |
2917 | def test_case800(self): | |
9f95a23c TL |
2918 | """ |
2919 | rename_positive | |
2920 | ||
2921 | Positive test for lvol store and lvol bdev rename. | |
2922 | """ | |
11fdf7f2 TL |
2923 | fail_count = 0 |
2924 | ||
2925 | bdev_uuids = [] | |
2926 | bdev_names = [self.lbd_name + str(i) for i in range(4)] | |
2927 | bdev_aliases = ["/".join([self.lvs_name, name]) for name in bdev_names] | |
2928 | ||
9f95a23c | 2929 | # Create malloc bdev |
11fdf7f2 TL |
2930 | base_name = self.c.construct_malloc_bdev(self.total_size, |
2931 | self.block_size) | |
9f95a23c | 2932 | # Construct lvol store on created malloc bdev |
11fdf7f2 TL |
2933 | lvs_uuid = self.c.construct_lvol_store(base_name, |
2934 | self.lvs_name) | |
2935 | fail_count += self.c.check_get_lvol_stores(base_name, | |
2936 | lvs_uuid, | |
2937 | self.cluster_size, | |
2938 | self.lvs_name) | |
9f95a23c | 2939 | # Create 4 lvol bdevs on top of previously created lvol store |
11fdf7f2 TL |
2940 | bdev_size = self.get_lvs_divided_size(4) |
2941 | for name, alias in zip(bdev_names, bdev_aliases): | |
2942 | uuid = self.c.construct_lvol_bdev(lvs_uuid, | |
2943 | name, | |
2944 | bdev_size) | |
2945 | fail_count += self.c.check_get_bdevs_methods(uuid, | |
2946 | bdev_size, | |
2947 | alias) | |
2948 | bdev_uuids.append(uuid) | |
2949 | ||
2950 | # Rename lvol store and check if lvol store name and | |
2951 | # lvol bdev aliases were updated properly | |
2952 | new_lvs_name = "lvs_new" | |
2953 | bdev_aliases = [alias.replace(self.lvs_name, new_lvs_name) for alias in bdev_aliases] | |
2954 | ||
2955 | fail_count += self.c.rename_lvol_store(self.lvs_name, new_lvs_name) | |
2956 | ||
2957 | fail_count += self.c.check_get_lvol_stores(base_name, | |
2958 | lvs_uuid, | |
2959 | self.cluster_size, | |
2960 | new_lvs_name) | |
2961 | ||
2962 | for uuid, alias in zip(bdev_uuids, bdev_aliases): | |
2963 | fail_count += self.c.check_get_bdevs_methods(uuid, | |
2964 | bdev_size, | |
2965 | alias) | |
2966 | ||
2967 | # Now try to rename the bdevs using their uuid as "old_name" | |
9f95a23c | 2968 | # Verify that all bdev names were successfully updated |
11fdf7f2 TL |
2969 | bdev_names = ["lbd_new" + str(i) for i in range(4)] |
2970 | bdev_aliases = ["/".join([new_lvs_name, name]) for name in bdev_names] | |
2971 | print(bdev_aliases) | |
2972 | for uuid, new_name, new_alias in zip(bdev_uuids, bdev_names, bdev_aliases): | |
2973 | fail_count += self.c.rename_lvol_bdev(uuid, new_name) | |
2974 | fail_count += self.c.check_get_bdevs_methods(uuid, | |
2975 | bdev_size, | |
2976 | new_alias) | |
9f95a23c TL |
2977 | # Rename lvol bdevs. Use lvols alias name to point which lvol bdev name to change |
2978 | # Verify that all bdev names were successfully updated | |
11fdf7f2 TL |
2979 | bdev_names = ["lbd_even_newer" + str(i) for i in range(4)] |
2980 | new_bdev_aliases = ["/".join([new_lvs_name, name]) for name in bdev_names] | |
2981 | print(bdev_aliases) | |
2982 | for uuid, old_alias, new_alias, new_name in zip(bdev_uuids, bdev_aliases, new_bdev_aliases, bdev_names): | |
2983 | fail_count += self.c.rename_lvol_bdev(old_alias, new_name) | |
2984 | fail_count += self.c.check_get_bdevs_methods(uuid, | |
2985 | bdev_size, | |
2986 | new_alias) | |
2987 | ||
2988 | # Delete configuration using names after rename operation | |
2989 | for bdev in new_bdev_aliases: | |
2990 | fail_count += self.c.destroy_lvol_bdev(bdev) | |
2991 | fail_count += self.c.destroy_lvol_store(new_lvs_name) | |
2992 | fail_count += self.c.delete_malloc_bdev(base_name) | |
2993 | ||
9f95a23c TL |
2994 | # Expected results: |
2995 | # - lvol store and lvol bdevs correctly created | |
2996 | # - lvol store and lvol bdevs names updated after renaming operation | |
2997 | # - lvol store and lvol bdevs possible to delete using new names | |
2998 | # - no other operation fails | |
11fdf7f2 TL |
2999 | return fail_count |
3000 | ||
3001 | @case_message | |
3002 | def test_case801(self): | |
9f95a23c TL |
3003 | """ |
3004 | rename_lvs_nonexistent | |
3005 | ||
3006 | Negative test case for lvol store rename. | |
3007 | Check that error is returned when trying to rename not existing lvol store. | |
3008 | """ | |
11fdf7f2 | 3009 | fail_count = 0 |
9f95a23c | 3010 | # Call rename_lvol_store with name pointing to not existing lvol store |
11fdf7f2 TL |
3011 | if self.c.rename_lvol_store("NOTEXIST", "WHATEVER") == 0: |
3012 | fail_count += 1 | |
9f95a23c TL |
3013 | |
3014 | # Expected results: | |
3015 | # - rename_lvol_store return code != 0 | |
3016 | # - no other operation fails | |
11fdf7f2 TL |
3017 | return fail_count |
3018 | ||
3019 | @case_message | |
3020 | def test_case802(self): | |
9f95a23c TL |
3021 | """ |
3022 | rename_lvs_EEXIST | |
3023 | ||
3024 | Negative test case for lvol store rename. | |
3025 | Check that error is returned when trying to rename to a name which is already | |
3026 | used by another lvol store. | |
3027 | """ | |
11fdf7f2 TL |
3028 | fail_count = 0 |
3029 | ||
3030 | lvs_name_1 = "lvs_1" | |
3031 | lvs_name_2 = "lvs_2" | |
3032 | ||
3033 | # Create lists with lvol bdev names and aliases for later use | |
3034 | bdev_names_1 = ["lvol_1_" + str(i) for i in range(4)] | |
3035 | bdev_aliases_1 = ["/".join([lvs_name_1, name]) for name in bdev_names_1] | |
3036 | bdev_uuids_1 = [] | |
3037 | bdev_names_2 = ["lvol_2_" + str(i) for i in range(4)] | |
3038 | bdev_aliases_2 = ["/".join([lvs_name_2, name]) for name in bdev_names_2] | |
3039 | bdev_uuids_2 = [] | |
3040 | ||
9f95a23c | 3041 | # Construct two malloc bdevs |
11fdf7f2 TL |
3042 | base_bdev_1 = self.c.construct_malloc_bdev(self.total_size, |
3043 | self.block_size) | |
3044 | base_bdev_2 = self.c.construct_malloc_bdev(self.total_size, | |
3045 | self.block_size) | |
3046 | ||
3047 | # Create lvol store on each malloc bdev | |
3048 | lvs_uuid_1 = self.c.construct_lvol_store(base_bdev_1, | |
3049 | lvs_name_1) | |
3050 | fail_count += self.c.check_get_lvol_stores(base_bdev_1, | |
3051 | lvs_uuid_1, | |
3052 | self.cluster_size, | |
3053 | lvs_name_1) | |
3054 | lvs_uuid_2 = self.c.construct_lvol_store(base_bdev_2, | |
3055 | lvs_name_2) | |
3056 | fail_count += self.c.check_get_lvol_stores(base_bdev_2, | |
3057 | lvs_uuid_2, | |
3058 | self.cluster_size, | |
3059 | lvs_name_2) | |
3060 | ||
3061 | # Create 4 lvol bdevs on top of each lvol store | |
3062 | bdev_size_1 = self.get_lvs_divided_size(4, lvs_name_1) | |
3063 | bdev_size_2 = self.get_lvs_divided_size(4, lvs_name_2) | |
3064 | for name, alias in zip(bdev_names_1, bdev_aliases_1): | |
3065 | uuid = self.c.construct_lvol_bdev(lvs_uuid_1, | |
3066 | name, | |
3067 | bdev_size_1) | |
3068 | fail_count += self.c.check_get_bdevs_methods(uuid, | |
3069 | bdev_size_1, | |
3070 | alias) | |
3071 | bdev_uuids_1.append(uuid) | |
3072 | for name, alias in zip(bdev_names_2, bdev_aliases_2): | |
3073 | uuid = self.c.construct_lvol_bdev(lvs_uuid_2, | |
3074 | name, | |
3075 | bdev_size_2) | |
3076 | fail_count += self.c.check_get_bdevs_methods(uuid, | |
3077 | bdev_size_2, | |
3078 | alias) | |
3079 | bdev_uuids_2.append(uuid) | |
3080 | ||
9f95a23c TL |
3081 | # Call rename_lvol_store on first lvol store and try to change its name to |
3082 | # the same name as used by second lvol store | |
11fdf7f2 TL |
3083 | if self.c.rename_lvol_store(lvs_name_1, lvs_name_2) == 0: |
3084 | fail_count += 1 | |
3085 | ||
3086 | # Verify that names of lvol stores and lvol bdevs did not change | |
3087 | fail_count += self.c.check_get_lvol_stores(base_bdev_1, | |
3088 | lvs_uuid_1, | |
3089 | self.cluster_size, | |
3090 | lvs_name_1) | |
3091 | fail_count += self.c.check_get_lvol_stores(base_bdev_2, | |
3092 | lvs_uuid_2, | |
3093 | self.cluster_size, | |
3094 | lvs_name_2) | |
3095 | ||
3096 | for name, alias, uuid in zip(bdev_names_1, bdev_aliases_1, bdev_uuids_1): | |
3097 | fail_count += self.c.check_get_bdevs_methods(uuid, | |
3098 | bdev_size_1, | |
3099 | alias) | |
3100 | ||
3101 | for name, alias, uuid in zip(bdev_names_2, bdev_aliases_2, bdev_uuids_2): | |
3102 | fail_count += self.c.check_get_bdevs_methods(uuid, | |
3103 | bdev_size_2, | |
3104 | alias) | |
3105 | ||
3106 | # Clean configuration | |
3107 | for lvol_uuid in bdev_uuids_1 + bdev_uuids_2: | |
3108 | fail_count += self.c.destroy_lvol_bdev(lvol_uuid) | |
3109 | fail_count += self.c.destroy_lvol_store(lvs_uuid_1) | |
3110 | fail_count += self.c.destroy_lvol_store(lvs_uuid_2) | |
3111 | fail_count += self.c.delete_malloc_bdev(base_bdev_1) | |
3112 | fail_count += self.c.delete_malloc_bdev(base_bdev_2) | |
3113 | ||
9f95a23c TL |
3114 | # Expected results: |
3115 | # - rename_lvol_store return code != 0; not possible to rename to already | |
3116 | # used name | |
3117 | # - no other operation fails | |
3118 | ||
11fdf7f2 TL |
3119 | return fail_count |
3120 | ||
3121 | @case_message | |
3122 | def test_case803(self): | |
9f95a23c TL |
3123 | """ |
3124 | rename_lvol_bdev_nonexistent | |
3125 | ||
3126 | Negative test case for lvol bdev rename. | |
3127 | Check that error is returned when trying to rename not existing lvol bdev. | |
3128 | """ | |
11fdf7f2 | 3129 | fail_count = 0 |
9f95a23c | 3130 | # Call rename_lvol_bdev with name pointing to not existing lvol bdev |
11fdf7f2 TL |
3131 | if self.c.rename_lvol_bdev("NOTEXIST", "WHATEVER") == 0: |
3132 | fail_count += 1 | |
9f95a23c TL |
3133 | |
3134 | # Expected results: | |
3135 | # - rename_lvol_bdev return code != 0 | |
3136 | # - no other operation fails | |
11fdf7f2 TL |
3137 | return fail_count |
3138 | ||
3139 | @case_message | |
3140 | def test_case804(self): | |
9f95a23c TL |
3141 | """ |
3142 | rename_lvol_bdev_EEXIST | |
3143 | ||
3144 | Negative test case for lvol bdev rename. | |
3145 | Check that error is returned when trying to rename to a name which is already | |
3146 | used by another lvol bdev. | |
3147 | """ | |
11fdf7f2 TL |
3148 | fail_count = 0 |
3149 | ||
9f95a23c | 3150 | # Construt malloc bdev |
11fdf7f2 TL |
3151 | base_bdev = self.c.construct_malloc_bdev(self.total_size, |
3152 | self.block_size) | |
9f95a23c | 3153 | # Create lvol store on created malloc bdev |
11fdf7f2 TL |
3154 | lvs_uuid = self.c.construct_lvol_store(base_bdev, |
3155 | self.lvs_name) | |
3156 | fail_count += self.c.check_get_lvol_stores(base_bdev, | |
3157 | lvs_uuid, | |
3158 | self.cluster_size, | |
3159 | self.lvs_name) | |
9f95a23c | 3160 | # Construct 2 lvol bdevs on lvol store |
11fdf7f2 TL |
3161 | bdev_size = self.get_lvs_divided_size(2) |
3162 | bdev_uuid_1 = self.c.construct_lvol_bdev(lvs_uuid, | |
3163 | self.lbd_name + "1", | |
3164 | bdev_size) | |
3165 | fail_count += self.c.check_get_bdevs_methods(bdev_uuid_1, | |
3166 | bdev_size) | |
3167 | bdev_uuid_2 = self.c.construct_lvol_bdev(lvs_uuid, | |
3168 | self.lbd_name + "2", | |
3169 | bdev_size) | |
3170 | fail_count += self.c.check_get_bdevs_methods(bdev_uuid_2, | |
3171 | bdev_size) | |
3172 | ||
9f95a23c TL |
3173 | # Call rename_lvol_bdev on first lvol bdev and try to change its name to |
3174 | # the same name as used by second lvol bdev | |
11fdf7f2 TL |
3175 | if self.c.rename_lvol_bdev(self.lbd_name + "1", self.lbd_name + "2") == 0: |
3176 | fail_count += 1 | |
9f95a23c | 3177 | # Verify that lvol bdev still have the same names as before |
11fdf7f2 TL |
3178 | fail_count += self.c.check_get_bdevs_methods(bdev_uuid_1, |
3179 | bdev_size, | |
3180 | "/".join([self.lvs_name, self.lbd_name + "1"])) | |
3181 | ||
3182 | fail_count += self.c.destroy_lvol_bdev(bdev_uuid_1) | |
3183 | fail_count += self.c.destroy_lvol_bdev(bdev_uuid_2) | |
3184 | fail_count += self.c.destroy_lvol_store(lvs_uuid) | |
3185 | fail_count += self.c.delete_malloc_bdev(base_bdev) | |
3186 | ||
9f95a23c TL |
3187 | # Expected results: |
3188 | # - rename_lvol_bdev return code != 0; not possible to rename to already | |
3189 | # used name | |
3190 | # - no other operation fails | |
11fdf7f2 TL |
3191 | return fail_count |
3192 | ||
3193 | @case_message | |
3194 | def test_case10000(self): | |
9f95a23c TL |
3195 | """ |
3196 | SIGTERM | |
11fdf7f2 | 3197 | |
9f95a23c TL |
3198 | Call CTRL+C (SIGTERM) occurs after creating lvol store |
3199 | """ | |
3200 | pid_path = path.join(self.path, 'vhost.pid') | |
3201 | # Create malloc bdev | |
11fdf7f2 TL |
3202 | base_name = self.c.construct_malloc_bdev(self.total_size, |
3203 | self.block_size) | |
9f95a23c | 3204 | # Construct lvol store on created malloc bddev |
11fdf7f2 TL |
3205 | uuid_store = self.c.construct_lvol_store(base_name, |
3206 | self.lvs_name) | |
9f95a23c | 3207 | # Check correct uuid values in response get_lvol_stores command |
11fdf7f2 TL |
3208 | fail_count = self.c.check_get_lvol_stores(base_name, uuid_store, |
3209 | self.cluster_size) | |
3210 | ||
9f95a23c | 3211 | # Send SIGTERM signal to the application |
11fdf7f2 | 3212 | fail_count += self._stop_vhost(pid_path) |
9f95a23c TL |
3213 | |
3214 | # Expected result: | |
3215 | # - calls successful, return code = 0 | |
3216 | # - get_bdevs: no change | |
3217 | # - no other operation fails | |
11fdf7f2 | 3218 | return fail_count |