From: "Michael Köppl" <m.koeppl@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH e2e-tests 15/38] tests: container: verify volume and bind mountpoints
Date: Wed, 4 Nov 2026 20:03:22 +0100 [thread overview]
Message-ID: <20261104190345.2573464-16-m.koeppl@proxmox.com> (raw)
In-Reply-To: <20261104190345.2573464-1-m.koeppl@proxmox.com>
Cover volume mountpoints on LVM-thin and on a directory storage as well
as a bind mountpoint from the host. All of them must be mounted in the
running container, an online resize must grow the file system, and
deleting a mountpoint must keep its volume as unused until that is
deleted as well.
Also destroy the container after its mountpoint storage was removed
from the storage configuration, which must succeed and only warn
about the volume it could not delete.
Signed-off-by: Michael Köppl <m.koeppl@proxmox.com>
---
tests/pve_ct_mountpoints.pl | 198 ++++++++++++++++++++++++++++++++++++
tests/testcases.ron | 9 ++
2 files changed, 207 insertions(+)
create mode 100755 tests/pve_ct_mountpoints.pl
diff --git a/tests/pve_ct_mountpoints.pl b/tests/pve_ct_mountpoints.pl
new file mode 100755
index 0000000..d6cbe70
--- /dev/null
+++ b/tests/pve_ct_mountpoints.pl
@@ -0,0 +1,198 @@
+#!/usr/bin/perl
+
+=head1 NAME
+
+C<pve_ct_mountpoints> - Test volume and bind mountpoints of a container.
+
+=head1 DESCRIPTION
+
+This testcase creates an unprivileged container with a volume mountpoint on
+local-lvm, a bind mountpoint from the host, and a volume mountpoint on a
+temporary directory storage. It verifies that all of them are mounted inside
+the running container, resizes the local-lvm mountpoint online, and detaches
+and deletes it again.
+
+Finally, the directory storage is removed from the storage configuration while
+the container still has a mountpoint on it. Destroying the container must
+still succeed and only warn about the volume it could not delete.
+
+=cut
+
+use strict;
+use warnings;
+
+use Test::More;
+
+use lib '.';
+use Proxmox::Test::Helper qw(CONTAINER_TEMPLATE get_pve_instance);
+use Proxmox::Test::Testcase;
+
+my $pve = get_pve_instance('pve1');
+my $node = $pve->get_nodename();
+my $client = $pve->client();
+
+my $dir_storage = 'ct-mp';
+my $dir_storage_path = '/var/lib/ct-mp-store';
+my $bind_source = '/var/lib/ct-bind';
+my $bind_marker = 'test';
+
+my $test_container = {
+ vmid => $client->get('/cluster/nextid'),
+ node => $node,
+ ostemplate => CONTAINER_TEMPLATE,
+ rootfs => 'local-lvm:2',
+ storage => 'local-lvm',
+ memory => 256,
+ unprivileged => 1,
+ features => 'nesting=1',
+ hostname => 'ct-mountpoints',
+ mp0 => 'local-lvm:1,mp=/data',
+ mp1 => "$bind_source,mp=/bind",
+ mp2 => "$dir_storage:1,mp=/dirstore",
+};
+
+my $vmid = $test_container->{vmid};
+my $mp0_volid;
+
+my $volume_exists = sub {
+ my ($storage, $volid) = @_;
+ my $content = $client->get("/nodes/$node/storage/$storage/content", { vmid => $vmid });
+ return grep { $_->{volid} eq $volid } $content->@*;
+};
+
+Proxmox::Test::Testcase->new('pve_ct_mountpoints')->with([{}])->step(
+ 'create directory storage',
+ sub {
+ $pve->run_command("mkdir -p $dir_storage_path");
+ $client->post(
+ '/storage',
+ {
+ storage => $dir_storage,
+ type => 'dir',
+ path => $dir_storage_path,
+ content => 'rootdir',
+ },
+ );
+ },
+ sub {
+ eval { $client->delete("/storage/$dir_storage") };
+ $pve->run_command("rm -rf $dir_storage_path");
+ },
+)->step(
+ 'create bind mount source',
+ sub {
+ $pve->run_command("mkdir -p $bind_source && echo $bind_marker > $bind_source/marker");
+ },
+ sub {
+ $pve->run_command("rm -rf $bind_source");
+ },
+)->step(
+ 'create container',
+ sub {
+ my $upid = $client->post("/nodes/$node/lxc", $test_container);
+ $pve->task_ok($upid, "created container $vmid")
+ or die "creating container $vmid failed\n";
+ },
+ sub {
+ $pve->destroy_guest('lxc', $vmid);
+ },
+)->step(
+ 'verify mountpoint config',
+ sub {
+ my $conf = $client->get("/nodes/$node/lxc/$vmid/config", {});
+
+ like(
+ $conf->{mp0} // '',
+ qr/^local-lvm:[^,]+,mp=\/data\b/,
+ 'mp0 is a volume on local-lvm',
+ );
+ like($conf->{mp1} // '', qr/^\Q$bind_source\E,mp=\/bind\b/, 'mp1 is a bind mount');
+ like(
+ $conf->{mp2} // '',
+ qr/^\Q$dir_storage\E:[^,]+,mp=\/dirstore\b/,
+ "mp2 is a volume on $dir_storage",
+ );
+
+ ($mp0_volid) = ($conf->{mp0} // '') =~ m/^([^,]+)/;
+ },
+)->step(
+ 'start container',
+ sub {
+ $pve->start_guest('lxc', $vmid);
+ pass("container $vmid reports status 'running'");
+ },
+)->step(
+ 'verify mountpoints inside container',
+ sub {
+ for my $path ('/data', '/bind', '/dirstore') {
+ is(
+ $pve->ct_exec($vmid, "findmnt -n -o TARGET $path"),
+ "$path\n",
+ "$path is mounted",
+ );
+ }
+
+ is(
+ $pve->ct_exec($vmid, 'cat /bind/marker'),
+ "$bind_marker\n",
+ 'bind mount shows the host file',
+ );
+
+ $pve->ct_exec($vmid, "sh -c 'echo e2e > /data/marker'");
+ is($pve->ct_exec($vmid, 'cat /data/marker'), "e2e\n", 'volume mountpoint is writable');
+ },
+)->step(
+ 'resize volume mountpoint online',
+ sub {
+ my $upid =
+ $client->put("/nodes/$node/lxc/$vmid/resize", { disk => 'mp0', size => '+1G' });
+ $pve->task_ok($upid, 'resized mp0 by 1 GiB') or die "resizing mp0 failed\n";
+
+ my $conf = $client->get("/nodes/$node/lxc/$vmid/config", {});
+ like($conf->{mp0} // '', qr/\bsize=2G\b/, 'config reports the new mp0 size');
+
+ # File system on the mountpoint grows as part of the resize, check that the container sees
+ # the change right away.
+ my ($size_mib) = $pve->ct_exec($vmid, 'df -B1M --output=size /data') =~ m/(\d+)\s*$/;
+ cmp_ok($size_mib // 0, '>', 1024, 'file system on /data has grown beyond 1 GiB');
+ },
+)->step(
+ 'stop container',
+ sub {
+ $pve->stop_guest('lxc', $vmid);
+ },
+)->step(
+ 'detach and delete volume mountpoint',
+ sub {
+ $client->put("/nodes/$node/lxc/$vmid/config", { delete => 'mp0' });
+
+ my $conf = $client->get("/nodes/$node/lxc/$vmid/config", {});
+ ok(!defined($conf->{mp0}), 'mp0 is gone from the config');
+ my ($unused) = grep { m/^unused\d+$/ && $conf->{$_} eq $mp0_volid } keys $conf->%*;
+ ok(defined($unused), 'the mp0 volume is kept as an unused volume');
+
+ $client->put("/nodes/$node/lxc/$vmid/config", { delete => $unused })
+ if defined($unused);
+
+ $conf = $client->get("/nodes/$node/lxc/$vmid/config", {});
+ ok(!(grep { m/^unused\d+$/ } keys $conf->%*), 'no unused volume is left in the config');
+ ok(!$volume_exists->('local-lvm', $mp0_volid), 'the mp0 volume is deleted');
+ },
+)->step(
+ 'destroy container with unavailable mountpoint storage',
+ sub {
+ $client->delete("/storage/$dir_storage");
+
+ my $upid = $client->delete("/nodes/$node/lxc/$vmid", {});
+ my $status = $pve->wait_for_task($upid, 1);
+ like(
+ $status,
+ qr/^WARNINGS: \d+$/,
+ 'destroying the container succeeds with warnings about the unavailable storage',
+ );
+
+ ok(!$pve->guest_exists('lxc', $vmid), "container $vmid is gone");
+ },
+)->run();
+
+done_testing();
diff --git a/tests/testcases.ron b/tests/testcases.ron
index 391eb09..79841ca 100644
--- a/tests/testcases.ron
+++ b/tests/testcases.ron
@@ -151,6 +151,15 @@ TestcaseConfig(
],
tag: "extended",
),
+ Testcase(
+ name: "pve_ct_mountpoints",
+ run: "./tests/pve_ct_mountpoints.pl",
+ timeout: 600,
+ instances: [
+ "pve1",
+ ],
+ tag: "extended",
+ ),
Testcase(
name: "pve_ha_resource_config",
run: "./tests/pve_ha_resource_config.pl",
--
2.47.3
next prev parent reply other threads:[~2026-11-04 19:06 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 ` Michael Köppl [this message]
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 ` [PATCH e2e-tests 33/38] tests: pbs: verify single file restore from a container backup Michael Köppl
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-16-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.