public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Max R. Carrara" <m.carrara@proxmox.com>
To: pve-devel@lists.proxmox.com
Cc: Wolfgang Bumiller <w.bumiller@proxmox.com>
Subject: [PATCH pve-storage v3 32/51] test: list volumes: remove legacy code and migrate cases to new format
Date: Tue, 17 Nov 2026 21:39:04 +0100	[thread overview]
Message-ID: <20261117203953.913035-33-m.carrara@proxmox.com> (raw)
In-Reply-To: <20261117203953.913035-1-m.carrara@proxmox.com>

Remove all that remains of the old testing code, including the
constants defined with the `use constant` pragma and other old
variables.

Migrate all remaining test cases over to the new format.

Signed-off-by: Max R. Carrara <m.carrara@proxmox.com>
---
 src/test/list_volumes_test.pm | 1390 ++++++++++++++++++---------------
 1 file changed, 777 insertions(+), 613 deletions(-)

diff --git a/src/test/list_volumes_test.pm b/src/test/list_volumes_test.pm
index 1a4bae7c..65fc7629 100644
--- a/src/test/list_volumes_test.pm
+++ b/src/test/list_volumes_test.pm
@@ -17,14 +17,10 @@ use File::Basename qw(fileparse);
 use File::Path qw(make_path remove_tree);
 use File::stat qw();
 use File::Temp;
 use Storable qw(dclone);
 
-use constant DEFAULT_SIZE => 131072; # 128 kiB
-use constant DEFAULT_USED => 262144; # 256 kiB
-use constant DEFAULT_CTIME => 1234567890;
-
 my $DEFAULT_SIZE = 128 * 1024; # 128 kiB
 my $DEFAULT_USED = 256 * 1024; # 256 kiB
 my $DEFAULT_CTIME = 1234567890;
 
 # get_vmlist() return values
@@ -62,26 +58,10 @@ my $mocked_vmlist = {
             'version' => 6,
         },
     },
 };
 
-my $storage_dir = File::Temp->newdir();
-my $scfg = {
-    'type' => 'dir',
-    'path' => $storage_dir,
-    'shared' => 0,
-    'content' => {
-        'iso' => 1,
-        'rootdir' => 1,
-        'vztmpl' => 1,
-        'images' => 1,
-        'snippets' => 1,
-        'backup' => 1,
-        'import' => 1,
-    },
-};
-
 my $DEFAULT_STOREID = 'local';
 my $DEFAULT_STORAGE_PATH = File::Temp->newdir();
 my $DEFAULT_SCFG = {
     type => 'dir',
     path => $DEFAULT_STORAGE_PATH,
@@ -97,549 +77,10 @@ my $DEFAULT_SCFG = {
     },
 };
 
 my @BACKING_FILE_SUFFIXES = ('qcow2', 'raw', 'vmdk', 'vhdx');
 
-# The test cases are comprised of an arry of hashes with the following keys:
-# description => displayed on error by Test::More
-# vmid        => used for image matches by list_volume
-# files       => array of files for qemu-img to create
-# expected    => returned result hash
-#                (content, ctime, format, parent, size, used, vimd, volid)
-my @tests = (
-    {
-        description => 'VMID: 16112, lxc, raw, backup',
-        vmid => '16112',
-        files => [
-            "$storage_dir/images/16112/vm-16112-disk-0.raw",
-            "$storage_dir/dump/vzdump-lxc-16112-2020_03_30-21_39_30.tar.lzo",
-            "$storage_dir/dump/vzdump-lxc-16112-2020_03_30-21_49_30.tar.gz",
-            "$storage_dir/dump/vzdump-lxc-16112-2020_03_30-21_49_30.tar.zst",
-            "$storage_dir/dump/vzdump-lxc-16112-2020_03_30-21_59_30.tgz",
-            "$storage_dir/dump/vzdump-openvz-16112-2020_03_30-21_39_30.tar.bz2",
-        ],
-        expected => [
-            {
-                'content' => 'rootdir',
-                'ctime' => DEFAULT_CTIME,
-                'format' => 'raw',
-                'parent' => undef,
-                'size' => DEFAULT_SIZE,
-                'used' => DEFAULT_USED,
-                'vmid' => '16112',
-                'volid' => 'local:16112/vm-16112-disk-0.raw',
-            },
-            {
-                'content' => 'backup',
-                'ctime' => 1585604370,
-                'format' => 'tar.lzo',
-                'size' => DEFAULT_SIZE,
-                'subtype' => 'lxc',
-                'vmid' => '16112',
-                'volid' => 'local:backup/vzdump-lxc-16112-2020_03_30-21_39_30.tar.lzo',
-            },
-            {
-                'content' => 'backup',
-                'ctime' => 1585604970,
-                'format' => 'tar.gz',
-                'size' => DEFAULT_SIZE,
-                'subtype' => 'lxc',
-                'vmid' => '16112',
-                'volid' => 'local:backup/vzdump-lxc-16112-2020_03_30-21_49_30.tar.gz',
-            },
-            {
-                'content' => 'backup',
-                'ctime' => 1585604970,
-                'format' => 'tar.zst',
-                'size' => DEFAULT_SIZE,
-                'subtype' => 'lxc',
-                'vmid' => '16112',
-                'volid' => 'local:backup/vzdump-lxc-16112-2020_03_30-21_49_30.tar.zst',
-            },
-            {
-                'content' => 'backup',
-                'ctime' => 1585605570,
-                'format' => 'tgz',
-                'size' => DEFAULT_SIZE,
-                'subtype' => 'lxc',
-                'vmid' => '16112',
-                'volid' => 'local:backup/vzdump-lxc-16112-2020_03_30-21_59_30.tgz',
-            },
-            {
-                'content' => 'backup',
-                'ctime' => 1585604370,
-                'format' => 'tar.bz2',
-                'size' => DEFAULT_SIZE,
-                'subtype' => 'openvz',
-                'vmid' => '16112',
-                'volid' => 'local:backup/vzdump-openvz-16112-2020_03_30-21_39_30.tar.bz2',
-            },
-        ],
-    },
-    {
-        description => 'VMID: 16116, no guest, subvol and raw',
-        vmid => '16116',
-        files => [
-            "$storage_dir/images/16116/subvol-16116-disk-0.subvol/",
-            "$storage_dir/images/16116/vm-16116-disk-1.raw",
-        ],
-        expected => [
-            {
-                'content' => 'rootdir',
-                'ctime' => DEFAULT_CTIME,
-                'format' => 'subvol',
-                'parent' => undef,
-                'size' => DEFAULT_SIZE,
-                'used' => DEFAULT_USED,
-                'vmid' => '16116',
-                'volid' => 'local:16116/subvol-16116-disk-0.subvol',
-            },
-            {
-                'content' => 'images',
-                'ctime' => DEFAULT_CTIME,
-                'format' => 'raw',
-                'parent' => undef,
-                'size' => DEFAULT_SIZE,
-                'used' => DEFAULT_USED,
-                'vmid' => '16116',
-                'volid' => 'local:16116/vm-16116-disk-1.raw',
-            },
-        ],
-    },
-    {
-        description => 'VMID: 16114, VM, qcow2, linked clone',
-        vmid => '16114',
-        files => [
-            "$storage_dir/images/16114/vm-16114-disk-0.qcow2",
-            "$storage_dir/images/16114/vm-16114-disk-1.qcow2",
-        ],
-        parent => [
-            "../9004/base-9004-disk-0.qcow2", "../9004/base-9004-disk-1.qcow2",
-        ],
-        expected => [
-            {
-                'content' => 'images',
-                'ctime' => DEFAULT_CTIME,
-                'format' => 'qcow2',
-                'parent' => '../9004/base-9004-disk-0.qcow2',
-                'size' => DEFAULT_SIZE,
-                'used' => DEFAULT_USED,
-                'vmid' => '16114',
-                'volid' => 'local:9004/base-9004-disk-0.qcow2/16114/vm-16114-disk-0.qcow2',
-            },
-            {
-                'content' => 'images',
-                'ctime' => DEFAULT_CTIME,
-                'format' => 'qcow2',
-                'parent' => '../9004/base-9004-disk-1.qcow2',
-                'size' => DEFAULT_SIZE,
-                'used' => DEFAULT_USED,
-                'vmid' => '16114',
-                'volid' => 'local:9004/base-9004-disk-1.qcow2/16114/vm-16114-disk-1.qcow2',
-            },
-        ],
-    },
-    {
-        description => 'VMID: 16110, renamed backups',
-        vmid => '16110',
-        files => [
-            "$storage_dir/dump/vzdump-qemu-16110-2020_03_30-21_11_40.vma.gz",
-            "$storage_dir/dump/vzdump-qemu-16110-before-upgrade.vma.zst",
-            "$storage_dir/dump/vzdump-qemu-16111-before-16110-upgrade.vma.zst",
-            "$storage_dir/dump/vzdump-16110-renamed.tar.zst",
-            "$storage_dir/dump/backup-16110-manual.vma",
-        ],
-        expected => [
-            {
-                'content' => 'backup',
-                'ctime' => 1585602700,
-                'format' => 'vma.gz',
-                'size' => DEFAULT_SIZE,
-                'subtype' => 'qemu',
-                'vmid' => '16110',
-                'volid' => 'local:backup/vzdump-qemu-16110-2020_03_30-21_11_40.vma.gz',
-            },
-            {
-                'content' => 'backup',
-                'ctime' => DEFAULT_CTIME,
-                'format' => 'vma.zst',
-                'size' => DEFAULT_SIZE,
-                'subtype' => 'qemu',
-                'vmid' => '16110',
-                'volid' => 'local:backup/vzdump-qemu-16110-before-upgrade.vma.zst',
-            },
-        ],
-    },
-    {
-        description => 'VMID: 9004, VM, template, qcow2',
-        vmid => '9004',
-        files => [
-            "$storage_dir/images/9004/base-9004-disk-0.qcow2",
-            "$storage_dir/images/9004/base-9004-disk-1.qcow2",
-        ],
-        expected => [
-            {
-                'content' => 'images',
-                'ctime' => DEFAULT_CTIME,
-                'format' => 'qcow2',
-                'parent' => undef,
-                'size' => DEFAULT_SIZE,
-                'used' => DEFAULT_USED,
-                'vmid' => '9004',
-                'volid' => 'local:9004/base-9004-disk-0.qcow2',
-            },
-            {
-                'content' => 'images',
-                'ctime' => DEFAULT_CTIME,
-                'format' => 'qcow2',
-                'parent' => undef,
-                'size' => DEFAULT_SIZE,
-                'used' => DEFAULT_USED,
-                'vmid' => '9004',
-                'volid' => 'local:9004/base-9004-disk-1.qcow2',
-            },
-        ],
-    },
-    {
-        description => 'VMID: none, templates, snippets, backup',
-        vmid => undef,
-        files => [
-            "$storage_dir/dump/vzdump-lxc-19253-2020_02_03-19_57_43.tar.gz",
-            "$storage_dir/dump/vzdump-lxc-19254-2019_01_21-19_29_19.tar",
-            "$storage_dir/template/iso/archlinux-2020.02.01-x86_64.iso",
-            "$storage_dir/template/iso/debian-8.11.1-amd64-DVD-1.iso",
-            "$storage_dir/template/iso/debian-9.12.0-amd64-netinst.iso",
-            "$storage_dir/template/iso/proxmox-ve_6.1-1.iso",
-            "$storage_dir/template/cache/archlinux-base_20190924-1_amd64.tar.gz",
-            "$storage_dir/template/cache/debian-10.0-standard_10.0-1_amd64.tar.gz",
-            "$storage_dir/template/cache/debian-11.0-standard_11.0-1_amd64.tar.bz2",
-            "$storage_dir/template/cache/alpine-3.10-default_20190626_amd64.tar.xz",
-            "$storage_dir/snippets/userconfig.yaml",
-            "$storage_dir/snippets/hookscript.pl",
-            "$storage_dir/private/1234/", # fileparse needs / at the end
-            "$storage_dir/private/1234/subvol-1234-disk-0.subvol/", # fileparse needs / at the end
-        ],
-        expected => [
-            {
-                'content' => 'vztmpl',
-                'ctime' => DEFAULT_CTIME,
-                'format' => 'txz',
-                'size' => DEFAULT_SIZE,
-                'volid' => 'local:vztmpl/alpine-3.10-default_20190626_amd64.tar.xz',
-            },
-            {
-                'content' => 'vztmpl',
-                'ctime' => DEFAULT_CTIME,
-                'format' => 'tgz',
-                'size' => DEFAULT_SIZE,
-                'volid' => 'local:vztmpl/archlinux-base_20190924-1_amd64.tar.gz',
-            },
-            {
-                'content' => 'vztmpl',
-                'ctime' => DEFAULT_CTIME,
-                'format' => 'tgz',
-                'size' => DEFAULT_SIZE,
-                'volid' => 'local:vztmpl/debian-10.0-standard_10.0-1_amd64.tar.gz',
-            },
-            {
-                'content' => 'vztmpl',
-                'ctime' => DEFAULT_CTIME,
-                'format' => 'tbz2',
-                'size' => DEFAULT_SIZE,
-                'volid' => 'local:vztmpl/debian-11.0-standard_11.0-1_amd64.tar.bz2',
-            },
-            {
-                'content' => 'iso',
-                'ctime' => DEFAULT_CTIME,
-                'format' => 'iso',
-                'size' => DEFAULT_SIZE,
-                'volid' => 'local:iso/archlinux-2020.02.01-x86_64.iso',
-            },
-            {
-                'content' => 'iso',
-                'ctime' => DEFAULT_CTIME,
-                'format' => 'iso',
-                'size' => DEFAULT_SIZE,
-                'volid' => 'local:iso/debian-8.11.1-amd64-DVD-1.iso',
-            },
-            {
-                'content' => 'iso',
-                'ctime' => DEFAULT_CTIME,
-                'format' => 'iso',
-                'size' => DEFAULT_SIZE,
-                'volid' => 'local:iso/debian-9.12.0-amd64-netinst.iso',
-            },
-            {
-                'content' => 'iso',
-                'ctime' => DEFAULT_CTIME,
-                'format' => 'iso',
-                'size' => DEFAULT_SIZE,
-                'volid' => 'local:iso/proxmox-ve_6.1-1.iso',
-            },
-            {
-                'content' => 'backup',
-                'ctime' => 1580759863,
-                'format' => 'tar.gz',
-                'size' => DEFAULT_SIZE,
-                'subtype' => 'lxc',
-                'vmid' => '19253',
-                'volid' => 'local:backup/vzdump-lxc-19253-2020_02_03-19_57_43.tar.gz',
-            },
-            {
-                'content' => 'backup',
-                'ctime' => 1548098959,
-                'format' => 'tar',
-                'size' => DEFAULT_SIZE,
-                'subtype' => 'lxc',
-                'vmid' => '19254',
-                'volid' => 'local:backup/vzdump-lxc-19254-2019_01_21-19_29_19.tar',
-            },
-            {
-                'content' => 'snippets',
-                'ctime' => DEFAULT_CTIME,
-                'format' => 'snippet',
-                'size' => DEFAULT_SIZE,
-                'volid' => 'local:snippets/hookscript.pl',
-            },
-            {
-                'content' => 'snippets',
-                'ctime' => DEFAULT_CTIME,
-                'format' => 'snippet',
-                'size' => DEFAULT_SIZE,
-                'volid' => 'local:snippets/userconfig.yaml',
-            },
-        ],
-    },
-    {
-        description => 'VMID: none, parent, non-matching',
-        # string instead of vmid in folder
-        #"$storage_dir/images/ssss/base-4321-disk-0.qcow2/1234/vm-1234-disk-0.qcow2",
-        vmid => undef,
-        files => [
-            "$storage_dir/images/1234/vm-1234-disk-0.qcow2",
-        ],
-        parent => [
-            "../ssss/base-4321-disk-0.qcow2",
-        ],
-        expected => [
-            {
-                'content' => 'images',
-                'ctime' => DEFAULT_CTIME,
-                'format' => 'qcow2',
-                'parent' => '../ssss/base-4321-disk-0.qcow2',
-                'size' => DEFAULT_SIZE,
-                'used' => DEFAULT_USED,
-                'vmid' => '1234',
-                'volid' => 'local:1234/vm-1234-disk-0.qcow2',
-            },
-        ],
-    },
-    {
-        description => 'VMID: none, non-matching',
-        # failed matches
-        vmid => undef,
-        files => [
-            "$storage_dir/images/ssss/base-4321-disk-0.raw",
-            "$storage_dir/images/ssss/vm-1234-disk-0.qcow2",
-            "$storage_dir/template/iso/yet-again-a-installation-disk.dvd",
-            "$storage_dir/template/cache/debian-10.0-standard_10.0-1_amd64.zip.gz",
-            "$storage_dir/private/subvol-19254-disk-0/19254",
-            "$storage_dir/dump/vzdump-openvz-16112-2020_03_30-21_39_30.zip.gz",
-            "$storage_dir/dump/vzdump-openvz-16112-2020_03_30-21_39_30.tgz.lzo",
-            "$storage_dir/dump/vzdump-qemu-16110-2020_03_30-21_12_40.vma.xz",
-            "$storage_dir/dump/vzdump-qemu-16110-2020_03_30-21_12_40.vms.gz",
-        ],
-        expected => [], # returns empty list
-    },
-    {
-        description => 'VMID: none, names with a newline',
-        vmid => undef,
-        files => [
-            "$storage_dir/template/iso/debian-9.12.0-amd64-netinst.iso",
-            "$storage_dir/template/iso/debian-9.12.0\namd64-netinst.iso",
-            "$storage_dir/template/iso/debian-9.12.0-amd64-netinst.iso\n",
-            "$storage_dir/dump/vzdump-qemu-16110-before\nupgrade.vma",
-            "$storage_dir/dump/vzdump-qemu-16110-2020_03_30-21_12_40.vma.gz\n",
-            "$storage_dir/snippets/hook\nscript.pl",
-        ],
-        expected => [
-            {
-                'content' => 'iso',
-                'ctime' => DEFAULT_CTIME,
-                'format' => 'iso',
-                'size' => DEFAULT_SIZE,
-                'volid' => 'local:iso/debian-9.12.0-amd64-netinst.iso',
-            },
-        ],
-    },
-    {
-        description => 'VMID: none, valid file names for import',
-        vmid => undef,
-        files => [
-            "$storage_dir/import/import.ova",
-            "$storage_dir/import/import.ovf",
-            "$storage_dir/import/some-disk.qcow2",
-            "$storage_dir/import/some-disk.vmdk",
-            "$storage_dir/import/some-raw-disk.raw",
-        ],
-        expected => [
-            {
-                content => 'import',
-                ctime => DEFAULT_CTIME,
-                format => 'ova',
-                size => DEFAULT_SIZE,
-                volid => "local:import/import.ova",
-            },
-            {
-                content => 'import',
-                ctime => DEFAULT_CTIME,
-                format => 'ovf',
-                size => DEFAULT_SIZE,
-                volid => "local:import/import.ovf",
-            },
-            {
-                content => 'import',
-                ctime => DEFAULT_CTIME,
-                format => 'qcow2',
-                size => DEFAULT_SIZE,
-                volid => "local:import/some-disk.qcow2",
-            },
-            {
-                content => 'import',
-                ctime => DEFAULT_CTIME,
-                format => 'vmdk',
-                size => DEFAULT_SIZE,
-                volid => "local:import/some-disk.vmdk",
-            },
-            {
-                content => 'import',
-                ctime => DEFAULT_CTIME,
-                format => 'raw',
-                size => DEFAULT_SIZE,
-                volid => "local:import/some-raw-disk.raw",
-            },
-        ],
-    },
-    {
-        description => 'VMID: none, non-matching file paths for import',
-        vmid => undef,
-        files => [
-            # Malformed file names
-            "$storage_dir/import/import.ovff",
-            "$storage_dir/import/importova",
-            "$storage_dir/import/import.ov",
-            "$storage_dir/import/diskraw",
-            "$storage_dir/import/diskvmdk",
-            "$storage_dir/import/disk.invalid",
-            "$storage_dir/import/.ova",
-            "$storage_dir/import/.raw",
-            # Trailing whitespace must not be trimmed
-            "$storage_dir/import/import.ova\t",
-            "$storage_dir/import/disk.raw    ",
-            # Whitespace in file name
-            "$storage_dir/import/something I want to import.ova",
-            "$storage_dir/import/ .raw",
-            "$storage_dir/import/ disk .vmdk",
-            "$storage_dir/import/disk .qcow2",
-            "$storage_dir/import/ import.ova",
-            # Unsafe characters in file name
-            "$storage_dir/import/linux🐧-vm.ova",
-            "$storage_dir/import/🐪perl-playground🐪.ova",
-            "$storage_dir/import/fish_<><_<><_<><.ova",
-            $storage_dir . '/import/C:\\\\Windows\\Path.ova',
-            # Content inside .ova files may only be specified as part
-            # of volume names, and may never appear when looked up as
-            # a file path
-            "$storage_dir/import/import.ova/disk.qcow2",
-            "$storage_dir/import/import.ova/disk.raw",
-            "$storage_dir/import/import.ova/disk.vmdk",
-            "$storage_dir/import/import.ova/disk.invalid",
-        ],
-        expected => [], # returns empty list
-    },
-    {
-        description => 'VMID: none, weird but valid file names for import',
-        vmid => undef,
-        files => [
-            "$storage_dir/import/import.ova.ova",
-            "$storage_dir/import/import.ova.ova.ova",
-            "$storage_dir/import/import.ova.ova.ova.ova",
-            "$storage_dir/import/ova.ova",
-            "$storage_dir/import/ova.ovf",
-            "$storage_dir/import/ova.vmdk",
-            "$storage_dir/import/raw.raw.qcow2",
-            "$storage_dir/import/raw.raw.qcow2.import.qcow2",
-            "$storage_dir/import/raw.raw.raw.your-boat.ova",
-        ],
-        expected => [
-            {
-                content => 'import',
-                ctime => DEFAULT_CTIME,
-                format => 'ova',
-                size => DEFAULT_SIZE,
-                volid => "local:import/import.ova.ova",
-            },
-            {
-                content => 'import',
-                ctime => DEFAULT_CTIME,
-                format => 'ova',
-                size => DEFAULT_SIZE,
-                volid => "local:import/import.ova.ova.ova",
-            },
-            {
-                content => 'import',
-                ctime => DEFAULT_CTIME,
-                format => 'ova',
-                size => DEFAULT_SIZE,
-                volid => "local:import/import.ova.ova.ova.ova",
-            },
-            {
-                content => 'import',
-                ctime => DEFAULT_CTIME,
-                format => 'ova',
-                size => DEFAULT_SIZE,
-                volid => "local:import/ova.ova",
-            },
-            {
-                content => 'import',
-                ctime => DEFAULT_CTIME,
-                format => 'ovf',
-                size => DEFAULT_SIZE,
-                volid => "local:import/ova.ovf",
-            },
-            {
-                content => 'import',
-                ctime => DEFAULT_CTIME,
-                format => 'vmdk',
-                size => DEFAULT_SIZE,
-                volid => "local:import/ova.vmdk",
-            },
-            {
-                content => 'import',
-                ctime => DEFAULT_CTIME,
-                format => 'qcow2',
-                size => DEFAULT_SIZE,
-                volid => "local:import/raw.raw.qcow2",
-            },
-            {
-                content => 'import',
-                ctime => DEFAULT_CTIME,
-                format => 'qcow2',
-                size => DEFAULT_SIZE,
-                volid => "local:import/raw.raw.qcow2.import.qcow2",
-            },
-            {
-                content => 'import',
-                ctime => DEFAULT_CTIME,
-                format => 'ova',
-                size => DEFAULT_SIZE,
-                volid => "local:import/raw.raw.raw.your-boat.ova",
-            },
-        ],
-    },
-);
-
 =head2 TEST CASE FORMAT
 
 The parameters for individual test cases are hashes with the following
 keys:
 
@@ -817,24 +258,796 @@ my $test_param_list = [
                     volid => 'local:snippets/userconfig.yaml',
                 },
             },
         ],
     },
+    {
+        description => 'VMID: 16112, lxc, raw, backup',
+        storeid => $DEFAULT_STOREID,
+        scfg => $DEFAULT_SCFG,
+        vmid => 16112,
+        vtypes => ['rootdir', 'backup'],
+        cases => [
+            {
+                file => "$DEFAULT_STORAGE_PATH/images/16112/vm-16112-disk-0.raw",
+                expected => {
+                    content => 'rootdir',
+                    ctime => $DEFAULT_CTIME,
+                    format => 'raw',
+                    parent => undef,
+                    size => $DEFAULT_SIZE,
+                    used => $DEFAULT_USED,
+                    vmid => '16112',
+                    volid => 'local:16112/vm-16112-disk-0.raw',
+                },
+            },
+            {
+                file =>
+                    "$DEFAULT_STORAGE_PATH/dump/vzdump-lxc-16112-2020_03_30-21_39_30.tar.lzo",
+                expected => {
+                    content => 'backup',
+                    ctime => 1585604370,
+                    format => 'tar.lzo',
+                    size => $DEFAULT_SIZE,
+                    subtype => 'lxc',
+                    vmid => '16112',
+                    volid => 'local:backup/vzdump-lxc-16112-2020_03_30-21_39_30.tar.lzo',
+                },
+            },
+            {
+                file =>
+                    "$DEFAULT_STORAGE_PATH/dump/vzdump-lxc-16112-2020_03_30-21_49_30.tar.gz",
+                expected => {
+                    content => 'backup',
+                    ctime => 1585604970,
+                    format => 'tar.gz',
+                    size => $DEFAULT_SIZE,
+                    subtype => 'lxc',
+                    vmid => '16112',
+                    volid => 'local:backup/vzdump-lxc-16112-2020_03_30-21_49_30.tar.gz',
+                },
+            },
+            {
+                file =>
+                    "$DEFAULT_STORAGE_PATH/dump/vzdump-lxc-16112-2020_03_30-21_49_30.tar.zst",
+                expected => {
+                    content => 'backup',
+                    ctime => 1585604970,
+                    format => 'tar.zst',
+                    size => $DEFAULT_SIZE,
+                    subtype => 'lxc',
+                    vmid => '16112',
+                    volid => 'local:backup/vzdump-lxc-16112-2020_03_30-21_49_30.tar.zst',
+                },
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/dump/vzdump-lxc-16112-2020_03_30-21_59_30.tgz",
+                expected => {
+                    content => 'backup',
+                    ctime => 1585605570,
+                    format => 'tgz',
+                    size => $DEFAULT_SIZE,
+                    subtype => 'lxc',
+                    vmid => '16112',
+                    volid => 'local:backup/vzdump-lxc-16112-2020_03_30-21_59_30.tgz',
+                },
+            },
+            {
+                file =>
+                    "$DEFAULT_STORAGE_PATH/dump/vzdump-openvz-16112-2020_03_30-21_39_30.tar.bz2",
+                expected => {
+                    content => 'backup',
+                    ctime => 1585604370,
+                    format => 'tar.bz2',
+                    size => $DEFAULT_SIZE,
+                    subtype => 'openvz',
+                    vmid => '16112',
+                    volid => 'local:backup/vzdump-openvz-16112-2020_03_30-21_39_30.tar.bz2',
+                },
+            },
+        ],
+    },
+    {
+        description => 'VMID: 16116, no guest, subvol and raw',
+        vmid => '16116',
+        storeid => $DEFAULT_STOREID,
+        scfg => $DEFAULT_SCFG,
+        vmid => 16116,
+        vtypes => ['images', 'rootdir'],
+        cases => [
+            {
+                file => "$DEFAULT_STORAGE_PATH/images/16116/subvol-16116-disk-0.subvol/",
+                expected => {
+                    content => 'rootdir',
+                    ctime => $DEFAULT_CTIME,
+                    format => 'subvol',
+                    parent => undef,
+                    size => $DEFAULT_SIZE,
+                    used => $DEFAULT_USED,
+                    vmid => '16116',
+                    volid => 'local:16116/subvol-16116-disk-0.subvol',
+                },
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/images/16116/vm-16116-disk-1.raw",
+                expected => {
+                    content => 'images',
+                    ctime => $DEFAULT_CTIME,
+                    format => 'raw',
+                    parent => undef,
+                    size => $DEFAULT_SIZE,
+                    used => $DEFAULT_USED,
+                    vmid => '16116',
+                    volid => 'local:16116/vm-16116-disk-1.raw',
+                },
+            },
+        ],
+    },
+    {
+        description => 'VMID: 16114, VM, qcow2, linked clone',
+        storeid => $DEFAULT_STOREID,
+        scfg => $DEFAULT_SCFG,
+        vmid => 16114,
+        vtypes => ['images'],
+        cases => [
+            {
+                file => "$DEFAULT_STORAGE_PATH/images/16114/vm-16114-disk-0.qcow2",
+                parent => '../9004/base-9004-disk-0.qcow2',
+                expected => {
+                    content => 'images',
+                    ctime => $DEFAULT_CTIME,
+                    format => 'qcow2',
+                    parent => '../9004/base-9004-disk-0.qcow2',
+                    size => $DEFAULT_SIZE,
+                    used => $DEFAULT_USED,
+                    vmid => '16114',
+                    volid => 'local:9004/base-9004-disk-0.qcow2/16114/vm-16114-disk-0.qcow2',
+                },
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/images/16114/vm-16114-disk-1.qcow2",
+                parent => '../9004/base-9004-disk-1.qcow2',
+                expected => {
+                    content => 'images',
+                    ctime => $DEFAULT_CTIME,
+                    format => 'qcow2',
+                    parent => '../9004/base-9004-disk-1.qcow2',
+                    size => $DEFAULT_SIZE,
+                    used => $DEFAULT_USED,
+                    vmid => '16114',
+                    volid => 'local:9004/base-9004-disk-1.qcow2/16114/vm-16114-disk-1.qcow2',
+                },
+            },
+        ],
+    },
+    {
+        description => 'VMID: 9004, VM, template, qcow2',
+        storeid => $DEFAULT_STOREID,
+        scfg => $DEFAULT_SCFG,
+        vmid => 9004,
+        vtypes => ['images'],
+        cases => [
+            {
+                file => "$DEFAULT_STORAGE_PATH/images/9004/base-9004-disk-0.qcow2",
+                expected => {
+                    content => 'images',
+                    ctime => $DEFAULT_CTIME,
+                    format => 'qcow2',
+                    parent => undef,
+                    size => $DEFAULT_SIZE,
+                    used => $DEFAULT_USED,
+                    vmid => '9004',
+                    volid => 'local:9004/base-9004-disk-0.qcow2',
+                },
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/images/9004/base-9004-disk-1.qcow2",
+                expected => {
+                    content => 'images',
+                    ctime => $DEFAULT_CTIME,
+                    format => 'qcow2',
+                    parent => undef,
+                    size => $DEFAULT_SIZE,
+                    used => $DEFAULT_USED,
+                    vmid => '9004',
+                    volid => 'local:9004/base-9004-disk-1.qcow2',
+                },
+            },
+        ],
+    },
+    {
+        description => 'VMID: none, templates, snippets, backup',
+        storeid => $DEFAULT_STOREID,
+        scfg => $DEFAULT_SCFG,
+        vmid => undef,
+        vtypes => ['vztmpl', 'iso', 'backup', 'snippets'],
+        cases => [
+            {
+                file =>
+                    "$DEFAULT_STORAGE_PATH/template/cache/alpine-3.10-default_20190626_amd64.tar.xz",
+                expected => {
+                    content => 'vztmpl',
+                    ctime => $DEFAULT_CTIME,
+                    format => 'txz',
+                    size => $DEFAULT_SIZE,
+                    volid => 'local:vztmpl/alpine-3.10-default_20190626_amd64.tar.xz',
+                },
+            },
+            {
+                file =>
+                    "$DEFAULT_STORAGE_PATH/template/cache/archlinux-base_20190924-1_amd64.tar.gz",
+                expected => {
+                    content => 'vztmpl',
+                    ctime => $DEFAULT_CTIME,
+                    format => 'tgz',
+                    size => $DEFAULT_SIZE,
+                    volid => 'local:vztmpl/archlinux-base_20190924-1_amd64.tar.gz',
+                },
+            },
+            {
+                file =>
+                    "$DEFAULT_STORAGE_PATH/template/cache/debian-10.0-standard_10.0-1_amd64.tar.gz",
+                expected => {
+                    content => 'vztmpl',
+                    ctime => $DEFAULT_CTIME,
+                    format => 'tgz',
+                    size => $DEFAULT_SIZE,
+                    volid => 'local:vztmpl/debian-10.0-standard_10.0-1_amd64.tar.gz',
+                },
+            },
+            {
+                file =>
+                    "$DEFAULT_STORAGE_PATH/template/cache/debian-11.0-standard_11.0-1_amd64.tar.bz2",
+                expected => {
+                    content => 'vztmpl',
+                    ctime => $DEFAULT_CTIME,
+                    format => 'tbz2',
+                    size => $DEFAULT_SIZE,
+                    volid => 'local:vztmpl/debian-11.0-standard_11.0-1_amd64.tar.bz2',
+                },
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/template/iso/archlinux-2020.02.01-x86_64.iso",
+                expected => {
+                    content => 'iso',
+                    ctime => $DEFAULT_CTIME,
+                    format => 'iso',
+                    size => $DEFAULT_SIZE,
+                    volid => 'local:iso/archlinux-2020.02.01-x86_64.iso',
+                },
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/template/iso/debian-8.11.1-amd64-DVD-1.iso",
+                expected => {
+                    content => 'iso',
+                    ctime => $DEFAULT_CTIME,
+                    format => 'iso',
+                    size => $DEFAULT_SIZE,
+                    volid => 'local:iso/debian-8.11.1-amd64-DVD-1.iso',
+                },
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/template/iso/debian-9.12.0-amd64-netinst.iso",
+                expected => {
+                    content => 'iso',
+                    ctime => $DEFAULT_CTIME,
+                    format => 'iso',
+                    size => $DEFAULT_SIZE,
+                    volid => 'local:iso/debian-9.12.0-amd64-netinst.iso',
+                },
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/template/iso/proxmox-ve_6.1-1.iso",
+                expected => {
+                    content => 'iso',
+                    ctime => $DEFAULT_CTIME,
+                    format => 'iso',
+                    size => $DEFAULT_SIZE,
+                    volid => 'local:iso/proxmox-ve_6.1-1.iso',
+                },
+            },
+            {
+                file =>
+                    "$DEFAULT_STORAGE_PATH/dump/vzdump-lxc-19253-2020_02_03-19_57_43.tar.gz",
+                expected => {
+                    content => 'backup',
+                    ctime => 1580759863,
+                    format => 'tar.gz',
+                    size => $DEFAULT_SIZE,
+                    subtype => 'lxc',
+                    vmid => '19253',
+                    volid => 'local:backup/vzdump-lxc-19253-2020_02_03-19_57_43.tar.gz',
+                },
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/dump/vzdump-lxc-19254-2019_01_21-19_29_19.tar",
+                expected => {
+                    content => 'backup',
+                    ctime => 1548098959,
+                    format => 'tar',
+                    size => $DEFAULT_SIZE,
+                    subtype => 'lxc',
+                    vmid => '19254',
+                    volid => 'local:backup/vzdump-lxc-19254-2019_01_21-19_29_19.tar',
+                },
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/snippets/hookscript.pl",
+                expected => {
+                    content => 'snippets',
+                    ctime => $DEFAULT_CTIME,
+                    format => 'snippet',
+                    size => $DEFAULT_SIZE,
+                    volid => 'local:snippets/hookscript.pl',
+                },
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/snippets/userconfig.yaml",
+                expected => {
+                    content => 'snippets',
+                    ctime => $DEFAULT_CTIME,
+                    format => 'snippet',
+                    size => $DEFAULT_SIZE,
+                    volid => 'local:snippets/userconfig.yaml',
+                },
+            },
+            {
+                # fileparse needs / at the end
+                file => "$DEFAULT_STORAGE_PATH/private/1234/",
+                expected => undef,
+            },
+            {
+                # fileparse needs / at the end
+                file => "$DEFAULT_STORAGE_PATH/private/1234/subvol-1234-disk-0.subvol/",
+                expected => undef,
+            },
+        ],
+    },
+    {
+        description => 'VMID: 16110, renamed backups',
+        storeid => $DEFAULT_STOREID,
+        scfg => $DEFAULT_SCFG,
+        vmid => 16110,
+        vtypes => [sort keys $DEFAULT_SCFG->{content}->%*],
+        cases => [
+            {
+                file =>
+                    "$DEFAULT_STORAGE_PATH/dump/vzdump-qemu-16110-2020_03_30-21_11_40.vma.gz",
+                expected => {
+                    content => 'backup',
+                    ctime => 1585602700,
+                    format => 'vma.gz',
+                    size => $DEFAULT_SIZE,
+                    subtype => 'qemu',
+                    vmid => '16110',
+                    volid => 'local:backup/vzdump-qemu-16110-2020_03_30-21_11_40.vma.gz',
+                },
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/dump/vzdump-qemu-16110-before-upgrade.vma.zst",
+                expected => {
+                    content => 'backup',
+                    ctime => $DEFAULT_CTIME,
+                    format => 'vma.zst',
+                    size => $DEFAULT_SIZE,
+                    subtype => 'qemu',
+                    vmid => '16110',
+                    volid => 'local:backup/vzdump-qemu-16110-before-upgrade.vma.zst',
+                },
+            },
+            {
+                file =>
+                    "$DEFAULT_STORAGE_PATH/dump/vzdump-qemu-16111-before-16110-upgrade.vma.zst",
+                expected => undef,
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/dump/vzdump-16110-renamed.tar.zst",
+                expected => undef,
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/dump/backup-16110-manual.vma",
+                expected => undef,
+            },
+        ],
+    },
+    {
+        description => 'VMID: none, parent, non-matching',
+        storeid => $DEFAULT_STOREID,
+        scfg => $DEFAULT_SCFG,
+        vmid => undef,
+        vtypes => ['images'],
+        cases => [
+            {
+                file => "$DEFAULT_STORAGE_PATH/images/1234/vm-1234-disk-0.qcow2",
+                parent => '../ssss/base-4321-disk-0.qcow2',
+                expected => {
+                    content => 'images',
+                    ctime => $DEFAULT_CTIME,
+                    format => 'qcow2',
+                    parent => '../ssss/base-4321-disk-0.qcow2',
+                    size => $DEFAULT_SIZE,
+                    used => $DEFAULT_USED,
+                    vmid => '1234',
+                    volid => 'local:1234/vm-1234-disk-0.qcow2',
+                },
+            },
+        ],
+    },
+    {
+        description => 'VMID: none, non-matching',
+        storeid => $DEFAULT_STOREID,
+        scfg => $DEFAULT_SCFG,
+        vmid => undef,
+        vtypes => [sort keys $DEFAULT_SCFG->{content}->%*],
+        cases => [
+            {
+                file => "$DEFAULT_STORAGE_PATH/images/ssss/base-4321-disk-0.raw",
+                expected => undef,
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/images/ssss/vm-1234-disk-0.qcow2",
+                expected => undef,
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/template/iso/yet-again-a-installation-disk.dvd",
+                expected => undef,
+            },
+            {
+                file =>
+                    "$DEFAULT_STORAGE_PATH/template/cache/debian-10.0-standard_10.0-1_amd64.zip.gz",
+                expected => undef,
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/private/subvol-19254-disk-0/19254",
+                expected => undef,
+            },
+            {
+                file =>
+                    "$DEFAULT_STORAGE_PATH/dump/vzdump-openvz-16112-2020_03_30-21_39_30.zip.gz",
+                expected => undef,
+            },
+            {
+                file =>
+                    "$DEFAULT_STORAGE_PATH/dump/vzdump-openvz-16112-2020_03_30-21_39_30.tgz.lzo",
+                expected => undef,
+            },
+            {
+                file =>
+                    "$DEFAULT_STORAGE_PATH/dump/vzdump-qemu-16110-2020_03_30-21_12_40.vma.xz",
+                expected => undef,
+            },
+            {
+                file =>
+                    "$DEFAULT_STORAGE_PATH/dump/vzdump-qemu-16110-2020_03_30-21_12_40.vms.gz",
+                expected => undef,
+            },
+        ],
+    },
+    {
+        description => 'VMID: none, names with a newline',
+        storeid => $DEFAULT_STOREID,
+        scfg => $DEFAULT_SCFG,
+        vmid => undef,
+        vtypes => [sort keys $DEFAULT_SCFG->{content}->%*],
+        cases => [
+            {
+                file => "$DEFAULT_STORAGE_PATH/template/iso/debian-9.12.0-amd64-netinst.iso",
+                expected => {
+                    content => 'iso',
+                    ctime => $DEFAULT_CTIME,
+                    format => 'iso',
+                    size => $DEFAULT_SIZE,
+                    volid => 'local:iso/debian-9.12.0-amd64-netinst.iso',
+                },
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/template/iso/debian-9.12.0\namd64-netinst.iso",
+                expected => undef,
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/template/iso/debian-9.12.0-amd64-netinst.iso\n",
+                expected => undef,
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/dump/vzdump-qemu-16110-before\nupgrade.vma",
+                expected => undef,
+            },
+            {
+                file =>
+                    "$DEFAULT_STORAGE_PATH/dump/vzdump-qemu-16110-2020_03_30-21_12_40.vma.gz\n",
+                expected => undef,
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/snippets/hook\nscript.pl",
+                expected => undef,
+            },
+        ],
+    },
+    {
+        description => 'VMID: none, valid file names for import',
+        storeid => $DEFAULT_STOREID,
+        scfg => $DEFAULT_SCFG,
+        vmid => undef,
+        vtypes => ['import'],
+        cases => [
+            {
+                file => "$DEFAULT_STORAGE_PATH/import/import.ova",
+                expected => {
+                    content => 'import',
+                    ctime => $DEFAULT_CTIME,
+                    format => 'ova',
+                    size => $DEFAULT_SIZE,
+                    volid => 'local:import/import.ova',
+                },
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/import/import.ovf",
+                expected => {
+                    content => 'import',
+                    ctime => $DEFAULT_CTIME,
+                    format => 'ovf',
+                    size => $DEFAULT_SIZE,
+                    volid => 'local:import/import.ovf',
+                },
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/import/some-disk.qcow2",
+                expected => {
+                    content => 'import',
+                    ctime => $DEFAULT_CTIME,
+                    format => 'qcow2',
+                    size => $DEFAULT_SIZE,
+                    volid => 'local:import/some-disk.qcow2',
+                },
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/import/some-disk.vmdk",
+                expected => {
+                    content => 'import',
+                    ctime => $DEFAULT_CTIME,
+                    format => 'vmdk',
+                    size => $DEFAULT_SIZE,
+                    volid => 'local:import/some-disk.vmdk',
+                },
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/import/some-raw-disk.raw",
+                expected => {
+                    content => 'import',
+                    ctime => $DEFAULT_CTIME,
+                    format => 'raw',
+                    size => $DEFAULT_SIZE,
+                    volid => 'local:import/some-raw-disk.raw',
+                },
+            },
+        ],
+    },
+    {
+        description => 'VMID: none, non-matching file paths for import',
+        storeid => $DEFAULT_STOREID,
+        scfg => $DEFAULT_SCFG,
+        vmid => undef,
+        vtypes => ['import'],
+        cases => [
+            # Malformed file names
+            {
+                file => "$DEFAULT_STORAGE_PATH/import/import.ovff",
+                expected => undef,
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/import/importova",
+                expected => undef,
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/import/import.ov",
+                expected => undef,
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/import/diskraw",
+                expected => undef,
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/import/diskvmdk",
+                expected => undef,
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/import/disk.invalid",
+                expected => undef,
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/import/.ova",
+                expected => undef,
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/import/.raw",
+                expected => undef,
+            },
+
+            # Trailing whitespace must not be trimmed
+            {
+                file => "$DEFAULT_STORAGE_PATH/import/import.ova\t",
+                expected => undef,
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/import/disk.raw    ",
+                expected => undef,
+            },
+
+            # Whitespace in file name
+            {
+                file => "$DEFAULT_STORAGE_PATH/import/something I want to import.ova",
+                expected => undef,
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/import/ .raw",
+                expected => undef,
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/import/ disk .vmdk",
+                expected => undef,
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/import/disk .qcow2",
+                expected => undef,
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/import/ import.ova",
+                expected => undef,
+            },
+
+            # Unsafe characters in file name
+            {
+                file => "$DEFAULT_STORAGE_PATH/import/linux🐧-vm.ova",
+                expected => undef,
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/import/🐪perl-playground🐪.ova",
+                expected => undef,
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/import/fish_<><_<><_<><.ova",
+                expected => undef,
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/import/C:\\\\Windows\\Path.ova",
+                expected => undef,
+            },
+
+            # Content inside .ova files may only be specified as part
+            # of volume names, and may never appear when looked up as
+            # a file path
+            {
+                file => "$DEFAULT_STORAGE_PATH/import/import.ova/disk.qcow2",
+                expected => undef,
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/import/import.ova/disk.raw",
+                expected => undef,
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/import/import.ova/disk.vmdk",
+                expected => undef,
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/import/import.ova/disk.invalid",
+                expected => undef,
+            },
+        ],
+    },
+    {
+        description => 'VMID: none, weird but valid file names for import',
+        storeid => $DEFAULT_STOREID,
+        scfg => $DEFAULT_SCFG,
+        vmid => undef,
+        vtypes => ['import'],
+        cases => [
+            {
+                file => "$DEFAULT_STORAGE_PATH/import/import.ova.ova",
+                expected => {
+                    content => 'import',
+                    ctime => $DEFAULT_CTIME,
+                    format => 'ova',
+                    size => $DEFAULT_SIZE,
+                    volid => 'local:import/import.ova.ova',
+                },
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/import/import.ova.ova.ova",
+                expected => {
+                    content => 'import',
+                    ctime => $DEFAULT_CTIME,
+                    format => 'ova',
+                    size => $DEFAULT_SIZE,
+                    volid => 'local:import/import.ova.ova.ova',
+                },
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/import/import.ova.ova.ova.ova",
+                expected => {
+                    content => 'import',
+                    ctime => $DEFAULT_CTIME,
+                    format => 'ova',
+                    size => $DEFAULT_SIZE,
+                    volid => 'local:import/import.ova.ova.ova.ova',
+                },
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/import/ova.ova",
+                expected => {
+                    content => 'import',
+                    ctime => $DEFAULT_CTIME,
+                    format => 'ova',
+                    size => $DEFAULT_SIZE,
+                    volid => 'local:import/ova.ova',
+                },
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/import/ova.ovf",
+                expected => {
+                    content => 'import',
+                    ctime => $DEFAULT_CTIME,
+                    format => 'ovf',
+                    size => $DEFAULT_SIZE,
+                    volid => 'local:import/ova.ovf',
+                },
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/import/ova.vmdk",
+                expected => {
+                    content => 'import',
+                    ctime => $DEFAULT_CTIME,
+                    format => 'vmdk',
+                    size => $DEFAULT_SIZE,
+                    volid => 'local:import/ova.vmdk',
+                },
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/import/raw.raw.qcow2",
+                expected => {
+                    content => 'import',
+                    ctime => $DEFAULT_CTIME,
+                    format => 'qcow2',
+                    size => $DEFAULT_SIZE,
+                    volid => 'local:import/raw.raw.qcow2',
+                },
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/import/raw.raw.qcow2.import.qcow2",
+                expected => {
+                    content => 'import',
+                    ctime => $DEFAULT_CTIME,
+                    format => 'qcow2',
+                    size => $DEFAULT_SIZE,
+                    volid => 'local:import/raw.raw.qcow2.import.qcow2',
+                },
+            },
+            {
+                file => "$DEFAULT_STORAGE_PATH/import/raw.raw.raw.your-boat.ova",
+                expected => {
+                    content => 'import',
+                    ctime => $DEFAULT_CTIME,
+                    format => 'ova',
+                    size => $DEFAULT_SIZE,
+                    volid => 'local:import/raw.raw.raw.your-boat.ova',
+                },
+            },
+        ],
+    },
 ];
 
 # provide static vmlist for tests
 my $mock_cluster = Test::MockModule->new('PVE::Cluster', no_auto => 1);
 $mock_cluster->redefine(get_vmlist => sub { return $mocked_vmlist; });
 
 # populate is File::stat's method to fill all information from CORE::stat into
 # an blessed array.
 my $mock_stat = Test::MockModule->new('File::stat', no_auto => 1);
 $mock_stat->redefine(
     populate => sub {
         my (@st) = @_;
-        $st[7] = DEFAULT_SIZE;
-        $st[10] = DEFAULT_CTIME;
+        $st[7] = $DEFAULT_SIZE;
+        $st[10] = $DEFAULT_CTIME;
 
         my $result = $mock_stat->original('populate')->(@st);
 
         return $result;
     },
@@ -845,68 +1058,21 @@ my $mock_fsi = Test::MockModule->new('PVE::Storage::Plugin', no_auto => 1);
 $mock_fsi->redefine(
     file_size_info => sub {
         my ($size, $format, $used, $parent, $ctime) =
             $mock_fsi->original('file_size_info')->(@_);
 
-        $size = DEFAULT_SIZE;
-        $used = DEFAULT_USED;
+        $size = $DEFAULT_SIZE;
+        $used = $DEFAULT_USED;
 
         return wantarray ? ($size, $format, $used, $parent, $ctime) : $size;
     },
 );
 
 my sub cmp_volinfo_by_volid {
     return $a->{volid} cmp $b->{volid};
 }
 
-my sub run_legacy_tests() {
-    my $sid = 'local';
-    my $types = [grep { $scfg->{content}->{$_} } keys $scfg->{content}->%*];
-
-    # run through test cases
-    foreach my $tt (@tests) {
-        my $vmid = $tt->{vmid};
-        my $files = $tt->{files};
-        my $expected = [sort cmp_volinfo_by_volid $tt->{expected}->@*];
-        my $description = $tt->{description};
-        my $parent = $tt->{parent};
-
-        # prepare environment
-        my $num = 0; #parent disks
-        for my $file (@$files) {
-            my ($name, $dir, $suffix) = fileparse($file, @BACKING_FILE_SUFFIXES);
-
-            make_path($dir, { verbose => 1, mode => 0755 });
-
-            if ($name) {
-                # using qemu-img to also be able to represent the backing device
-                my @cmd = ('/usr/bin/qemu-img', 'create', "$file", DEFAULT_SIZE);
-                push @cmd, ('-f', $suffix) if $suffix;
-                push @cmd, ('-u', '-b', @$parent[$num]) if $parent;
-                push @cmd, ('-F', $suffix) if $parent && $suffix;
-                $num++;
-
-                run_command([@cmd]);
-            }
-        }
-
-        my $got = eval {
-            my $volume_list = PVE::Storage::Plugin->list_volumes($sid, $scfg, $vmid, $types);
-            return [sort cmp_volinfo_by_volid $volume_list->@*];
-        };
-        $got = $@ if $@;
-
-        is_deeply($got, $expected, $description) || diag(explain($got));
-
-        # clean up after each test case, otherwise
-        # we get wrong results from leftover files
-        remove_tree($storage_dir, { verbose => 1 });
-    }
-
-    return;
-}
-
 my sub setup_test_env($test_params) {
     my ($storeid, $scfg) = $test_params->@{qw(storeid scfg)};
 
     make_path($scfg->{path}, { verbose => 1, mode => 0700 });
 
@@ -993,24 +1159,22 @@ my sub assert_test_params_keys_exist($test_params) {
 
     return;
 }
 
 sub main() {
-    plan tests => scalar(@tests) + scalar($test_param_list->@*) + 1;
+    plan tests => scalar($test_param_list->@*) + 1;
 
     # Keep the original vmlist around in order to check whether it was modified
     # after running all the tests. See:
     # https://pve.proxmox.com/pipermail/pve-devel/2020-January/041096.html
     my $original_vmlist = dclone(PVE::Cluster::get_vmlist());
 
     for my $test_params ($test_param_list->@*) {
         assert_test_params_keys_exist($test_params);
         run_test_for_params($test_params);
     }
 
-    run_legacy_tests();
-
     my $vmlist = PVE::Cluster::get_vmlist();
 
     is_deeply(
         $vmlist, $original_vmlist, 'Result of PVE::Cluster::get_vmlist remains unmodified',
     );
-- 
2.47.3





  parent reply	other threads:[~2026-11-17 20:46 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 20:38 [PATCH manager/storage v3 00/51] Fix #2884: Implement Subdirectory Scanning for Dir-Based Storage Types Max R. Carrara
2026-11-17 20:38 ` [PATCH pve-storage v3 01/51] test: plugin tests: run tests with at most 4 jobs Max R. Carrara
2026-11-17 20:38 ` [PATCH pve-storage v3 02/51] plugin, common: remove superfluous use of =pod command paragraph Max R. Carrara
2026-11-17 20:38 ` [PATCH pve-storage v3 03/51] common: use Exporter module for PVE::Storage::Common Max R. Carrara
2026-11-17 20:38 ` [PATCH pve-storage v3 04/51] plugin: make get_subdir_files a proper subroutine and update style Max R. Carrara
2026-11-17 20:38 ` [PATCH pve-storage v3 05/51] plugin api: replace subdir helper methods with standalone functions Max R. Carrara
2026-11-17 20:38 ` [PATCH pve-storage v3 06/51] common: prevent autovivification in plugin_get_vtype_subdir helper Max R. Carrara
2026-11-17 20:38 ` [PATCH pve-storage v3 07/51] plugin: break up if-elsif chain into separate if-blocks Max R. Carrara
2026-11-17 20:38 ` [PATCH pve-storage v3 08/51] plugin: adapt get_subdir_files helper of list_volumes API method Max R. Carrara
2026-11-17 20:38 ` [PATCH pve-storage v3 09/51] plugin: update code style of list_volumes plugin " Max R. Carrara
2026-11-17 20:38 ` [PATCH pve-storage v3 10/51] plugin: use closure for obtaining raw volume data in list_volumes Max R. Carrara
2026-11-17 20:38 ` [PATCH pve-storage v3 11/51] plugin: use closure for inner loop logic " Max R. Carrara
2026-11-17 20:38 ` [PATCH pve-storage v3 12/51] storage: update code style in function path_to_volume_id Max R. Carrara
2026-11-17 20:38 ` [PATCH pve-storage v3 13/51] storage: break up if-elsif chain in path_to_volume_id Max R. Carrara
2026-11-17 20:38 ` [PATCH pve-storage v3 14/51] storage: heave vtype file path parsing logic inside loop into helper Max R. Carrara
2026-11-17 20:38 ` [PATCH pve-storage v3 15/51] storage: clean up code that was moved into helper in path_to_volume_id Max R. Carrara
2026-11-17 20:38 ` [PATCH pve-storage v3 16/51] api: status: move content type assert for up-/downloads into helper Max R. Carrara
2026-11-17 20:38 ` [PATCH pve-storage v3 17/51] api: status: use get_subdir helper method to get content directory Max R. Carrara
2026-11-17 20:38 ` [PATCH pve-storage v3 18/51] api: status: move up-/download file path parsing code into helper Max R. Carrara
2026-11-17 20:38 ` [PATCH pve-storage v3 19/51] api: status: simplify file content assertion logic for up-/download Max R. Carrara
2026-11-17 20:38 ` [PATCH pve-storage v3 20/51] test: guest import: add tests for PVE::GuestImport Max R. Carrara
2026-11-17 20:38 ` [PATCH pve-storage v3 21/51] tree-wide: introduce parsing module and replace usages of ISO_EXT_RE_0 Max R. Carrara
2026-11-17 20:38 ` [PATCH pve-storage v3 22/51] common: test: set up parser testing code, add tests for 'iso' vtype Max R. Carrara
2026-11-17 20:38 ` [PATCH pve-storage v3 23/51] tree-wide: replace usages of VZTMPL_EXT_RE_1 with parsing functions Max R. Carrara
2026-11-17 20:38 ` [PATCH pve-storage v3 24/51] tree-wide: replace usages of BACKUP_EXT_RE_2 " Max R. Carrara
2026-11-17 20:38 ` [PATCH pve-storage v3 25/51] tree-wide: replace usages of inline regexes for snippets with parsers Max R. Carrara
2026-11-17 20:38 ` [PATCH pve-storage v3 26/51] tree-wide: partially replace usages of regexes for 'import' vtype Max R. Carrara
2026-11-17 20:38 ` [PATCH pve-storage v3 27/51] tree-wide: replace remaining " Max R. Carrara
2026-11-17 20:39 ` [PATCH pve-storage v3 28/51] tree-wide: simplify recently refactored parsing logic Max R. Carrara
2026-11-17 20:39 ` [PATCH pve-storage v3 29/51] test: list volumes: reorganize and modernize test running code Max R. Carrara
2026-11-17 20:39 ` [PATCH pve-storage v3 30/51] test: list volumes: fix broken test checking for vmlist modifications Max R. Carrara
2026-11-17 20:39 ` [PATCH pve-storage v3 31/51] test: list volumes: introduce new format for test cases Max R. Carrara
2026-11-17 20:39 ` Max R. Carrara [this message]
2026-11-17 20:39 ` [PATCH pve-storage v3 33/51] plugin: do not return volumes of undeclared content types anymore Max R. Carrara
2026-11-17 20:39 ` [PATCH pve-storage v3 34/51] plugin: correct comment in get_subdir_files helper Max R. Carrara
2026-11-17 20:39 ` [PATCH pve-storage v3 35/51] test: parse volname: modernize code Max R. Carrara
2026-11-17 20:39 ` [PATCH pve-storage v3 36/51] test: parse volname: adapt tests regarding 'import' volume type Max R. Carrara
2026-11-17 20:39 ` [PATCH pve-storage v3 37/51] test: parse volname: move VM disk test creation into separate block Max R. Carrara
2026-11-17 20:39 ` [PATCH pve-storage v3 38/51] test: parse volname: move backup file test creation into sep. block Max R. Carrara
2026-11-17 20:39 ` [PATCH pve-storage v3 39/51] test: parse volname: parameterize test case creation for some vtypes Max R. Carrara
2026-11-17 20:39 ` [PATCH pve-storage v3 40/51] test: volume id: modernize code Max R. Carrara
2026-11-17 20:39 ` [PATCH pve-storage v3 41/51] test: volume id: rename 'volname' test case parameter to 'file' Max R. Carrara
2026-11-17 20:39 ` [PATCH pve-storage v3 42/51] test: filesystem path: modernize code Max R. Carrara
2026-11-17 20:39 ` [PATCH pve-storage v3 43/51] plugin: list content directories without globbing Max R. Carrara
2026-11-18  9:12 ` [PATCH pve-storage v3 44/51] fix #2884: implement nested subdir scanning and support 'iso' vtype Max R. Carrara
2026-11-18  9:14 ` [PATCH pve-storage v3 45/51] fix #2884: support nested subdir scanning for 'vztmpl' volume type Max R. Carrara
2026-11-18  9:14   ` [PATCH pve-storage v3 46/51] fix #2884: support nested subdir scanning for 'snippets' vtype Max R. Carrara
2026-11-18  9:14   ` [PATCH pve-storage v3 47/51] test: add more tests for 'import' vtype & guard against nested subdirs Max R. Carrara
2026-11-18  9:14   ` [PATCH pve-storage v3 48/51] test: add tests guarding against subdir scanning for vtypes Max R. Carrara
2026-11-18  9:14   ` [PATCH pve-storage v3 49/51] storage: resolve images in content dir overrides ending with a slash Max R. Carrara
2026-11-18  9:14   ` [PATCH pve-storage v3 50/51] bump the storage plugin API version Max R. Carrara
2026-11-18  9:14   ` [PATCH pve-manager v3 51/51] fix #2884: ui: storage: add field for 'max-scan-depth' property Max R. Carrara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261117203953.913035-33-m.carrara@proxmox.com \
    --to=m.carrara@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    --cc=w.bumiller@proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal