5 use Data
::Dumper
qw(Dumper);
8 use PVE
::Tools
qw(run_command);
10 $Data::Dumper
::Sortkeys
= 1;
14 my $storagename = "zfstank99";
15 my $subvol = 'regressiontest';
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";
26 my $basesnap = '@__base__';
29 #create zfs suvol for testing
40 print "\nrun test17 \"scan_zfs\"\n";
44 $res = PVE
::Storage
::scan_zfs
($cfg, $storagename);
47 foreach my $subvol (@$res){
48 if ($subvol->{pool
} eq 'regressiontest') {
54 warn "Test 18 a: not pool";
64 $res = PVE
::Storage
::scan_zfs
($cfg, $storagename);
66 foreach my $subvol (@$res){
67 if ($subvol->{pool
} eq 'zfspool/subvol') {
73 foreach my $subvol (@$res){
74 if ($subvol->{pool
} eq 'zfspool/basevol') {
85 $tests->{18} = $test18;
89 print "\nrun test17 \"deactivate_storage\"\n";
92 PVE
::Storage
::activate_storage
($cfg, $storagename);
99 $tests->{17} = $test17;
103 print "\nrun test16 \"activate_storage\"\n";
106 PVE
::Storage
::activate_storage
($cfg, $storagename);
110 warn "Test 16 a: $@";
113 $tests->{16} = $test16;
117 print "\nrun test15 \"template_list and vdisk_list\"\n";
119 my $hash = Dumper
{};
121 my $res = Dumper PVE
::Storage
::template_list
($cfg, $storagename, "vztmpl");
122 if ( $hash ne $res ) {
124 warn "Test 15 a failed\n";
128 $res = Dumper PVE
::Storage
::template_list
($cfg, $storagename, "iso");
129 if ( $hash ne $res ) {
131 warn "Test 15 b failed\n";
135 $res = Dumper PVE
::Storage
::template_list
($cfg, $storagename, "backup");
136 if ( $hash ne $res ) {
138 warn "Test 15 c failed\n";
142 $hash = Dumper
{'zfstank99' => [
145 'volid' => 'zfstank99:base-100-disk-1',
146 'name' => 'base-100-disk-1',
148 'size' => 1073741824,
153 $res = Dumper PVE
::Storage
::vdisk_list
($cfg, $storagename, 100, ["$storagename:$vmbase"]);
155 if ( $hash ne $res ) {
157 warn "Test 15 d failed\n";
161 $hash = Dumper
{'zfstank99' => [
164 'volid' => 'zfstank99:vm-102-disk-1',
165 'name' => 'vm-102-disk-1',
167 'size' => 1073741824,
172 $res = Dumper PVE
::Storage
::vdisk_list
($cfg, $storagename, 102, ["$storagename:$vmdisk"]);
173 if ( $hash ne $res ) {
175 warn "Test 15 e failed\n";
179 $hash = Dumper
{'zfstank99' => [
181 'parent' => 'base-100-disk-1@__base__',
182 'volid' => "$storagename:$vmbase\/$vmlinked",
183 'name' => 'vm-101-disk-1',
185 'size' => 1073741824,
190 $res = Dumper PVE
::Storage
::vdisk_list
($cfg, $storagename, 101, ["$storagename:$vmbase\/$vmlinked"]);
191 if ( $hash ne $res ) {
193 warn "Test 15 f failed\n";
197 $hash = Dumper
{'zfstank99' => [
200 'volid' => 'zfstank99:basevol-200-disk-1',
201 'name' => 'basevol-200-disk-1',
203 'size' => 1073741824,
208 $res = Dumper PVE
::Storage
::vdisk_list
($cfg, $storagename, 200, ["$storagename:$ctbase"]);
209 if ( $hash ne $res ) {
211 warn "Test 15 g failed\n";
215 $hash = Dumper
{'zfstank99' => [
218 'volid' => 'zfstank99:subvol-202-disk-1',
219 'name' => 'subvol-202-disk-1',
221 'size' => 1073741824,
226 $res = Dumper PVE
::Storage
::vdisk_list
($cfg, $storagename, 202, ["$storagename:$ctdisk"]);
227 if ( $hash ne $res ) {
229 warn "Test 15 h failed\n";
233 $hash = Dumper
{'zfstank99' => [
235 'parent' => 'basevol-200-disk-1@__base__',
236 'volid' => "$storagename:$ctbase\/$ctlinked",
237 'name' => 'subvol-201-disk-1',
239 'size' => 1073741824,
243 $res = Dumper PVE
::Storage
::vdisk_list
($cfg, $storagename, 201, ["$storagename:$ctbase\/$ctlinked"]);
244 if ( $hash ne $res ) {
246 warn "Test 15 i failed\n";
249 $tests->{15} = $test15;
253 print "\nrun test14 \"vdisk_free\"\n";
256 PVE
::Storage
::vdisk_free
($cfg, "$storagename:$vmdisk");
259 run_command
("zfs list $zpath\/$vmdisk", outfunc
=> sub {}, errfunc
=> sub {});
263 warn "Test14 a: vdisk still exists\n";
272 PVE
::Storage
::vdisk_free
($cfg, "$storagename:$vmbase");
276 warn "Test14 b: free vdisk should not work\n";
280 PVE
::Storage
::vdisk_free
($cfg, "$storagename:$vmbase\/$vmlinked");
283 run_command
("zfs list $zpath\/$vmlinked", outfunc
=> sub {}, errfunc
=> sub {});
287 warn "Test14 c: vdisk still exists\n";
296 PVE
::Storage
::vdisk_free
($cfg, "$storagename:$ctdisk");
299 run_command
("zfs list $zpath\/$ctdisk", outfunc
=> sub {}, errfunc
=> sub {});
303 warn "Test14 d: vdisk still exists\n";
312 PVE
::Storage
::vdisk_free
($cfg, "$storagename:$ctbase");
316 warn "Test14 e: free vdisk should not work\n";
320 PVE
::Storage
::vdisk_free
($cfg, "$storagename:$ctbase\/$ctlinked");
323 run_command
("zfs list $zpath\/$ctlinked", outfunc
=> sub {}, errfunc
=> sub {});
327 warn "Test14 f: vdisk still exists\n";
336 PVE
::Storage
::vdisk_free
($cfg, "$storagename:$vmbase");
339 run_command
("zfs list $zpath\/$vmbase", outfunc
=> sub {}, errfunc
=> sub {});
343 warn "Test14 g: vdisk still exists\n";
352 PVE
::Storage
::vdisk_free
($cfg, "$storagename:$ctbase");
355 run_command
("zfs list $zpath\/$ctbase", outfunc
=> sub {}, errfunc
=> sub {});
359 warn "Test14 h: vdisk still exists\n";
367 $tests->{14} = $test14;
371 print "\nrun test13 \"vdisk_alloc\"\n";
374 my $tmp_volid = PVE
::Storage
::vdisk_alloc
($cfg, $storagename, "112", "raw", undef ,1024 * 1024);
376 if ($tmp_volid ne "$storagename:vm-112-disk-1") {
377 die "volname:$tmp_volid don't match\n";
380 run_command
("zfs get -H volsize $zpath\/vm-112-disk-1", outfunc
=>
381 sub { my $tmp = shift;
382 if ($tmp !~ m/^$zpath\/vm-112-disk-1
.*volsize
.*1G
.*$/) {
383 die "size don't match\n";
398 my $tmp_volid = PVE
::Storage
::vdisk_alloc
($cfg, $storagename, "112", "raw", undef ,2048 * 1024);
400 if ($tmp_volid ne "$storagename:vm-112-disk-2") {
401 die "volname:$tmp_volid don't match\n";
404 run_command
("zfs get -H volsize $zpath\/vm-112-disk-2", outfunc
=>
405 sub { my $tmp = shift;
406 if ($tmp !~ m/^$zpath\/vm-112-disk-2
.*volsize
.*2G
.*$/) {
407 die "size don't match\n";
422 my $tmp_volid = PVE
::Storage
::vdisk_alloc
($cfg, $storagename, "113", "subvol", undef ,1024 * 1024);
424 if ($tmp_volid ne "$storagename:subvol-113-disk-1") {
425 die "volname:$tmp_volid don't match\n";
428 run_command
("zfs get -H refquota $zpath\/subvol-113-disk-1", outfunc
=>
429 sub { my $tmp = shift;
430 if ($tmp !~ m/^$zpath\/subvol
-113-disk
-1.*refquota
.*1G
.*$/) {
431 die "size don't match\n";
446 my $tmp_volid = PVE
::Storage
::vdisk_alloc
($cfg, $storagename, "113", "subvol", undef ,2048 * 1024);
448 if ($tmp_volid ne "$storagename:subvol-113-disk-2") {
449 die "volname:$tmp_volid don't match\n";
452 run_command
("zfs get -H refquota $zpath\/subvol-113-disk-2", outfunc
=>
453 sub { my $tmp = shift;
454 if ($tmp !~ m/^$zpath\/subvol
-113-disk
-2.*refquota
.*G
.*$/) {
455 die "size don't match\n";
469 $tests->{13} = $test13;
473 print "\nrun test12 \"vdisk_create_base\"\n";
476 my $tmp_volid = PVE
::Storage
::vdisk_create_base
($cfg, "$storagename:$vmdisk");
478 if ($tmp_volid ne "$storagename:base-102-disk-1") {
482 run_command
("zfs list $zpath\/base-102-disk-1", outfunc
=> sub {});
495 my $tmp_volid = PVE
::Storage
::vdisk_create_base
($cfg, "$storagename:$vmlinked");
497 if ($tmp_volid ne "$storagename:base-101-disk-1") {
501 run_command
("zfs list $zpath\/base-101-disk-1", outfunc
=> sub {});
514 my $tmp_volid = PVE
::Storage
::vdisk_create_base
($cfg, "$storagename:$ctdisk");
516 if ($tmp_volid ne "$storagename:basevol-202-disk-1") {
520 run_command
("zfs list $zpath\/basevol-202-disk-1", outfunc
=> sub {});
533 my $tmp_volid = PVE
::Storage
::vdisk_create_base
($cfg, "$storagename:$ctlinked");
535 if ($tmp_volid ne "$storagename:basevol-201-disk-1") {
539 run_command
("zfs list $zpath\/basevol-201-disk-1", outfunc
=> sub {});
551 $tests->{12} = $test12;
555 print "\nrun test11 \"volume_is_base\"\n";
558 PVE
::Storage
::vdisk_clone
($cfg, "$storagename:$vmdisk", 110);
562 warn "Test11 a: clone_image only works on base images";
566 if ("$storagename:$vmbase\/vm-110-disk-1" ne
567 PVE
::Storage
::vdisk_clone
($cfg, "$storagename:$vmbase", 110, '__base__')){
571 run_command
("zfs list -H -o volsize $zpath\/vm-110-disk-1", outfunc
=> sub {
575 warn "Test11 b not correct volsize" if $line !~ m/$volsize/;
584 PVE
::Storage
::vdisk_clone
($cfg, "$storagename:$vmbase\/$vmlinked", 111);
588 warn "Test11 c: clone_image only works on base images";
592 PVE
::Storage
::vdisk_clone
($cfg, "$storagename:$ctdisk", 110);
596 warn "Test11 d: clone_image only works on base images";
600 if ( "$storagename:$ctbase\/subvol-210-disk-1" ne
601 PVE
::Storage
::vdisk_clone
($cfg, "$storagename:$ctbase", 210, '__base__')){
605 run_command
("zfs list -H -o refquota $zpath\/subvol-210-disk-1", outfunc
=> sub {
609 warn "Test11 e not correct volsize" if $line !~ m/$volsize/;
618 PVE
::Storage
::vdisk_clone
($cfg, "$storagename:$ctbase\/$ctlinked", 211);
622 warn "Test11 f: clone_image only works on base images";
625 $tests->{11} = $test11;
629 print "\nrun test10 \"volume_is_base\"\n";
632 if (1 == PVE
::Storage
::volume_is_base
($cfg, "$storagename:$vmdisk")) {
634 warn "Test10 a: is no base";
644 if (0 == PVE
::Storage
::volume_is_base
($cfg, "$storagename:$vmbase")) {
646 warn "Test10 b: is base";
656 if (1 == PVE
::Storage
::volume_is_base
($cfg, "$storagename:$vmbase\/$vmlinked")) {
658 warn "Test10 c: is no base";
668 if (1 == PVE
::Storage
::volume_is_base
($cfg, "$storagename:$ctdisk")) {
670 warn "Test10 d: is no base";
680 if (0 == PVE
::Storage
::volume_is_base
($cfg, "$storagename:$ctbase")) {
682 warn "Test10 e: is base";
692 if (1 == PVE
::Storage
::volume_is_base
($cfg, "$storagename:$ctbase\/$ctlinked")) {
694 warn "Test10 f: is no base";
703 $tests->{10} = $test10;
707 print "\nrun test9 \"parse_volname\"\n";
710 my ($store, $disk) = PVE
::Storage
::parse_volume_id
("$storagename:$vmdisk");
712 if ($store ne $storagename || $disk ne $vmdisk) {
714 warn "Test9 a: parsing wrong";
724 my ($store, $disk) = PVE
::Storage
::parse_volume_id
("$storagename:$vmbase");
726 if ($store ne $storagename || $disk ne $vmbase) {
728 warn "Test9 b: parsing wrong";
738 my ($store, $disk) = PVE
::Storage
::parse_volume_id
("$storagename:$vmbase\/$vmlinked");
740 if ($store ne $storagename || $disk ne "$vmbase\/$vmlinked") {
742 warn "Test9 c: parsing wrong";
752 my ($store, $disk) = PVE
::Storage
::parse_volume_id
("$storagename:$ctdisk");
754 if ($store ne $storagename || $disk ne $ctdisk) {
756 warn "Test9 d: parsing wrong";
766 my ($store, $disk) = PVE
::Storage
::parse_volume_id
("$storagename:$ctbase");
768 if ($store ne $storagename || $disk ne $ctbase) {
770 warn "Test9 e: parsing wrong";
780 my ($store, $disk) = PVE
::Storage
::parse_volume_id
("$storagename:$ctbase\/$ctlinked");
782 if ($store ne $storagename || $disk ne "$ctbase\/$ctlinked") {
784 warn "Test9 f: parsing wrong";
793 $tests->{9} = $test9;
797 print "\nrun test8 \"parse_volname\"\n";
800 my ($vtype, $name, $vmid, $basename, $basevmid, $isBase, $format) = PVE
::Storage
::parse_volname
($cfg, "$storagename:$vmdisk");
802 if ($vtype ne 'images' || $vmid ne '102' || $name ne $vmdisk ||
803 defined($basename) || defined($basevmid) || $isBase ||
806 warn "Test8 a: parsing wrong";
816 my ($vtype, $name, $vmid, $basename, $basevmid, $isBase, $format) = PVE
::Storage
::parse_volname
($cfg, "$storagename:$vmbase");
818 if ($vtype ne 'images' || $vmid ne '100' || $name ne $vmbase ||
819 defined($basename) || defined($basevmid) || !$isBase ||
822 warn "Test8 b: parsing wrong";
831 my ($vtype, $name, $vmid, $basename, $basevmid, $isBase, $format) = PVE
::Storage
::parse_volname
($cfg, "$storagename:$vmbase\/$vmlinked");
833 if ($vtype ne 'images' || $name ne $vmlinked || $vmid ne '101' ||
834 $basename ne $vmbase || $basevmid ne '100' || $isBase ||
837 warn "Test8 c: parsing wrong";
846 my ($vtype, $name, $vmid, $basename, $basevmid, $isBase, $format) = PVE
::Storage
::parse_volname
($cfg, "$storagename:$ctdisk");
848 if ($vtype ne 'images' || $vmid ne '202' || $name ne $ctdisk ||
849 defined($basename) || defined($basevmid) || $isBase ||
850 $format ne 'subvol') {
852 warn "Test8 d: parsing wrong";
862 my ($vtype, $name, $vmid, $basename, $basevmid, $isBase, $format) = PVE
::Storage
::parse_volname
($cfg, "$storagename:$ctbase");
863 if ($vtype ne 'images' || $vmid ne '200' || $name ne $ctbase ||
864 defined($basename) || defined($basevmid) || !$isBase ||
865 $format ne 'subvol') {
867 warn "Test8 e: parsing wrong";
876 my ($vtype, $name, $vmid, $basename, $basevmid, $isBase, $format) = PVE
::Storage
::parse_volname
($cfg, "$storagename:$ctbase\/$ctlinked");
878 if ($vtype ne 'images' || $name ne $ctlinked || $vmid ne '201' ||
879 $basename ne $ctbase || $basevmid ne '200' || $isBase ||
880 $format ne 'subvol') {
882 warn "Test8 f: parsing wrong";
890 $tests->{8} = $test8;
894 print "\nrun test7 \"volume_rollback\"\n";
897 my $parse_guid = sub {
900 if ( $line =~ m/^Disk identifier \(GUID\)\: (.*)$/ ) {
906 run_command
("sgdisk --randomize-guids \/dev\/zvol\/$zpath\/$vmdisk", outfunc
=> $parse_guid);
907 run_command
("sgdisk -p \/dev\/zvol\/$zpath\/$vmdisk", outfunc
=> $parse_guid);
909 my $old_guid = $tmp_guid;
910 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmdisk", 'snap1');
912 run_command
("sgdisk --randomize-guids \/dev\/zvol\/$zpath\/$vmdisk", outfunc
=> $parse_guid);
914 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$vmdisk", 'snap1');
916 run_command
("sgdisk -p \/dev\/zvol\/$zpath\/$vmdisk", outfunc
=> $parse_guid);
917 if ($old_guid ne $tmp_guid) {
919 warn "Test7 a: Zvol makes no rollback";
934 run_command
("sgdisk --randomize-guids \/dev\/zvol\/$zpath\/$vmbase", outfunc
=> $parse_guid);
935 run_command
("sgdisk -p \/dev\/zvol\/$zpath\/$vmbase", outfunc
=> $parse_guid);
937 my $old_guid = $tmp_guid;
938 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmbase", 'snap1');
940 run_command
("sgdisk --randomize-guids \/dev\/zvol\/$zpath\/$vmbase", outfunc
=> $parse_guid);
942 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$vmbase", 'snap1');
944 run_command
("sgdisk -p \/dev\/zvol\/$zpath\/$vmbase", outfunc
=> $parse_guid);
945 if ($old_guid ne $tmp_guid) {
947 warn "Test7 b: Zvol makes no rollback";
962 run_command
("sgdisk --randomize-guids \/dev\/zvol\/$zpath\/$vmlinked", outfunc
=> $parse_guid);
963 run_command
("sgdisk -p \/dev\/zvol\/$zpath\/$vmlinked", outfunc
=> $parse_guid);
965 my $old_guid = $tmp_guid;
966 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmbase\/$vmlinked", 'snap1');
968 run_command
("sgdisk --randomize-guids \/dev\/zvol\/$zpath\/$vmlinked", outfunc
=> $parse_guid);
970 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$vmbase\/$vmlinked", 'snap1');
972 run_command
("sgdisk -p \/dev\/zvol\/$zpath\/$vmlinked", outfunc
=> $parse_guid);
973 if ($old_guid ne $tmp_guid) {
975 warn "Test7 c: Zvol makes no rollback";
990 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctdisk", 'snap1');
992 run_command
("touch \/$zpath\/$ctdisk\/test.txt", outfunc
=> $parse_guid);
994 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$ctdisk", 'snap1');
996 run_command
("ls \/$zpath\/$ctdisk\/test.txt", errofunc
=> sub {});
1014 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctbase", 'snap1');
1016 run_command
("touch \/$zpath\/$ctbase\/test.txt", outfunc
=> $parse_guid);
1018 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$ctbase", 'snap1');
1020 run_command
("ls \/$zpath\/$ctbase\/test.txt", errofunc
=> sub {});
1038 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctbase/$ctlinked", 'snap1');
1040 run_command
("touch \/$zpath\/$ctlinked\/test.txt", outfunc
=> $parse_guid);
1042 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$ctbase/$ctlinked", 'snap1');
1044 run_command
("ls \/$zpath\/$ctlinked\/test.txt", errofunc
=> sub {});
1062 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmdisk", 'snap2');
1065 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$vmdisk", 'snap1');
1069 warn "Test7 h: Not allowed to rollback";
1078 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmbase", 'snap2');
1081 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$vmbase", 'snap1');
1085 warn "Test7 i: Not allowed to rollback";
1094 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmbase\/$vmlinked", 'snap2');
1097 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$vmbase\/$vmlinked", 'snap1');
1101 warn "Test7 j: Not allowed to rollback";
1110 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctdisk", 'snap2');
1113 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$ctdisk", 'snap1');
1117 warn "Test7 k: Not allowed to rollback";
1126 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctbase", 'snap2');
1129 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$ctbase", 'snap1');
1133 warn "Test7 l: Not allowed to rollback";
1142 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctbase/$ctlinked", 'snap2');
1145 PVE
::Storage
::volume_snapshot_rollback
($cfg, "$storagename:$ctbase/$ctlinked", 'snap1');
1149 warn "Test7 m: Not allowed to rollback";
1157 $tests->{7} = $test7;
1161 print "\nrun test6 \"volume_rollback_is_possible\"\n";
1164 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmdisk", 'snap1');
1166 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$vmdisk", 'snap1')) {
1168 warn "Test6 a: Rollback sould possible"
1177 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmbase", 'snap1');
1179 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$vmbase", 'snap1')) {
1181 warn "Test6 b: Rollback sould possible"
1190 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmlinked", 'snap1');
1192 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$vmbase\/$vmlinked", 'snap1')) {
1194 warn "Test6 c: Rollback sould possible"
1203 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctdisk", 'snap1');
1205 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$ctdisk", 'snap1')) {
1207 warn "Test6 d: Rollback sould possible"
1216 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctbase", 'snap1');
1218 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$ctbase", 'snap1')) {
1220 warn "Test6 e: Rollback sould possible"
1229 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctlinked", 'snap1');
1231 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$ctbase\/$ctlinked", 'snap1')) {
1233 warn "Test6 f: Rollback sould possible"
1242 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmdisk", 'snap2');
1243 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$vmdisk", 'snap1');
1247 warn "Test6 g: Rollback should not possible";
1251 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmbase", 'snap2');
1252 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$vmbase", 'snap1');
1256 warn "Test6 h: Rollback should not possible";
1260 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmlinked", 'snap2');
1261 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$vmbase\/$vmlinked", 'snap1');
1265 warn "Test6 j: Rollback should not possible";
1269 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctdisk", 'snap2');
1270 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$ctdisk", 'snap1');
1274 warn "Test6 k: Rollback should not possible";
1278 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctbase", 'snap2');
1279 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$ctbase", 'snap1');
1283 warn "Test6 l: Rollback should not possible";
1287 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctlinked", 'snap2');
1288 PVE
::Storage
::volume_rollback_is_possible
($cfg, "$storagename:$ctbase\/$ctlinked", 'snap1');
1292 warn "Test6 m: Rollback should not possible";
1295 $tests->{6} = $test6;
1299 print "\nrun test5 \"volume_snapshot_delete\"\n";
1300 my $out = sub{my $tmp = shift;};
1303 run_command
("zfs snapshot $zpath\/$vmdisk\@snap");
1305 PVE
::Storage
::volume_snapshot_delete
($cfg, "$storagename:$vmdisk", 'snap');
1307 run_command
("zfs list $zpath\/$vmdisk\@snap", errfunc
=> $out, outfunc
=> $out);
1311 warn "Test5 a: snapshot still exists";
1316 warn "Test5 PVE a: $@";
1325 run_command
("zfs snapshot $zpath\/$vmbase\@snap");
1327 PVE
::Storage
::volume_snapshot_delete
($cfg, "$storagename:$vmbase", 'snap');
1329 run_command
("zfs list $zpath\/$vmbase\@snap", errmsg
=> $out, outfunc
=> $out);
1333 warn "Test5 b: snapshot still exists";
1338 warn "Test5 PVE b: $@";
1347 run_command
("zfs snapshot $zpath\/$vmlinked\@snap");
1349 PVE
::Storage
::volume_snapshot_delete
($cfg, "$storagename:$vmbase\/$vmlinked", 'snap');
1351 run_command
("zfs list $zpath\/$vmlinked\@snap", errmsg
=> $out, outfunc
=> $out);
1355 warn "Test5 c: snapshot still exists";
1360 warn "Test5 PVE c: $@";
1369 run_command
("zfs snapshot $zpath\/$ctdisk\@snap");
1371 PVE
::Storage
::volume_snapshot_delete
($cfg, "$storagename:$ctdisk", 'snap');
1373 run_command
("zfs list $zpath\/$ctdisk\@snap", errmsg
=> $out, outfunc
=> $out);
1377 warn "Test5 d: snapshot still exists";
1382 warn "Test5 PVE d: $@";
1391 run_command
("zfs snapshot $zpath\/$ctbase\@snap");
1393 PVE
::Storage
::volume_snapshot_delete
($cfg, "$storagename:$ctbase", 'snap');
1395 run_command
("zfs list $zpath\/$ctbase\@snap", errmsg
=> $out, outfunc
=> $out);
1399 warn "Test5 e: snapshot still exists";
1404 warn "Test5 PVE e: $@";
1413 run_command
("zfs snapshot $zpath\/$ctlinked\@snap");
1415 PVE
::Storage
::volume_snapshot_delete
($cfg, "$storagename:$ctbase\/$ctlinked", 'snap');
1417 run_command
("zfs list $zpath\/$ctlinked\@snap", errmsg
=> $out, outfunc
=> $out);
1421 warn "Test5 f: snapshot still exists";
1426 warn "Test5 PVE f: $@";
1433 print "######Ignore Output if no Test5 g: is includet######\n";
1435 PVE
::Storage
::volume_snapshot_delete
($cfg, "$storagename:$vmbase", '__base__');
1437 run_command
("zfs list $zpath\/$vmbase\@__base__", outfunc
=> $out);
1446 warn "Test5 PVE g: snapshot __base__ can be erased";
1448 print "######End Ignroe#######\n";
1450 $tests->{5} = $test5;
1454 print "\nrun test4 \"volume_snapshot\"\n";
1458 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmdisk", 'snap');
1460 run_command
("zfs list $zpath\/$vmdisk\@snap", errmsg
=> $out, outfunc
=> $out);
1473 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmbase", 'snap');
1475 run_command
("zfs list $zpath\/$vmbase\@snap", errmsg
=> $out, outfunc
=> $out);
1488 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$vmbase\/$vmlinked", 'snap');
1490 run_command
("zfs list $zpath\/$vmdisk\@snap", errmsg
=> $out, outfunc
=> $out);
1503 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctdisk", 'snap');
1505 run_command
("zfs list $zpath\/$ctdisk\@snap", errmsg
=> $out, outfunc
=> $out);
1518 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctbase", 'snap');
1520 run_command
("zfs list $zpath\/$ctbase\@snap", errmsg
=> $out, outfunc
=> $out);
1533 PVE
::Storage
::volume_snapshot
($cfg, "$storagename:$ctbase\/$ctlinked", 'snap');
1535 run_command
("zfs list $zpath\/$ctdisk\@snap", errmsg
=> $out, outfunc
=> $out);
1547 $tests->{4} = $test4;
1551 print "\nrun test3 \"volume_has_feature\"\n";
1554 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$vmdisk", undef, 0)) {
1556 warn "Test3 a failed";
1565 if (PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$vmbase", undef, 0)) {
1567 warn "Test3 b failed";
1576 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$vmbase\/$vmlinked", undef, 0)) {
1578 warn "Test3 c failed";
1587 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$ctdisk", undef, 0)) {
1589 warn "Test3 d failed";
1598 if (PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$ctbase", undef, 0)) {
1600 warn "Test3 e failed";
1609 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$ctbase\/$ctlinked", undef, 0)) {
1611 warn "Test3 f failed";
1620 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$vmdisk", undef, 0)) {
1622 warn "Test3 g failed";
1631 if (!PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$vmbase", undef, 0)) {
1633 warn "Test3 h failed";
1642 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$vmbase\/$vmlinked", undef, 0)) {
1644 warn "Test3 h failed";
1653 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$ctdisk", undef, 0)) {
1655 warn "Test3 i failed";
1664 if (!PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$ctbase", undef, 0)) {
1666 warn "Test3 j failed";
1675 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$ctbase\/$ctlinked", undef, 0)) {
1677 warn "Test3 k failed";
1686 if (!PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$vmdisk", undef, 0)) {
1688 warn "Test3 l failed";
1697 if (PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$vmbase", undef, 0)) {
1699 warn "Test3 m failed";
1708 if (!PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$vmbase\/$vmlinked", undef, 0)) {
1710 warn "Test3 n failed";
1719 if (!PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$ctdisk", undef, 0)) {
1721 warn "Test3 o failed";
1730 if (PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$ctbase", undef, 0)) {
1732 warn "Test3 p failed";
1741 if (!PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$ctbase\/$ctlinked", undef, 0)) {
1743 warn "Test3 q failed";
1752 if (!PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$vmdisk", undef, 0)) {
1754 warn "Test3 r failed";
1763 if (!PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$vmbase", undef, 0)) {
1765 warn "Test3 s failed";
1774 if (!PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$vmbase\/$vmlinked", undef, 0)) {
1776 warn "Test3 t failed";
1785 if (!PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$ctdisk", undef, 0)) {
1787 warn "Test3 u failed";
1796 if (!PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$ctbase", undef, 0)) {
1798 warn "Test3 v failed";
1807 if (!PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$ctbase\/$ctlinked", undef, 0)) {
1809 warn "Test3 w failed";
1818 if (!PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$vmdisk", undef, 0)) {
1820 warn "Test3 x failed";
1829 if (!PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$vmbase", undef, 0)) {
1831 warn "Test3 y failed";
1840 if (!PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$vmbase\/$vmlinked", undef, 0)) {
1842 warn "Test3 z failed";
1851 if (!PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$ctdisk", undef, 0)) {
1853 warn "Test3 A failed";
1862 if (!PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$ctbase", undef, 0)) {
1864 warn "Test3 B failed";
1873 if (!PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$ctbase\/$ctlinked", undef, 0)) {
1875 warn "Test3 C failed";
1884 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$vmdisk", 'test', 0)) {
1886 warn "Test3 a1 failed";
1891 warn "Test3 a1: $@";
1895 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$vmbase", 'test', 0)) {
1897 warn "Test3 b1 failed";
1902 warn "Test3 b1: $@";
1906 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$vmbase\/$vmlinked", 'test', 0)) {
1908 warn "Test3 c1 failed";
1913 warn "Test3 c1: $@";
1917 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$ctdisk", 'test', 0)) {
1919 warn "Test3 d1 failed";
1924 warn "Test3 d1: $@";
1928 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$ctbase", 'test', 0)) {
1930 warn "Test3 e1 failed";
1935 warn "Test3 e1: $@";
1939 if (!PVE
::Storage
::volume_has_feature
($cfg, 'snapshot', "$storagename:$ctbase\/$ctlinked", 'test', 0)) {
1941 warn "Test3 f1 failed";
1946 warn "Test3 f1: $@";
1950 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$vmdisk", 'test', 0)) {
1952 warn "Test3 g1 failed";
1957 warn "Test3 g1: $@";
1961 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$vmbase", 'test', 0)) {
1963 warn "Test3 h1 failed";
1968 warn "Test3 h1: $@";
1972 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$vmbase\/$vmlinked", 'test', 0)) {
1974 warn "Test3 h1 failed";
1979 warn "Test3 h1: $@";
1983 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$ctdisk", 'test', 0)) {
1985 warn "Test3 i1 failed";
1990 warn "Test3 i1: $@";
1994 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$ctbase", 'test', 0)) {
1996 warn "Test3 j1 failed";
2001 warn "Test3 j1: $@";
2005 if (PVE
::Storage
::volume_has_feature
($cfg, 'clone', "$storagename:$ctbase\/$ctlinked", 'test', 0)) {
2007 warn "Test3 k1 failed";
2012 warn "Test3 k1: $@";
2016 if (PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$vmdisk", 'test', 0)) {
2018 warn "Test3 l1 failed";
2023 warn "Test3 l1: $@";
2027 if (PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$vmbase", 'test', 0)) {
2029 warn "Test3 m1 failed";
2034 warn "Test3 m1: $@";
2038 if (PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$vmbase\/$vmlinked", 'test', 0)) {
2040 warn "Test3 n1 failed";
2045 warn "Test3 n1: $@";
2049 if (PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$ctdisk", 'test', 0)) {
2051 warn "Test3 o1 failed";
2056 warn "Test3 o1: $@";
2060 if (PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$ctbase", 'test', 0)) {
2062 warn "Test3 p1 failed";
2067 warn "Test3 p1: $@";
2071 if (PVE
::Storage
::volume_has_feature
($cfg, 'template', "$storagename:$ctbase\/$ctlinked", 'test', 0)) {
2073 warn "Test3 q1 failed";
2078 warn "Test3 q1: $@";
2082 if (PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$vmdisk", 'test', 0)) {
2084 warn "Test3 r1 failed";
2089 warn "Test3 r1: $@";
2093 if (PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$vmbase", 'test', 0)) {
2095 warn "Test3 s1 failed";
2100 warn "Test3 s1: $@";
2104 if (PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$vmbase\/$vmlinked", 'test', 0)) {
2106 warn "Test3 t1 failed";
2111 warn "Test3 t1: $@";
2115 if (PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$ctdisk", 'test', 0)) {
2117 warn "Test3 u1 failed";
2122 warn "Test3 u1: $@";
2126 if (PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$ctbase", 'test', 0)) {
2128 warn "Test3 v1 failed";
2133 warn "Test3 v1: $@";
2137 if (PVE
::Storage
::volume_has_feature
($cfg, 'copy', "$storagename:$ctbase\/$ctlinked", 'test', 0)) {
2139 warn "Test3 w1 failed";
2144 warn "Test3 w1: $@";
2148 if (PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$vmdisk", 'test', 0)) {
2150 warn "Test3 x1 failed";
2155 warn "Test3 x1: $@";
2159 if (PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$vmbase", 'test', 0)) {
2161 warn "Test3 y1 failed";
2166 warn "Test3 y1: $@";
2170 if (PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$vmbase\/$vmlinked", 'test', 0)) {
2172 warn "Test3 z1 failed";
2177 warn "Test3 z1: $@";
2181 if (PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$ctdisk", 'test', 0)) {
2183 warn "Test3 A1 failed";
2188 warn "Test3 A1: $@";
2192 if (PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$ctbase", 'test', 0)) {
2194 warn "Test3 B1 failed";
2199 warn "Test3 B1: $@";
2203 if (PVE
::Storage
::volume_has_feature
($cfg, 'sparseinit', "$storagename:$ctbase\/$ctlinked", 'test', 0)) {
2205 warn "Test3 C1 failed";
2210 warn "Test3 C1: $@";
2213 $tests->{3} = $test3;
2217 print "\nrun test2 \"volume_resize\"\n";
2218 my $newsize = ($volsize + 1) * 1024 * 1024 * 1024;
2221 if (($newsize/1024) !=
2222 PVE
::Storage
::volume_resize
($cfg, "$storagename:$vmdisk", $newsize, 0)) {
2224 warn "Test2 a failed";
2227 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$vmdisk")) {
2229 warn "Test2 a failed";
2238 warn "Test2 b failed" if ($newsize/1024) != PVE
::Storage
::volume_resize
($cfg, "$storagename:$vmbase", $newsize, 0);
2239 warn "Test2 b failed" if $newsize !=
2240 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$vmbase");
2248 if (($newsize/1024) != PVE
::Storage
::volume_resize
($cfg, "$storagename:$vmbase\/$vmlinked", $newsize, 0)) {
2250 warn "Test2 c failed";
2253 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$vmbase\/$vmlinked")) {
2255 warn "Test2 c failed";
2264 if (($newsize/1024) != PVE
::Storage
::volume_resize
($cfg, "$storagename:$ctdisk", $newsize, 0)) {
2266 warn "Test2 d failed";
2269 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$ctdisk")) {
2271 warn "Test2 d failed"
2280 if (($newsize/1024) !=
2281 PVE
::Storage
::volume_resize
($cfg, "$storagename:$ctbase", $newsize, 0)) {
2283 warn "Test2 e failed";
2286 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$ctbase")) {
2288 warn "Test2 e failed";
2297 if (($newsize/1024) !=
2298 PVE
::Storage
::volume_resize
($cfg, "$storagename:$ctbase\/$ctlinked", $newsize, 0)) {
2300 warn "Test2 f failed";
2303 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$ctbase\/$ctlinked")) {
2305 warn "Test2 f failed";
2313 $tests->{2} = $test2;
2317 print "\nrun test1 \"volume_size_info\"\n";
2318 my $size = ($volsize * 1024 * 1024 * 1024);
2321 if ($size != PVE
::Storage
::volume_size_info
($cfg, "$storagename:$vmdisk")) {
2323 warn "Test1 a failed";
2328 warn "Test1 a : $@";
2332 if ($size != PVE
::Storage
::volume_size_info
($cfg, "$storagename:$vmbase")) {
2334 warn "Test1 b failed";
2340 warn "Test1 b : $@";
2345 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$vmbase\/$vmlinked")) {
2347 warn "Test1 c failed";
2352 warn "Test1 c : $@";
2357 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$ctdisk")) {
2359 warn "Test1 d failed";
2364 warn "Test1 d : $@";
2369 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$ctbase")) {
2371 warn "Test1 e failed";
2376 warn "Test1 e : $@";
2381 PVE
::Storage
::volume_size_info
($cfg, "$storagename:$vmbase\/$vmlinked")) {
2383 warn "Test1 f failed"
2388 warn "Test1 f : $@";
2392 $tests->{1} = $test1;
2399 print "create zvol $vmdisk\n" if $verbose;
2400 run_command
("zfs create -V${volsize}G $zpath\/$vmdisk");
2402 print "create zvol $vmbase\n" if $verbose;
2403 run_command
("zfs create -V${volsize}G $zpath\/$vmbase");
2404 run_command
("zfs snapshot $zpath\/$vmbase$basesnap");
2406 print "create linked clone $vmlinked\n" if $verbose;
2407 run_command
("zfs clone $zpath\/$vmbase$basesnap $zpath\/$vmlinked");
2410 print "create subvol $ctdisk\n" if $verbose;
2411 run_command
("zfs create -o refquota=${volsize}G $zpath\/$ctdisk");
2413 print "create subvol $vmbase\n" if $verbose;
2414 run_command
("zfs create -o refquota=${volsize}G $zpath\/$ctbase");
2415 run_command
("zfs snapshot $zpath\/$ctbase$basesnap");
2417 print "create linked clone $vmlinked\n" if $verbose;
2418 run_command
("zfs clone $zpath\/$ctbase$basesnap $zpath\/$ctlinked -o refquota=${volsize}G");
2423 print "destroy $pool\/$subvol\n" if $verbose;
2424 run_command
("zfs destroy $zpath -r");
2430 run_command
("dd if=/dev/zero of=zpool.img bs=1M count=8000 ");
2437 run_command
("zpool create $subvol $pwd\/zpool.img");
2444 sub clean_up_zpool
{
2447 run_command
("zpool destroy $subvol");
2457 print "Start tests for ZFSPoolPlugin\n";
2469 'order' => {'zfstank99' => 1,}
2474 for (my $i = 1; $i <= $testnum; $i++) {
2486 $time = time - $time;
2488 print "Stop tests for ZFSPoolPlugin\n";
2489 print "$count tests failed\n";
2490 print "Time: ${time}s\n";