From: "Michael Köppl" <m.koeppl@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH e2e-tests 33/38] tests: pbs: verify single file restore from a container backup
Date: Wed, 4 Nov 2026 20:03:40 +0100 [thread overview]
Message-ID: <20261104190345.2573464-34-m.koeppl@proxmox.com> (raw)
In-Reply-To: <20261104190345.2573464-1-m.koeppl@proxmox.com>
Back up a container with a marker file to PBS, browse the backup
through the file restore API down to the file and download it.
Signed-off-by: Michael Köppl <m.koeppl@proxmox.com>
---
Notes:
The test accepts curl's exit code 56 for the download, which curl
with OpenSSL 3 returns because pveproxy ends the streamed response
without a TLS close_notify. This workaround is only meant to stay
until http-server patch [0] is applied, or the issue is resolved in
some other way.
[0] https://lore.proxmox.com/pve-devel/20261103155223.1960754-1-m.koeppl@proxmox.com/
tests/pbs/test_pbs_file_restore.pl | 151 +++++++++++++++++++++++++++++
tests/testcases.ron | 10 ++
2 files changed, 161 insertions(+)
create mode 100755 tests/pbs/test_pbs_file_restore.pl
diff --git a/tests/pbs/test_pbs_file_restore.pl b/tests/pbs/test_pbs_file_restore.pl
new file mode 100755
index 0000000..1d9a20e
--- /dev/null
+++ b/tests/pbs/test_pbs_file_restore.pl
@@ -0,0 +1,151 @@
+#!/usr/bin/perl
+
+=head1 NAME
+
+C<test_pbs_file_restore> - Restore single files from a container backup on PBS.
+
+=head1 DESCRIPTION
+
+This testcase creates a local datastore on PBS and adds it to PVE as a storage.
+It creates a container, writes a file to it and backs it up to the PBS datastore.
+It then browses the backup through the single file restore API down to the file,
+which must be listed with its size. It then downloads the file, which must have
+the content written before the backup.
+
+=cut
+
+use strict;
+use warnings;
+
+use Test::More;
+
+use URI::Escape qw(uri_escape);
+
+use lib '.';
+use Proxmox::Test::Helper qw(CONTAINER_TEMPLATE get_pbs_instance get_pve_instance);
+use Proxmox::Test::Testcase;
+
+my $pve = get_pve_instance('pve1');
+my $pbs = get_pbs_instance('pbs1');
+my $node = $pve->get_nodename();
+my $client = $pve->client();
+
+my $datastore = 'e2e-file-restore';
+my $storage_id = 'e2e-pbs-file-restore';
+
+my $ctid;
+my $backup_volid;
+my $marker_file = 'e2e-marker';
+my $marker = "e2e-file-restore-$$";
+my $marker_entry;
+
+# Entries below $filepath in the backup
+my $list = sub {
+ my ($filepath) = @_;
+ return $client->get(
+ "/nodes/$node/storage/$storage_id/file-restore/list",
+ { volume => $backup_volid, filepath => $filepath },
+ );
+};
+
+my $find_entry = sub {
+ my ($entries, $match) = @_;
+ my ($entry) = grep { $_->{text} =~ $match } $entries->@*;
+ return $entry;
+};
+
+Proxmox::Test::Testcase->new('pbs_file_restore')->with([{}])->step(
+ 'create datastore on PBS',
+ sub {
+ $pbs->create_datastore($datastore);
+ },
+ sub {
+ $pbs->remove_datastore($datastore);
+ },
+)->step(
+ 'add PBS as storage on PVE',
+ sub {
+ $pve->add_pbs_storage($storage_id, $pbs, $datastore);
+ },
+ sub {
+ $client->delete("/storage/$storage_id");
+ },
+)->step(
+ 'create container and write file',
+ sub {
+ $ctid = $client->get('/cluster/nextid');
+ my $upid = $client->post(
+ "/nodes/$node/lxc",
+ {
+ vmid => $ctid,
+ ostemplate => CONTAINER_TEMPLATE,
+ rootfs => 'local-lvm:2',
+ memory => 256,
+ unprivileged => 1,
+ features => 'nesting=1',
+ hostname => 'ct-file-restore',
+ },
+ );
+ $pve->task_ok($upid, "created container $ctid")
+ or die "creating container $ctid failed\n";
+
+ $pve->start_guest('lxc', $ctid);
+ $pve->ct_exec($ctid, "sh -c 'echo $marker > /root/$marker_file'");
+ },
+ sub {
+ $pve->destroy_guest('lxc', $ctid) if defined($ctid);
+ },
+)->step(
+ 'back up container to PBS',
+ sub {
+ my $upid = $client->post(
+ "/nodes/$node/vzdump",
+ { vmid => $ctid, storage => $storage_id, mode => 'snapshot' },
+ );
+ $pve->task_ok($upid, 'backed up container to PBS') or die "backup failed\n";
+
+ my $content =
+ $client->get("/nodes/$node/storage/$storage_id/content", { content => 'backup' });
+ my ($backup) = grep { ($_->{vmid} // 0) == $ctid } $content->@*;
+ $backup_volid = $backup->{volid};
+ ok($backup_volid, 'found container backup on PBS storage') or die "backup not found\n";
+ },
+)->step(
+ 'browse backup down to the file',
+ sub {
+ my $archive = $find_entry->($list->('/'), qr/^root\.pxar/);
+ ok($archive, 'backup contains the root file system archive')
+ or die "archive not found\n";
+
+ my $root_dir = $find_entry->($list->($archive->{filepath}), qr/^root$/);
+ ok($root_dir, "archive contains the directory '/root'") or die "'/root' not found\n";
+
+ $marker_entry = $find_entry->($list->($root_dir->{filepath}), qr/^\Q$marker_file\E$/);
+ ok($marker_entry, 'directory contains the file') or die "file not found\n";
+ is($marker_entry->{size}, length("$marker\n"), 'file is listed with its size');
+ },
+)->step(
+ 'download file',
+ sub {
+ # This doesn't work with the API client (expects JSON), to use ticket from the node for
+ # manual request.
+ my $ticket = $client->post(
+ '/access/ticket',
+ { username => 'root@pam', password => $pve->get_root_password() },
+ )->{ticket};
+
+ my $query = join(
+ '&',
+ 'volume=' . uri_escape($backup_volid),
+ 'filepath=' . uri_escape($marker_entry->{filepath}),
+ );
+ # FIXME: remove workaround once api server sends TLS close notify
+ my ($content) =
+ $pve->run_command("curl -sSfk -H 'Cookie: PVEAuthCookie=$ticket'"
+ . " 'https://localhost:8006/api2/json/nodes/$node/storage/$storage_id"
+ . "/file-restore/download?$query'; rc=\$?; [ \$rc -eq 0 ] || [ \$rc -eq 56 ]");
+ is($content, "$marker\n", 'downloaded file has the content from the backup');
+ },
+)->run();
+
+done_testing();
diff --git a/tests/testcases.ron b/tests/testcases.ron
index b107835..51ceb81 100644
--- a/tests/testcases.ron
+++ b/tests/testcases.ron
@@ -293,6 +293,16 @@ TestcaseConfig(
],
tag: "pbs",
),
+ Testcase(
+ name: "pbs_file_restore",
+ run: "./tests/pbs/test_pbs_file_restore.pl",
+ timeout: 600,
+ instances: [
+ "pve1",
+ "pbs1",
+ ],
+ tag: "pbs",
+ ),
Testcase(
name: "sdn_create_vlan_zone",
run: "./tests/sdn/test_vlan_zone.pl",
--
2.47.3
next prev parent reply other threads:[~2026-11-04 19:08 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 19:03 [PATCH e2e-tests/test-tools 00/38] tests: add tests for guests, Ceph, PBS and cluster workflows Michael Köppl
2026-11-04 19:03 ` [PATCH test-tools 01/38] ansible: rename snd_test bridge to tt_test as multi-purpose bridge Michael Köppl
2026-11-04 19:03 ` [PATCH e2e-tests 02/38] plans: rename sdn_test bridge to tt_test Michael Köppl
2026-11-04 19:03 ` [PATCH e2e-tests 03/38] debian: add missing jq dependency Michael Köppl
2026-11-04 19:03 ` [PATCH e2e-tests 04/38] test framework: move the default container template to the helper Michael Köppl
2026-11-04 19:03 ` [PATCH e2e-tests 05/38] lib: instance: add helper to check if an address answers ping Michael Köppl
2026-11-04 19:03 ` [PATCH e2e-tests 06/38] lib: pveinstance: look up disks by their SCSI serial Michael Köppl
2026-11-04 19:03 ` [PATCH e2e-tests 07/38] lib: pveinstance: add helper to find a task started by another task Michael Köppl
2026-11-04 19:03 ` [PATCH e2e-tests 08/38] lib: pveinstance: add helpers to start and stop guests Michael Köppl
2026-11-04 19:03 ` [PATCH e2e-tests 09/38] lib: pveinstance: add helper to run commands in containers Michael Köppl
2026-11-04 19:03 ` [PATCH e2e-tests 10/38] lib: pveinstance: add helper to wait for qmeventd's cleanup Michael Köppl
2026-11-04 19:03 ` [PATCH e2e-tests 11/38] lib: pveinstance: add helper to check if guest exists Michael Köppl
2026-11-04 19:03 ` [PATCH e2e-tests 12/38] lib: add helpers to use a PBS datastore as PVE storage Michael Köppl
2026-11-04 19:03 ` [PATCH e2e-tests 13/38] scripts: retry container template download, fail if it fails Michael Köppl
2026-11-04 19:03 ` [PATCH e2e-tests 14/38] tests: container: verify lifecycle and guest setup Michael Köppl
2026-11-04 19:03 ` [PATCH e2e-tests 15/38] tests: container: verify volume and bind mountpoints Michael Köppl
2026-11-04 19:03 ` [PATCH e2e-tests 16/38] tests: container: verify snapshots, clones, templates Michael Köppl
2026-11-04 19:03 ` [PATCH e2e-tests 17/38] tests: container: verify device passthrough Michael Köppl
2026-11-04 19:03 ` [PATCH e2e-tests 18/38] plans,scripts: build a minimal OCI image onto pve1 Michael Köppl
2026-11-04 19:03 ` [PATCH e2e-tests 19/38] tests: container: verify application containers from OCI images Michael Köppl
2026-11-04 19:03 ` [PATCH e2e-tests 20/38] tests: vm: verify snapshots, clones, templates Michael Köppl
2026-11-04 19:03 ` [PATCH e2e-tests 21/38] tests: vm: verify adding, resizing, and removing disks Michael Köppl
2026-11-04 19:03 ` [PATCH e2e-tests 22/38] plans,scripts: download a Debian cloud image onto pve1 Michael Köppl
2026-11-04 19:03 ` [PATCH e2e-tests 23/38] tests: vm: verify lifecycle operations and cloud-init guest setup Michael Köppl
2026-11-04 19:03 ` [PATCH e2e-tests 24/38] plans,scripts: install Ceph Tentacle on the cluster nodes Michael Köppl
2026-11-04 19:03 ` [PATCH e2e-tests 25/38] test framework: add Ceph test helpers Michael Köppl
2026-11-06 12:24 ` Kefu Chai
2026-11-06 13:04 ` Michael Köppl
2026-11-04 19:03 ` [PATCH e2e-tests 26/38] tests: ceph: verify setting up a hyper-converged cluster Michael Köppl
2026-11-06 12:50 ` Kefu Chai
2026-11-06 13:05 ` Michael Köppl
2026-11-04 19:03 ` [PATCH e2e-tests 27/38] tests: ceph: verify guests on RBD storage Michael Köppl
2026-11-06 13:01 ` Kefu Chai
2026-11-06 13:07 ` Michael Köppl
2026-11-04 19:03 ` [PATCH e2e-tests 28/38] tests: ceph: verify setting up, using and destroying a CephFS Michael Köppl
2026-11-04 19:03 ` [PATCH e2e-tests 29/38] tests: ceph: verify replacing an OSD Michael Köppl
2026-11-06 13:14 ` Kefu Chai
2026-11-04 19:03 ` [PATCH e2e-tests 30/38] tests: ceph: drop the outdated Ceph setup Michael Köppl
2026-11-04 19:03 ` [PATCH e2e-tests 31/38] tests: pbs: verify container backup and restore Michael Köppl
2026-11-04 19:03 ` [PATCH e2e-tests 32/38] tests: backup: verify VM backup and restore, locally and on PBS Michael Köppl
2026-11-04 19:03 ` Michael Köppl [this message]
2026-11-04 19:03 ` [PATCH e2e-tests 34/38] tests: storage: verify moving guest volumes between storages Michael Köppl
2026-11-04 19:03 ` [PATCH e2e-tests 35/38] tests: migration: verify container migration between nodes Michael Köppl
2026-11-04 19:03 ` [PATCH e2e-tests 36/38] tests: migration: verify VM migration with local disks Michael Köppl
2026-11-04 19:03 ` [PATCH e2e-tests 37/38] tests: ha: verify moving guests off a node for maintenance Michael Köppl
2026-11-04 19:03 ` [PATCH e2e-tests 38/38] tests: migration: verify migrating guests in bulk Michael Köppl
2026-11-06 13:25 ` [PATCH e2e-tests/test-tools 00/38] tests: add tests for guests, Ceph, PBS and cluster workflows Kefu Chai
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=20261104190345.2573464-34-m.koeppl@proxmox.com \
--to=m.koeppl@proxmox.com \
--cc=pve-devel@lists.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