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
19 MEGABYTE
= 1024 * 1024
25 # The purpose of these tests is to verify the possibility of using lvol configuration in SPDK.
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.
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
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.
45 def is_process_alive(pid
):
48 except Exception as e
:
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"
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
}
68 def run_fio(fio_cmd
, expected_ret_value
):
69 global current_fio_pid
71 proc
= subprocess
.Popen([fio_cmd
], shell
=True)
72 current_fio_pid
= proc
.pid
75 except Exception as e
:
76 print("ERROR: Fio test ended with unexpected exception.")
78 if expected_ret_value
== rv
:
82 print("ERROR: Fio test ended with unexpected success")
84 print("ERROR: Fio test ended with unexpected failure")
88 class FioThread(threading
.Thread
):
89 def __init__(self
, nbd_disk
, offset
, size
, rw
, pattern
, expected_ret_value
,
91 super(FioThread
, self
).__init
__()
92 self
.fio_cmd
= get_fio_cmd(nbd_disk
, offset
, size
, rw
, pattern
,
93 extra_params
=extra_params
)
95 self
.expected_ret_value
= expected_ret_value
98 print("INFO: Starting fio")
99 self
.rv
= run_fio(self
.fio_cmd
, self
.expected_ret_value
)
100 print("INFO: Fio test finished")
105 :return: the number of tests
107 return ['test_case' in i
for i
in dir(TestCases
)].count(True)
110 def case_message(func
):
111 def inner(*args
, **kwargs
):
113 # construct_lvol_store - positive tests
114 1: 'construct_lvs_positive',
115 # construct_lvol_bdev - positive tests
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',
120 # construct_lvol_bdev - negative tests
121 100: 'construct_logical_volume_nonexistent_lvs_uuid',
122 101: 'construct_lvol_bdev_on_full_lvol_store',
123 102: 'construct_lvol_bdev_name_twice',
124 # resize_lvol_store - positive tests
125 150: 'resize_lvol_bdev_positive',
126 # resize lvol store - negative tests
127 200: 'resize_logical_volume_nonexistent_logical_volume',
128 201: 'resize_logical_volume_with_size_out_of_range',
129 # destroy_lvol_store - positive tests
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',
136 # destroy_lvol_store - negative tests
137 300: 'destroy_lvol_store_nonexistent_lvs_uuid',
138 301: 'delete_lvol_store_underlying_bdev',
139 # construct_lvol_store - negative tests
140 450: 'construct_lvs_nonexistent_bdev',
141 451: 'construct_lvs_on_bdev_twice',
142 452: 'construct_lvs_name_twice',
143 # nested construct_lvol_bdev - test negative
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',
151 602: 'construct_lvol_store_with_all_clear_methods',
153 650: 'thin_provisioning_check_space',
154 651: 'thin_provisioning_read_empty_bdev',
155 652: 'thin_provisioning_data_integrity_test',
156 653: 'thin_provisioning_resize',
157 654: 'thin_overprovisioning',
158 655: 'thin_provisioning_filling_disks_less_than_lvs_size',
159 # logical volume tasting tests
160 700: 'tasting_positive',
161 701: 'tasting_lvol_store_positive',
162 702: 'tasting_positive_with_different_lvol_store_cluster_size',
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',
174 760: 'set_read_only',
175 # logical volume rename tests
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',
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("************************************")
191 print("END TEST CASE {name} PASS".format(name
=test_name
[num
]))
193 print("END TEST CASE {name} FAIL".format(name
=test_name
[num
]))
194 print("************************************")
199 class TestCases(object):
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')
212 def _gen_lvs_uuid(self
):
215 def _gen_lvb_uuid(self
):
216 return "_".join([str(uuid4()), str(random
.randrange(9999999999))])
218 def compare_two_disks(self
, disk1
, disk2
, expected_ret_value
):
219 cmp_cmd
= "cmp %s %s" % (disk1
, disk2
)
221 process
= subprocess
.check_output(cmp_cmd
, stderr
=subprocess
.STDOUT
, shell
=True)
223 except subprocess
.CalledProcessError
as ex
:
225 except Exception as e
:
226 print("ERROR: Cmp ended with unexpected exception.")
229 if expected_ret_value
== rv
:
232 print("ERROR: Cmp ended with unexpected success")
234 print("ERROR: Cmp ended with unexpected failure")
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
)
242 def _stop_vhost(self
, pid_path
):
243 with io
.open(pid_path
, 'r') as vhost_pid
:
244 pid
= int(vhost_pid
.readline())
247 kill(pid
, signal
.SIGTERM
)
248 for count
in range(30):
251 except OSError as err
:
252 if err
.errno
== ESRCH
:
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):
268 print("ERROR: Timeout on waiting for app start")
270 if not path
.exists(pid_path
):
271 print("Info: Waiting for PID file...")
277 # Wait for RPC to open
278 sock
= socket
.socket(socket
.AF_UNIX
)
279 for timeo
in range(30):
281 print("ERROR: Timeout on waiting for RPC start")
284 sock
.connect("/var/tmp/spdk.sock")
286 except socket
.error
as e
:
287 print("Info: Waiting for RPC Unix socket...")
294 with io
.open(pid_path
, 'r') as vhost_pid
:
295 pid
= int(vhost_pid
.readline())
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
)
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
)
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
)
317 def test_case1(self
):
319 construct_lvs_positive
321 Positive test for constructing a new lvol store.
322 Call construct_lvol_store with correct base bdev name.
325 base_name
= self
.c
.construct_malloc_bdev(self
.total_size
,
327 # Construct_lvol_store on correct, exisitng malloc bdev
328 uuid_store
= self
.c
.construct_lvol_store(base_name
,
330 # Check correct uuid values in response get_lvol_stores command
331 fail_count
= self
.c
.check_get_lvol_stores(base_name
, uuid_store
,
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:
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
346 def test_case50(self
):
348 construct_logical_volume_positive
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
354 base_name
= self
.c
.construct_malloc_bdev(self
.total_size
,
356 # Create lvol store on correct, exisitng malloc bdev
357 uuid_store
= self
.c
.construct_lvol_store(base_name
,
359 # Check correct uuid values in response get_lvol_stores command
360 fail_count
= self
.c
.check_get_lvol_stores(base_name
, uuid_store
,
363 lvs_size
= self
.get_lvs_size()
364 # Construct lvol bdev on correct lvs_uuid and size
365 uuid_bdev
= self
.c
.construct_lvol_bdev(uuid_store
,
368 # Check correct uuid values in response get_bdevs command
369 fail_count
+= self
.c
.check_get_bdevs_methods(uuid_bdev
,
371 self
.c
.destroy_lvol_bdev(uuid_bdev
)
372 self
.c
.destroy_lvol_store(uuid_store
)
373 self
.c
.delete_malloc_bdev(base_name
)
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
383 def test_case51(self
):
385 construct_multi_logical_volumes_positive
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.
392 base_name
= self
.c
.construct_malloc_bdev(self
.total_size
,
394 # Construct lvol store on correct, exisitng malloc bdev
395 uuid_store
= self
.c
.construct_lvol_store(base_name
,
397 # Verify lvol store was created correctly
398 fail_count
= self
.c
.check_get_lvol_stores(base_name
, uuid_store
,
400 size
= self
.get_lvs_divided_size(4)
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
409 uuid_bdev
= self
.c
.construct_lvol_bdev(uuid_store
,
410 self
.lbd_name
+ str(i
),
412 uuid_bdevs
.append(uuid_bdev
)
413 fail_count
+= self
.c
.check_get_bdevs_methods(uuid_bdev
, size
)
415 for uuid_bdev
in uuid_bdevs
:
416 self
.c
.destroy_lvol_bdev(uuid_bdev
)
418 self
.c
.destroy_lvol_store(uuid_store
)
419 self
.c
.delete_malloc_bdev(base_name
)
422 # - calls successful, return code = 0
423 # - no other operation fails
427 def test_case52(self
):
429 construct_lvol_bdev_using_name_positive
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.
436 base_name
= self
.c
.construct_malloc_bdev(self
.total_size
,
438 # Construct lvol store
439 uuid_store
= self
.c
.construct_lvol_store(base_name
,
441 # Check correct uuid values in response get_lvol_stores command
442 fail_count
= self
.c
.check_get_lvol_stores(base_name
, uuid_store
,
444 lvs_size
= self
.get_lvs_size()
445 # Create logical volume on lvol store by using a friendly name
447 uuid_bdev
= self
.c
.construct_lvol_bdev(self
.lvs_name
,
450 # Verify logical volume was correctly created
451 fail_count
+= self
.c
.check_get_bdevs_methods(uuid_bdev
,
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
)
459 # - calls successful, return code = 0
460 # - no other operation fails
464 def test_case53(self
):
466 construct_lvol_bdev_duplicate_names_positive
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.
472 # Construct two malloc bdevs
473 base_name_1
= self
.c
.construct_malloc_bdev(self
.total_size
,
475 base_name_2
= self
.c
.construct_malloc_bdev(self
.total_size
,
477 # Create logical volume stores on created malloc bdevs
478 uuid_store_1
= self
.c
.construct_lvol_store(base_name_1
,
480 uuid_store_2
= self
.c
.construct_lvol_store(base_name_2
,
482 # Verify stores were created correctly
483 fail_count
= self
.c
.check_get_lvol_stores(base_name_1
, uuid_store_1
,
485 fail_count
= self
.c
.check_get_lvol_stores(base_name_2
, uuid_store_2
,
488 lvs_size
= self
.get_lvs_size(self
.lvs_name
+ "1")
489 # Create logical volume on first lvol store
490 uuid_bdev_1
= self
.c
.construct_lvol_bdev(uuid_store_1
,
493 # Using the same friendly name argument create logical volume on second
495 uuid_bdev_2
= self
.c
.construct_lvol_bdev(uuid_store_2
,
498 # Verify two lvol bdevs were correctly created
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
)
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
)
510 # - calls successful, return code = 0
511 # - no other operation fails
515 def test_case100(self
):
517 construct_logical_volume_nonexistent_lvs_uuid
519 Negative test for constructing a new logical_volume.
520 Call construct_lvol_bdev with lvs_uuid which does not
521 exist in configuration.
524 # Try to call construct_lvol_bdev with lvs_uuid which does not exist
525 if self
.c
.construct_lvol_bdev(self
._gen
_lvs
_uuid
(),
532 # - ENODEV response printed to stdout
536 def test_case101(self
):
538 construct_lvol_bdev_on_full_lvol_store
540 Negative test for constructing a new lvol bdev.
541 Call construct_lvol_bdev on a full lvol store.
544 base_name
= self
.c
.construct_malloc_bdev(self
.total_size
,
546 # Create logical volume store on malloc bdev
547 uuid_store
= self
.c
.construct_lvol_store(base_name
,
549 # Check correct uuid values in response from get_lvol_stores command
550 fail_count
= self
.c
.check_get_lvol_stores(base_name
, uuid_store
,
552 lvs_size
= self
.get_lvs_size()
553 # Construct lvol bdev on correct lvs_uuid
554 uuid_bdev
= self
.c
.construct_lvol_bdev(uuid_store
,
557 # Verify if lvol bdev was correctly created
558 fail_count
+= self
.c
.check_get_bdevs_methods(uuid_bdev
,
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
563 if self
.c
.construct_lvol_bdev(uuid_store
,
564 self
.lbd_name
+ "_1",
568 self
.c
.destroy_lvol_bdev(uuid_bdev
)
569 self
.c
.destroy_lvol_store(uuid_store
)
570 self
.c
.delete_malloc_bdev(base_name
)
573 # - first call successful
574 # - second construct_lvol_bdev call return code != 0
575 # - EEXIST response printed to stdout
576 # - no other operation fails
580 def test_case102(self
):
582 construct_lvol_bdev_name_twice
584 Negative test for constructing lvol bdev using the same
585 friendly name twice on the same logical volume store.
587 # Construct malloc bdev
588 base_name
= self
.c
.construct_malloc_bdev(self
.total_size
,
590 # Create logical volume store on malloc bdev
591 uuid_store
= self
.c
.construct_lvol_store(base_name
,
593 # Using get_lvol_stores verify that logical volume store was correctly created
594 fail_count
= self
.c
.check_get_lvol_stores(base_name
, uuid_store
,
596 size
= self
.get_lvs_size()
597 # Construct logical volume on lvol store and verify it was correctly created
598 uuid_bdev
= self
.c
.construct_lvol_bdev(uuid_store
,
601 fail_count
+= self
.c
.check_get_bdevs_methods(uuid_bdev
,
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
606 if self
.c
.construct_lvol_bdev(uuid_store
,
611 self
.c
.destroy_lvol_bdev(uuid_bdev
)
612 self
.c
.destroy_lvol_store(uuid_store
)
613 self
.c
.delete_malloc_bdev(base_name
)
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
622 def test_case150(self
):
624 resize_logical_volume_positive
627 Positive test for resizing a logical_volume.
628 Call resize_lvol_bdev with correct logical_volumes name and new size.
630 # Construct malloc bdev
631 base_name
= self
.c
.construct_malloc_bdev(self
.total_size
,
634 uuid_store
= self
.c
.construct_lvol_store(base_name
,
636 # Check correct uuid values in response get_lvol_stores command
637 fail_count
= self
.c
.check_get_lvol_stores(base_name
, uuid_store
,
639 # Construct lvol bdev on correct lvs_uuid and
640 # size is equal to one quarter of size malloc bdev
641 size
= self
.get_lvs_divided_size(4)
642 uuid_bdev
= self
.c
.construct_lvol_bdev(uuid_store
, self
.lbd_name
, size
)
643 # Check size of the lvol bdev by rpc command get_bdevs
644 fail_count
+= self
.c
.check_get_bdevs_methods(uuid_bdev
, size
)
646 # Resize lvol bdev on correct lvs_uuid and
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
)
650 # Check size of the lvol bdev by rpc command get_bdevs
651 fail_count
+= self
.c
.check_get_bdevs_methods(uuid_bdev
, size
)
653 # Resize lvol bdev on the correct lvs_uuid and
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
)
657 # Check size of the lvol bdev by rpc command get_bdevs
658 fail_count
+= self
.c
.check_get_bdevs_methods(uuid_bdev
, size
)
660 # Resize lvol bdev on the correct lvs_uuid and
661 # size is equal 0 MiB
663 self
.c
.resize_lvol_bdev(uuid_bdev
, size
)
664 # Check size of the lvol bdev by rpc command get_bdevs
665 fail_count
+= self
.c
.check_get_bdevs_methods(uuid_bdev
, size
)
667 self
.c
.destroy_lvol_bdev(uuid_bdev
)
668 self
.c
.destroy_lvol_store(uuid_store
)
669 self
.c
.delete_malloc_bdev(base_name
)
671 # - lvol bdev should change size after resize operations
672 # - calls successful, return code = 0
673 # - no other operation fails
677 def test_case200(self
):
679 resize_logical_volume_nonexistent_logical_volume
681 Negative test for resizing a logical_volume.
682 Call resize_lvol_bdev with logical volume which does not
683 exist in configuration.
686 # Try resize lvol bdev on logical volume which does not exist
687 if self
.c
.resize_lvol_bdev(self
._gen
_lvb
_uuid
(), 16) == 0:
692 # - Error code: ENODEV ("No such device") response printed to stdout
696 def test_case201(self
):
698 resize_logical_volume_with_size_out_of_range
700 Negative test for resizing a logical volume.
701 Call resize_lvol_store with size argument bigger than size of base bdev.
704 base_name
= self
.c
.construct_malloc_bdev(self
.total_size
,
706 # Construct lvol store on created malloc bdev
707 uuid_store
= self
.c
.construct_lvol_store(base_name
,
709 # Check correct uuid values in response get_lvol_stores command
710 fail_count
= self
.c
.check_get_lvol_stores(base_name
, uuid_store
,
712 # Construct_lvol_bdev on correct lvs_uuid and
713 # size is equal one quarter of size malloc bdev
714 lvs_size
= self
.get_lvs_size()
715 uuid_bdev
= self
.c
.construct_lvol_bdev(uuid_store
,
718 fail_count
+= self
.c
.check_get_bdevs_methods(uuid_bdev
,
720 # Try resize_lvol_bdev on correct lvs_uuid and size is
721 # equal to size malloc bdev + 1MiB; this call should fail
722 if self
.c
.resize_lvol_bdev(uuid_bdev
, self
.total_size
+ 1) == 0:
725 self
.c
.destroy_lvol_bdev(uuid_bdev
)
726 self
.c
.destroy_lvol_store(uuid_store
)
727 self
.c
.delete_malloc_bdev(base_name
)
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
737 def test_case250(self
):
739 destroy_lvol_store_positive
741 Positive test for destroying a logical volume store.
742 Call destroy_lvol_store with correct logical_volumes name
744 # Construct malloc bdev
745 base_name
= self
.c
.construct_malloc_bdev(self
.total_size
,
747 # Create lvol store on created malloc bdev
748 uuid_store
= self
.c
.construct_lvol_store(base_name
,
750 # check correct uuid values in response get_lvol_stores command
751 fail_count
= self
.c
.check_get_lvol_stores(base_name
, uuid_store
,
754 self
.c
.destroy_lvol_store(uuid_store
)
755 # Check correct response get_lvol_stores command
756 if self
.c
.check_get_lvol_stores("", "", "") == 1:
758 self
.c
.delete_malloc_bdev(base_name
)
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
767 def test_case251(self
):
769 destroy_lvol_store_use_name_positive
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
776 base_name
= self
.c
.construct_malloc_bdev(self
.total_size
,
778 # Construct lvol store on created malloc bdev
779 uuid_store
= self
.c
.construct_lvol_store(base_name
,
781 # Check correct uuid values in response get_lvol_stores command
782 fail_count
= self
.c
.check_get_lvol_stores(base_name
, uuid_store
,
785 fail_count
+= self
.c
.destroy_lvol_store(self
.lvs_name
)
786 # Check correct response get_lvol_stores command
787 if self
.c
.check_get_lvol_stores("", "", "") == 1:
789 fail_count
+= self
.c
.delete_malloc_bdev(base_name
)
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
798 def test_case252(self
):
800 destroy_lvol_store_with_lvol_bdev_positive
802 Positive test for destroying a logical volume store with lvol bdev
804 Call destroy_lvol_store with correct logical_volumes name
807 base_name
= self
.c
.construct_malloc_bdev(self
.total_size
,
809 # Construct lvol store on created malloc bdev
810 uuid_store
= self
.c
.construct_lvol_store(base_name
,
812 # Check correct uuid values in response get_lvol_stores command
813 fail_count
= self
.c
.check_get_lvol_stores(base_name
, uuid_store
,
815 # Construct lvol bdev on correct lvs_uuid
816 # and size is equal to size malloc bdev
817 lvs_size
= self
.get_lvs_size()
818 uuid_bdev
= self
.c
.construct_lvol_bdev(uuid_store
,
821 fail_count
+= self
.c
.check_get_bdevs_methods(uuid_bdev
,
824 if self
.c
.destroy_lvol_store(uuid_store
) != 0:
827 # Check correct response get_lvol_stores command
828 if self
.c
.check_get_lvol_stores("", "", "") == 1:
830 self
.c
.delete_malloc_bdev(base_name
)
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
839 def test_case253(self
):
841 Name: destroy_multi_logical_volumes_positive
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.
849 base_name
= self
.c
.construct_malloc_bdev(self
.total_size
,
851 # Construct lvol store on correct, exisitng malloc bdev
852 uuid_store
= self
.c
.construct_lvol_store(base_name
,
854 # Check correct uuid values in response get_lvol_stores command
855 fail_count
= self
.c
.check_get_lvol_stores(base_name
, uuid_store
,
857 size
= self
.get_lvs_divided_size(4)
858 # Construct four lvol bdevs on correct lvs_uuid and
859 # size is equal to one quarter of the lvol size
861 uuid_bdev
= self
.c
.construct_lvol_bdev(uuid_store
,
862 self
.lbd_name
+ str(i
),
864 fail_count
+= self
.c
.check_get_bdevs_methods(uuid_bdev
, size
)
867 self
.c
.destroy_lvol_store(uuid_store
)
868 # Check correct response get_lvol_stores command
869 if self
.c
.check_get_lvol_stores("", "", "") == 1:
871 self
.c
.delete_malloc_bdev(base_name
)
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
881 def test_case254(self
):
883 destroy_resize_logical_volume_positive
885 Positive test for destroying a logical_volume after resizing.
886 Call destroy_lvol_store with correct logical_volumes name.
889 base_name
= self
.c
.construct_malloc_bdev(self
.total_size
,
891 # Construct lvol store on create malloc bdev
892 uuid_store
= self
.c
.construct_lvol_store(base_name
,
894 # Check correct uuid values in response get_lvol_stores command
895 fail_count
= self
.c
.check_get_lvol_stores(base_name
, uuid_store
,
897 size
= self
.get_lvs_divided_size(4)
898 # construct_lvol_bdev on correct lvs_uuid and size is
899 # equal to one quarter of size malloc bdev
900 uuid_bdev
= self
.c
.construct_lvol_bdev(uuid_store
,
903 # check size of the lvol bdev
904 fail_count
+= self
.c
.check_get_bdevs_methods(uuid_bdev
, size
)
906 # Resize_lvol_bdev on correct lvs_uuid and size is
907 # equal to one quarter of size malloc bdev plus 4 MB
908 self
.c
.resize_lvol_bdev(uuid_bdev
, sz
)
909 # check size of the lvol bdev by command RPC : get_bdevs
910 fail_count
+= self
.c
.check_get_bdevs_methods(uuid_bdev
, sz
)
911 # Resize_lvol_bdev on correct lvs_uuid and size is
912 # equal half of size malloc bdev
914 self
.c
.resize_lvol_bdev(uuid_bdev
, sz
)
915 # check size of the lvol bdev by command RPC : get_bdevs
916 fail_count
+= self
.c
.check_get_bdevs_methods(uuid_bdev
, sz
)
917 # Resize_lvol_bdev on correct lvs_uuid and size is
918 # equal to three quarters of size malloc bdev
920 self
.c
.resize_lvol_bdev(uuid_bdev
, sz
)
921 # check size of the lvol bdev by command RPC : get_bdevs
922 fail_count
+= self
.c
.check_get_bdevs_methods(uuid_bdev
, sz
)
923 # Resize_lvol_bdev on correct lvs_uuid and size is
924 # equal to size if malloc bdev minus 4 MB
926 self
.c
.resize_lvol_bdev(uuid_bdev
, sz
)
927 # check size of the lvol bdev by command RPC : get_bdevs
928 fail_count
+= self
.c
.check_get_bdevs_methods(uuid_bdev
, sz
)
929 # Resize_lvol_bdev on the correct lvs_uuid and size is equal 0 MiB
931 self
.c
.resize_lvol_bdev(uuid_bdev
, sz
)
932 # check size of the lvol bdev by command RPC : get_bdevs
933 fail_count
+= self
.c
.check_get_bdevs_methods(uuid_bdev
, sz
)
936 self
.c
.destroy_lvol_store(uuid_store
)
937 if self
.c
.check_get_lvol_stores("", "", "") == 1:
939 self
.c
.delete_malloc_bdev(base_name
)
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
949 def test_case255(self
):
951 delete_lvol_store_persistent_positive
953 Positive test for removing lvol store persistently
955 base_path
= path
.dirname(sys
.argv
[0])
956 base_name
= "aio_bdev0"
957 aio_bdev0
= path
.join(base_path
, "aio_bdev_0")
959 self
.c
.construct_aio_bdev(aio_bdev0
, base_name
, 4096)
960 # Create lvol store on created aio bdev
961 uuid_store
= self
.c
.construct_lvol_store(base_name
,
963 fail_count
= self
.c
.check_get_lvol_stores(base_name
, uuid_store
,
966 if self
.c
.destroy_lvol_store(self
.lvs_name
) != 0:
970 self
.c
.delete_aio_bdev(base_name
)
971 # Create aio bdev on the same file
972 self
.c
.construct_aio_bdev(aio_bdev0
, base_name
, 4096)
973 # Wait 1 second to allow time for lvolstore tasting
976 # check if destroyed lvol store does not exist on aio bdev
977 ret_value
= self
.c
.check_get_lvol_stores(base_name
, uuid_store
,
981 self
.c
.delete_aio_bdev(base_name
)
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
990 def test_case300(self
):
992 destroy_lvol_store_nonexistent_lvs_uuid
994 Call destroy_lvol_store with nonexistent logical_volumes name
995 exist in configuration.
998 # try to call destroy_lvol_store with lvs_uuid which does not exist
999 if self
.c
.destroy_lvol_store(self
._gen
_lvs
_uuid
()) == 0:
1003 # - return code != 0
1004 # - Error code response printed to stdout
1008 def test_case301(self
):
1010 delete_lvol_store_underlying_bdev
1012 Call destroy_lvol_store after deleting it's base bdev.
1013 Lvol store should be automatically removed on deleting underlying bdev.
1015 # Create malloc bdev
1016 base_name
= self
.c
.construct_malloc_bdev(self
.total_size
,
1018 # Construct lvol store on created malloc bdev
1019 uuid_store
= self
.c
.construct_lvol_store(base_name
,
1021 # Check correct uuid values in response get_lvol_stores command
1022 fail_count
= self
.c
.check_get_lvol_stores(base_name
, uuid_store
,
1025 # Delete malloc bdev
1026 if self
.c
.delete_malloc_bdev(base_name
) != 0:
1029 # Try to destroy lvol store. This call should fail as lvol store
1030 # is no longer present
1031 if self
.c
.destroy_lvol_store(uuid_store
) == 0:
1035 # - destroy_lvol_store return code != 0
1036 # - Error code: ENODEV ("No such device") response printed to stdout
1037 # - no other operation fails
1042 def test_case450(self
):
1044 construct_lvs_nonexistent_bdev
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.
1051 bad_bdev_id
= random
.randrange(999999999)
1052 # Try construct_lvol_store on bdev which does not exist
1053 if self
.c
.construct_lvol_store(bad_bdev_id
,
1055 self
.cluster_size
) == 0:
1060 def test_case451(self
):
1062 construct_lvs_on_bdev_twice
1064 Negative test for constructing a new lvol store.
1065 Call construct_lvol_store with base bdev name twice.
1067 # Create malloc bdev
1068 base_name
= self
.c
.construct_malloc_bdev(self
.total_size
,
1070 # Construct lvol store on created malloc bdev
1071 uuid_store
= self
.c
.construct_lvol_store(base_name
,
1073 # Check correct uuid values in response get_lvol_stores command
1074 fail_count
= self
.c
.check_get_lvol_stores(base_name
, uuid_store
,
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
1078 if self
.c
.construct_lvol_store(base_name
,
1079 self
.lvs_name
) == 0:
1081 self
.c
.destroy_lvol_store(uuid_store
)
1082 self
.c
.delete_malloc_bdev(base_name
)
1086 def test_case452(self
):
1088 construct_lvs_name_twice
1090 Negative test for constructing a new lvol store using the same
1091 friendly name twice.
1094 # Create malloc bdev
1095 base_name_1
= self
.c
.construct_malloc_bdev(self
.total_size
,
1097 # Construct second malloc bdev
1098 base_name_2
= self
.c
.construct_malloc_bdev(self
.total_size
,
1100 # Construct lvol store on first malloc
1101 uuid_store_1
= self
.c
.construct_lvol_store(base_name_1
,
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)
1105 fail_count
+= self
.c
.check_get_lvol_stores(base_name_1
,
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
1111 if self
.c
.construct_lvol_store(base_name_2
,
1112 self
.lvs_name
) == 0:
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
)
1122 def test_case500(self
):
1124 nested_construct_lvol_bdev_on_full_lvol_store
1126 Negative test for constructing a new nested lvol bdev.
1127 Call construct_lvol_bdev on a full lvol store.
1129 # Create malloc bdev
1130 base_name
= self
.c
.construct_malloc_bdev(self
.total_size
,
1132 # Construct_lvol_store on correct, exisitng malloc bdev
1133 uuid_store
= self
.c
.construct_lvol_store(base_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
,
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
,
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
,
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
)
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:
1163 fail_count
+= self
.c
.delete_malloc_bdev(base_name
)
1166 # - second construct_lvol_bdev call on nested lvol store return code != 0
1167 # - EEXIST response printed to stdout
1168 # - no other operation fails
1172 def test_case550(self
):
1174 delete_bdev_positive
1176 Positive test for deleting malloc bdev.
1177 Call construct_lvol_store with correct base bdev name.
1179 # Create malloc bdev
1180 base_name
= self
.c
.construct_malloc_bdev(self
.total_size
,
1182 # Construct_lvol_store on correct, exisitng malloc bdev
1183 uuid_store
= self
.c
.construct_lvol_store(base_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
,
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:
1195 # - get_lvol_stores: response should be of no value after destroyed lvol store
1196 # - no other operation fails
1200 def test_case551(self
):
1202 destroy_lvol_bdev_ordering
1204 Test for destroying lvol bdevs in particular order.
1205 Check destroying wrong one is not possible and returns error.
1209 snapshot_name
= "snapshot"
1210 clone_name
= "clone"
1212 # Create malloc bdev
1213 base_name
= self
.c
.construct_malloc_bdev(self
.total_size
,
1215 # Construct_lvol_store on correct, exisitng malloc bdev
1216 uuid_store
= self
.c
.construct_lvol_store(base_name
,
1219 # Check correct uuid values in response get_lvol_stores command
1220 fail_count
= self
.c
.check_get_lvol_stores(base_name
, uuid_store
,
1222 lvs
= self
.c
.get_lvol_stores()
1223 size
= int(int(lvs
[0]['free_clusters'] * lvs
[0]['cluster_size']) / 4 / MEGABYTE
)
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
)
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
)
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
)
1238 # Try to destroy snapshot with clones and check if it fails
1239 ret_value
= self
.c
.destroy_lvol_bdev(snapshot_bdev
['name'])
1241 print("ERROR: Delete snapshot should fail but didn't")
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'])
1249 # Destroy lvol store
1250 fail_count
+= self
.c
.destroy_lvol_store(uuid_store
)
1252 # Check response get_lvol_stores command
1253 if self
.c
.check_get_lvol_stores("", "", "") == 1:
1256 # Delete malloc bdev
1257 self
.c
.delete_malloc_bdev(base_name
)
1259 # - get_lvol_stores: response should be of no value after destroyed lvol store
1260 # - no other operation fails
1264 def test_case552(self
):
1266 destroy_lvol_store_with_clones
1268 Test for destroying lvol store with clones present,
1269 without removing them first.
1273 snapshot_name
= "snapshot"
1274 snapshot_name2
= "snapshot2"
1275 clone_name
= "clone"
1277 # Create malloc bdev
1278 base_name
= self
.c
.construct_malloc_bdev(self
.total_size
,
1280 # Construct_lvol_store on correct, exisitng malloc bdev
1281 uuid_store
= self
.c
.construct_lvol_store(base_name
,
1284 # Check correct uuid values in response get_lvol_stores command
1285 fail_count
= self
.c
.check_get_lvol_stores(base_name
, uuid_store
,
1287 lvs
= self
.c
.get_lvol_stores()
1288 size
= int(int(lvs
[0]['free_clusters'] * lvs
[0]['cluster_size']) / 4 / MEGABYTE
)
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
)
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
)
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
)
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
)
1303 # Try to destroy snapshots with clones and check if it fails
1304 ret_value
= self
.c
.destroy_lvol_bdev(snapshot_bdev
['name'])
1306 print("ERROR: Delete snapshot should fail but didn't")
1308 ret_value
= self
.c
.destroy_lvol_bdev(snapshot_bdev2
['name'])
1310 print("ERROR: Delete snapshot should fail but didn't")
1313 # Destroy lvol store without deleting lvol bdevs
1314 fail_count
+= self
.c
.destroy_lvol_store(uuid_store
)
1316 # Check response get_lvol_stores command
1317 if self
.c
.check_get_lvol_stores("", "", "") == 1:
1320 # Delete malloc bdev
1321 self
.c
.delete_malloc_bdev(base_name
)
1323 # - get_lvol_stores: response should be of no value after destroyed lvol store
1324 # - no other operation fails
1328 def test_case553(self
):
1330 unregister_lvol_bdev
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.
1338 snapshot_name
= "snapshot"
1339 snapshot_name2
= "snapshot2"
1340 clone_name
= "clone"
1342 # Create malloc bdev
1343 base_name
= self
.c
.construct_malloc_bdev(self
.total_size
,
1345 # Construct_lvol_store on correct, exisitng malloc bdev
1346 uuid_store
= self
.c
.construct_lvol_store(base_name
,
1349 # Check correct uuid values in response get_lvol_stores command
1350 fail_count
= self
.c
.check_get_lvol_stores(base_name
, uuid_store
,
1352 lvs
= self
.c
.get_lvol_stores()
1353 size
= int(int(lvs
[0]['free_clusters'] * lvs
[0]['cluster_size']) / 4 / MEGABYTE
)
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
)
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
)
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
)
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
)
1368 # Delete malloc bdev
1369 self
.c
.delete_malloc_bdev(base_name
)
1371 # Check response get_lvol_stores command
1372 if self
.c
.check_get_lvol_stores("", "", "") == 1:
1376 # - get_lvol_stores: response should be of no value after destroyed lvol store
1377 # - no other operation fails
1381 def test_case600(self
):
1383 construct_lvol_store_with_cluster_size_max
1385 Negative test for constructing a new lvol store.
1386 Call construct_lvol_store with cluster size is equal malloc bdev size + 1B.
1389 # Create malloc bdev
1390 base_name
= self
.c
.construct_malloc_bdev(self
.total_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
,
1396 (self
.total_size
* 1024 * 1024) + 1) == 0
1397 if self
.c
.check_get_lvol_stores(base_name
, lvol_uuid
) == 0:
1399 fail_count
+= self
.c
.delete_malloc_bdev(base_name
)
1402 # - return code != 0
1403 # - Error code response printed to stdout
1407 def test_case601(self
):
1409 construct_lvol_store_with_cluster_size_min
1411 Negative test for constructing a new lvol store.
1412 Call construct_lvol_store with cluster size smaller than minimal value of 8192.
1415 # Create malloc bdev
1416 base_name
= self
.c
.construct_malloc_bdev(self
.total_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:
1423 fail_count
+= self
.c
.delete_malloc_bdev(base_name
)
1426 # - construct lvol store return code != 0
1427 # - Error code response printed to stdout
1431 def test_case602(self
):
1433 construct_lvol_store_with_all_clear_methods
1435 Call construct_lvol_store with all options for clear methods.
1438 # Create malloc bdev
1439 base_name
= self
.c
.construct_malloc_bdev(self
.total_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
)
1446 # Create malloc bdev
1447 base_name
= self
.c
.construct_malloc_bdev(self
.total_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
)
1454 # Create malloc bdev
1455 base_name
= self
.c
.construct_malloc_bdev(self
.total_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
)
1463 # - construct lvol store return code != 0
1464 # - Error code response printed to stdout
1468 def test_case650(self
):
1470 thin_provisioning_check_space
1472 Check if free clusters number on lvol store decreases
1473 if we write to created thin provisioned lvol bdev
1475 # create malloc bdev
1476 base_name
= self
.c
.construct_malloc_bdev(self
.total_size
,
1478 # create lvol store on mamloc bdev
1479 uuid_store
= self
.c
.construct_lvol_store(base_name
,
1481 fail_count
= self
.c
.check_get_lvol_stores(base_name
, uuid_store
,
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
:
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
)
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:
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:
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:
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
:
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
)
1543 # - calls successful, return code = 0
1544 # - no other operation fails
1548 def test_case651(self
):
1550 thin_provisioning_read_empty_bdev
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.
1555 # create malloc bdev
1556 base_name
= self
.c
.construct_malloc_bdev(self
.total_size
,
1558 # construct lvol store on malloc bdev
1559 uuid_store
= self
.c
.construct_lvol_store(base_name
,
1561 fail_count
= self
.c
.check_get_lvol_stores(base_name
, uuid_store
,
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
)
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)
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")
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
)
1601 # - calls successful, return code = 0
1602 # - no other operation fails
1606 def test_case652(self
):
1608 thin_provisioning_data_integrity_test
1610 Check if data written to thin provisioned lvol bdev
1611 were properly written (fio test with verification).
1613 # create malloc bdev
1614 base_name
= self
.c
.construct_malloc_bdev(self
.total_size
,
1616 # construct lvol store on malloc bdev
1617 uuid_store
= self
.c
.construct_lvol_store(base_name
,
1619 fail_count
= self
.c
.check_get_lvol_stores(base_name
, uuid_store
,
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)
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")
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
)
1643 # - calls successful, return code = 0
1644 # - verification ends with success
1645 # - no other operation fails
1649 def test_case653(self
):
1651 thin_provisioning_resize
1653 Check thin provisioned bdev resize.
1655 # Create malloc bdev
1656 base_name
= self
.c
.construct_malloc_bdev(self
.total_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
,
1662 # Construct thin provisioned lvol bdevs on created lvol store
1663 # with size equal to 50% of lvol store
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
:
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
:
1690 # Perform write operation with verification
1691 # to newly created free space of lvol bdev
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:
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
:
1711 self
.c
.destroy_lvol_bdev(uuid_bdev
)
1712 self
.c
.destroy_lvol_store(uuid_store
)
1713 self
.c
.delete_malloc_bdev(base_name
)
1716 # - calls successful, return code = 0
1717 # - no other operation fails
1721 def test_case654(self
):
1723 thin_overprovisioning
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.
1729 # create malloc bdev
1730 base_name
= self
.c
.construct_malloc_bdev(self
.total_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
,
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)
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
:
1752 lvol_bdev0
= self
.c
.get_lvol_bdev_with_name(bdev_name0
)
1753 lvol_bdev1
= self
.c
.get_lvol_bdev_with_name(bdev_name1
)
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
)
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")
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)
1771 # check if data on first disk stayed unchanged
1772 fail_count
+= self
.run_fio_test(nbd_name0
, 0, size
, "read", "0xcc")
1776 fail_count
+= self
.run_fio_test(nbd_name0
, offset
, size
, "read", "0x00")
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
)
1788 # - calls successful, return code = 0
1789 # - no other operation fails
1793 def test_case655(self
):
1795 thin_provisioning_filling_disks_less_than_lvs_size
1797 Check if writing to two thin provisioned lvol bdevs
1798 less than total size of lvol store will end with success
1800 # create malloc bdev
1801 base_name
= self
.c
.construct_malloc_bdev(self
.total_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
,
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)
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")
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
)
1846 # - calls successful, return code = 0
1847 # - no other operation fails
1851 def test_case700(self
):
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.
1863 base_name
= "aio_bdev0"
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')
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
,
1876 fail_count
+= self
.c
.check_get_lvol_stores(base_name
,
1880 size
= self
.get_lvs_divided_size(10)
1883 uuid_bdev
= self
.c
.construct_lvol_bdev(uuid_store
,
1884 self
.lbd_name
+ str(i
),
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
)
1890 old_bdevs
= sorted(self
.c
.get_lvol_bdevs(), key
=lambda x
: x
["name"])
1891 old_stores
= self
.c
.get_lvol_stores()
1893 # Shut down vhost instance and restart with new instance
1894 fail_count
+= self
._stop
_vhost
(pid_path
)
1896 if self
._start
_vhost
(vhost_path
, pid_path
) != 0:
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()
1906 if old_stores
!= new_stores
:
1908 print("ERROR: old and loaded lvol store is not the same")
1913 if len(old_bdevs
) != len(new_bdevs
):
1915 print("ERROR: old and loaded lvol bdev list count is not equal")
1917 for o
, n
in zip(old_bdevs
, new_bdevs
):
1920 print("ERROR: old and loaded lvol bdev is not the same")
1922 pprint
.pprint([o
, n
])
1925 self
.c
.delete_aio_bdev(aio_bdev0
)
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
),
1935 uuid_bdevs
.append(uuid_bdev
)
1936 fail_count
+= self
.c
.check_get_bdevs_methods(uuid_bdev
, size
)
1938 for uuid_bdev
in uuid_bdevs
:
1939 self
.c
.destroy_lvol_bdev(uuid_bdev
)
1941 if self
.c
.destroy_lvol_store(uuid_store
) != 0:
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
,
1950 fail_count
+= self
.c
.check_get_lvol_stores(base_name
,
1955 uuid_bdev
= self
.c
.construct_lvol_bdev(uuid_store
,
1956 self
.lbd_name
+ str(i
),
1958 uuid_bdevs
.append(uuid_bdev
)
1959 fail_count
+= self
.c
.check_get_bdevs_methods(uuid_bdev
, size
)
1961 # Destroy lvol store
1962 if self
.c
.destroy_lvol_store(uuid_store
) != 0:
1965 self
.c
.delete_aio_bdev(base_name
)
1970 def test_case701(self
):
1972 tasting_lvol_store_positive
1974 Positive test for tasting lvol store.
1976 base_path
= path
.dirname(sys
.argv
[0])
1977 aio_bdev0
= path
.join(base_path
, 'aio_bdev_0')
1978 base_name
= "aio_bdev0"
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
,
1984 fail_count
= self
.c
.check_get_lvol_stores(base_name
, uuid_store
,
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
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:
1995 # destroy lvol store from aio bdev
1996 if self
.c
.destroy_lvol_store(uuid_store
) != 0:
1999 self
.c
.delete_aio_bdev(base_name
)
2003 def test_case702(self
):
2005 tasting_positive_with_different_lvol_store_cluster_size
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.
2015 cluster_size_1M
= MEGABYTE
2016 cluster_size_32M
= 32 * MEGABYTE
2017 base_name_1M
= "aio_bdev0"
2018 base_name_32M
= "aio_bdev1"
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')
2026 self
.c
.construct_aio_bdev(aio_bdev0
, base_name_1M
, 4096)
2027 self
.c
.construct_aio_bdev(aio_bdev1
, base_name_32M
, 4096)
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",
2036 fail_count
+= self
.c
.check_get_lvol_stores(base_name_1M
,
2040 uuid_store_32M
= self
.c
.construct_lvol_store(base_name_32M
,
2041 self
.lvs_name
+ "_32M",
2044 fail_count
+= self
.c
.check_get_lvol_stores(base_name_32M
,
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")
2053 uuid_bdev
= self
.c
.construct_lvol_bdev(uuid_store_1M
,
2054 self
.lbd_name
+ str(i
) + "_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
)
2061 uuid_bdev
= self
.c
.construct_lvol_bdev(uuid_store_32M
,
2062 self
.lbd_name
+ str(i
) + "_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
)
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"])
2071 # Shut down vhost instance and restart with new instance
2072 fail_count
+= self
._stop
_vhost
(pid_path
)
2074 if self
._start
_vhost
(vhost_path
, pid_path
) != 0:
2078 self
.c
.construct_aio_bdev(aio_bdev0
, base_name_1M
, 4096)
2079 self
.c
.construct_aio_bdev(aio_bdev1
, base_name_32M
, 4096)
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"])
2086 if old_stores
!= new_stores
:
2088 print("ERROR: old and loaded lvol store is not the same")
2093 if len(old_bdevs
) != len(new_bdevs
):
2095 print("ERROR: old and loaded lvol bdev list count is not equal")
2097 for o
, n
in zip(old_bdevs
, new_bdevs
):
2100 print("ERROR: old and loaded lvol bdev is not the same")
2102 pprint
.pprint([o
, n
])
2105 self
.c
.delete_aio_bdev(base_name_1M
)
2106 self
.c
.delete_aio_bdev(base_name_32M
)
2109 for uuid_bdev
in uuid_bdevs
:
2110 self
.c
.destroy_lvol_bdev(uuid_bdev
)
2112 if self
.c
.destroy_lvol_store(uuid_store_1M
) != 0:
2115 if self
.c
.destroy_lvol_store(uuid_store_32M
) != 0:
2118 self
.c
.delete_aio_bdev(base_name_1M
)
2119 self
.c
.delete_aio_bdev(base_name_32M
)
2124 def test_case750(self
):
2128 Create snaphot of lvol bdev and check if it is readonly.
2131 nbd_name0
= "/dev/nbd0"
2132 snapshot_name
= "snapshot0"
2133 # Construct malloc bdev
2134 base_name
= self
.c
.construct_malloc_bdev(self
.total_size
,
2136 # Construct lvol store on malloc bdev
2137 uuid_store
= self
.c
.construct_lvol_store(base_name
,
2139 fail_count
+= self
.c
.check_get_lvol_stores(base_name
, uuid_store
,
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
,
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
)
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)
2159 fail_count
+= self
.c
.stop_nbd_disk(nbd_name0
)
2161 fail_count
+= self
.c
.destroy_lvol_bdev(lvol_bdev
['name'])
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
)
2170 # - calls successful, return code = 0
2171 # - no other operation fails
2175 def test_case751(self
):
2177 snapshot_compare_with_lvol_bdev
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.
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
,
2190 # Construct lvol store
2191 uuid_store
= self
.c
.construct_lvol_store(base_name
,
2193 fail_count
+= self
.c
.check_get_lvol_stores(base_name
, uuid_store
,
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)
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)
2225 fill_size
= int(size
* MEGABYTE
/ 2)
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
)
2234 fail_count
+= self
.c
.destroy_lvol_bdev(lvol_bdev0
['name'])
2235 fail_count
+= self
.c
.destroy_lvol_bdev(lvol_bdev1
['name'])
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
)
2240 fail_count
+= self
.c
.destroy_lvol_store(uuid_store
)
2241 # Delete malloc bdev
2242 fail_count
+= self
.c
.delete_malloc_bdev(base_name
)
2245 # - calls successful, return code = 0
2246 # - removing snapshot should always end with success
2247 # - no other operation fails
2251 def test_case752(self
):
2253 snapshot_during_io_traffic
2255 Check that when writing to lvol bdev
2256 creating snapshot ends with success
2258 global current_fio_pid
2260 nbd_name
= "/dev/nbd0"
2261 snapshot_name
= "snapshot"
2262 # Create malloc bdev
2263 base_name
= self
.c
.construct_malloc_bdev(self
.total_size
,
2265 # Construct lvol store
2266 uuid_store
= self
.c
.construct_lvol_store(base_name
,
2268 fail_count
+= self
.c
.check_get_lvol_stores(base_name
, uuid_store
,
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
,
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
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
)
2290 # Check that write operation ended with success
2291 fail_count
+= thread
.rv
2292 fail_count
+= self
.c
.stop_nbd_disk(nbd_name
)
2294 fail_count
+= self
.c
.destroy_lvol_bdev(lvol_bdev
['name'])
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
)
2303 # - calls successful, return code = 0
2304 # - no other operation fails
2308 def test_case753(self
):
2310 snapshot_of_snapshot
2312 Check that creating snapshot of snapshot will fail
2315 snapshot_name0
= "snapshot0"
2316 snapshot_name1
= "snapshot1"
2317 # Create malloc bdev
2318 base_name
= self
.c
.construct_malloc_bdev(self
.total_size
,
2320 # Construct lvol store
2321 uuid_store
= self
.c
.construct_lvol_store(base_name
,
2323 fail_count
+= self
.c
.check_get_lvol_stores(base_name
, uuid_store
,
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
,
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")
2339 fail_count
+= self
.c
.destroy_lvol_bdev(lvol_bdev
['name'])
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
)
2348 # - calls successful, return code = 0
2349 # - creating snapshot of snapshot should fail
2350 # - no other operation fails
2354 def test_case754(self
):
2358 Check that only clone of snapshot can be created.
2359 Creating clone of lvol bdev should fail.
2362 clone_name
= "clone"
2363 snapshot_name
= "snapshot"
2364 # Create malloc bdev
2365 base_name
= self
.c
.construct_malloc_bdev(self
.total_size
,
2367 # Construct lvol store
2368 uuid_store
= self
.c
.construct_lvol_store(base_name
,
2370 fail_count
+= self
.c
.check_get_lvol_stores(base_name
, uuid_store
,
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
,
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
)
2382 print("ERROR: Creating clone of lvol bdev ended with unexpected success")
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
)
2389 print("ERROR: Creating clone of lvol bdev ended with unexpected success")
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
)
2394 print("ERROR: Creating clone of snapshot ended with unexpected failure")
2396 clone_bdev
= self
.c
.get_lvol_bdev_with_name(self
.lvs_name
+ "/" + clone_name
)
2399 fail_count
+= self
.c
.destroy_lvol_bdev(lvol_bdev
['name'])
2401 fail_count
+= self
.c
.destroy_lvol_bdev(clone_bdev
['name'])
2403 fail_count
+= self
.c
.destroy_lvol_bdev(self
.lvs_name
+ "/" + snapshot_name
)
2405 fail_count
+= self
.c
.destroy_lvol_store(uuid_store
)
2406 # Destroy malloc bdev
2407 fail_count
+= self
.c
.delete_malloc_bdev(base_name
)
2410 # - calls successful, return code = 0
2411 # - cloning thick provisioned lvol bdev should fail
2412 # - no other operation fails
2416 def test_case755(self
):
2418 clone_writing_to_clone
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
,
2431 uuid_store
= self
.c
.construct_lvol_store(base_name
,
2433 fail_count
+= self
.c
.check_get_lvol_stores(base_name
, uuid_store
,
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)
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
)
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
2465 fail_count
+= self
.compare_two_disks(nbd_name
[2], nbd_name
[3], 0)
2467 for nbd
in nbd_name
:
2468 fail_count
+= self
.c
.stop_nbd_disk(nbd
)
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'])
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
)
2479 fail_count
+= self
.c
.delete_malloc_bdev(base_name
)
2482 # - calls successful, return code = 0
2483 # - no other operation fails
2487 def test_case756(self
):
2489 clone_and_snapshot_relations
2491 Check if relations between clones and snapshots
2492 are properly set in configuration
2495 snapshot_name
= 'snapshot'
2496 clone_name0
= 'clone1'
2497 clone_name1
= 'clone2'
2498 lbd_name
= clone_name1
2500 # Create malloc bdev
2501 base_name
= self
.c
.construct_malloc_bdev(self
.total_size
,
2504 uuid_store
= self
.c
.construct_lvol_store(base_name
,
2506 fail_count
+= self
.c
.check_get_lvol_stores(base_name
, uuid_store
,
2508 size
= self
.get_lvs_divided_size(6)
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
)
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
)
2519 # Create clone of created snapshot
2520 fail_count
+= self
.c
.clone_lvol_bdev(snapshot_bdev
['name'], clone_name0
)
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
)
2527 # Check snapshot consistency
2528 snapshot_lvol
= snapshot_bdev
['driver_specific']['lvol']
2529 if snapshot_lvol
['snapshot'] is not True:
2531 if snapshot_lvol
['clone'] is not False:
2533 if sorted([clone_name0
, clone_name1
]) != sorted(snapshot_lvol
['clones']):
2536 # Check first clone consistency
2537 lvol_clone0_lvol
= lvol_clone0
['driver_specific']['lvol']
2538 if lvol_clone0_lvol
['snapshot'] is not False:
2540 if lvol_clone0_lvol
['clone'] is not True:
2542 if lvol_clone0_lvol
['base_snapshot'] != 'snapshot':
2545 # Check second clone consistency
2546 lvol_clone1_lvol
= lvol_clone1
['driver_specific']['lvol']
2547 if lvol_clone1_lvol
['snapshot'] is not False:
2549 if lvol_clone1_lvol
['clone'] is not True:
2551 if lvol_clone1_lvol
['base_snapshot'] != 'snapshot':
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']:
2560 # Destroy second clone
2561 fail_count
+= self
.c
.destroy_lvol_bdev(lvol_clone1
['name'])
2564 fail_count
+= self
.c
.destroy_lvol_bdev(snapshot_bdev
['name'])
2566 # Destroy lvol store
2567 fail_count
+= self
.c
.destroy_lvol_store(uuid_store
)
2570 fail_count
+= self
.c
.delete_malloc_bdev(base_name
)
2573 # - calls successful, return code = 0
2574 # - no other operation fails
2578 def test_case757(self
):
2583 Test inflate rpc method
2586 snapshot_name
= "snapshot"
2587 nbd_name
= "/dev/nbd0"
2589 # Create malloc bdev
2590 base_name
= self
.c
.construct_malloc_bdev(self
.total_size
,
2594 uuid_store
= self
.c
.construct_lvol_store(base_name
,
2596 fail_count
+= self
.c
.check_get_lvol_stores(base_name
, uuid_store
,
2598 size
= self
.get_lvs_divided_size(4)
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
)
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
)
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
)
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:
2620 # Fill part of clone with data of known pattern
2621 fail_count
+= self
.c
.start_nbd_disk(lvol_clone
['name'], nbd_name
)
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
)
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:
2637 fail_count
+= self
.c
.destroy_lvol_bdev(snapshot_bdev
['name'])
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
,
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
,
2651 self
.c
.stop_nbd_disk(nbd_name
)
2654 fail_count
+= self
.c
.destroy_lvol_bdev(lvol_bdev
['name'])
2656 # Destroy lvol store
2657 fail_count
+= self
.c
.destroy_lvol_store(uuid_store
)
2660 fail_count
+= self
.c
.delete_malloc_bdev(base_name
)
2663 # - calls successful, return code = 0
2664 # - no other operation fails
2668 def test_case758(self
):
2670 clone_decouple_parent
2672 Detach parent from clone and check if parent can be safely removed.
2673 Check data consistency.
2677 snapshot_name
= "snapshot"
2678 nbd_name
= "/dev/nbd0"
2680 # Create malloc bdev
2681 base_name
= self
.c
.construct_malloc_bdev(self
.total_size
,
2685 uuid_store
= self
.c
.construct_lvol_store(base_name
,
2687 fail_count
+= self
.c
.check_get_lvol_stores(base_name
, uuid_store
,
2689 size
= self
.get_lvs_divided_size(4)
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
)
2696 # Decouple parent lvol bdev and check if it fails
2697 ret_value
= self
.c
.decouple_parent_lvol_bdev(lvol_bdev
['name'])
2699 print("ERROR: Decouple parent on bdev without parent should "
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
)
2707 # Try to destroy snapshot and check if it fails
2708 ret_value
= self
.c
.destroy_lvol_bdev(snapshot_bdev
['name'])
2710 print("ERROR: Delete snapshot should fail but didn't")
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:
2719 if lvol_bdev
['driver_specific']['lvol']['clone'] is not False:
2721 if lvol_bdev
['driver_specific']['lvol']['snapshot'] is not False:
2723 if snapshot_bdev
['driver_specific']['lvol']['clone'] is not False:
2727 fail_count
+= self
.c
.destroy_lvol_bdev(snapshot_bdev
['name'])
2730 fail_count
+= self
.c
.destroy_lvol_bdev(lvol_bdev
['name'])
2732 # Destroy lvol store
2733 fail_count
+= self
.c
.destroy_lvol_store(uuid_store
)
2736 fail_count
+= self
.c
.delete_malloc_bdev(base_name
)
2739 # - calls successful, return code = 0
2740 # - no other operation fails
2744 def test_case759(self
):
2746 clone_decouple_parent_rw
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.
2753 snapshot_name
= "snapshot"
2754 snapshot_name2
= "snapshot2"
2755 nbd_name
= "/dev/nbd0"
2757 # Create malloc bdev
2758 base_name
= self
.c
.construct_malloc_bdev(self
.total_size
,
2762 uuid_store
= self
.c
.construct_lvol_store(base_name
,
2764 fail_count
+= self
.c
.check_get_lvol_stores(base_name
, uuid_store
,
2766 lvs
= self
.c
.get_lvol_stores()
2767 size
= int(5 * lvs
[0]['cluster_size'] / MEGABYTE
)
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
)
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
)
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)
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
)
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)
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
)
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)
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
])
2810 # Delete snapshot and check if it fails
2811 ret_value
= self
.c
.destroy_lvol_bdev(snapshot_bdev2
['name'])
2813 print("ERROR: Delete snapshot should fail but didn't")
2817 fail_count
+= self
.c
.decouple_parent_lvol_bdev(lvol_bdev
['name'])
2818 lvol_bdev
= self
.c
.get_lvol_bdev_with_name(uuid_bdev0
)
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
])
2826 # Delete second snapshot
2827 ret_value
= self
.c
.destroy_lvol_bdev(snapshot_bdev2
['name'])
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
])
2836 fail_count
+= self
.c
.destroy_lvol_bdev(lvol_bdev
['name'])
2839 fail_count
+= self
.c
.destroy_lvol_bdev(snapshot_bdev
['name'])
2841 # Destroy lvol store
2842 fail_count
+= self
.c
.destroy_lvol_store(uuid_store
)
2845 fail_count
+= self
.c
.delete_malloc_bdev(base_name
)
2848 # - calls successful, return code = 0
2849 # - no other operation fails
2853 def test_case760(self
):
2857 Set lvol bdev as read only and perform clone on it.
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
,
2866 # Construct lvol store on malloc bdev
2867 uuid_store
= self
.c
.construct_lvol_store(base_name
,
2869 fail_count
+= self
.c
.check_get_lvol_stores(base_name
, uuid_store
,
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
,
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'])
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)
2887 # Create clone of lvol set to read only
2888 rv
= self
.c
.clone_lvol_bdev(lvol_bdev
['name'], clone_name
)
2890 print("ERROR: Creating clone of snapshot ended with unexpected failure")
2892 clone_bdev
= self
.c
.get_lvol_bdev_with_name(self
.lvs_name
+ "/" + clone_name
)
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)
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'])
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
)
2912 # - calls successful, return code = 0
2913 # - no other operation fails
2917 def test_case800(self
):
2921 Positive test for lvol store and lvol bdev rename.
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
]
2929 # Create malloc bdev
2930 base_name
= self
.c
.construct_malloc_bdev(self
.total_size
,
2932 # Construct lvol store on created malloc bdev
2933 lvs_uuid
= self
.c
.construct_lvol_store(base_name
,
2935 fail_count
+= self
.c
.check_get_lvol_stores(base_name
,
2939 # Create 4 lvol bdevs on top of previously created lvol store
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
,
2945 fail_count
+= self
.c
.check_get_bdevs_methods(uuid
,
2948 bdev_uuids
.append(uuid
)
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
]
2955 fail_count
+= self
.c
.rename_lvol_store(self
.lvs_name
, new_lvs_name
)
2957 fail_count
+= self
.c
.check_get_lvol_stores(base_name
,
2962 for uuid
, alias
in zip(bdev_uuids
, bdev_aliases
):
2963 fail_count
+= self
.c
.check_get_bdevs_methods(uuid
,
2967 # Now try to rename the bdevs using their uuid as "old_name"
2968 # Verify that all bdev names were successfully updated
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
]
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
,
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
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
]
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
,
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
)
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
3002 def test_case801(self
):
3004 rename_lvs_nonexistent
3006 Negative test case for lvol store rename.
3007 Check that error is returned when trying to rename not existing lvol store.
3010 # Call rename_lvol_store with name pointing to not existing lvol store
3011 if self
.c
.rename_lvol_store("NOTEXIST", "WHATEVER") == 0:
3015 # - rename_lvol_store return code != 0
3016 # - no other operation fails
3020 def test_case802(self
):
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.
3030 lvs_name_1
= "lvs_1"
3031 lvs_name_2
= "lvs_2"
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
]
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
]
3041 # Construct two malloc bdevs
3042 base_bdev_1
= self
.c
.construct_malloc_bdev(self
.total_size
,
3044 base_bdev_2
= self
.c
.construct_malloc_bdev(self
.total_size
,
3047 # Create lvol store on each malloc bdev
3048 lvs_uuid_1
= self
.c
.construct_lvol_store(base_bdev_1
,
3050 fail_count
+= self
.c
.check_get_lvol_stores(base_bdev_1
,
3054 lvs_uuid_2
= self
.c
.construct_lvol_store(base_bdev_2
,
3056 fail_count
+= self
.c
.check_get_lvol_stores(base_bdev_2
,
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
,
3068 fail_count
+= self
.c
.check_get_bdevs_methods(uuid
,
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
,
3076 fail_count
+= self
.c
.check_get_bdevs_methods(uuid
,
3079 bdev_uuids_2
.append(uuid
)
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
3083 if self
.c
.rename_lvol_store(lvs_name_1
, lvs_name_2
) == 0:
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
,
3091 fail_count
+= self
.c
.check_get_lvol_stores(base_bdev_2
,
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
,
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
,
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
)
3115 # - rename_lvol_store return code != 0; not possible to rename to already
3117 # - no other operation fails
3122 def test_case803(self
):
3124 rename_lvol_bdev_nonexistent
3126 Negative test case for lvol bdev rename.
3127 Check that error is returned when trying to rename not existing lvol bdev.
3130 # Call rename_lvol_bdev with name pointing to not existing lvol bdev
3131 if self
.c
.rename_lvol_bdev("NOTEXIST", "WHATEVER") == 0:
3135 # - rename_lvol_bdev return code != 0
3136 # - no other operation fails
3140 def test_case804(self
):
3142 rename_lvol_bdev_EEXIST
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.
3150 # Construt malloc bdev
3151 base_bdev
= self
.c
.construct_malloc_bdev(self
.total_size
,
3153 # Create lvol store on created malloc bdev
3154 lvs_uuid
= self
.c
.construct_lvol_store(base_bdev
,
3156 fail_count
+= self
.c
.check_get_lvol_stores(base_bdev
,
3160 # Construct 2 lvol bdevs on lvol store
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",
3165 fail_count
+= self
.c
.check_get_bdevs_methods(bdev_uuid_1
,
3167 bdev_uuid_2
= self
.c
.construct_lvol_bdev(lvs_uuid
,
3168 self
.lbd_name
+ "2",
3170 fail_count
+= self
.c
.check_get_bdevs_methods(bdev_uuid_2
,
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
3175 if self
.c
.rename_lvol_bdev(self
.lbd_name
+ "1", self
.lbd_name
+ "2") == 0:
3177 # Verify that lvol bdev still have the same names as before
3178 fail_count
+= self
.c
.check_get_bdevs_methods(bdev_uuid_1
,
3180 "/".join([self
.lvs_name
, self
.lbd_name
+ "1"]))
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
)
3188 # - rename_lvol_bdev return code != 0; not possible to rename to already
3190 # - no other operation fails
3194 def test_case10000(self
):
3198 Call CTRL+C (SIGTERM) occurs after creating lvol store
3200 pid_path
= path
.join(self
.path
, 'vhost.pid')
3201 # Create malloc bdev
3202 base_name
= self
.c
.construct_malloc_bdev(self
.total_size
,
3204 # Construct lvol store on created malloc bddev
3205 uuid_store
= self
.c
.construct_lvol_store(base_name
,
3207 # Check correct uuid values in response get_lvol_stores command
3208 fail_count
= self
.c
.check_get_lvol_stores(base_name
, uuid_store
,
3211 # Send SIGTERM signal to the application
3212 fail_count
+= self
._stop
_vhost
(pid_path
)
3215 # - calls successful, return code = 0
3216 # - get_bdevs: no change
3217 # - no other operation fails