]>
Commit | Line | Data |
---|---|---|
81ebc68f WL |
1 | #!/usr/bin/perl |
2 | ||
3 | use strict; | |
4 | use warnings; | |
5 | use Data::Dumper qw(Dumper); | |
6 | use PVE::Storage; | |
7 | use PVE::Cluster; | |
8 | use PVE::Tools qw(run_command); | |
9 | use Cwd; | |
10 | $Data::Dumper::Sortkeys = 1; | |
11 | ||
12 | my $verbose = undef; | |
13 | ||
14 | my $storagename = "zfstank99"; | |
15 | my $subvol = 'regressiontest'; | |
16 | ||
17 | #volsize in GB | |
18 | my $volsize = 1; | |
19 | my $vmdisk = "vm-102-disk-1"; | |
20 | my $vmbase = "base-100-disk-1"; | |
21 | my $vmlinked = "vm-101-disk-1"; | |
22 | my $ctdisk = "subvol-202-disk-1"; | |
23 | my $ctbase = "basevol-200-disk-1"; | |
24 | my $ctlinked = "subvol-201-disk-1"; | |
25 | ||
26 | my $basesnap = '@__base__'; | |
27 | my $tests = {}; | |
28 | ||
29 | #create zfs suvol for testing | |
81ebc68f WL |
30 | my $pool = undef; |
31 | my $zpath = undef; | |
32 | my $cfg = undef; | |
33 | my $scfg = undef; | |
34 | my $count = 0; | |
3672677d | 35 | my $testnum = 19; |
46001581 WL |
36 | my $end_test = $testnum; |
37 | my $start_test = 1; | |
38 | ||
39 | if (@ARGV == 2) { | |
40 | $end_test = $ARGV[1]; | |
41 | $start_test = $ARGV[0]; | |
42 | } elsif (@ARGV == 1) { | |
43 | $start_test = $ARGV[0]; | |
44 | $end_test = $ARGV[0]; | |
45 | } | |
46 | ||
3672677d WL |
47 | my $test19 = sub { |
48 | ||
49 | print "\nrun test19 \"path\"\n"; | |
50 | ||
51 | my @res; | |
52 | my $fail = 0; | |
53 | eval { | |
54 | @res = PVE::Storage::path($cfg, "$storagename:$vmdisk"); | |
55 | if ($res[0] ne "\/dev\/zvol\/regressiontest\/$vmdisk") { | |
56 | $count++; | |
57 | $fail = 1; | |
58 | warn "Test 19 a: path is not correct: expected \'\/dev\/zvol\/regressiontest\/$vmdisk'\ get \'$res[0]\'"; | |
59 | } | |
60 | if ($res[1] ne "102") { | |
61 | if (!$fail) { | |
62 | $count++; | |
63 | $fail = 1; | |
64 | } | |
65 | warn "Test 19 a: owner is not correct: expected \'102\' get \'$res[1]\'"; | |
66 | } | |
67 | if ($res[2] ne "images") { | |
68 | if (!$fail) { | |
69 | $count++; | |
70 | $fail = 1; | |
71 | } | |
72 | warn "Test 19 a: owner is not correct: expected \'images\' get \'$res[2]\'"; | |
73 | } | |
74 | }; | |
75 | if ( $@ ) { | |
76 | $count++; | |
77 | warn "Test 19 a: $@"; | |
78 | } | |
79 | ||
80 | @res = undef; | |
81 | $fail = 0; | |
82 | eval { | |
83 | @res = PVE::Storage::path($cfg, "$storagename:$vmbase"); | |
84 | if ($res[0] ne "\/dev\/zvol\/regressiontest\/$vmbase") { | |
85 | $count++; | |
86 | $fail = 1; | |
87 | warn "Test 19 b: path is not correct: expected \'\/dev\/zvol\/regressiontest\/$vmbase'\ get \'$res[0]\'"; | |
88 | } | |
89 | if ($res[1] ne "100") { | |
90 | if (!$fail) { | |
91 | $count++; | |
92 | $fail = 1; | |
93 | } | |
94 | warn "Test 19 b: owner is not correct: expected \'100\' get \'$res[1]\'"; | |
95 | } | |
96 | if ($res[2] ne "images") { | |
97 | if (!$fail) { | |
98 | $count++; | |
99 | $fail = 1; | |
100 | } | |
101 | warn "Test 19 b: owner is not correct: expected \'images\' get \'$res[2]\'"; | |
102 | } | |
103 | }; | |
104 | if ( $@ ) { | |
105 | $count++; | |
106 | warn "Test 19 b: $@"; | |
107 | } | |
108 | ||
109 | @res = undef; | |
110 | $fail = 0; | |
111 | eval { | |
112 | @res = PVE::Storage::path($cfg, "$storagename:$vmbase\/$vmlinked"); | |
113 | if ($res[0] ne "\/dev\/zvol\/regressiontest\/$vmlinked") { | |
114 | $count++; | |
115 | $fail = 1; | |
116 | warn "Test 19 c: path is not correct: expected \'\/dev\/zvol\/regressiontest\/$vmlinked'\ get \'$res[0]\'"; | |
117 | } | |
118 | if ($res[1] ne "101") { | |
119 | if (!$fail) { | |
120 | $count++; | |
121 | $fail = 1; | |
122 | } | |
123 | warn "Test 19 c: owner is not correct: expected \'101\' get \'$res[1]\'"; | |
124 | } | |
125 | if ($res[2] ne "images") { | |
126 | if (!$fail) { | |
127 | $count++; | |
128 | $fail = 1; | |
129 | } | |
130 | warn "Test 19 c: owner is not correct: expected \'images\' get \'$res[2]\'"; | |
131 | } | |
132 | }; | |
133 | if ( $@ ) { | |
134 | $count++; | |
135 | warn "Test 19 c: $@"; | |
136 | } | |
137 | ||
138 | @res = undef; | |
139 | $fail = 0; | |
140 | eval { | |
141 | @res = PVE::Storage::path($cfg, "$storagename:$ctdisk"); | |
142 | if ($res[0] ne "\/regressiontest\/$ctdisk") { | |
143 | $count++; | |
144 | $fail = 1; | |
145 | warn "Test 19 d: path is not correct: expected \'/regressiontest\/$ctdisk'\ get \'$res[0]\'"; | |
146 | } | |
147 | if ($res[1] ne "202") { | |
148 | if (!$fail) { | |
149 | $count++; | |
150 | $fail = 1; | |
151 | } | |
152 | warn "Test 19 d: owner is not correct: expected \'202\' get \'$res[1]\'"; | |
153 | } | |
154 | if ($res[2] ne "images") { | |
155 | if (!$fail) { | |
156 | $count++; | |
157 | $fail = 1; | |
158 | } | |
159 | warn "Test 19 d: owner is not correct: expected \'images\' get \'$res[2]\'"; | |
160 | } | |
161 | }; | |
162 | if ( $@ ) { | |
163 | $count++; | |
164 | warn "Test 19 d: $@"; | |
165 | } | |
166 | ||
167 | @res = undef; | |
168 | $fail = 0; | |
169 | eval { | |
170 | @res = PVE::Storage::path($cfg, "$storagename:$ctbase"); | |
171 | if ($res[0] ne "\/regressiontest\/$ctbase") { | |
172 | $count++; | |
173 | $fail = 1; | |
174 | warn "Test 19 e: path is not correct: expected \'\/regressiontest\/$ctbase'\ get \'$res[0]\'"; | |
175 | } | |
176 | if ($res[1] ne "200") { | |
177 | if (!$fail) { | |
178 | $count++; | |
179 | $fail = 1; | |
180 | } | |
181 | warn "Test 19 e: owner is not correct: expected \'200\' get \'$res[1]\'"; | |
182 | } | |
183 | if ($res[2] ne "images") { | |
184 | if (!$fail) { | |
185 | $count++; | |
186 | $fail = 1; | |
187 | } | |
188 | warn "Test 19 e: owner is not correct: expected \'images\' get \'$res[2]\'"; | |
189 | } | |
190 | }; | |
191 | if ( $@ ) { | |
192 | $count++; | |
193 | warn "Test 19 e: $@"; | |
194 | } | |
195 | ||
196 | @res = undef; | |
197 | $fail = 0; | |
198 | eval { | |
199 | @res = PVE::Storage::path($cfg, "$storagename:$ctbase\/$ctlinked"); | |
200 | if ($res[0] ne "\/regressiontest\/$ctlinked") { | |
201 | $count++; | |
202 | $fail = 1; | |
203 | warn "Test 19 f: path is not correct: expected \'\/regressiontest\/$ctlinked'\ get \'$res[0]\'"; | |
204 | } | |
205 | if ($res[1] ne "201") { | |
206 | if (!$fail) { | |
207 | $count++; | |
208 | $fail = 1; | |
209 | } | |
210 | warn "Test 19 f: owner is not correct: expected \'201\' get \'$res[1]\'"; | |
211 | } | |
212 | if ($res[2] ne "images") { | |
213 | if (!$fail) { | |
214 | $count++; | |
215 | $fail = 1; | |
216 | } | |
217 | warn "Test 19 f: owner is not correct: expected \'images\' get \'$res[2]\'"; | |
218 | } | |
219 | }; | |
220 | if ( $@ ) { | |
221 | $count++; | |
222 | warn "Test 19 f: $@"; | |
223 | } | |
224 | }; | |
225 | $tests->{19} = $test19; | |
81ebc68f WL |
226 | |
227 | my $test18 = sub { | |
228 | ||
229 | print "\nrun test17 \"scan_zfs\"\n"; | |
230 | my $res; | |
231 | ||
232 | eval { | |
233 | $res = PVE::Storage::scan_zfs($cfg, $storagename); | |
234 | ||
235 | my $exists = 0; | |
236 | foreach my $subvol (@$res){ | |
237 | if ($subvol->{pool} eq 'regressiontest') { | |
238 | $exists++; | |
239 | } | |
240 | } | |
241 | if (!$exists) { | |
242 | $count++; | |
243 | warn "Test 18 a: not pool"; | |
244 | } | |
245 | }; | |
246 | if ( $@ ) { | |
247 | $count++; | |
248 | warn "Test 18 a: $@"; | |
249 | } | |
250 | $res = undef; | |
251 | ||
252 | eval { | |
253 | $res = PVE::Storage::scan_zfs($cfg, $storagename); | |
254 | ||
255 | foreach my $subvol (@$res){ | |
256 | if ($subvol->{pool} eq 'zfspool/subvol') { | |
257 | $count++; | |
258 | warn "Test 18 b:"; | |
259 | } | |
260 | } | |
261 | ||
262 | foreach my $subvol (@$res){ | |
263 | if ($subvol->{pool} eq 'zfspool/basevol') { | |
264 | $count++; | |
265 | warn "Test 18 c"; | |
266 | } | |
267 | } | |
268 | }; | |
269 | if ( $@ ) { | |
270 | $count++; | |
271 | warn "Test 18 a: $@"; | |
272 | } | |
273 | }; | |
274 | $tests->{18} = $test18; | |
275 | ||
276 | my $test17 = sub { | |
277 | ||
278 | print "\nrun test17 \"deactivate_storage\"\n"; | |
279 | ||
280 | eval { | |
281 | PVE::Storage::activate_storage($cfg, $storagename); | |
282 | }; | |
283 | if ($@) { | |
284 | $count++; | |
285 | warn "Test 17 a: $@"; | |
286 | } | |
287 | }; | |
288 | $tests->{17} = $test17; | |
289 | ||
290 | my $test16 = sub { | |
291 | ||
292 | print "\nrun test16 \"activate_storage\"\n"; | |
293 | ||
294 | eval { | |
295 | PVE::Storage::activate_storage($cfg, $storagename); | |
296 | }; | |
297 | if ($@) { | |
298 | $count++; | |
299 | warn "Test 16 a: $@"; | |
300 | } | |
301 | }; | |
302 | $tests->{16} = $test16; | |
303 | ||
304 | my $test15 = sub { | |
305 | ||
306 | print "\nrun test15 \"template_list and vdisk_list\"\n"; | |
307 | ||
308 | my $hash = Dumper {}; | |
309 | ||
310 | my $res = Dumper PVE::Storage::template_list($cfg, $storagename, "vztmpl"); | |
311 | if ( $hash ne $res ) { | |
312 | $count++; | |
313 | warn "Test 15 a failed\n"; | |
314 | } | |
315 | $res = undef; | |
316 | ||
317 | $res = Dumper PVE::Storage::template_list($cfg, $storagename, "iso"); | |
318 | if ( $hash ne $res ) { | |
319 | $count++; | |
320 | warn "Test 15 b failed\n"; | |
321 | } | |
322 | $res = undef; | |
323 | ||
324 | $res = Dumper PVE::Storage::template_list($cfg, $storagename, "backup"); | |
325 | if ( $hash ne $res ) { | |
326 | $count++; | |
327 | warn "Test 15 c failed\n"; | |
328 | } | |
329 | $res = undef; | |
330 | ||
331 | $hash = Dumper {'zfstank99' => [ | |
332 | { | |
333 | 'parent' => undef, | |
334 | 'volid' => 'zfstank99:base-100-disk-1', | |
335 | 'name' => 'base-100-disk-1', | |
336 | 'vmid' => '100', | |
337 | 'size' => 1073741824, | |
338 | 'format' => 'raw' | |
339 | } | |
340 | ]}; | |
341 | ||
342 | $res = Dumper PVE::Storage::vdisk_list($cfg, $storagename, 100, ["$storagename:$vmbase"]); | |
343 | ||
344 | if ( $hash ne $res ) { | |
345 | $count++; | |
346 | warn "Test 15 d failed\n"; | |
347 | } | |
348 | $res = undef; | |
349 | ||
350 | $hash = Dumper {'zfstank99' => [ | |
351 | { | |
352 | 'parent' => undef, | |
353 | 'volid' => 'zfstank99:vm-102-disk-1', | |
354 | 'name' => 'vm-102-disk-1', | |
355 | 'vmid' => '102', | |
356 | 'size' => 1073741824, | |
357 | 'format' => 'raw' | |
358 | } | |
359 | ]}; | |
360 | ||
361 | $res = Dumper PVE::Storage::vdisk_list($cfg, $storagename, 102, ["$storagename:$vmdisk"]); | |
362 | if ( $hash ne $res ) { | |
363 | $count++; | |
364 | warn "Test 15 e failed\n"; | |
365 | } | |
366 | $res = undef; | |
367 | ||
368 | $hash = Dumper {'zfstank99' => [ | |
369 | { | |
370 | 'parent' => 'base-100-disk-1@__base__', | |
371 | 'volid' => "$storagename:$vmbase\/$vmlinked", | |
372 | 'name' => 'vm-101-disk-1', | |
373 | 'vmid' => '101', | |
374 | 'size' => 1073741824, | |
375 | 'format' => 'raw' | |
376 | } | |
377 | ]}; | |
378 | ||
379 | $res = Dumper PVE::Storage::vdisk_list($cfg, $storagename, 101, ["$storagename:$vmbase\/$vmlinked"]); | |
380 | if ( $hash ne $res ) { | |
381 | $count++; | |
382 | warn "Test 15 f failed\n"; | |
383 | } | |
384 | $res = undef; | |
385 | ||
386 | $hash = Dumper {'zfstank99' => [ | |
387 | { | |
388 | 'parent' => undef, | |
389 | 'volid' => 'zfstank99:basevol-200-disk-1', | |
390 | 'name' => 'basevol-200-disk-1', | |
391 | 'vmid' => '200', | |
392 | 'size' => 1073741824, | |
393 | 'format' => 'subvol' | |
394 | } | |
395 | ]}; | |
396 | ||
397 | $res = Dumper PVE::Storage::vdisk_list($cfg, $storagename, 200, ["$storagename:$ctbase"]); | |
398 | if ( $hash ne $res ) { | |
399 | $count++; | |
400 | warn "Test 15 g failed\n"; | |
401 | } | |
402 | $res = undef; | |
403 | ||
404 | $hash = Dumper {'zfstank99' => [ | |
405 | { | |
406 | 'parent' => undef, | |
407 | 'volid' => 'zfstank99:subvol-202-disk-1', | |
408 | 'name' => 'subvol-202-disk-1', | |
409 | 'vmid' => '202', | |
410 | 'size' => 1073741824, | |
411 | 'format' => 'subvol' | |
412 | } | |
413 | ]}; | |
414 | ||
415 | $res = Dumper PVE::Storage::vdisk_list($cfg, $storagename, 202, ["$storagename:$ctdisk"]); | |
416 | if ( $hash ne $res ) { | |
417 | $count++; | |
418 | warn "Test 15 h failed\n"; | |
419 | } | |
420 | $res = undef; | |
421 | ||
422 | $hash = Dumper {'zfstank99' => [ | |
423 | { | |
424 | 'parent' => 'basevol-200-disk-1@__base__', | |
425 | 'volid' => "$storagename:$ctbase\/$ctlinked", | |
426 | 'name' => 'subvol-201-disk-1', | |
427 | 'vmid' => '201', | |
428 | 'size' => 1073741824, | |
429 | 'format' => 'subvol' | |
430 | } | |
431 | ]}; | |
432 | $res = Dumper PVE::Storage::vdisk_list($cfg, $storagename, 201, ["$storagename:$ctbase\/$ctlinked"]); | |
433 | if ( $hash ne $res ) { | |
434 | $count++; | |
435 | warn "Test 15 i failed\n"; | |
436 | } | |
437 | }; | |
438 | $tests->{15} = $test15; | |
439 | ||
440 | my $test14 = sub { | |
441 | ||
442 | print "\nrun test14 \"vdisk_free\"\n"; | |
443 | ||
444 | eval { | |
445 | PVE::Storage::vdisk_free($cfg, "$storagename:$vmdisk"); | |
446 | ||
447 | eval { | |
448 | run_command("zfs list $zpath\/$vmdisk", outfunc => sub {}, errfunc => sub {}); | |
449 | }; | |
450 | if (!$@) { | |
451 | $count++; | |
452 | warn "Test14 a: vdisk still exists\n"; | |
453 | } | |
454 | }; | |
455 | if ($@) { | |
456 | $count++; | |
457 | warn "Test14 a: $@"; | |
458 | } | |
459 | ||
460 | eval { | |
461 | PVE::Storage::vdisk_free($cfg, "$storagename:$vmbase"); | |
462 | }; | |
463 | if (!$@) { | |
464 | $count++; | |
465 | warn "Test14 b: free vdisk should not work\n"; | |
466 | } | |
467 | ||
468 | eval { | |
469 | PVE::Storage::vdisk_free($cfg, "$storagename:$vmbase\/$vmlinked"); | |
470 | ||
471 | eval { | |
472 | run_command("zfs list $zpath\/$vmlinked", outfunc => sub {}, errfunc => sub {}); | |
473 | }; | |
474 | if (!$@) { | |
475 | $count++; | |
476 | warn "Test14 c: vdisk still exists\n"; | |
477 | } | |
478 | }; | |
479 | if ($@) { | |
480 | $count++; | |
481 | warn "Test14 c: $@"; | |
482 | } | |
483 | ||
484 | eval { | |
485 | PVE::Storage::vdisk_free($cfg, "$storagename:$ctdisk"); | |
486 | ||
487 | eval { | |
488 | run_command("zfs list $zpath\/$ctdisk", outfunc => sub {}, errfunc => sub {}); | |
489 | }; | |
490 | if (!$@) { | |
491 | $count++; | |
492 | warn "Test14 d: vdisk still exists\n"; | |
493 | } | |
494 | }; | |
495 | if ($@) { | |
496 | $count++; | |
497 | warn "Test14 d: $@"; | |
498 | } | |
499 | ||
500 | eval { | |
501 | PVE::Storage::vdisk_free($cfg, "$storagename:$ctbase"); | |
502 | }; | |
503 | if (!$@) { | |
504 | $count++; | |
505 | warn "Test14 e: free vdisk should not work\n"; | |
506 | } | |
507 | ||
508 | eval { | |
509 | PVE::Storage::vdisk_free($cfg, "$storagename:$ctbase\/$ctlinked"); | |
510 | ||
511 | eval { | |
512 | run_command("zfs list $zpath\/$ctlinked", outfunc => sub {}, errfunc => sub {}); | |
513 | }; | |
514 | if (!$@) { | |
515 | $count++; | |
516 | warn "Test14 f: vdisk still exists\n"; | |
517 | } | |
518 | }; | |
519 | if ($@) { | |
520 | $count++; | |
521 | warn "Test14 f: $@"; | |
522 | } | |
523 | ||
524 | eval { | |
525 | PVE::Storage::vdisk_free($cfg, "$storagename:$vmbase"); | |
526 | ||
527 | eval { | |
528 | run_command("zfs list $zpath\/$vmbase", outfunc => sub {}, errfunc => sub {}); | |
529 | }; | |
530 | if (!$@) { | |
531 | $count++; | |
532 | warn "Test14 g: vdisk still exists\n"; | |
533 | } | |
534 | }; | |
535 | if ($@) { | |
536 | $count++; | |
537 | warn "Test14 g: $@"; | |
538 | } | |
539 | ||
540 | eval { | |
541 | PVE::Storage::vdisk_free($cfg, "$storagename:$ctbase"); | |
542 | ||
543 | eval { | |
544 | run_command("zfs list $zpath\/$ctbase", outfunc => sub {}, errfunc => sub {}); | |
545 | }; | |
546 | if (!$@) { | |
547 | $count++; | |
548 | warn "Test14 h: vdisk still exists\n"; | |
549 | } | |
550 | }; | |
551 | if ($@) { | |
552 | $count++; | |
553 | warn "Test14 h: $@"; | |
554 | } | |
555 | }; | |
556 | $tests->{14} = $test14; | |
557 | ||
558 | my $test13 = sub { | |
559 | ||
560 | print "\nrun test13 \"vdisk_alloc\"\n"; | |
561 | ||
562 | eval { | |
563 | my $tmp_volid = PVE::Storage::vdisk_alloc($cfg, $storagename, "112", "raw", undef ,1024 * 1024); | |
564 | ||
565 | if ($tmp_volid ne "$storagename:vm-112-disk-1") { | |
566 | die "volname:$tmp_volid don't match\n"; | |
567 | } | |
568 | eval { | |
569 | run_command("zfs get -H volsize $zpath\/vm-112-disk-1", outfunc => | |
570 | sub { my $tmp = shift; | |
571 | if ($tmp !~ m/^$zpath\/vm-112-disk-1.*volsize.*1G.*$/) { | |
572 | die "size don't match\n"; | |
573 | } | |
574 | }); | |
575 | }; | |
576 | if ($@) { | |
577 | $count++; | |
578 | warn "Test13 a: $@"; | |
579 | } | |
580 | }; | |
581 | if ($@) { | |
582 | $count++; | |
583 | warn "Test13 a: $@"; | |
584 | } | |
585 | ||
586 | eval { | |
587 | my $tmp_volid = PVE::Storage::vdisk_alloc($cfg, $storagename, "112", "raw", undef ,2048 * 1024); | |
588 | ||
589 | if ($tmp_volid ne "$storagename:vm-112-disk-2") { | |
590 | die "volname:$tmp_volid don't match\n"; | |
591 | } | |
592 | eval { | |
593 | run_command("zfs get -H volsize $zpath\/vm-112-disk-2", outfunc => | |
594 | sub { my $tmp = shift; | |
595 | if ($tmp !~ m/^$zpath\/vm-112-disk-2.*volsize.*2G.*$/) { | |
596 | die "size don't match\n"; | |
597 | } | |
598 | }); | |
599 | }; | |
600 | if ($@) { | |
601 | $count++; | |
602 | warn "Test13 b: $@"; | |
603 | } | |
604 | }; | |
605 | if ($@) { | |
606 | $count++; | |
607 | warn "Test13 b: $@"; | |
608 | } | |
609 | ||
610 | eval { | |
611 | my $tmp_volid = PVE::Storage::vdisk_alloc($cfg, $storagename, "113", "subvol", undef ,1024 * 1024); | |
612 | ||
613 | if ($tmp_volid ne "$storagename:subvol-113-disk-1") { | |
614 | die "volname:$tmp_volid don't match\n"; | |
615 | } | |
616 | eval { | |
617 | run_command("zfs get -H refquota $zpath\/subvol-113-disk-1", outfunc => | |
618 | sub { my $tmp = shift; | |
619 | if ($tmp !~ m/^$zpath\/subvol-113-disk-1.*refquota.*1G.*$/) { | |
620 | die "size don't match\n"; | |
621 | } | |
622 | }); | |
623 | }; | |
624 | if ($@) { | |
625 | $count++; | |
626 | warn "Test13 c: $@"; | |
627 | } | |
628 | }; | |
629 | if ($@) { | |
630 | $count++; | |
631 | warn "Test13 c: $@"; | |
632 | } | |
633 | ||
634 | eval { | |
635 | my $tmp_volid = PVE::Storage::vdisk_alloc($cfg, $storagename, "113", "subvol", undef ,2048 * 1024); | |
636 | ||
637 | if ($tmp_volid ne "$storagename:subvol-113-disk-2") { | |
638 | die "volname:$tmp_volid don't match\n"; | |
639 | } | |
640 | eval { | |
641 | run_command("zfs get -H refquota $zpath\/subvol-113-disk-2", outfunc => | |
642 | sub { my $tmp = shift; | |
643 | if ($tmp !~ m/^$zpath\/subvol-113-disk-2.*refquota.*G.*$/) { | |
644 | die "size don't match\n"; | |
645 | } | |
646 | }); | |
647 | }; | |
648 | if ($@) { | |
649 | $count++; | |
650 | warn "Test13 d: $@"; | |
651 | } | |
652 | }; | |
653 | if ($@) { | |
654 | $count++; | |
655 | warn "Test13 d: $@"; | |
656 | } | |
657 | }; | |
658 | $tests->{13} = $test13; | |
659 | ||
660 | my $test12 = sub { | |
661 | ||
662 | print "\nrun test12 \"vdisk_create_base\"\n"; | |
663 | ||
664 | eval { | |
665 | my $tmp_volid = PVE::Storage::vdisk_create_base($cfg, "$storagename:$vmdisk"); | |
666 | ||
667 | if ($tmp_volid ne "$storagename:base-102-disk-1") { | |
668 | die; | |
669 | } | |
670 | eval { | |
671 | run_command("zfs list $zpath\/base-102-disk-1", outfunc => sub {}); | |
672 | }; | |
673 | if ($@) { | |
674 | $count++; | |
675 | warn "Test12 a: $@"; | |
676 | } | |
677 | }; | |
678 | if ($@) { | |
679 | $count++; | |
680 | warn "Test12 a: $@"; | |
681 | } | |
682 | ||
683 | eval { | |
684 | my $tmp_volid = PVE::Storage::vdisk_create_base($cfg, "$storagename:$vmlinked"); | |
685 | ||
686 | if ($tmp_volid ne "$storagename:base-101-disk-1") { | |
687 | die; | |
688 | } | |
689 | eval { | |
690 | run_command("zfs list $zpath\/base-101-disk-1", outfunc => sub {}); | |
691 | }; | |
692 | if ($@) { | |
693 | $count++; | |
694 | warn "Test12 b: $@"; | |
695 | } | |
696 | }; | |
697 | if ($@) { | |
698 | $count++; | |
699 | warn "Test12 b: $@"; | |
700 | } | |
701 | ||
702 | eval { | |
703 | my $tmp_volid = PVE::Storage::vdisk_create_base($cfg, "$storagename:$ctdisk"); | |
704 | ||
705 | if ($tmp_volid ne "$storagename:basevol-202-disk-1") { | |
706 | die ; | |
707 | } | |
708 | eval { | |
709 | run_command("zfs list $zpath\/basevol-202-disk-1", outfunc => sub {}); | |
710 | }; | |
711 | if ($@) { | |
712 | $count++; | |
713 | warn "Test12 c: $@"; | |
714 | } | |
715 | }; | |
716 | if ($@) { | |
717 | $count++; | |
718 | warn "Test12 c: $@"; | |
719 | } | |
720 | ||
721 | eval { | |
722 | my $tmp_volid = PVE::Storage::vdisk_create_base($cfg, "$storagename:$ctlinked"); | |
723 | ||
724 | if ($tmp_volid ne "$storagename:basevol-201-disk-1") { | |
725 | die; | |
726 | } | |
727 | eval { | |
728 | run_command("zfs list $zpath\/basevol-201-disk-1", outfunc => sub {}); | |
729 | }; | |
730 | if ($@) { | |
731 | $count++; | |
732 | warn "Test12 d: $@"; | |
733 | } | |
734 | }; | |
735 | if ($@) { | |
736 | $count++; | |
737 | warn "Test12 d: $@"; | |
738 | } | |
739 | }; | |
740 | $tests->{12} = $test12; | |
741 | ||
742 | my $test11 = sub { | |
743 | ||
744 | print "\nrun test11 \"volume_is_base\"\n"; | |
745 | ||
746 | eval { | |
747 | PVE::Storage::vdisk_clone($cfg, "$storagename:$vmdisk", 110); | |
748 | }; | |
749 | if (!$@) { | |
750 | $count++; | |
751 | warn "Test11 a: clone_image only works on base images"; | |
752 | } | |
753 | ||
754 | eval { | |
755 | if ("$storagename:$vmbase\/vm-110-disk-1" ne | |
756 | PVE::Storage::vdisk_clone($cfg, "$storagename:$vmbase", 110, '__base__')){ | |
757 | $count++; | |
758 | warn "Test11 b"; | |
759 | } | |
760 | run_command("zfs list -H -o volsize $zpath\/vm-110-disk-1", outfunc => sub { | |
761 | my $line = shift; | |
762 | ||
763 | chomp($line); | |
764 | warn "Test11 b not correct volsize" if $line !~ m/$volsize/; | |
765 | }); | |
766 | }; | |
767 | if ($@) { | |
768 | $count++; | |
769 | warn "Test11 b: $@"; | |
770 | } | |
771 | ||
772 | eval { | |
773 | PVE::Storage::vdisk_clone($cfg, "$storagename:$vmbase\/$vmlinked", 111); | |
774 | }; | |
775 | if (!$@) { | |
776 | $count++; | |
777 | warn "Test11 c: clone_image only works on base images"; | |
778 | } | |
779 | ||
780 | eval { | |
781 | PVE::Storage::vdisk_clone($cfg, "$storagename:$ctdisk", 110); | |
782 | }; | |
783 | if (!$@) { | |
784 | $count++; | |
785 | warn "Test11 d: clone_image only works on base images"; | |
786 | } | |
787 | ||
788 | eval { | |
789 | if ( "$storagename:$ctbase\/subvol-210-disk-1" ne | |
790 | PVE::Storage::vdisk_clone($cfg, "$storagename:$ctbase", 210, '__base__')){ | |
791 | $count++; | |
792 | warn "Test11 e"; | |
793 | } | |
794 | run_command("zfs list -H -o refquota $zpath\/subvol-210-disk-1", outfunc => sub { | |
795 | my $line = shift; | |
796 | ||
797 | chomp($line); | |
798 | warn "Test11 e not correct volsize" if $line !~ m/$volsize/; | |
799 | }); | |
800 | }; | |
801 | if ($@) { | |
802 | $count++; | |
803 | warn "Test11 e: $@"; | |
804 | } | |
805 | ||
806 | eval { | |
807 | PVE::Storage::vdisk_clone($cfg, "$storagename:$ctbase\/$ctlinked", 211); | |
808 | }; | |
809 | if (!$@) { | |
810 | $count++; | |
811 | warn "Test11 f: clone_image only works on base images"; | |
812 | } | |
813 | }; | |
814 | $tests->{11} = $test11; | |
815 | ||
816 | my $test10 =sub { | |
817 | ||
818 | print "\nrun test10 \"volume_is_base\"\n"; | |
819 | ||
820 | eval { | |
821 | if (1 == PVE::Storage::volume_is_base($cfg, "$storagename:$vmdisk")) { | |
822 | $count++; | |
823 | warn "Test10 a: is no base"; | |
824 | } | |
825 | ||
826 | }; | |
827 | if ($@) { | |
828 | $count++; | |
829 | warn "Test10 a: $@"; | |
830 | } | |
831 | ||
832 | eval { | |
833 | if (0 == PVE::Storage::volume_is_base($cfg, "$storagename:$vmbase")) { | |
834 | $count++; | |
835 | warn "Test10 b: is base"; | |
836 | } | |
837 | ||
838 | }; | |
839 | if ($@) { | |
840 | $count++; | |
841 | warn "Test10 b: $@"; | |
842 | } | |
843 | ||
844 | eval { | |
845 | if (1 == PVE::Storage::volume_is_base($cfg, "$storagename:$vmbase\/$vmlinked")) { | |
846 | $count++; | |
847 | warn "Test10 c: is no base"; | |
848 | } | |
849 | ||
850 | }; | |
851 | if ($@) { | |
852 | $count++; | |
853 | warn "Test10 c: $@"; | |
854 | } | |
855 | ||
856 | eval { | |
857 | if (1 == PVE::Storage::volume_is_base($cfg, "$storagename:$ctdisk")) { | |
858 | $count++; | |
859 | warn "Test10 d: is no base"; | |
860 | } | |
861 | ||
862 | }; | |
863 | if ($@) { | |
864 | $count++; | |
865 | warn "Test10 d: $@"; | |
866 | } | |
867 | ||
868 | eval { | |
869 | if (0 == PVE::Storage::volume_is_base($cfg, "$storagename:$ctbase")) { | |
870 | $count++; | |
871 | warn "Test10 e: is base"; | |
872 | } | |
873 | ||
874 | }; | |
875 | if ($@) { | |
876 | $count++; | |
877 | warn "Test10 e: $@"; | |
878 | } | |
879 | ||
880 | eval { | |
881 | if (1 == PVE::Storage::volume_is_base($cfg, "$storagename:$ctbase\/$ctlinked")) { | |
882 | $count++; | |
883 | warn "Test10 f: is no base"; | |
884 | } | |
885 | ||
886 | }; | |
887 | if ($@) { | |
888 | $count++; | |
889 | warn "Test10 f: $@"; | |
890 | } | |
891 | }; | |
892 | $tests->{10} = $test10; | |
893 | ||
894 | my $test9 =sub { | |
895 | ||
896 | print "\nrun test9 \"parse_volname\"\n"; | |
897 | ||
898 | eval { | |
899 | my ($store, $disk) = PVE::Storage::parse_volume_id("$storagename:$vmdisk"); | |
900 | ||
901 | if ($store ne $storagename || $disk ne $vmdisk) { | |
902 | $count++; | |
903 | warn "Test9 a: parsing wrong"; | |
904 | } | |
905 | ||
906 | }; | |
907 | if ($@) { | |
908 | $count++; | |
909 | warn "Test9 a: $@"; | |
910 | } | |
911 | ||
912 | eval { | |
913 | my ($store, $disk) = PVE::Storage::parse_volume_id("$storagename:$vmbase"); | |
914 | ||
915 | if ($store ne $storagename || $disk ne $vmbase) { | |
916 | $count++; | |
917 | warn "Test9 b: parsing wrong"; | |
918 | } | |
919 | ||
920 | }; | |
921 | if ($@) { | |
922 | $count++; | |
923 | warn "Test9 b: $@"; | |
924 | } | |
925 | ||
926 | eval { | |
927 | my ($store, $disk) = PVE::Storage::parse_volume_id("$storagename:$vmbase\/$vmlinked"); | |
928 | ||
929 | if ($store ne $storagename || $disk ne "$vmbase\/$vmlinked") { | |
930 | $count++; | |
931 | warn "Test9 c: parsing wrong"; | |
932 | } | |
933 | ||
934 | }; | |
935 | if ($@) { | |
936 | $count++; | |
937 | warn "Test9 c: $@"; | |
938 | } | |
939 | ||
940 | eval { | |
941 | my ($store, $disk) = PVE::Storage::parse_volume_id("$storagename:$ctdisk"); | |
942 | ||
943 | if ($store ne $storagename || $disk ne $ctdisk) { | |
944 | $count++; | |
945 | warn "Test9 d: parsing wrong"; | |
946 | } | |
947 | ||
948 | }; | |
949 | if ($@) { | |
950 | $count++; | |
951 | warn "Test9 d: $@"; | |
952 | } | |
953 | ||
954 | eval { | |
955 | my ($store, $disk) = PVE::Storage::parse_volume_id("$storagename:$ctbase"); | |
956 | ||
957 | if ($store ne $storagename || $disk ne $ctbase) { | |
958 | $count++; | |
959 | warn "Test9 e: parsing wrong"; | |
960 | } | |
961 | ||
962 | }; | |
963 | if ($@) { | |
964 | $count++; | |
965 | warn "Test9 e: $@"; | |
966 | } | |
967 | ||
968 | eval { | |
969 | my ($store, $disk) = PVE::Storage::parse_volume_id("$storagename:$ctbase\/$ctlinked"); | |
970 | ||
971 | if ($store ne $storagename || $disk ne "$ctbase\/$ctlinked") { | |
972 | $count++; | |
973 | warn "Test9 f: parsing wrong"; | |
974 | } | |
975 | ||
976 | }; | |
977 | if ($@) { | |
978 | $count++; | |
979 | warn "Test9 f: $@"; | |
980 | } | |
981 | }; | |
982 | $tests->{9} = $test9; | |
983 | ||
984 | my $test8 = sub { | |
985 | ||
986 | print "\nrun test8 \"parse_volname\"\n"; | |
987 | ||
988 | eval { | |
989 | my ($vtype, $name, $vmid, $basename, $basevmid, $isBase, $format) = PVE::Storage::parse_volname($cfg, "$storagename:$vmdisk"); | |
990 | ||
991 | if ($vtype ne 'images' || $vmid ne '102' || $name ne $vmdisk || | |
b3bb525e | 992 | defined($basename) || defined($basevmid) || $isBase || |
81ebc68f WL |
993 | $format ne 'raw') { |
994 | $count++; | |
995 | warn "Test8 a: parsing wrong"; | |
996 | } | |
997 | ||
998 | }; | |
999 | if ($@) { | |
1000 | $count++; | |
1001 | warn "Test8 a: $@"; | |
1002 | } | |
1003 | ||
1004 | eval { | |
1005 | my ($vtype, $name, $vmid, $basename, $basevmid, $isBase, $format) = PVE::Storage::parse_volname($cfg, "$storagename:$vmbase"); | |
1006 | ||
1007 | if ($vtype ne 'images' || $vmid ne '100' || $name ne $vmbase || | |
b3bb525e | 1008 | defined($basename) || defined($basevmid) || !$isBase || |
81ebc68f WL |
1009 | $format ne 'raw') { |
1010 | $count++; | |
1011 | warn "Test8 b: parsing wrong"; | |
1012 | } | |
1013 | }; | |
1014 | if ($@) { | |
1015 | $count++; | |
1016 | warn "Test8 b: $@"; | |
1017 | } | |
1018 | ||
1019 | eval { | |
1020 | my ($vtype, $name, $vmid, $basename, $basevmid, $isBase, $format) = PVE::Storage::parse_volname($cfg, "$storagename:$vmbase\/$vmlinked"); | |
1021 | ||
1022 | if ($vtype ne 'images' || $name ne $vmlinked || $vmid ne '101' || | |
b3bb525e | 1023 | $basename ne $vmbase || $basevmid ne '100' || $isBase || |
81ebc68f WL |
1024 | $format ne 'raw') { |
1025 | $count++; | |
1026 | warn "Test8 c: parsing wrong"; | |
1027 | } | |
1028 | }; | |
1029 | if ($@) { | |
1030 | $count++; | |
1031 | warn "Test8 c: $@"; | |
1032 | } | |
1033 | ||
1034 | eval { | |
1035 | my ($vtype, $name, $vmid, $basename, $basevmid, $isBase, $format) = PVE::Storage::parse_volname($cfg, "$storagename:$ctdisk"); | |
1036 | ||
1037 | if ($vtype ne 'images' || $vmid ne '202' || $name ne $ctdisk || | |
b3bb525e | 1038 | defined($basename) || defined($basevmid) || $isBase || |
81ebc68f WL |
1039 | $format ne 'subvol') { |
1040 | $count++; | |
1041 | warn "Test8 d: parsing wrong"; | |
1042 | } | |
1043 | ||
1044 | }; | |
1045 | if ($@) { | |
1046 | $count++; | |
1047 | warn "Test8 d: $@"; | |
1048 | } | |
1049 | ||
1050 | eval { | |
1051 | my ($vtype, $name, $vmid, $basename, $basevmid, $isBase, $format) = PVE::Storage::parse_volname($cfg, "$storagename:$ctbase"); | |
1052 | if ($vtype ne 'images' || $vmid ne '200' || $name ne $ctbase || | |
b3bb525e | 1053 | defined($basename) || defined($basevmid) || !$isBase || |
81ebc68f WL |
1054 | $format ne 'subvol') { |
1055 | $count++; | |
1056 | warn "Test8 e: parsing wrong"; | |
1057 | } | |
1058 | }; | |
1059 | if ($@) { | |
1060 | $count++; | |
1061 | warn "Test8 e: $@"; | |
1062 | } | |
1063 | ||
1064 | eval { | |
1065 | my ($vtype, $name, $vmid, $basename, $basevmid, $isBase, $format) = PVE::Storage::parse_volname($cfg, "$storagename:$ctbase\/$ctlinked"); | |
1066 | ||
1067 | if ($vtype ne 'images' || $name ne $ctlinked || $vmid ne '201' || | |
b3bb525e | 1068 | $basename ne $ctbase || $basevmid ne '200' || $isBase || |
81ebc68f WL |
1069 | $format ne 'subvol') { |
1070 | $count++; | |
1071 | warn "Test8 f: parsing wrong"; | |
1072 | } | |
1073 | }; | |
1074 | if ($@) { | |
1075 | $count++; | |
1076 | warn "Test8 f: $@"; | |
1077 | } | |
1078 | }; | |
1079 | $tests->{8} = $test8; | |
1080 | ||
1081 | my $test7 = sub { | |
1082 | ||
1083 | print "\nrun test7 \"volume_rollback\"\n"; | |
1084 | ||
1085 | my $tmp_guid; | |
1086 | my $parse_guid = sub { | |
1087 | my ($line) = shift; | |
1088 | ||
1089 | if ( $line =~ m/^Disk identifier \(GUID\)\: (.*)$/ ) { | |
1090 | $tmp_guid = $1; | |
1091 | } | |
1092 | }; | |
1093 | ||
1094 | eval { | |
1095 | run_command("sgdisk --randomize-guids \/dev\/zvol\/$zpath\/$vmdisk", outfunc => $parse_guid); | |
1096 | run_command("sgdisk -p \/dev\/zvol\/$zpath\/$vmdisk", outfunc => $parse_guid); | |
1097 | ||
1098 | my $old_guid = $tmp_guid; | |
1099 | PVE::Storage::volume_snapshot($cfg, "$storagename:$vmdisk", 'snap1'); | |
1100 | ||
1101 | run_command("sgdisk --randomize-guids \/dev\/zvol\/$zpath\/$vmdisk", outfunc => $parse_guid); | |
1102 | eval { | |
1103 | PVE::Storage::volume_snapshot_rollback($cfg, "$storagename:$vmdisk", 'snap1'); | |
1104 | $tmp_guid = undef; | |
1105 | run_command("sgdisk -p \/dev\/zvol\/$zpath\/$vmdisk", outfunc => $parse_guid); | |
1106 | if ($old_guid ne $tmp_guid) { | |
1107 | $count++; | |
1108 | warn "Test7 a: Zvol makes no rollback"; | |
1109 | } | |
1110 | }; | |
1111 | if ($@) { | |
1112 | $count++; | |
1113 | warn "Test7 a: $@"; | |
1114 | } | |
1115 | }; | |
1116 | if ($@) { | |
1117 | $count++; | |
1118 | warn "Test7 a: $@"; | |
1119 | } | |
1120 | $tmp_guid = undef; | |
1121 | ||
1122 | eval { | |
1123 | run_command("sgdisk --randomize-guids \/dev\/zvol\/$zpath\/$vmbase", outfunc => $parse_guid); | |
1124 | run_command("sgdisk -p \/dev\/zvol\/$zpath\/$vmbase", outfunc => $parse_guid); | |
1125 | ||
1126 | my $old_guid = $tmp_guid; | |
1127 | PVE::Storage::volume_snapshot($cfg, "$storagename:$vmbase", 'snap1'); | |
1128 | ||
1129 | run_command("sgdisk --randomize-guids \/dev\/zvol\/$zpath\/$vmbase", outfunc => $parse_guid); | |
1130 | eval { | |
1131 | PVE::Storage::volume_snapshot_rollback($cfg, "$storagename:$vmbase", 'snap1'); | |
1132 | $tmp_guid = undef; | |
1133 | run_command("sgdisk -p \/dev\/zvol\/$zpath\/$vmbase", outfunc => $parse_guid); | |
1134 | if ($old_guid ne $tmp_guid) { | |
1135 | $count++; | |
1136 | warn "Test7 b: Zvol makes no rollback"; | |
1137 | } | |
1138 | }; | |
1139 | if ($@) { | |
1140 | $count++; | |
1141 | warn "Test7 b: $@"; | |
1142 | } | |
1143 | }; | |
1144 | if ($@) { | |
1145 | $count++; | |
1146 | warn "Test7 b: $@"; | |
1147 | } | |
1148 | $tmp_guid = undef; | |
1149 | ||
1150 | eval { | |
1151 | run_command("sgdisk --randomize-guids \/dev\/zvol\/$zpath\/$vmlinked", outfunc => $parse_guid); | |
1152 | run_command("sgdisk -p \/dev\/zvol\/$zpath\/$vmlinked", outfunc => $parse_guid); | |
1153 | ||
1154 | my $old_guid = $tmp_guid; | |
1155 | PVE::Storage::volume_snapshot($cfg, "$storagename:$vmbase\/$vmlinked", 'snap1'); | |
1156 | ||
1157 | run_command("sgdisk --randomize-guids \/dev\/zvol\/$zpath\/$vmlinked", outfunc => $parse_guid); | |
1158 | eval { | |
1159 | PVE::Storage::volume_snapshot_rollback($cfg, "$storagename:$vmbase\/$vmlinked", 'snap1'); | |
1160 | $tmp_guid = undef; | |
1161 | run_command("sgdisk -p \/dev\/zvol\/$zpath\/$vmlinked", outfunc => $parse_guid); | |
1162 | if ($old_guid ne $tmp_guid) { | |
1163 | $count++; | |
1164 | warn "Test7 c: Zvol makes no rollback"; | |
1165 | } | |
1166 | }; | |
1167 | if ($@) { | |
1168 | $count++; | |
1169 | warn "Test7 c: $@"; | |
1170 | } | |
1171 | }; | |
1172 | if ($@) { | |
1173 | $count++; | |
1174 | warn "Test7 c: $@"; | |
1175 | } | |
1176 | $tmp_guid = undef; | |
1177 | ||
1178 | eval { | |
1179 | PVE::Storage::volume_snapshot($cfg, "$storagename:$ctdisk", 'snap1'); | |
1180 | ||
1181 | run_command("touch \/$zpath\/$ctdisk\/test.txt", outfunc => $parse_guid); | |
1182 | eval { | |
1183 | PVE::Storage::volume_snapshot_rollback($cfg, "$storagename:$ctdisk", 'snap1'); | |
1184 | eval { | |
1185 | run_command("ls \/$zpath\/$ctdisk\/test.txt", errofunc => sub {}); | |
1186 | }; | |
1187 | if (!$@) { | |
1188 | $count++; | |
1189 | warn "Test7 d: $@"; | |
1190 | } | |
1191 | }; | |
1192 | if ($@) { | |
1193 | $count++; | |
1194 | warn "Test7 d: $@"; | |
1195 | } | |
1196 | }; | |
1197 | if ($@) { | |
1198 | $count++; | |
1199 | warn "Test7 d: $@"; | |
1200 | } | |
1201 | ||
1202 | eval { | |
1203 | PVE::Storage::volume_snapshot($cfg, "$storagename:$ctbase", 'snap1'); | |
1204 | ||
1205 | run_command("touch \/$zpath\/$ctbase\/test.txt", outfunc => $parse_guid); | |
1206 | eval { | |
1207 | PVE::Storage::volume_snapshot_rollback($cfg, "$storagename:$ctbase", 'snap1'); | |
1208 | eval { | |
1209 | run_command("ls \/$zpath\/$ctbase\/test.txt", errofunc => sub {}); | |
1210 | }; | |
1211 | if (!$@) { | |
1212 | $count++; | |
1213 | warn "Test7 e: $@"; | |
1214 | } | |
1215 | }; | |
1216 | if ($@) { | |
1217 | $count++; | |
1218 | warn "Test7 e: $@"; | |
1219 | } | |
1220 | }; | |
1221 | if ($@) { | |
1222 | $count++; | |
1223 | warn "Test7 f: $@"; | |
1224 | } | |
1225 | ||
1226 | eval { | |
1227 | PVE::Storage::volume_snapshot($cfg, "$storagename:$ctbase/$ctlinked", 'snap1'); | |
1228 | ||
1229 | run_command("touch \/$zpath\/$ctlinked\/test.txt", outfunc => $parse_guid); | |
1230 | eval { | |
1231 | PVE::Storage::volume_snapshot_rollback($cfg, "$storagename:$ctbase/$ctlinked", 'snap1'); | |
1232 | eval { | |
1233 | run_command("ls \/$zpath\/$ctlinked\/test.txt", errofunc => sub {}); | |
1234 | }; | |
1235 | if (!$@) { | |
1236 | $count++; | |
1237 | warn "Test7 g: $@"; | |
1238 | } | |
1239 | }; | |
1240 | if ($@) { | |
1241 | $count++; | |
1242 | warn "Test7 g: $@"; | |
1243 | } | |
1244 | }; | |
1245 | if ($@) { | |
1246 | $count++; | |
1247 | warn "Test7 g: $@"; | |
1248 | } | |
1249 | ||
1250 | eval { | |
1251 | PVE::Storage::volume_snapshot($cfg, "$storagename:$vmdisk", 'snap2'); | |
1252 | ||
1253 | eval { | |
1254 | PVE::Storage::volume_snapshot_rollback($cfg, "$storagename:$vmdisk", 'snap1'); | |
1255 | }; | |
1256 | if (!$@) { | |
1257 | $count++; | |
1258 | warn "Test7 h: Not allowed to rollback"; | |
1259 | } | |
1260 | }; | |
1261 | if ($@) { | |
1262 | $count++; | |
1263 | warn "Test7 h: $@"; | |
1264 | } | |
1265 | ||
1266 | eval { | |
1267 | PVE::Storage::volume_snapshot($cfg, "$storagename:$vmbase", 'snap2'); | |
1268 | ||
1269 | eval { | |
1270 | PVE::Storage::volume_snapshot_rollback($cfg, "$storagename:$vmbase", 'snap1'); | |
1271 | }; | |
1272 | if (!$@) { | |
1273 | $count++; | |
1274 | warn "Test7 i: Not allowed to rollback"; | |
1275 | } | |
1276 | }; | |
1277 | if ($@) { | |
1278 | $count++; | |
1279 | warn "Test7 i: $@"; | |
1280 | } | |
1281 | ||
1282 | eval { | |
1283 | PVE::Storage::volume_snapshot($cfg, "$storagename:$vmbase\/$vmlinked", 'snap2'); | |
1284 | ||
1285 | eval { | |
1286 | PVE::Storage::volume_snapshot_rollback($cfg, "$storagename:$vmbase\/$vmlinked", 'snap1'); | |
1287 | }; | |
1288 | if (!$@) { | |
1289 | $count++; | |
1290 | warn "Test7 j: Not allowed to rollback"; | |
1291 | } | |
1292 | }; | |
1293 | if ($@) { | |
1294 | $count++; | |
1295 | warn "Test7 j: $@"; | |
1296 | } | |
1297 | ||
1298 | eval { | |
1299 | PVE::Storage::volume_snapshot($cfg, "$storagename:$ctdisk", 'snap2'); | |
1300 | ||
1301 | eval { | |
1302 | PVE::Storage::volume_snapshot_rollback($cfg, "$storagename:$ctdisk", 'snap1'); | |
1303 | }; | |
1304 | if (!$@) { | |
1305 | $count++; | |
1306 | warn "Test7 k: Not allowed to rollback"; | |
1307 | } | |
1308 | }; | |
1309 | if ($@) { | |
1310 | $count++; | |
1311 | warn "Test7 k: $@"; | |
1312 | } | |
1313 | ||
1314 | eval { | |
1315 | PVE::Storage::volume_snapshot($cfg, "$storagename:$ctbase", 'snap2'); | |
1316 | ||
1317 | eval { | |
1318 | PVE::Storage::volume_snapshot_rollback($cfg, "$storagename:$ctbase", 'snap1'); | |
1319 | }; | |
1320 | if (!$@) { | |
1321 | $count++; | |
1322 | warn "Test7 l: Not allowed to rollback"; | |
1323 | } | |
1324 | }; | |
1325 | if ($@) { | |
1326 | $count++; | |
1327 | warn "Test7 l: $@"; | |
1328 | } | |
1329 | ||
1330 | eval { | |
1331 | PVE::Storage::volume_snapshot($cfg, "$storagename:$ctbase/$ctlinked", 'snap2'); | |
1332 | ||
1333 | eval { | |
1334 | PVE::Storage::volume_snapshot_rollback($cfg, "$storagename:$ctbase/$ctlinked", 'snap1'); | |
1335 | }; | |
1336 | if (!$@) { | |
1337 | $count++; | |
1338 | warn "Test7 m: Not allowed to rollback"; | |
1339 | } | |
1340 | }; | |
1341 | if ($@) { | |
1342 | $count++; | |
1343 | warn "Test7 m: $@"; | |
1344 | } | |
1345 | }; | |
1346 | $tests->{7} = $test7; | |
1347 | ||
1348 | my $test6 = sub { | |
1349 | ||
1350 | print "\nrun test6 \"volume_rollback_is_possible\"\n"; | |
1351 | ||
1352 | eval { | |
1353 | PVE::Storage::volume_snapshot($cfg, "$storagename:$vmdisk", 'snap1'); | |
1354 | if ( 1 != | |
1355 | PVE::Storage::volume_rollback_is_possible($cfg, "$storagename:$vmdisk", 'snap1')) { | |
1356 | $count++; | |
1357 | warn "Test6 a: Rollback sould possible" | |
1358 | } | |
1359 | }; | |
1360 | if ($@) { | |
1361 | $count++; | |
1362 | warn "Test6 a: $@"; | |
1363 | } | |
1364 | ||
1365 | eval { | |
1366 | PVE::Storage::volume_snapshot($cfg, "$storagename:$vmbase", 'snap1'); | |
1367 | if ( 1 != | |
1368 | PVE::Storage::volume_rollback_is_possible($cfg, "$storagename:$vmbase", 'snap1')) { | |
1369 | $count++; | |
1370 | warn "Test6 b: Rollback sould possible" | |
1371 | } | |
1372 | }; | |
1373 | if ($@) { | |
1374 | $count++; | |
1375 | warn "Test6 b: $@"; | |
1376 | } | |
1377 | ||
1378 | eval { | |
1379 | PVE::Storage::volume_snapshot($cfg, "$storagename:$vmlinked", 'snap1'); | |
1380 | if ( 1 != | |
1381 | PVE::Storage::volume_rollback_is_possible($cfg, "$storagename:$vmbase\/$vmlinked", 'snap1')) { | |
1382 | $count++; | |
1383 | warn "Test6 c: Rollback sould possible" | |
1384 | } | |
1385 | }; | |
1386 | if ($@) { | |
1387 | $count++; | |
1388 | warn "Test6 c: $@"; | |
1389 | } | |
1390 | ||
1391 | eval { | |
1392 | PVE::Storage::volume_snapshot($cfg, "$storagename:$ctdisk", 'snap1'); | |
1393 | if ( 1 != | |
1394 | PVE::Storage::volume_rollback_is_possible($cfg, "$storagename:$ctdisk", 'snap1')) { | |
1395 | $count++; | |
1396 | warn "Test6 d: Rollback sould possible" | |
1397 | } | |
1398 | }; | |
1399 | if ($@) { | |
1400 | $count++; | |
1401 | warn "Test6 d: $@"; | |
1402 | } | |
1403 | ||
1404 | eval { | |
1405 | PVE::Storage::volume_snapshot($cfg, "$storagename:$ctbase", 'snap1'); | |
1406 | if ( 1 != | |
1407 | PVE::Storage::volume_rollback_is_possible($cfg, "$storagename:$ctbase", 'snap1')) { | |
1408 | $count++; | |
1409 | warn "Test6 e: Rollback sould possible" | |
1410 | } | |
1411 | }; | |
1412 | if ($@) { | |
1413 | $count++; | |
1414 | warn "Test6 e: $@"; | |
1415 | } | |
1416 | ||
1417 | eval { | |
1418 | PVE::Storage::volume_snapshot($cfg, "$storagename:$ctlinked", 'snap1'); | |
1419 | if ( 1 != | |
1420 | PVE::Storage::volume_rollback_is_possible($cfg, "$storagename:$ctbase\/$ctlinked", 'snap1')) { | |
1421 | $count++; | |
1422 | warn "Test6 f: Rollback sould possible" | |
1423 | } | |
1424 | }; | |
1425 | if ($@) { | |
1426 | $count++; | |
1427 | warn "Test6 f: $@"; | |
1428 | } | |
1429 | ||
1430 | eval { | |
1431 | PVE::Storage::volume_snapshot($cfg, "$storagename:$vmdisk", 'snap2'); | |
1432 | PVE::Storage::volume_rollback_is_possible($cfg, "$storagename:$vmdisk", 'snap1'); | |
1433 | }; | |
1434 | if (!$@) { | |
1435 | $count++; | |
1436 | warn "Test6 g: Rollback should not possible"; | |
1437 | } | |
1438 | ||
1439 | eval { | |
1440 | PVE::Storage::volume_snapshot($cfg, "$storagename:$vmbase", 'snap2'); | |
1441 | PVE::Storage::volume_rollback_is_possible($cfg, "$storagename:$vmbase", 'snap1'); | |
1442 | }; | |
1443 | if (!$@) { | |
1444 | $count++; | |
1445 | warn "Test6 h: Rollback should not possible"; | |
1446 | } | |
1447 | ||
1448 | eval { | |
1449 | PVE::Storage::volume_snapshot($cfg, "$storagename:$vmlinked", 'snap2'); | |
1450 | PVE::Storage::volume_rollback_is_possible($cfg, "$storagename:$vmbase\/$vmlinked", 'snap1'); | |
1451 | }; | |
1452 | if (!$@) { | |
1453 | $count++; | |
1454 | warn "Test6 j: Rollback should not possible"; | |
1455 | } | |
1456 | ||
1457 | eval { | |
1458 | PVE::Storage::volume_snapshot($cfg, "$storagename:$ctdisk", 'snap2'); | |
1459 | PVE::Storage::volume_rollback_is_possible($cfg, "$storagename:$ctdisk", 'snap1'); | |
1460 | }; | |
1461 | if (!$@) { | |
1462 | $count++; | |
1463 | warn "Test6 k: Rollback should not possible"; | |
1464 | } | |
1465 | ||
1466 | eval { | |
1467 | PVE::Storage::volume_snapshot($cfg, "$storagename:$ctbase", 'snap2'); | |
1468 | PVE::Storage::volume_rollback_is_possible($cfg, "$storagename:$ctbase", 'snap1'); | |
1469 | }; | |
1470 | if (!$@) { | |
1471 | $count++; | |
1472 | warn "Test6 l: Rollback should not possible"; | |
1473 | } | |
1474 | ||
1475 | eval { | |
1476 | PVE::Storage::volume_snapshot($cfg, "$storagename:$ctlinked", 'snap2'); | |
1477 | PVE::Storage::volume_rollback_is_possible($cfg, "$storagename:$ctbase\/$ctlinked", 'snap1'); | |
1478 | }; | |
1479 | if (!$@) { | |
1480 | $count++; | |
1481 | warn "Test6 m: Rollback should not possible"; | |
1482 | } | |
1483 | }; | |
1484 | $tests->{6} = $test6; | |
1485 | ||
1486 | my $test5 = sub { | |
1487 | ||
1488 | print "\nrun test5 \"volume_snapshot_delete\"\n"; | |
1489 | my $out = sub{my $tmp = shift;}; | |
1490 | ||
1491 | eval { | |
1492 | run_command("zfs snapshot $zpath\/$vmdisk\@snap"); | |
1493 | eval{ | |
1494 | PVE::Storage::volume_snapshot_delete($cfg, "$storagename:$vmdisk", 'snap'); | |
1495 | eval{ | |
1496 | run_command("zfs list $zpath\/$vmdisk\@snap", errfunc => $out, outfunc => $out); | |
1497 | }; | |
1498 | if (!$@) { | |
1499 | $count++; | |
1500 | warn "Test5 a: snapshot still exists"; | |
1501 | } | |
1502 | }; | |
1503 | if ($@) { | |
1504 | $count++; | |
1505 | warn "Test5 PVE a: $@"; | |
1506 | } | |
1507 | }; | |
1508 | if ($@) { | |
1509 | $count++; | |
1510 | warn "Test5 a: $@"; | |
1511 | } | |
1512 | ||
1513 | eval { | |
1514 | run_command("zfs snapshot $zpath\/$vmbase\@snap"); | |
1515 | eval{ | |
1516 | PVE::Storage::volume_snapshot_delete($cfg, "$storagename:$vmbase", 'snap'); | |
1517 | eval{ | |
1518 | run_command("zfs list $zpath\/$vmbase\@snap", errmsg => $out, outfunc => $out); | |
1519 | }; | |
1520 | if (!$@) { | |
1521 | $count++; | |
1522 | warn "Test5 b: snapshot still exists"; | |
1523 | } | |
1524 | }; | |
1525 | if ($@) { | |
1526 | $count++; | |
1527 | warn "Test5 PVE b: $@"; | |
1528 | } | |
1529 | }; | |
1530 | if ($@) { | |
1531 | $count++; | |
1532 | warn "Test5 b: $@"; | |
1533 | } | |
1534 | ||
1535 | eval { | |
1536 | run_command("zfs snapshot $zpath\/$vmlinked\@snap"); | |
1537 | eval{ | |
1538 | PVE::Storage::volume_snapshot_delete($cfg, "$storagename:$vmbase\/$vmlinked", 'snap'); | |
1539 | eval{ | |
1540 | run_command("zfs list $zpath\/$vmlinked\@snap", errmsg => $out, outfunc => $out); | |
1541 | }; | |
1542 | if (!$@) { | |
1543 | $count++; | |
1544 | warn "Test5 c: snapshot still exists"; | |
1545 | } | |
1546 | }; | |
1547 | if ($@) { | |
1548 | $count++; | |
1549 | warn "Test5 PVE c: $@"; | |
1550 | } | |
1551 | }; | |
1552 | if ($@) { | |
1553 | $count++; | |
1554 | warn "Test5 c: $@"; | |
1555 | } | |
1556 | ||
1557 | eval { | |
1558 | run_command("zfs snapshot $zpath\/$ctdisk\@snap"); | |
1559 | eval{ | |
1560 | PVE::Storage::volume_snapshot_delete($cfg, "$storagename:$ctdisk", 'snap'); | |
1561 | eval{ | |
1562 | run_command("zfs list $zpath\/$ctdisk\@snap", errmsg => $out, outfunc => $out); | |
1563 | }; | |
1564 | if (!$@) { | |
1565 | $count++; | |
1566 | warn "Test5 d: snapshot still exists"; | |
1567 | } | |
1568 | }; | |
1569 | if ($@) { | |
1570 | $count++; | |
1571 | warn "Test5 PVE d: $@"; | |
1572 | } | |
1573 | }; | |
1574 | if ($@) { | |
1575 | $count++; | |
1576 | warn "Test5 d: $@"; | |
1577 | } | |
1578 | ||
1579 | eval { | |
1580 | run_command("zfs snapshot $zpath\/$ctbase\@snap"); | |
1581 | eval{ | |
1582 | PVE::Storage::volume_snapshot_delete($cfg, "$storagename:$ctbase", 'snap'); | |
1583 | eval{ | |
1584 | run_command("zfs list $zpath\/$ctbase\@snap", errmsg => $out, outfunc => $out); | |
1585 | }; | |
1586 | if (!$@) { | |
1587 | $count++; | |
1588 | warn "Test5 e: snapshot still exists"; | |
1589 | } | |
1590 | }; | |
1591 | if ($@) { | |
1592 | $count++; | |
1593 | warn "Test5 PVE e: $@"; | |
1594 | } | |
1595 | }; | |
1596 | if ($@) { | |
1597 | $count++; | |
1598 | warn "Test5 e: $@"; | |
1599 | } | |
1600 | ||
1601 | eval { | |
1602 | run_command("zfs snapshot $zpath\/$ctlinked\@snap"); | |
1603 | eval{ | |
1604 | PVE::Storage::volume_snapshot_delete($cfg, "$storagename:$ctbase\/$ctlinked", 'snap'); | |
1605 | eval{ | |
1606 | run_command("zfs list $zpath\/$ctlinked\@snap", errmsg => $out, outfunc => $out); | |
1607 | }; | |
1608 | if (!$@) { | |
1609 | $count++; | |
1610 | warn "Test5 f: snapshot still exists"; | |
1611 | } | |
1612 | }; | |
1613 | if ($@) { | |
1614 | $count++; | |
1615 | warn "Test5 PVE f: $@"; | |
1616 | } | |
1617 | }; | |
1618 | if ($@) { | |
1619 | $count++; | |
1620 | warn "Test5 f: $@"; | |
1621 | } | |
1622 | print "######Ignore Output if no Test5 g: is includet######\n"; | |
1623 | eval{ | |
1624 | PVE::Storage::volume_snapshot_delete($cfg, "$storagename:$vmbase", '__base__'); | |
1625 | eval{ | |
1626 | run_command("zfs list $zpath\/$vmbase\@__base__", outfunc => $out); | |
1627 | }; | |
1628 | if ($@) { | |
1629 | $count++; | |
1630 | warn "Test5 g: $@"; | |
1631 | } | |
1632 | }; | |
1633 | if (!$@) { | |
1634 | $count++; | |
1635 | warn "Test5 PVE g: snapshot __base__ can be erased"; | |
1636 | } | |
1637 | print "######End Ignroe#######\n"; | |
1638 | }; | |
1639 | $tests->{5} = $test5; | |
1640 | ||
1641 | my $test4 = sub { | |
1642 | ||
1643 | print "\nrun test4 \"volume_snapshot\"\n"; | |
1644 | my $out = sub{}; | |
1645 | ||
1646 | eval { | |
1647 | PVE::Storage::volume_snapshot($cfg, "$storagename:$vmdisk", 'snap'); | |
1648 | eval{ | |
1649 | run_command("zfs list $zpath\/$vmdisk\@snap", errmsg => $out, outfunc => $out); | |
1650 | }; | |
1651 | if ($@) { | |
1652 | $count++; | |
1653 | warn "Test4 a: $@"; | |
1654 | } | |
1655 | }; | |
1656 | if ($@) { | |
1657 | $count++; | |
1658 | warn "Test4 a: $@"; | |
1659 | } | |
1660 | ||
1661 | eval { | |
1662 | PVE::Storage::volume_snapshot($cfg, "$storagename:$vmbase", 'snap'); | |
1663 | eval{ | |
1664 | run_command("zfs list $zpath\/$vmbase\@snap", errmsg => $out, outfunc => $out); | |
1665 | }; | |
1666 | if ($@) { | |
1667 | $count++; | |
1668 | warn "Test4 b: $@"; | |
1669 | } | |
1670 | }; | |
1671 | if ($@) { | |
1672 | $count++; | |
1673 | warn "Test4 c: $@"; | |
1674 | } | |
1675 | ||
1676 | eval { | |
1677 | PVE::Storage::volume_snapshot($cfg, "$storagename:$vmbase\/$vmlinked", 'snap'); | |
1678 | eval{ | |
1679 | run_command("zfs list $zpath\/$vmdisk\@snap", errmsg => $out, outfunc => $out); | |
1680 | }; | |
1681 | if ($@) { | |
1682 | $count++; | |
1683 | warn "Test4 c: $@"; | |
1684 | } | |
1685 | }; | |
1686 | if ($@) { | |
1687 | $count++; | |
1688 | warn "Test4 c: $@"; | |
1689 | } | |
1690 | ||
1691 | eval { | |
1692 | PVE::Storage::volume_snapshot($cfg, "$storagename:$ctdisk", 'snap'); | |
1693 | eval{ | |
1694 | run_command("zfs list $zpath\/$ctdisk\@snap", errmsg => $out, outfunc => $out); | |
1695 | }; | |
1696 | if ($@) { | |
1697 | $count++; | |
1698 | warn "Test4 d: $@"; | |
1699 | } | |
1700 | }; | |
1701 | if ($@) { | |
1702 | $count++; | |
1703 | warn "Test4 d: $@"; | |
1704 | } | |
1705 | ||
1706 | eval { | |
1707 | PVE::Storage::volume_snapshot($cfg, "$storagename:$ctbase", 'snap'); | |
1708 | eval{ | |
1709 | run_command("zfs list $zpath\/$ctbase\@snap", errmsg => $out, outfunc => $out); | |
1710 | }; | |
1711 | if ($@) { | |
1712 | $count++; | |
1713 | warn "Test4 e: $@"; | |
1714 | } | |
1715 | }; | |
1716 | if ($@) { | |
1717 | $count++; | |
1718 | warn "Test4 e: $@"; | |
1719 | } | |
1720 | ||
1721 | eval { | |
1722 | PVE::Storage::volume_snapshot($cfg, "$storagename:$ctbase\/$ctlinked", 'snap'); | |
1723 | eval{ | |
1724 | run_command("zfs list $zpath\/$ctdisk\@snap", errmsg => $out, outfunc => $out); | |
1725 | }; | |
1726 | if ($@) { | |
1727 | $count++; | |
1728 | warn "Test4 f: $@"; | |
1729 | } | |
1730 | }; | |
1731 | if ($@) { | |
1732 | $count++; | |
1733 | warn "Test4 f: $@"; | |
1734 | } | |
1735 | }; | |
1736 | $tests->{4} = $test4; | |
1737 | ||
1738 | my $test3 = sub { | |
1739 | ||
1740 | print "\nrun test3 \"volume_has_feature\"\n"; | |
1741 | ||
1742 | eval { | |
1743 | if (!PVE::Storage::volume_has_feature($cfg, 'snapshot', "$storagename:$vmdisk", undef, 0)) { | |
1744 | $count++; | |
1745 | warn "Test3 a failed"; | |
1746 | } | |
1747 | }; | |
1748 | if ($@) { | |
1749 | $count++; | |
1750 | warn "Test3 a: $@"; | |
1751 | } | |
1752 | ||
1753 | eval { | |
1754 | if (PVE::Storage::volume_has_feature($cfg, 'snapshot', "$storagename:$vmbase", undef, 0)) { | |
1755 | $count++; | |
1756 | warn "Test3 b failed"; | |
1757 | } | |
1758 | }; | |
1759 | if ($@) { | |
1760 | $count++; | |
1761 | warn "Test3 b: $@"; | |
1762 | } | |
1763 | ||
1764 | eval { | |
1765 | if (!PVE::Storage::volume_has_feature($cfg, 'snapshot', "$storagename:$vmbase\/$vmlinked", undef, 0)) { | |
1766 | $count++; | |
1767 | warn "Test3 c failed"; | |
1768 | } | |
1769 | }; | |
1770 | if ($@) { | |
1771 | $count++; | |
1772 | warn "Test3 c: $@"; | |
1773 | } | |
1774 | ||
1775 | eval { | |
1776 | if (!PVE::Storage::volume_has_feature($cfg, 'snapshot', "$storagename:$ctdisk", undef, 0)) { | |
1777 | $count++; | |
1778 | warn "Test3 d failed"; | |
1779 | } | |
1780 | }; | |
1781 | if ($@) { | |
1782 | $count++; | |
1783 | warn "Test3 d: $@"; | |
1784 | } | |
1785 | ||
1786 | eval { | |
1787 | if (PVE::Storage::volume_has_feature($cfg, 'snapshot', "$storagename:$ctbase", undef, 0)) { | |
1788 | $count++; | |
1789 | warn "Test3 e failed"; | |
1790 | } | |
1791 | }; | |
1792 | if ($@) { | |
1793 | $count++; | |
1794 | warn "Test3 e: $@"; | |
1795 | } | |
1796 | ||
1797 | eval { | |
1798 | if (!PVE::Storage::volume_has_feature($cfg, 'snapshot', "$storagename:$ctbase\/$ctlinked", undef, 0)) { | |
1799 | $count++; | |
1800 | warn "Test3 f failed"; | |
1801 | } | |
1802 | }; | |
1803 | if ($@) { | |
1804 | $count++; | |
1805 | warn "Test3 f: $@"; | |
1806 | } | |
1807 | ||
1808 | eval { | |
1809 | if (PVE::Storage::volume_has_feature($cfg, 'clone', "$storagename:$vmdisk", undef, 0)) { | |
1810 | $count++; | |
1811 | warn "Test3 g failed"; | |
1812 | } | |
1813 | }; | |
1814 | if ($@) { | |
1815 | $count++; | |
1816 | warn "Test3 g: $@"; | |
1817 | } | |
1818 | ||
1819 | eval { | |
1820 | if (!PVE::Storage::volume_has_feature($cfg, 'clone', "$storagename:$vmbase", undef, 0)) { | |
1821 | $count++; | |
1822 | warn "Test3 h failed"; | |
1823 | } | |
1824 | }; | |
1825 | if ($@) { | |
1826 | $count++; | |
1827 | warn "Test3 h: $@"; | |
1828 | } | |
1829 | ||
1830 | eval { | |
1831 | if (PVE::Storage::volume_has_feature($cfg, 'clone', "$storagename:$vmbase\/$vmlinked", undef, 0)) { | |
1832 | $count++; | |
1833 | warn "Test3 h failed"; | |
1834 | } | |
1835 | }; | |
1836 | if ($@) { | |
1837 | $count++; | |
1838 | warn "Test3 h: $@"; | |
1839 | } | |
1840 | ||
1841 | eval { | |
1842 | if (PVE::Storage::volume_has_feature($cfg, 'clone', "$storagename:$ctdisk", undef, 0)) { | |
1843 | $count++; | |
1844 | warn "Test3 i failed"; | |
1845 | } | |
1846 | }; | |
1847 | if ($@) { | |
1848 | $count++; | |
1849 | warn "Test3 i: $@"; | |
1850 | } | |
1851 | ||
1852 | eval { | |
1853 | if (!PVE::Storage::volume_has_feature($cfg, 'clone', "$storagename:$ctbase", undef, 0)) { | |
1854 | $count++; | |
1855 | warn "Test3 j failed"; | |
1856 | } | |
1857 | }; | |
1858 | if ($@) { | |
1859 | $count++; | |
1860 | warn "Test3 j: $@"; | |
1861 | } | |
1862 | ||
1863 | eval { | |
1864 | if (PVE::Storage::volume_has_feature($cfg, 'clone', "$storagename:$ctbase\/$ctlinked", undef, 0)) { | |
1865 | $count++; | |
1866 | warn "Test3 k failed"; | |
1867 | } | |
1868 | }; | |
1869 | if ($@) { | |
1870 | $count++; | |
1871 | warn "Test3 k: $@"; | |
1872 | } | |
1873 | ||
1874 | eval { | |
1875 | if (!PVE::Storage::volume_has_feature($cfg, 'template', "$storagename:$vmdisk", undef, 0)) { | |
1876 | $count++; | |
1877 | warn "Test3 l failed"; | |
1878 | } | |
1879 | }; | |
1880 | if ($@) { | |
1881 | $count++; | |
1882 | warn "Test3 l: $@"; | |
1883 | } | |
1884 | ||
1885 | eval { | |
1886 | if (PVE::Storage::volume_has_feature($cfg, 'template', "$storagename:$vmbase", undef, 0)) { | |
1887 | $count++; | |
1888 | warn "Test3 m failed"; | |
1889 | } | |
1890 | }; | |
1891 | if ($@) { | |
1892 | $count++; | |
1893 | warn "Test3 m: $@"; | |
1894 | } | |
1895 | ||
1896 | eval { | |
1897 | if (!PVE::Storage::volume_has_feature($cfg, 'template', "$storagename:$vmbase\/$vmlinked", undef, 0)) { | |
1898 | $count++; | |
1899 | warn "Test3 n failed"; | |
1900 | } | |
1901 | }; | |
1902 | if ($@) { | |
1903 | $count++; | |
1904 | warn "Test3 n: $@"; | |
1905 | } | |
1906 | ||
1907 | eval { | |
1908 | if (!PVE::Storage::volume_has_feature($cfg, 'template', "$storagename:$ctdisk", undef, 0)) { | |
1909 | $count++; | |
1910 | warn "Test3 o failed"; | |
1911 | } | |
1912 | }; | |
1913 | if ($@) { | |
1914 | $count++; | |
1915 | warn "Test3 o: $@"; | |
1916 | } | |
1917 | ||
1918 | eval { | |
1919 | if (PVE::Storage::volume_has_feature($cfg, 'template', "$storagename:$ctbase", undef, 0)) { | |
1920 | $count++; | |
1921 | warn "Test3 p failed"; | |
1922 | } | |
1923 | }; | |
1924 | if ($@) { | |
1925 | $count++; | |
1926 | warn "Test3 p: $@"; | |
1927 | } | |
1928 | ||
1929 | eval { | |
1930 | if (!PVE::Storage::volume_has_feature($cfg, 'template', "$storagename:$ctbase\/$ctlinked", undef, 0)) { | |
1931 | $count++; | |
1932 | warn "Test3 q failed"; | |
1933 | } | |
1934 | }; | |
1935 | if ($@) { | |
1936 | $count++; | |
1937 | warn "Test3 q: $@"; | |
1938 | } | |
1939 | ||
1940 | eval { | |
1941 | if (!PVE::Storage::volume_has_feature($cfg, 'copy', "$storagename:$vmdisk", undef, 0)) { | |
1942 | $count++; | |
1943 | warn "Test3 r failed"; | |
1944 | } | |
1945 | }; | |
1946 | if ($@) { | |
1947 | $count++; | |
1948 | warn "Test3 r: $@"; | |
1949 | } | |
1950 | ||
1951 | eval { | |
1952 | if (!PVE::Storage::volume_has_feature($cfg, 'copy', "$storagename:$vmbase", undef, 0)) { | |
1953 | $count++; | |
1954 | warn "Test3 s failed"; | |
1955 | } | |
1956 | }; | |
1957 | if ($@) { | |
1958 | $count++; | |
1959 | warn "Test3 s: $@"; | |
1960 | } | |
1961 | ||
1962 | eval { | |
1963 | if (!PVE::Storage::volume_has_feature($cfg, 'copy', "$storagename:$vmbase\/$vmlinked", undef, 0)) { | |
1964 | $count++; | |
1965 | warn "Test3 t failed"; | |
1966 | } | |
1967 | }; | |
1968 | if ($@) { | |
1969 | $count++; | |
1970 | warn "Test3 t: $@"; | |
1971 | } | |
1972 | ||
1973 | eval { | |
1974 | if (!PVE::Storage::volume_has_feature($cfg, 'copy', "$storagename:$ctdisk", undef, 0)) { | |
1975 | $count++; | |
1976 | warn "Test3 u failed"; | |
1977 | } | |
1978 | }; | |
1979 | if ($@) { | |
1980 | $count++; | |
1981 | warn "Test3 u: $@"; | |
1982 | } | |
1983 | ||
1984 | eval { | |
1985 | if (!PVE::Storage::volume_has_feature($cfg, 'copy', "$storagename:$ctbase", undef, 0)) { | |
1986 | $count++; | |
1987 | warn "Test3 v failed"; | |
1988 | } | |
1989 | }; | |
1990 | if ($@) { | |
1991 | $count++; | |
1992 | warn "Test3 v: $@"; | |
1993 | } | |
1994 | ||
1995 | eval { | |
1996 | if (!PVE::Storage::volume_has_feature($cfg, 'copy', "$storagename:$ctbase\/$ctlinked", undef, 0)) { | |
1997 | $count++; | |
1998 | warn "Test3 w failed"; | |
1999 | } | |
2000 | }; | |
2001 | if ($@) { | |
2002 | $count++; | |
2003 | warn "Test3 w: $@"; | |
2004 | } | |
2005 | ||
2006 | eval { | |
2007 | if (!PVE::Storage::volume_has_feature($cfg, 'sparseinit', "$storagename:$vmdisk", undef, 0)) { | |
2008 | $count++; | |
2009 | warn "Test3 x failed"; | |
2010 | } | |
2011 | }; | |
2012 | if ($@) { | |
2013 | $count++; | |
2014 | warn "Test3 x: $@"; | |
2015 | } | |
2016 | ||
2017 | eval { | |
2018 | if (!PVE::Storage::volume_has_feature($cfg, 'sparseinit', "$storagename:$vmbase", undef, 0)) { | |
2019 | $count++; | |
2020 | warn "Test3 y failed"; | |
2021 | } | |
2022 | }; | |
2023 | if ($@) { | |
2024 | $count++; | |
2025 | warn "Test3 y: $@"; | |
2026 | } | |
2027 | ||
2028 | eval { | |
2029 | if (!PVE::Storage::volume_has_feature($cfg, 'sparseinit', "$storagename:$vmbase\/$vmlinked", undef, 0)) { | |
2030 | $count++; | |
2031 | warn "Test3 z failed"; | |
2032 | } | |
2033 | }; | |
2034 | if ($@) { | |
2035 | $count++; | |
2036 | warn "Test3 z: $@"; | |
2037 | } | |
2038 | ||
2039 | eval { | |
2040 | if (!PVE::Storage::volume_has_feature($cfg, 'sparseinit', "$storagename:$ctdisk", undef, 0)) { | |
2041 | $count++; | |
2042 | warn "Test3 A failed"; | |
2043 | } | |
2044 | }; | |
2045 | if ($@) { | |
2046 | $count++; | |
2047 | warn "Test3 A: $@"; | |
2048 | } | |
2049 | ||
2050 | eval { | |
2051 | if (!PVE::Storage::volume_has_feature($cfg, 'sparseinit', "$storagename:$ctbase", undef, 0)) { | |
2052 | $count++; | |
2053 | warn "Test3 B failed"; | |
2054 | } | |
2055 | }; | |
2056 | if ($@) { | |
2057 | $count++; | |
2058 | warn "Test3 B: $@"; | |
2059 | } | |
2060 | ||
2061 | eval { | |
2062 | if (!PVE::Storage::volume_has_feature($cfg, 'sparseinit', "$storagename:$ctbase\/$ctlinked", undef, 0)) { | |
2063 | $count++; | |
2064 | warn "Test3 C failed"; | |
2065 | } | |
2066 | }; | |
2067 | if ($@) { | |
2068 | $count++; | |
2069 | warn "Test3 C: $@"; | |
2070 | } | |
2071 | ||
2072 | eval { | |
2073 | if (!PVE::Storage::volume_has_feature($cfg, 'snapshot', "$storagename:$vmdisk", 'test', 0)) { | |
2074 | $count++; | |
2075 | warn "Test3 a1 failed"; | |
2076 | } | |
2077 | }; | |
2078 | if ($@) { | |
2079 | $count++; | |
2080 | warn "Test3 a1: $@"; | |
2081 | } | |
2082 | ||
2083 | eval { | |
2084 | if (!PVE::Storage::volume_has_feature($cfg, 'snapshot', "$storagename:$vmbase", 'test', 0)) { | |
2085 | $count++; | |
2086 | warn "Test3 b1 failed"; | |
2087 | } | |
2088 | }; | |
2089 | if ($@) { | |
2090 | $count++; | |
2091 | warn "Test3 b1: $@"; | |
2092 | } | |
2093 | ||
2094 | eval { | |
2095 | if (!PVE::Storage::volume_has_feature($cfg, 'snapshot', "$storagename:$vmbase\/$vmlinked", 'test', 0)) { | |
2096 | $count++; | |
2097 | warn "Test3 c1 failed"; | |
2098 | } | |
2099 | }; | |
2100 | if ($@) { | |
2101 | $count++; | |
2102 | warn "Test3 c1: $@"; | |
2103 | } | |
2104 | ||
2105 | eval { | |
2106 | if (!PVE::Storage::volume_has_feature($cfg, 'snapshot', "$storagename:$ctdisk", 'test', 0)) { | |
2107 | $count++; | |
2108 | warn "Test3 d1 failed"; | |
2109 | } | |
2110 | }; | |
2111 | if ($@) { | |
2112 | $count++; | |
2113 | warn "Test3 d1: $@"; | |
2114 | } | |
2115 | ||
2116 | eval { | |
2117 | if (!PVE::Storage::volume_has_feature($cfg, 'snapshot', "$storagename:$ctbase", 'test', 0)) { | |
2118 | $count++; | |
2119 | warn "Test3 e1 failed"; | |
2120 | } | |
2121 | }; | |
2122 | if ($@) { | |
2123 | $count++; | |
2124 | warn "Test3 e1: $@"; | |
2125 | } | |
2126 | ||
2127 | eval { | |
2128 | if (!PVE::Storage::volume_has_feature($cfg, 'snapshot', "$storagename:$ctbase\/$ctlinked", 'test', 0)) { | |
2129 | $count++; | |
2130 | warn "Test3 f1 failed"; | |
2131 | } | |
2132 | }; | |
2133 | if ($@) { | |
2134 | $count++; | |
2135 | warn "Test3 f1: $@"; | |
2136 | } | |
2137 | ||
2138 | eval { | |
2139 | if (PVE::Storage::volume_has_feature($cfg, 'clone', "$storagename:$vmdisk", 'test', 0)) { | |
2140 | $count++; | |
2141 | warn "Test3 g1 failed"; | |
2142 | } | |
2143 | }; | |
2144 | if ($@) { | |
2145 | $count++; | |
2146 | warn "Test3 g1: $@"; | |
2147 | } | |
2148 | ||
2149 | eval { | |
2150 | if (PVE::Storage::volume_has_feature($cfg, 'clone', "$storagename:$vmbase", 'test', 0)) { | |
2151 | $count++; | |
2152 | warn "Test3 h1 failed"; | |
2153 | } | |
2154 | }; | |
2155 | if ($@) { | |
2156 | $count++; | |
2157 | warn "Test3 h1: $@"; | |
2158 | } | |
2159 | ||
2160 | eval { | |
2161 | if (PVE::Storage::volume_has_feature($cfg, 'clone', "$storagename:$vmbase\/$vmlinked", 'test', 0)) { | |
2162 | $count++; | |
2163 | warn "Test3 h1 failed"; | |
2164 | } | |
2165 | }; | |
2166 | if ($@) { | |
2167 | $count++; | |
2168 | warn "Test3 h1: $@"; | |
2169 | } | |
2170 | ||
2171 | eval { | |
2172 | if (PVE::Storage::volume_has_feature($cfg, 'clone', "$storagename:$ctdisk", 'test', 0)) { | |
2173 | $count++; | |
2174 | warn "Test3 i1 failed"; | |
2175 | } | |
2176 | }; | |
2177 | if ($@) { | |
2178 | $count++; | |
2179 | warn "Test3 i1: $@"; | |
2180 | } | |
2181 | ||
2182 | eval { | |
2183 | if (PVE::Storage::volume_has_feature($cfg, 'clone', "$storagename:$ctbase", 'test', 0)) { | |
2184 | $count++; | |
2185 | warn "Test3 j1 failed"; | |
2186 | } | |
2187 | }; | |
2188 | if ($@) { | |
2189 | $count++; | |
2190 | warn "Test3 j1: $@"; | |
2191 | } | |
2192 | ||
2193 | eval { | |
2194 | if (PVE::Storage::volume_has_feature($cfg, 'clone', "$storagename:$ctbase\/$ctlinked", 'test', 0)) { | |
2195 | $count++; | |
2196 | warn "Test3 k1 failed"; | |
2197 | } | |
2198 | }; | |
2199 | if ($@) { | |
2200 | $count++; | |
2201 | warn "Test3 k1: $@"; | |
2202 | } | |
2203 | ||
2204 | eval { | |
2205 | if (PVE::Storage::volume_has_feature($cfg, 'template', "$storagename:$vmdisk", 'test', 0)) { | |
2206 | $count++; | |
2207 | warn "Test3 l1 failed"; | |
2208 | } | |
2209 | }; | |
2210 | if ($@) { | |
2211 | $count++; | |
2212 | warn "Test3 l1: $@"; | |
2213 | } | |
2214 | ||
2215 | eval { | |
2216 | if (PVE::Storage::volume_has_feature($cfg, 'template', "$storagename:$vmbase", 'test', 0)) { | |
2217 | $count++; | |
2218 | warn "Test3 m1 failed"; | |
2219 | } | |
2220 | }; | |
2221 | if ($@) { | |
2222 | $count++; | |
2223 | warn "Test3 m1: $@"; | |
2224 | } | |
2225 | ||
2226 | eval { | |
2227 | if (PVE::Storage::volume_has_feature($cfg, 'template', "$storagename:$vmbase\/$vmlinked", 'test', 0)) { | |
2228 | $count++; | |
2229 | warn "Test3 n1 failed"; | |
2230 | } | |
2231 | }; | |
2232 | if ($@) { | |
2233 | $count++; | |
2234 | warn "Test3 n1: $@"; | |
2235 | } | |
2236 | ||
2237 | eval { | |
2238 | if (PVE::Storage::volume_has_feature($cfg, 'template', "$storagename:$ctdisk", 'test', 0)) { | |
2239 | $count++; | |
2240 | warn "Test3 o1 failed"; | |
2241 | } | |
2242 | }; | |
2243 | if ($@) { | |
2244 | $count++; | |
2245 | warn "Test3 o1: $@"; | |
2246 | } | |
2247 | ||
2248 | eval { | |
2249 | if (PVE::Storage::volume_has_feature($cfg, 'template', "$storagename:$ctbase", 'test', 0)) { | |
2250 | $count++; | |
2251 | warn "Test3 p1 failed"; | |
2252 | } | |
2253 | }; | |
2254 | if ($@) { | |
2255 | $count++; | |
2256 | warn "Test3 p1: $@"; | |
2257 | } | |
2258 | ||
2259 | eval { | |
2260 | if (PVE::Storage::volume_has_feature($cfg, 'template', "$storagename:$ctbase\/$ctlinked", 'test', 0)) { | |
2261 | $count++; | |
2262 | warn "Test3 q1 failed"; | |
2263 | } | |
2264 | }; | |
2265 | if ($@) { | |
2266 | $count++; | |
2267 | warn "Test3 q1: $@"; | |
2268 | } | |
2269 | ||
2270 | eval { | |
2271 | if (PVE::Storage::volume_has_feature($cfg, 'copy', "$storagename:$vmdisk", 'test', 0)) { | |
2272 | $count++; | |
2273 | warn "Test3 r1 failed"; | |
2274 | } | |
2275 | }; | |
2276 | if ($@) { | |
2277 | $count++; | |
2278 | warn "Test3 r1: $@"; | |
2279 | } | |
2280 | ||
2281 | eval { | |
2282 | if (PVE::Storage::volume_has_feature($cfg, 'copy', "$storagename:$vmbase", 'test', 0)) { | |
2283 | $count++; | |
2284 | warn "Test3 s1 failed"; | |
2285 | } | |
2286 | }; | |
2287 | if ($@) { | |
2288 | $count++; | |
2289 | warn "Test3 s1: $@"; | |
2290 | } | |
2291 | ||
2292 | eval { | |
2293 | if (PVE::Storage::volume_has_feature($cfg, 'copy', "$storagename:$vmbase\/$vmlinked", 'test', 0)) { | |
2294 | $count++; | |
2295 | warn "Test3 t1 failed"; | |
2296 | } | |
2297 | }; | |
2298 | if ($@) { | |
2299 | $count++; | |
2300 | warn "Test3 t1: $@"; | |
2301 | } | |
2302 | ||
2303 | eval { | |
2304 | if (PVE::Storage::volume_has_feature($cfg, 'copy', "$storagename:$ctdisk", 'test', 0)) { | |
2305 | $count++; | |
2306 | warn "Test3 u1 failed"; | |
2307 | } | |
2308 | }; | |
2309 | if ($@) { | |
2310 | $count++; | |
2311 | warn "Test3 u1: $@"; | |
2312 | } | |
2313 | ||
2314 | eval { | |
2315 | if (PVE::Storage::volume_has_feature($cfg, 'copy', "$storagename:$ctbase", 'test', 0)) { | |
2316 | $count++; | |
2317 | warn "Test3 v1 failed"; | |
2318 | } | |
2319 | }; | |
2320 | if ($@) { | |
2321 | $count++; | |
2322 | warn "Test3 v1: $@"; | |
2323 | } | |
2324 | ||
2325 | eval { | |
2326 | if (PVE::Storage::volume_has_feature($cfg, 'copy', "$storagename:$ctbase\/$ctlinked", 'test', 0)) { | |
2327 | $count++; | |
2328 | warn "Test3 w1 failed"; | |
2329 | } | |
2330 | }; | |
2331 | if ($@) { | |
2332 | $count++; | |
2333 | warn "Test3 w1: $@"; | |
2334 | } | |
2335 | ||
2336 | eval { | |
2337 | if (PVE::Storage::volume_has_feature($cfg, 'sparseinit', "$storagename:$vmdisk", 'test', 0)) { | |
2338 | $count++; | |
2339 | warn "Test3 x1 failed"; | |
2340 | } | |
2341 | }; | |
2342 | if ($@) { | |
2343 | $count++; | |
2344 | warn "Test3 x1: $@"; | |
2345 | } | |
2346 | ||
2347 | eval { | |
2348 | if (PVE::Storage::volume_has_feature($cfg, 'sparseinit', "$storagename:$vmbase", 'test', 0)) { | |
2349 | $count++; | |
2350 | warn "Test3 y1 failed"; | |
2351 | } | |
2352 | }; | |
2353 | if ($@) { | |
2354 | $count++; | |
2355 | warn "Test3 y1: $@"; | |
2356 | } | |
2357 | ||
2358 | eval { | |
2359 | if (PVE::Storage::volume_has_feature($cfg, 'sparseinit', "$storagename:$vmbase\/$vmlinked", 'test', 0)) { | |
2360 | $count++; | |
2361 | warn "Test3 z1 failed"; | |
2362 | } | |
2363 | }; | |
2364 | if ($@) { | |
2365 | $count++; | |
2366 | warn "Test3 z1: $@"; | |
2367 | } | |
2368 | ||
2369 | eval { | |
2370 | if (PVE::Storage::volume_has_feature($cfg, 'sparseinit', "$storagename:$ctdisk", 'test', 0)) { | |
2371 | $count++; | |
2372 | warn "Test3 A1 failed"; | |
2373 | } | |
2374 | }; | |
2375 | if ($@) { | |
2376 | $count++; | |
2377 | warn "Test3 A1: $@"; | |
2378 | } | |
2379 | ||
2380 | eval { | |
2381 | if (PVE::Storage::volume_has_feature($cfg, 'sparseinit', "$storagename:$ctbase", 'test', 0)) { | |
2382 | $count++; | |
2383 | warn "Test3 B1 failed"; | |
2384 | } | |
2385 | }; | |
2386 | if ($@) { | |
2387 | $count++; | |
2388 | warn "Test3 B1: $@"; | |
2389 | } | |
2390 | ||
2391 | eval { | |
2392 | if (PVE::Storage::volume_has_feature($cfg, 'sparseinit', "$storagename:$ctbase\/$ctlinked", 'test', 0)) { | |
2393 | $count++; | |
2394 | warn "Test3 C1 failed"; | |
2395 | } | |
2396 | }; | |
2397 | if ($@) { | |
2398 | $count++; | |
2399 | warn "Test3 C1: $@"; | |
2400 | } | |
2401 | }; | |
2402 | $tests->{3} = $test3; | |
2403 | ||
2404 | my $test2 = sub { | |
2405 | ||
2406 | print "\nrun test2 \"volume_resize\"\n"; | |
2407 | my $newsize = ($volsize + 1) * 1024 * 1024 * 1024; | |
2408 | ||
2409 | eval { | |
2410 | if (($newsize/1024) != | |
2411 | PVE::Storage::volume_resize($cfg, "$storagename:$vmdisk", $newsize, 0)) { | |
2412 | $count++; | |
2413 | warn "Test2 a failed"; | |
2414 | } | |
2415 | if ($newsize != | |
2416 | PVE::Storage::volume_size_info($cfg, "$storagename:$vmdisk")) { | |
2417 | $count++; | |
2418 | warn "Test2 a failed"; | |
2419 | } | |
2420 | }; | |
2421 | if ($@) { | |
2422 | $count++; | |
2423 | warn "Test2 a: $@"; | |
2424 | } | |
2425 | ||
2426 | eval { | |
2427 | warn "Test2 b failed" if ($newsize/1024) != PVE::Storage::volume_resize($cfg, "$storagename:$vmbase", $newsize, 0); | |
2428 | warn "Test2 b failed" if $newsize != | |
2429 | PVE::Storage::volume_size_info($cfg, "$storagename:$vmbase"); | |
2430 | }; | |
2431 | if ($@) { | |
2432 | $count++; | |
2433 | warn "Test2 b: $@"; | |
2434 | } | |
2435 | ||
2436 | eval { | |
2437 | if (($newsize/1024) != PVE::Storage::volume_resize($cfg, "$storagename:$vmbase\/$vmlinked", $newsize, 0)) { | |
2438 | $count++; | |
2439 | warn "Test2 c failed"; | |
2440 | } | |
2441 | if ($newsize != | |
2442 | PVE::Storage::volume_size_info($cfg, "$storagename:$vmbase\/$vmlinked")) { | |
2443 | $count++; | |
2444 | warn "Test2 c failed"; | |
2445 | } | |
2446 | }; | |
2447 | if ($@) { | |
2448 | $count++; | |
2449 | warn "Test2 c: $@"; | |
2450 | } | |
2451 | ||
2452 | eval { | |
2453 | if (($newsize/1024) != PVE::Storage::volume_resize($cfg, "$storagename:$ctdisk", $newsize, 0)) { | |
2454 | $count++; | |
2455 | warn "Test2 d failed"; | |
2456 | } | |
2457 | if ($newsize != | |
2458 | PVE::Storage::volume_size_info($cfg, "$storagename:$ctdisk")) { | |
2459 | $count++; | |
2460 | warn "Test2 d failed" | |
2461 | } | |
2462 | }; | |
2463 | if ($@) { | |
2464 | $count++; | |
2465 | warn "Test2 d: $@"; | |
2466 | } | |
2467 | ||
2468 | eval { | |
2469 | if (($newsize/1024) != | |
2470 | PVE::Storage::volume_resize($cfg, "$storagename:$ctbase", $newsize, 0)) { | |
2471 | $count++; | |
2472 | warn "Test2 e failed"; | |
2473 | } | |
2474 | if ($newsize != | |
2475 | PVE::Storage::volume_size_info($cfg, "$storagename:$ctbase")) { | |
2476 | $count++; | |
2477 | warn "Test2 e failed"; | |
2478 | } | |
2479 | }; | |
2480 | if ($@) { | |
2481 | $count++; | |
2482 | warn "Test2 e: $@"; | |
2483 | } | |
2484 | ||
2485 | eval { | |
2486 | if (($newsize/1024) != | |
2487 | PVE::Storage::volume_resize($cfg, "$storagename:$ctbase\/$ctlinked", $newsize, 0)) { | |
2488 | $count++; | |
2489 | warn "Test2 f failed"; | |
2490 | } | |
2491 | if ($newsize != | |
2492 | PVE::Storage::volume_size_info($cfg, "$storagename:$ctbase\/$ctlinked")) { | |
2493 | $count++; | |
2494 | warn "Test2 f failed"; | |
2495 | } | |
2496 | }; | |
2497 | if ($@) { | |
2498 | $count++; | |
2499 | warn "Test2 f: $@"; | |
2500 | } | |
2501 | }; | |
2502 | $tests->{2} = $test2; | |
2503 | ||
2504 | my $test1 = sub { | |
2505 | ||
2506 | print "\nrun test1 \"volume_size_info\"\n"; | |
2507 | my $size = ($volsize * 1024 * 1024 * 1024); | |
2508 | ||
2509 | eval { | |
2510 | if ($size != PVE::Storage::volume_size_info($cfg, "$storagename:$vmdisk")) { | |
2511 | $count++; | |
2512 | warn "Test1 a failed"; | |
2513 | } | |
2514 | }; | |
2515 | if ($@) { | |
2516 | $count++; | |
2517 | warn "Test1 a : $@"; | |
2518 | } | |
2519 | ||
2520 | eval { | |
2521 | if ($size != PVE::Storage::volume_size_info($cfg, "$storagename:$vmbase")) { | |
2522 | $count++; | |
2523 | warn "Test1 b failed"; | |
2524 | } | |
2525 | ||
2526 | }; | |
2527 | if ($@) { | |
2528 | $count++; | |
2529 | warn "Test1 b : $@"; | |
2530 | } | |
2531 | ||
2532 | eval { | |
2533 | if ($size != | |
2534 | PVE::Storage::volume_size_info($cfg, "$storagename:$vmbase\/$vmlinked")) { | |
2535 | $count++; | |
2536 | warn "Test1 c failed"; | |
2537 | } | |
2538 | }; | |
2539 | if ($@) { | |
2540 | $count++; | |
2541 | warn "Test1 c : $@"; | |
2542 | } | |
2543 | ||
2544 | eval { | |
2545 | if ($size != | |
2546 | PVE::Storage::volume_size_info($cfg, "$storagename:$ctdisk")) { | |
2547 | $count++; | |
2548 | warn "Test1 d failed"; | |
2549 | } | |
2550 | }; | |
2551 | if ($@) { | |
2552 | $count++; | |
2553 | warn "Test1 d : $@"; | |
2554 | } | |
2555 | ||
2556 | eval { | |
2557 | if ($size != | |
2558 | PVE::Storage::volume_size_info($cfg, "$storagename:$ctbase")) { | |
2559 | $count++; | |
2560 | warn "Test1 e failed"; | |
2561 | } | |
2562 | }; | |
2563 | if ($@) { | |
2564 | $count++; | |
2565 | warn "Test1 e : $@"; | |
2566 | } | |
2567 | ||
2568 | eval { | |
2569 | if ($size != | |
2570 | PVE::Storage::volume_size_info($cfg, "$storagename:$vmbase\/$vmlinked")) { | |
2571 | $count++; | |
2572 | warn "Test1 f failed" | |
2573 | } | |
2574 | }; | |
2575 | if ($@) { | |
2576 | $count++; | |
2577 | warn "Test1 f : $@"; | |
2578 | } | |
2579 | ||
2580 | }; | |
2581 | $tests->{1} = $test1; | |
2582 | ||
2583 | sub setup_zfs { | |
2584 | ||
2585 | my $tmp = undef; | |
2586 | ||
2587 | #create VM zvol | |
2588 | print "create zvol $vmdisk\n" if $verbose; | |
2589 | run_command("zfs create -V${volsize}G $zpath\/$vmdisk"); | |
2590 | ||
2591 | print "create zvol $vmbase\n" if $verbose; | |
2592 | run_command("zfs create -V${volsize}G $zpath\/$vmbase"); | |
2593 | run_command("zfs snapshot $zpath\/$vmbase$basesnap"); | |
2594 | ||
2595 | print "create linked clone $vmlinked\n" if $verbose; | |
2596 | run_command("zfs clone $zpath\/$vmbase$basesnap $zpath\/$vmlinked"); | |
2597 | ||
2598 | #create CT subvol | |
2599 | print "create subvol $ctdisk\n" if $verbose; | |
2600 | run_command("zfs create -o refquota=${volsize}G $zpath\/$ctdisk"); | |
2601 | ||
2602 | print "create subvol $vmbase\n" if $verbose; | |
2603 | run_command("zfs create -o refquota=${volsize}G $zpath\/$ctbase"); | |
2604 | run_command("zfs snapshot $zpath\/$ctbase$basesnap"); | |
2605 | ||
2606 | print "create linked clone $vmlinked\n" if $verbose; | |
2607 | run_command("zfs clone $zpath\/$ctbase$basesnap $zpath\/$ctlinked -o refquota=${volsize}G"); | |
2608 | } | |
2609 | ||
2610 | sub cleanup_zfs { | |
2611 | ||
2612 | print "destroy $pool\/$subvol\n" if $verbose; | |
2613 | run_command("zfs destroy $zpath -r"); | |
2614 | } | |
2615 | ||
2616 | sub setup_zpool { | |
2617 | ||
2618 | eval { | |
2619 | run_command("dd if=/dev/zero of=zpool.img bs=1M count=8000 "); | |
2620 | }; | |
2621 | if ($@) { | |
2622 | clean_up_zpool(); | |
2623 | } | |
2624 | my $pwd = cwd(); | |
2625 | eval { | |
2626 | run_command("zpool create $subvol $pwd\/zpool.img"); | |
2627 | }; | |
2628 | if ($@) { | |
2629 | clean_up_zpool(); | |
2630 | } | |
2631 | } | |
2632 | ||
2633 | sub clean_up_zpool { | |
2634 | ||
2635 | eval { | |
2636 | run_command("zpool destroy $subvol"); | |
2637 | }; | |
2638 | if ($@) { | |
2639 | warn $@;} | |
2640 | unlink 'zpool.img'; | |
2641 | } | |
2642 | ||
2643 | setup_zpool(); | |
2644 | ||
2645 | my $time = time; | |
2646 | print "Start tests for ZFSPoolPlugin\n"; | |
2647 | ||
2648 | $cfg = {'ids' => { | |
2649 | $storagename => { | |
2650 | 'content' => { | |
2651 | 'images' => 1, | |
2652 | 'rootdir' => 1 | |
2653 | }, | |
2654 | 'pool' => $subvol, | |
2655 | 'type' => 'zfspool' | |
2656 | }, | |
2657 | }, | |
2658 | 'order' => {'zfstank99' => 1,} | |
2659 | }; | |
2660 | ||
2661 | $zpath = $subvol; | |
2662 | ||
46001581 | 2663 | for (my $i = $start_test; $i <= $end_test; $i++) { |
81ebc68f WL |
2664 | setup_zfs(); |
2665 | ||
2666 | eval { | |
2667 | $tests->{$i}(); | |
2668 | }; | |
2669 | warn $@ if $@; | |
2670 | cleanup_zfs(); | |
2671 | } | |
2672 | ||
2673 | clean_up_zpool(); | |
2674 | ||
2675 | $time = time - $time; | |
2676 | ||
2677 | print "Stop tests for ZFSPoolPlugin\n"; | |
2678 | print "$count tests failed\n"; | |
2679 | print "Time: ${time}s\n"; |