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