* [PATCH e2e-tests/test-tools 0/8] instance: rework hooks and set up Ceph as a cluster hook
@ 2026-12-01 14:58 Michael Köppl
2026-12-01 14:58 ` [PATCH test-tools 1/8] readme: drop token fields from the hook config example Michael Köppl
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: Michael Köppl @ 2026-12-01 14:58 UTC (permalink / raw)
To: pve-devel
So far, post_setup hooks were plain command lines resolved against the
current dir of proxmox-test-instance. Under proxmox-test-scheduler,
that is the home dir of the SSH user, so plans only found their scripts
if they happened to be placed there. The scripts also lived in
proxmox-e2e-tests, even though nothing in them is specific to E2E tests.
1/8 drops the outdated token fields from the hook config example in the
README.
2/8, 3/8 ship the generic scripts with proxmox-test-instance and let a
hook either name such a builtin, as in
Builtin("update-packages pve staging"), or a script of its own, as in
File("../scripts/setup-ldap.sh"), resolved relative to the plan file.
4/8 adds post_cluster hooks, which run once for a whole cluster
after it has been formed, with all of its nodes in $CONFIG_PATH. 5/8
adds `run-script --cluster`, which does the same for clusters formed
manually with create-cluster.
6/8 adds the setup-ceph builtin, a cluster hook that installs Ceph on
all nodes, configures the Ceph networks on a spare NIC and creates a
monitor, a manager and OSDs on every node, optionally with a pool and
an RBD storage:
post_cluster: [
Builtin("setup-ceph --pool rbd"),
],
As a hook, it needs no Ceph-specific plan options, and it works for
manually formed clusters through `run-script --cluster` as well.
Plain string hooks are no longer accepted. 7/8 converts the plans in
proxmox-e2e-tests to Builtin(...) and File(...), and 8/8 removes the
scripts moved to proxmox-test-instance. The Ceph tests keep setting up
Ceph themselves, so their plan only uses the install-ceph builtin
rather than setup-ceph.
Tested with a 3-node plan using Builtin("setup-ceph --pool rbd"). Also
tested setup --no-cluster, create-cluster and run-script --cluster with
the same plan.
Also installed the patched packages on one of the e2e test hosts and
had it do a couple of runs, which all worked as expected.
Dependency note:
The proxmox-e2e-tests changes require a versioned dependency on the
new proxmox-test-instance version.
test-tools:
Michael Köppl (6):
readme: drop token fields from the hook config example
instance: ship generic hook scripts
instance: distinguish builtin hooks from hook files
instance: add hooks that run once a cluster is formed
instance: cli: run a script once for a whole cluster
instance: add a builtin hook to set up a Ceph cluster
Makefile | 2 +-
README.md | 98 +++++++-
debian/proxmox-test-instance.install | 1 +
proxmox-test-instance/src/cli.rs | 41 ++-
proxmox-test-instance/src/config.rs | 56 ++++-
.../src/instance_manager/mod.rs | 202 +++++++++++++--
scripts/download-cloud-image.sh | 21 ++
scripts/download-container-image.sh | 22 ++
scripts/install-ceph.sh | 13 +
scripts/setup-ceph.sh | 234 ++++++++++++++++++
scripts/setup-frr.sh | 18 ++
scripts/setup-zfs-storage.sh | 64 +++++
scripts/update-packages.sh | 69 ++++++
13 files changed, 812 insertions(+), 29 deletions(-)
create mode 100755 scripts/download-cloud-image.sh
create mode 100755 scripts/download-container-image.sh
create mode 100755 scripts/install-ceph.sh
create mode 100755 scripts/setup-ceph.sh
create mode 100755 scripts/setup-frr.sh
create mode 100755 scripts/setup-zfs-storage.sh
create mode 100755 scripts/update-packages.sh
e2e-tests:
Michael Köppl (2):
plans: use the hook scripts shipped with proxmox-test-instance
scripts: drop the scripts now shipped by proxmox-test-instance
plans/complete.ron | 46 +++++++++----------
plans/pbs.ron | 6 +--
plans/sdn.ron | 18 ++++----
scripts/download-cloud-image.sh | 21 ---------
scripts/download-container-image.sh | 22 ---------
scripts/install-ceph.sh | 13 ------
scripts/setup-frr.sh | 18 --------
scripts/setup-zfs-storage.sh | 65 ---------------------------
scripts/update-packages.sh | 69 -----------------------------
tests/pve_replication.pl | 2 +-
10 files changed, 36 insertions(+), 244 deletions(-)
delete mode 100755 scripts/download-cloud-image.sh
delete mode 100755 scripts/download-container-image.sh
delete mode 100755 scripts/install-ceph.sh
delete mode 100755 scripts/setup-frr.sh
delete mode 100755 scripts/setup-zfs-storage.sh
delete mode 100755 scripts/update-packages.sh
Summary over all repositories:
23 files changed, 848 insertions(+), 273 deletions(-)
--
Generated by murpp 0.12.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH test-tools 1/8] readme: drop token fields from the hook config example
2026-12-01 14:58 [PATCH e2e-tests/test-tools 0/8] instance: rework hooks and set up Ceph as a cluster hook Michael Köppl
@ 2026-12-01 14:58 ` Michael Köppl
2026-12-01 14:58 ` [PATCH test-tools 2/8] instance: ship generic hook scripts Michael Köppl
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Michael Köppl @ 2026-12-01 14:58 UTC (permalink / raw)
To: pve-devel
Hook scripts only get the host, the SSH private key, and the SSH user in
their $CONFIG_PATH. The example still showed token fields, which are not
passed anymore.
Signed-off-by: Michael Köppl <m.koeppl@proxmox.com>
---
README.md | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/README.md b/README.md
index bf040e14..abef2c61 100644
--- a/README.md
+++ b/README.md
@@ -185,9 +185,7 @@ located at `$CONFIG_PATH`. This allows to use the same hook script for multiple
{
"host": "172.16.0.100",
"ssh_private_keyfile": "/home/user/.ssh/id_rsa",
- "ssh_user": "root",
- "token_userid": "",
- "token_value": ""
+ "ssh_user": "root"
}
```
--
2.47.3
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH test-tools 2/8] instance: ship generic hook scripts
2026-12-01 14:58 [PATCH e2e-tests/test-tools 0/8] instance: rework hooks and set up Ceph as a cluster hook Michael Köppl
2026-12-01 14:58 ` [PATCH test-tools 1/8] readme: drop token fields from the hook config example Michael Köppl
@ 2026-12-01 14:58 ` Michael Köppl
2026-12-01 14:58 ` [PATCH test-tools 3/8] instance: distinguish builtin hooks from hook files Michael Köppl
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Michael Köppl @ 2026-12-01 14:58 UTC (permalink / raw)
To: pve-devel
Updating the packages of an instance, downloading images into a storage,
installing Ceph, or setting up a ZFS storage or FRR are not specific to
E2E tests. So far, plans could only use these scripts from
proxmox-e2e-tests under a path relative to wherever
proxmox-test-instance was run from.
Ship them with proxmox-test-instance (installed to
/usr/share/proxmox-test-instance/scripts), so that every plan can rely
on them being available at a fixed location. They are copied from
proxmox-e2e-tests.
Signed-off-by: Michael Köppl <m.koeppl@proxmox.com>
---
Makefile | 2 +-
debian/proxmox-test-instance.install | 1 +
scripts/download-cloud-image.sh | 21 +++++++++
scripts/download-container-image.sh | 22 +++++++++
scripts/install-ceph.sh | 13 ++++++
scripts/setup-frr.sh | 18 ++++++++
scripts/setup-zfs-storage.sh | 64 ++++++++++++++++++++++++++
scripts/update-packages.sh | 69 ++++++++++++++++++++++++++++
8 files changed, 209 insertions(+), 1 deletion(-)
create mode 100755 scripts/download-cloud-image.sh
create mode 100755 scripts/download-container-image.sh
create mode 100755 scripts/install-ceph.sh
create mode 100755 scripts/setup-frr.sh
create mode 100755 scripts/setup-zfs-storage.sh
create mode 100755 scripts/update-packages.sh
diff --git a/Makefile b/Makefile
index 789bb353..8bce483f 100644
--- a/Makefile
+++ b/Makefile
@@ -64,7 +64,7 @@ cargo-build-scheduler:
build: $(BUILDDIR)
$(BUILDDIR): | submodule
rm -rf $@ $@.tmp; mkdir $@.tmp
- cp -a proxmox-test-api-types proxmox-test-common proxmox-test-runner proxmox-test-instance proxmox-test-scheduler ui debian Cargo.toml LICENSE Makefile README.md defines.mk $@.tmp/
+ cp -a proxmox-test-api-types proxmox-test-common proxmox-test-runner proxmox-test-instance proxmox-test-scheduler scripts ui debian Cargo.toml LICENSE Makefile README.md defines.mk $@.tmp/
rm -rf $@.tmp/ui/target $@.tmp/ui/dist $@.tmp/ui/Cargo.lock
mv $@.tmp $@
diff --git a/debian/proxmox-test-instance.install b/debian/proxmox-test-instance.install
index a7d2ec88..681bd6e5 100644
--- a/debian/proxmox-test-instance.install
+++ b/debian/proxmox-test-instance.install
@@ -1 +1,2 @@
target/x86_64-unknown-linux-gnu/release/proxmox-test-instance usr/bin/
+scripts/ usr/share/proxmox-test-instance/
diff --git a/scripts/download-cloud-image.sh b/scripts/download-cloud-image.sh
new file mode 100755
index 00000000..56c57fdf
--- /dev/null
+++ b/scripts/download-cloud-image.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+# Downloads a VM disk image to the import content of a storage, so that VMs can be created from it
+# with 'import-from'. The download is only kept if it matches the given SHA-512 checksum.
+SSH_KEY=$(jq -r '.ssh_private_keyfile' "$CONFIG_PATH")
+HOST=$(jq -r '.host' "$CONFIG_PATH")
+USER=$(jq -r '.ssh_user' "$CONFIG_PATH")
+
+STORAGE=$1
+URL=$2
+FILENAME=$3
+SHA512=$4
+
+ssh -i "$SSH_KEY" "$USER"@"$HOST" -o StrictHostKeyChecking=no <<EOF
+set -e
+
+pvesh create /nodes/localhost/storage/$STORAGE/download-url --content import \
+ --url '$URL' --filename '$FILENAME' --checksum $SHA512 --checksum-algorithm sha512
+# Check the file itself. pvesh exits with 0 even if the download failed, which leaves a file that
+# already exists in place, whatever its content.
+echo "$SHA512 \$(pvesm path $STORAGE:import/$FILENAME)" | sha512sum --check --quiet
+EOF
diff --git a/scripts/download-container-image.sh b/scripts/download-container-image.sh
new file mode 100755
index 00000000..a6539901
--- /dev/null
+++ b/scripts/download-container-image.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+SSH_KEY=$(jq -r '.ssh_private_keyfile' $CONFIG_PATH)
+HOST=$(jq -r '.host' $CONFIG_PATH)
+USER=$(jq -r '.ssh_user' $CONFIG_PATH)
+
+STORAGE=$1
+IMAGE=$2
+
+ssh -i $SSH_KEY $USER@$HOST -o StrictHostKeyChecking=no <<EOF
+set -e
+
+path=\$(pvesm path $STORAGE:vztmpl/$IMAGE)
+# Sometimes requests are rejected with 503, to try again after a while.
+for attempt in 1 2 3 4 5; do
+ pveam download $STORAGE $IMAGE || true
+ # Explicitly check for the path, since download will still return 0 if it fails.
+ [ -e "\$path" ] && exit 0
+ sleep \$((attempt * 10))
+done
+echo "downloading $IMAGE to $STORAGE failed" >&2
+exit 1
+EOF
diff --git a/scripts/install-ceph.sh b/scripts/install-ceph.sh
new file mode 100755
index 00000000..23dc3a06
--- /dev/null
+++ b/scripts/install-ceph.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+SSH_KEY=$(jq -r '.ssh_private_keyfile' $CONFIG_PATH)
+HOST=$(jq -r '.host' $CONFIG_PATH)
+USER=$(jq -r '.ssh_user' $CONFIG_PATH)
+
+VERSION=$1
+REPOSITORY=$2
+
+ssh -i $SSH_KEY $USER@$HOST -o StrictHostKeyChecking=no <<EOT
+set -e
+
+yes | pveceph install --version $VERSION --repository $REPOSITORY
+EOT
diff --git a/scripts/setup-frr.sh b/scripts/setup-frr.sh
new file mode 100755
index 00000000..5be2e1f7
--- /dev/null
+++ b/scripts/setup-frr.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+SSH_KEY=$(jq -r '.ssh_private_keyfile' $CONFIG_PATH)
+HOST=$(jq -r '.host' $CONFIG_PATH)
+USER=$(jq -r '.ssh_user' $CONFIG_PATH)
+
+ssh -i $SSH_KEY $USER@$HOST -o StrictHostKeyChecking=no <<'EOF'
+set -e
+
+echo -e "LANG=C\nLC_ALL=C" | tee /etc/default/locale /etc/environment
+export LANG=C LC_ALL=C
+
+export DEBIAN_FRONTEND=noninteractive
+apt-get -y update
+apt-get -y dist-upgrade
+apt-get -y install frr vlan
+
+systemctl enable --now frr
+EOF
diff --git a/scripts/setup-zfs-storage.sh b/scripts/setup-zfs-storage.sh
new file mode 100755
index 00000000..a00ac552
--- /dev/null
+++ b/scripts/setup-zfs-storage.sh
@@ -0,0 +1,64 @@
+#!/bin/bash
+# Create a ZFS pool on an additional disk of a PVE node and register it as a zfspool storage, so
+# tests that need ZFS-backed guest images (storage replication) find one.
+#
+# Usage: setup-zfs-storage.sh <disk-serial> <name>
+#
+# The node needs an extra disk with the given serial. The name is used both for the pool and for
+# the storage id. The disk is looked up by ID_SCSI_SERIAL.
+#
+# Enabling zfs-import@<pool> is what makes the pool come back after the node is powered down at
+# the end of the setup.
+
+set -euo pipefail
+
+SSH_KEY=$(jq -r '.ssh_private_keyfile' $CONFIG_PATH)
+HOST=$(jq -r '.host' $CONFIG_PATH)
+USER=$(jq -r '.ssh_user' $CONFIG_PATH)
+
+SERIAL=$1
+POOL=$2
+
+ssh -i $SSH_KEY $USER@$HOST -o StrictHostKeyChecking=no bash -s -- "$SERIAL" "$POOL" <<'EOF'
+set -e
+
+serial=$1
+pool=$2
+
+dev=""
+for disk in /dev/sd?; do
+ udevadm info --query=property --name="$disk" | grep -qx "ID_SCSI_SERIAL=$serial" || continue
+ dev="$disk"
+ break
+done
+
+if [ -z "$dev" ]; then
+ echo "no disk with SCSI serial '$serial' on $(hostname); disks on this node:" >&2
+ for disk in /dev/sd?; do
+ echo " $disk $(udevadm info --query=property --name="$disk" \
+ | grep '^ID_SCSI_SERIAL=' || echo 'ID_SCSI_SERIAL=')" >&2
+ done
+ exit 1
+fi
+
+# Prefer the persistent link, as PVE's disk management does, and fall back to the device node
+# for a disk udev created no such link for.
+if link=$(udevadm info --query=symlink --name="$dev" | tr ' ' '\n' | grep -m1 '^disk/by-id/scsi-')
+then
+ dev="/dev/$link"
+fi
+
+if ! zpool list -H "$pool" >/dev/null 2>&1; then
+ zpool create -o ashift=12 "$pool" "$dev"
+ zfs set compression=on "$pool"
+fi
+
+if [ -e /lib/systemd/system/zfs-import@.service ]; then
+ systemctl enable "zfs-import@$pool.service"
+fi
+
+# The storage is what the tests look for, so it needs the content types for guest images.
+if ! pvesm status --storage "$pool" >/dev/null 2>&1; then
+ pvesm add zfspool "$pool" --pool "$pool" --content images,rootdir --sparse 1
+fi
+EOF
diff --git a/scripts/update-packages.sh b/scripts/update-packages.sh
new file mode 100755
index 00000000..b4648dcb
--- /dev/null
+++ b/scripts/update-packages.sh
@@ -0,0 +1,69 @@
+#!/bin/bash
+SSH_KEY=$(jq -r '.ssh_private_keyfile' $CONFIG_PATH)
+HOST=$(jq -r '.host' $CONFIG_PATH)
+USER=$(jq -r '.ssh_user' $CONFIG_PATH)
+
+product=$1
+repo=$2
+
+case $product in
+ "pve")
+ maj=9
+ ;;
+ "pmg")
+ maj=9
+ ;;
+ "pbs")
+ maj=4
+ ;;
+ "pdm")
+ maj=1
+ ;;
+ *)
+ echo "unknown product: $product"
+ exit 1
+ ;;
+esac
+
+case $repo in
+ "staging")
+ full_repo="Types: deb
+URIs: http://repo.intra.proxmox.com/staging/${product}
+Suites: trixie
+Components: ${product}-${maj}
+Signed-By: /usr/share/keyrings/proxmox-archive-keyring.gpg"
+ ;;
+ "no-subscription")
+ full_repo="Types: deb
+URIs: http://download.proxmox.com/debian/${product}
+Suites: trixie
+Components: ${product}-no-subscription
+Signed-By: /usr/share/keyrings/proxmox-archive-keyring.gpg"
+ ;;
+ "test")
+ full_repo="Types: deb
+URIs: http://download.proxmox.com/debian/${product}
+Suites: trixie
+Components: ${product}-test
+Signed-By: /usr/share/keyrings/proxmox-archive-keyring.gpg"
+ ;;
+esac
+
+ssh -i $SSH_KEY $USER@$HOST -o StrictHostKeyChecking=no <<EOF
+set -e
+
+echo "Update packages hook running"
+
+tee > /etc/apt/sources.list.d/pve-$repo.sources <<EOT
+$full_repo
+EOT
+
+rm -f /etc/apt/sources.list.d/pve-enterprise.sources
+rm -f /etc/apt/sources.list.d/pbs-enterprise.sources
+rm -f /etc/apt/sources.list.d/pmg-enterprise.sources
+rm -f /etc/apt/sources.list.d/ceph.sources
+
+export DEBIAN_FRONTEND=noninteractive
+apt-get update -y
+apt-get dist-upgrade -y
+EOF
--
2.47.3
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH test-tools 3/8] instance: distinguish builtin hooks from hook files
2026-12-01 14:58 [PATCH e2e-tests/test-tools 0/8] instance: rework hooks and set up Ceph as a cluster hook Michael Köppl
2026-12-01 14:58 ` [PATCH test-tools 1/8] readme: drop token fields from the hook config example Michael Köppl
2026-12-01 14:58 ` [PATCH test-tools 2/8] instance: ship generic hook scripts Michael Köppl
@ 2026-12-01 14:58 ` Michael Köppl
2026-12-01 14:58 ` [PATCH test-tools 4/8] instance: add hooks that run once a cluster is formed Michael Köppl
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Michael Köppl @ 2026-12-01 14:58 UTC (permalink / raw)
To: pve-devel
Hooks were command lines run relative to the current dir of
proxmox-test-instance. For proxmox-test-scheduler, that is the home dir
of the SSH user, so a plan only found its scripts if they happened to be
placed there, regardless of where the plan itself was.
Hooks now either name a script shipped with proxmox-test-instance, as in
Builtin("update-packages pve staging"), or a script of their own, as in
File("../scripts/setup-ldap.sh"), which is resolved relative to the
directory of the plan file. A symlink to the plan is resolved first, so
that the scripts next to the plan itself are found.
Hooks given as plain strings are no longer accepted, so existing plans
need to be adapted. The setup digest of plans with hooks changes
accordingly and their next setup starts fresh.
Signed-off-by: Michael Köppl <m.koeppl@proxmox.com>
---
README.md | 23 ++++++--
proxmox-test-instance/src/cli.rs | 20 ++++++-
proxmox-test-instance/src/config.rs | 53 ++++++++++++++++++-
.../src/instance_manager/mod.rs | 10 ++--
4 files changed, 96 insertions(+), 10 deletions(-)
diff --git a/README.md b/README.md
index abef2c61..8bca2818 100644
--- a/README.md
+++ b/README.md
@@ -164,7 +164,8 @@ Plan(
// root_password: Inline("password"),
),
post_setup: [
- "scripts/update-packages.sh pve staging",
+ Builtin("update-packages pve staging"),
+ File("scripts/my-hook.sh"),
],
),
]
@@ -177,7 +178,24 @@ Plan(
The `proxmox-test-instance run-script` command can be used to run scripts on test instances, e.g.
to update them to the latest packages, to inject test artifacts etc.
+### Setup hooks
+The `post_setup` hooks of an instance run after its installation. Each hook is a command line
+naming a script, followed by its arguments, which are passed through the shell:
+
+- `Builtin("<name> [<args>]")` runs a script shipped with `proxmox-test-instance`, installed as
+ `/usr/share/proxmox-test-instance/scripts/<name>.sh`.
+- `File("<path> [<args>]")` runs a script of your own. A relative path is resolved against the
+ directory of the plan file, after resolving symlinks to it.
+
+| Builtin | Arguments | Description |
+|---|---|---|
+| `update-packages` | `<pve\|pbs\|pmg\|pdm> <staging\|no-subscription\|test>` | Switch to the given repository and upgrade all packages |
+| `download-container-image` | `<storage> <template>` | Download a container template into a storage |
+| `download-cloud-image` | `<storage> <url> <filename> <sha512>` | Download a disk image into the import content of a storage, keeping it only if the checksum matches |
+| `install-ceph` | `<version> <repository>` | Install the Ceph packages, without setting up a Ceph cluster |
+| `setup-zfs-storage` | `<disk-serial> <name>` | Create a ZFS pool on the additional disk with the given serial and add it as a storage of the same name |
+| `setup-frr` | | Install and enable FRR |
Setup hooks for assets are also provided with the asset configuration via a JSON configuration file,
located at `$CONFIG_PATH`. This allows to use the same hook script for multiple assets.
@@ -192,8 +210,7 @@ located at `$CONFIG_PATH`. This allows to use the same hook script for multiple
To get the contents in a hook script, `jq` may be used.
Scripts are executed on the same host where `proxmox-test-instance`
is executed. SSH may be used to perform any setup steps on the instance itself.
-An example can be seen in `hooks/update-packages.sh` in the sibling
-`proxmox-e2e-tests` repository.
+The builtin hooks in `scripts/` serve as examples.
# proxmox-test-runner
diff --git a/proxmox-test-instance/src/cli.rs b/proxmox-test-instance/src/cli.rs
index bbc9cb34..1033f5dd 100644
--- a/proxmox-test-instance/src/cli.rs
+++ b/proxmox-test-instance/src/cli.rs
@@ -1,10 +1,10 @@
use std::{
io::{BufRead, BufReader, Write},
- path::PathBuf,
+ path::{Path, PathBuf},
sync::{Arc, atomic::AtomicBool},
};
-use anyhow::{Error, bail};
+use anyhow::{Context, Error, bail};
use pico_args::Arguments;
use proxmox_test_common::{
inventory::TestInventory, log, secrets::SecretResolver, utils::from_file,
@@ -370,6 +370,18 @@ fn parse_u64(s: &std::ffi::OsStr) -> Result<u64, Error> {
Ok(s.to_string_lossy().parse::<u64>()?)
}
+/// Returns the directory the plan is in. This is used e.g. by relative hook paths of a plan.
+/// Symlinks are resolved first so that hooks are found next to the plan itself rather than next
+/// to a link.
+fn resolve_plan_dir(plan: &Path) -> Result<PathBuf, Error> {
+ let plan = plan
+ .canonicalize()
+ .with_context(|| format!("cannot resolve plan path '{}'", plan.display()))?;
+ plan.parent()
+ .map(Path::to_path_buf)
+ .context("plan path has no parent directory")
+}
+
#[derive(Clone, Debug)]
pub struct Cli {
pub command: Command,
@@ -795,8 +807,10 @@ impl Command {
let mut manager = InstanceManager::new(testrunner_config, secret_resolver, interrupted)?;
let plan: Plan = from_file(args.plan.clone())?;
+ let plan_dir = resolve_plan_dir(&args.plan)?;
manager.fresh_setup(
+ &plan_dir,
&plan,
&args.output,
&testrunner_config.default_bridge,
@@ -817,8 +831,10 @@ impl Command {
let mut manager = InstanceManager::new(testrunner_config, secret_resolver, interrupted)?;
let plan: Plan = from_file(args.plan.clone())?;
+ let plan_dir = resolve_plan_dir(&args.plan)?;
manager.setup(
+ &plan_dir,
&plan,
&args.output,
&testrunner_config.default_bridge,
diff --git a/proxmox-test-instance/src/config.rs b/proxmox-test-instance/src/config.rs
index b1d99de0..7842ae1b 100644
--- a/proxmox-test-instance/src/config.rs
+++ b/proxmox-test-instance/src/config.rs
@@ -1,12 +1,16 @@
use std::fmt::Display;
+use std::path::Path;
-use anyhow::{Error, bail};
+use anyhow::{Context, Error, bail};
use serde::{Deserialize, Serialize};
use proxmox_test_common::secrets::Secret;
use proxmox_test_common::types::Disk;
use proxmox_test_common::utils;
+/// Where builtin hook scripts are installed.
+pub const BUILTIN_HOOK_DIR: &str = "/usr/share/proxmox-test-instance/scripts";
+
pub const DEFAULT_SDN_ZONE_NAME: &str = "ttzone";
pub const DEFAULT_SDN_VNET_NAME: &str = "ttvnet";
pub const DEFAULT_SDN_SUBNET: &str = "172.16.0.0/24";
@@ -26,10 +30,55 @@ pub struct SetupInstance {
pub name: String,
pub kind: InstanceKind,
#[serde(default)]
- pub post_setup: Vec<String>,
+ pub post_setup: Vec<Hook>,
pub playbook: Option<String>,
}
+/// A script to run on the host, connecting to the test instance at some pre-defined lifecycle
+/// stage. Its command line names the script first, followed by the arguments, which are passed
+/// through the shell.
+#[derive(Clone, Debug, Deserialize, Serialize)]
+pub enum Hook {
+ /// A script shipped with the deb package, named without its `.sh` suffix.
+ Builtin(String),
+ /// A script path relative to the directory of the plan file unless absolute.
+ File(String),
+}
+
+impl Hook {
+ /// Returns the command line that runs this hook for a plan located in `plan_dir`.
+ pub fn command(&self, plan_dir: &Path) -> Result<String, Error> {
+ let (Hook::Builtin(command) | Hook::File(command)) = self;
+ let command = command.trim();
+ let (script, args) = command
+ .split_once(char::is_whitespace)
+ .unwrap_or((command, ""));
+ if script.is_empty() {
+ bail!("hook does not name a script");
+ }
+
+ let path = match self {
+ Hook::Builtin(_) => {
+ if script.contains('/') {
+ bail!("builtin hook '{script}' must be a name, not a path");
+ }
+ Path::new(BUILTIN_HOOK_DIR).join(format!("{script}.sh"))
+ }
+ Hook::File(_) => plan_dir.join(script),
+ };
+ let path = path
+ .to_str()
+ .with_context(|| format!("hook path '{}' is not valid UTF-8", path.display()))?;
+
+ let script = format!("'{}'", path.replace('\'', r"'\''"));
+ Ok(if args.is_empty() {
+ script
+ } else {
+ format!("{script} {args}")
+ })
+ }
+}
+
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum InstanceKind {
Vm(VmSettings),
diff --git a/proxmox-test-instance/src/instance_manager/mod.rs b/proxmox-test-instance/src/instance_manager/mod.rs
index 53dee7dd..fceec04e 100644
--- a/proxmox-test-instance/src/instance_manager/mod.rs
+++ b/proxmox-test-instance/src/instance_manager/mod.rs
@@ -115,6 +115,7 @@ impl<'a> InstanceManager<'a> {
pub fn fresh_setup(
&mut self,
+ plan_dir: &Path,
config: &Plan,
inventory_path: &Option<PathBuf>,
default_bridge: &str,
@@ -410,7 +411,7 @@ impl<'a> InstanceManager<'a> {
}
}
- self.run_instance_startup(&config.instances, timeout)?;
+ self.run_instance_startup(plan_dir, &config.instances, timeout)?;
if let Some(managed_datacenter) = &config.managed_datacenter {
let s = self.state.clone();
@@ -566,6 +567,7 @@ impl<'a> InstanceManager<'a> {
/// leaving it powered off again afterwards.
fn run_instance_startup(
&self,
+ plan_dir: &Path,
setup_instances: &[SetupInstance],
timeout: &Option<u64>,
) -> Result<(), Error> {
@@ -590,8 +592,8 @@ impl<'a> InstanceManager<'a> {
self.run_script_impl(&script, Some("first boot setup"), name)?;
}
- for script in &instance.post_setup {
- self.run_script_impl(script, None, name)?;
+ for hook in &instance.post_setup {
+ self.run_script_impl(&hook.command(plan_dir)?, None, name)?;
}
if let Some(playbook) = &instance.playbook {
@@ -787,6 +789,7 @@ systemctl list-unit-files --type=timer --state=enabled --no-legend | grep daily
pub fn setup(
&mut self,
+ plan_dir: &Path,
config: &Plan,
inventory_path: &PathBuf,
default_bridge: &str,
@@ -835,6 +838,7 @@ systemctl list-unit-files --type=timer --state=enabled --no-legend | grep daily
self.state = TestInventory::default();
self.fresh_setup(
+ plan_dir,
config,
&Some(inventory_path.clone()),
default_bridge,
--
2.47.3
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH test-tools 4/8] instance: add hooks that run once a cluster is formed
2026-12-01 14:58 [PATCH e2e-tests/test-tools 0/8] instance: rework hooks and set up Ceph as a cluster hook Michael Köppl
` (2 preceding siblings ...)
2026-12-01 14:58 ` [PATCH test-tools 3/8] instance: distinguish builtin hooks from hook files Michael Köppl
@ 2026-12-01 14:58 ` Michael Köppl
2026-12-01 14:58 ` [PATCH test-tools 5/8] instance: cli: run a script once for a whole cluster Michael Köppl
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Michael Köppl @ 2026-12-01 14:58 UTC (permalink / raw)
To: pve-devel
Some setup steps need the formed cluster with all of its nodes at once.
Setting up Ceph, for example, needs a monitor on every node and creates
its pools only once. Setup hooks cannot do this. They run before the
cluster is formed, once per instance, and only know about that one
instance.
Clusters in plans can now have 'post_cluster' hooks. They run once for
the whole cluster after it has been formed, while all of its nodes are
still running, so that their result is part of the 'post-setup'
snapshot. Their $CONFIG_PATH lists all nodes, ordered by IP address, the
first being the one the cluster was created on.
Scripts messages now name their target without calling it an instance,
since it can also be a cluster.
Plans without cluster hooks serialize as before, so their setup digest
stays the same and not rebuilds are necessary.
Signed-off-by: Michael Köppl <m.koeppl@proxmox.com>
---
README.md | 35 ++++++-
proxmox-test-instance/src/cli.rs | 1 +
proxmox-test-instance/src/config.rs | 5 +-
.../src/instance_manager/mod.rs | 94 ++++++++++++++++---
4 files changed, 121 insertions(+), 14 deletions(-)
diff --git a/README.md b/README.md
index 8bca2818..d54095aa 100644
--- a/README.md
+++ b/README.md
@@ -84,7 +84,7 @@ Depending on the plan, this will
- Start the PVE/PBS autoinstaller from a provided ISO
- Wait for the installation to finish
- Run any post-setup scripts/playbooks
- - Form configured clusters and shut down the guests
+ - Form configured clusters, run their post-cluster hooks, and shut down the guests
- Create an offline snapshot called `post-setup`
- Write the current inventory state to the given inventory file, which can
be used by `proxmox-test-runner`
@@ -212,6 +212,39 @@ Scripts are executed on the same host where `proxmox-test-instance`
is executed. SSH may be used to perform any setup steps on the instance itself.
The builtin hooks in `scripts/` serve as examples.
+### Cluster hooks
+
+The `post_cluster` hooks of a cluster run once the cluster has been formed, while all of its nodes
+are running. They take the same `Builtin(...)` and `File(...)` forms as setup hooks, but run once
+for the whole cluster rather than once per node. They do not run with `setup --no-cluster`.
+
+```ron
+clusters: [
+ Cluster(
+ name: "pvecluster",
+ nodes: ["pve1", "pve2", "pve3"],
+ post_cluster: [
+ File("scripts/my-cluster-hook.sh"),
+ ],
+ ),
+],
+```
+
+Instead of a single host, their `$CONFIG_PATH` lists all nodes of the cluster, ordered by IP
+address. The first node is the one the cluster was created on.
+```json
+{
+ "ssh_private_keyfile": "/home/user/.ssh/id_rsa",
+ "ssh_user": "root",
+ "cluster": "pvecluster",
+ "nodes": [
+ { "name": "pve1", "host": "172.16.0.100" },
+ { "name": "pve2", "host": "172.16.0.101" },
+ { "name": "pve3", "host": "172.16.0.102" }
+ ]
+}
+```
+
# proxmox-test-runner
## TL;DR
diff --git a/proxmox-test-instance/src/cli.rs b/proxmox-test-instance/src/cli.rs
index 1033f5dd..1aca340a 100644
--- a/proxmox-test-instance/src/cli.rs
+++ b/proxmox-test-instance/src/cli.rs
@@ -928,6 +928,7 @@ impl Command {
name: args.cluster_name.clone(),
// TODO: make this configurable
nodes: None,
+ post_cluster: Vec::new(),
};
let created = manager.create_cluster(&cluster)?;
manager.record_cluster(created)?;
diff --git a/proxmox-test-instance/src/config.rs b/proxmox-test-instance/src/config.rs
index 7842ae1b..59f2b6f2 100644
--- a/proxmox-test-instance/src/config.rs
+++ b/proxmox-test-instance/src/config.rs
@@ -37,7 +37,7 @@ pub struct SetupInstance {
/// A script to run on the host, connecting to the test instance at some pre-defined lifecycle
/// stage. Its command line names the script first, followed by the arguments, which are passed
/// through the shell.
-#[derive(Clone, Debug, Deserialize, Serialize)]
+#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, Hash)]
pub enum Hook {
/// A script shipped with the deb package, named without its `.sh` suffix.
Builtin(String),
@@ -134,6 +134,9 @@ fn iso_type_default() -> String {
pub struct Cluster {
pub name: String,
pub nodes: Option<Vec<String>>,
+ /// Hooks run once for the whole cluster after the cluster has been formed.
+ #[serde(default, skip_serializing_if = "Vec::is_empty")]
+ pub post_cluster: Vec<Hook>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
diff --git a/proxmox-test-instance/src/instance_manager/mod.rs b/proxmox-test-instance/src/instance_manager/mod.rs
index fceec04e..0c23eca9 100644
--- a/proxmox-test-instance/src/instance_manager/mod.rs
+++ b/proxmox-test-instance/src/instance_manager/mod.rs
@@ -62,6 +62,21 @@ struct HookRuntimeConfig {
ssh_user: String,
}
+/// The `$CONFIG_PATH` of a cluster hook.
+#[derive(Serialize)]
+struct ClusterHookRuntimeConfig {
+ ssh_private_keyfile: String,
+ ssh_user: String,
+ cluster: String,
+ nodes: Vec<ClusterHookNode>,
+}
+
+#[derive(Serialize)]
+struct ClusterHookNode {
+ name: String,
+ host: String,
+}
+
pub struct InstanceManager<'a> {
config: &'a Config,
secret_resolver: &'a SecretResolver,
@@ -455,8 +470,8 @@ impl<'a> InstanceManager<'a> {
if let Some(clusters) = &config.clusters {
for cluster in clusters {
- let nodes: Vec<String> = self
- .cluster_instances(cluster)?
+ let members = self.cluster_instances(cluster)?;
+ let nodes: Vec<String> = members
.iter()
.map(|instance| instance.nodename.clone())
.collect();
@@ -468,7 +483,10 @@ impl<'a> InstanceManager<'a> {
// of them reachable at once.
let result = self
.start(&cluster_instances, &[])
- .and_then(|()| self.create_cluster(cluster));
+ .and_then(|()| self.create_cluster(cluster))
+ .and_then(|_| {
+ self.run_cluster_hooks(plan_dir, cluster, &members, &cluster_instances)
+ });
let cleanup = self.shutdown(&cluster_instances, &[]);
finish_instance_visit(result, cleanup)?;
}
@@ -922,9 +940,19 @@ systemctl list-unit-files --type=timer --state=enabled --no-legend | grep daily
ssh_user: "root".into(),
};
+ self.run_command(cmd, label, instance, &serde_json::to_value(runtime_config)?)
+ }
+
+ /// Runs `cmd` with `data` in `$CONFIG_PATH`. `target` names what it runs against in the log.
+ fn run_command(
+ &self,
+ cmd: &str,
+ label: Option<&str>,
+ target: &str,
+ data: &serde_json::Value,
+ ) -> Result<(), Error> {
let label = label.unwrap_or(cmd);
- let data = serde_json::to_value(runtime_config)?;
- log::log_step("Running script", &format!("'{label}' on '{instance}'"));
+ log::log_step("Running script", &format!("'{label}' on '{target}'"));
// Groups run concurrently, so the streamed lines of half a dozen instances are interleaved.
// Keep a copy to report with a failure, since by then the cause has scrolled far out of
@@ -932,14 +960,14 @@ systemctl list-unit-files --type=timer --state=enabled --no-legend | grep daily
let output = Arc::new(Mutex::new(Vec::new()));
let stdout_output = Arc::clone(&output);
- let stdout_name = instance.to_string();
+ let stdout_name = target.to_string();
let stdout_cb = move |s: String| {
log::log_command_output(&format!("[{stdout_name}] {s}"));
stdout_output.lock().unwrap().push(s);
};
let stderr_output = Arc::clone(&output);
- let stderr_name = instance.to_string();
+ let stderr_name = target.to_string();
let stderr_cb = move |s: String| {
log::log_command_output(&format!("[{stderr_name}] {s}"));
stderr_output.lock().unwrap().push(s);
@@ -948,7 +976,7 @@ systemctl list-unit-files --type=timer --state=enabled --no-legend | grep daily
let status = run_with_timeout(
cmd,
None,
- Some(&data),
+ Some(data),
&[],
&self.interrupted,
stdout_cb,
@@ -957,18 +985,18 @@ systemctl list-unit-files --type=timer --state=enabled --no-legend | grep daily
match status {
RunStatus::Timeout(t) => {
- bail!("'{label}' for instance '{instance}' timed out after {t} seconds")
+ bail!("'{label}' for '{target}' timed out after {t} seconds")
}
- RunStatus::Interrupted => bail!("'{label}' for instance '{instance}' was interrupted"),
+ RunStatus::Interrupted => bail!("'{label}' for '{target}' was interrupted"),
RunStatus::Success => {
- log::log(format!("'{label}' for instance '{instance}' finished"));
+ log::log(format!("'{label}' for '{target}' finished"));
}
RunStatus::Failure(s) => {
let output = output.lock().unwrap();
let tail = &output[output.len().saturating_sub(FAILED_SCRIPT_LOG_LINES)..];
bail!(
- "'{label}' for instance '{instance}' failed with exit status {s}\n{}",
+ "'{label}' for '{target}' failed with exit status {s}\n{}",
tail.join("\n")
)
}
@@ -1102,6 +1130,45 @@ systemctl list-unit-files --type=timer --state=enabled --no-legend | grep daily
})
}
+ /// Runs the hooks of `cluster` once for all its members, which must be running.
+ fn run_cluster_hooks(
+ &self,
+ plan_dir: &Path,
+ cluster: &Cluster,
+ members: &[TestInstance],
+ instances: &[String],
+ ) -> Result<(), Error> {
+ if cluster.post_cluster.is_empty() {
+ return Ok(());
+ }
+
+ for instance in instances {
+ // Nodes were just booted, so overdue package timers could hold the apt lock a hook
+ // needs.
+ self.disable_package_management(instance)?;
+ }
+
+ let runtime_config = ClusterHookRuntimeConfig {
+ ssh_private_keyfile: self.config.ssh_private_keyfile.clone(),
+ ssh_user: "root".into(),
+ cluster: cluster.name.clone(),
+ nodes: members
+ .iter()
+ .map(|member| ClusterHookNode {
+ name: member.nodename.clone(),
+ host: member.ip.clone(),
+ })
+ .collect(),
+ };
+ let data = serde_json::to_value(runtime_config)?;
+ let target = format!("cluster {}", cluster.name);
+
+ for hook in &cluster.post_cluster {
+ self.run_command(&hook.command(plan_dir)?, None, &target, &data)?;
+ }
+ Ok(())
+ }
+
/// Record disjoint topology, or confirm an identical planned cluster without duplicating it.
pub fn record_cluster(&mut self, cluster: TestInstanceCluster) -> Result<(), Error> {
let clusters = self.state.clusters.get_or_insert_default();
@@ -1734,6 +1801,7 @@ mod tests {
let default = Cluster {
name: "test".into(),
nodes: None,
+ post_cluster: Vec::new(),
};
assert!(
manager
@@ -1756,6 +1824,7 @@ mod tests {
.cluster_instances(&Cluster {
name: "test".into(),
nodes: Some(vec!["missing".into()]),
+ post_cluster: Vec::new(),
})
.unwrap_err()
.to_string()
@@ -1811,6 +1880,7 @@ mod tests {
.create_cluster(&Cluster {
name: "manual".into(),
nodes: None,
+ post_cluster: Vec::new(),
})
.unwrap_err();
// Attempting authentication would instead fail parsing the deliberately invalid address.
--
2.47.3
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH test-tools 5/8] instance: cli: run a script once for a whole cluster
2026-12-01 14:58 [PATCH e2e-tests/test-tools 0/8] instance: rework hooks and set up Ceph as a cluster hook Michael Köppl
` (3 preceding siblings ...)
2026-12-01 14:58 ` [PATCH test-tools 4/8] instance: add hooks that run once a cluster is formed Michael Köppl
@ 2026-12-01 14:58 ` Michael Köppl
2026-12-01 14:58 ` [PATCH test-tools 6/8] instance: add a builtin hook to set up a Ceph cluster Michael Köppl
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Michael Köppl @ 2026-12-01 14:58 UTC (permalink / raw)
To: pve-devel
Clusters formed with `setup --no-cluster` and `create-cluster` do not
run post_cluster hooks, so there was no way to run a script that needs
the whole cluster against them.
Add `run-script --cluster NAME`, which runs the script once with the
same $CONFIG_PATH as post_cluster hooks, targeting all nodes of the
cluster, ordered by IP. Unlike per-instance runs, which keep at most
max_concurrent_setups instances up, all nodes are powered on together.
Nodes that were not running before are shut down again afterwards.
Signed-off-by: Michael Köppl <m.koeppl@proxmox.com>
---
README.md | 9 ++
proxmox-test-instance/src/cli.rs | 20 ++-
.../src/instance_manager/mod.rs | 118 ++++++++++++++++--
3 files changed, 135 insertions(+), 12 deletions(-)
diff --git a/README.md b/README.md
index d54095aa..fe727133 100644
--- a/README.md
+++ b/README.md
@@ -245,6 +245,15 @@ address. The first node is the one the cluster was created on.
}
```
+Clusters formed manually (`setup --no-cluster` followed by `create-cluster`) do not run
+`post_cluster` hooks. Once such a cluster is formed, `run-script --cluster` runs a script once for
+it, with the same `$CONFIG_PATH`. As with other `run-script` calls, the script path is relative to
+the current directory:
+
+```shell
+proxmox-test-instance run-script --cluster pvecluster inventory.ron ./scripts/my-cluster-hook.sh
+```
+
# proxmox-test-runner
## TL;DR
diff --git a/proxmox-test-instance/src/cli.rs b/proxmox-test-instance/src/cli.rs
index 1aca340a..5745c9fd 100644
--- a/proxmox-test-instance/src/cli.rs
+++ b/proxmox-test-instance/src/cli.rs
@@ -157,6 +157,9 @@ OPTIONS:
--config PATH Provide a custom config file
--include INSTANCE Include this instance. Can be set multiple times.
--exclude INSTANCE Exclude this instance. Can be set multiple times.
+ --cluster NAME Run the script once for this cluster instead, with all
+ of its nodes in $CONFIG_PATH. Cannot be combined with
+ --include or --exclude.
If neither --include nor --exclude are provided, the script
is executed against ALL instances from the inventory.
@@ -164,7 +167,8 @@ If both are provided, excluded instances are subtracted from included ones.
ARGS:
<INVENTORY> Inventory of test instances
- <SCRIPT> Script to run for each selected instance
+ <SCRIPT> Script to run for each selected instance, or once for
+ the cluster
";
const CREATE_CLUSTER_HELP: &str = "\
@@ -447,6 +451,7 @@ impl Cli {
Some("run-script") => Command::RunScript(RunScriptArgs {
secrets: args.opt_value_from_os_str("--secrets", parse_path)?,
config: args.opt_value_from_os_str("--config", parse_path)?,
+ cluster: args.opt_value_from_str("--cluster")?,
include: args.values_from_str("--include")?,
exclude: args.values_from_str("--exclude")?,
inventory: args.free_from_os_str(parse_path)?,
@@ -591,6 +596,9 @@ pub struct RunScriptArgs {
pub include: Vec<String>,
/// Don't run the script on these instances
pub exclude: Vec<String>,
+
+ /// Run the script once for this cluster instead of on each instance.
+ pub cluster: Option<String>,
}
#[derive(Clone, Debug)]
@@ -905,10 +913,18 @@ impl Command {
secret_resolver: &SecretResolver,
interrupted: Arc<AtomicBool>,
) -> Result<(), Error> {
+ if args.cluster.is_some() && (!args.include.is_empty() || !args.exclude.is_empty()) {
+ bail!("--cluster cannot be combined with --include or --exclude");
+ }
+
let inventory = TestInventory::load(&args.inventory)?;
let mut manager = InstanceManager::new(testrunner_config, secret_resolver, interrupted)?;
manager.set_state(inventory);
- manager.run_script(&args.script, &args.include, &args.exclude)?;
+
+ match &args.cluster {
+ Some(cluster) => manager.run_cluster_script(&args.script, cluster)?,
+ None => manager.run_script(&args.script, &args.include, &args.exclude)?,
+ }
Ok(())
}
diff --git a/proxmox-test-instance/src/instance_manager/mod.rs b/proxmox-test-instance/src/instance_manager/mod.rs
index 0c23eca9..f4cc9085 100644
--- a/proxmox-test-instance/src/instance_manager/mod.rs
+++ b/proxmox-test-instance/src/instance_manager/mod.rs
@@ -1026,6 +1026,37 @@ systemctl list-unit-files --type=timer --state=enabled --no-legend | grep daily
})
}
+ /// Runs a script once for a cluster from the inventory, powering on its nodes that are not
+ /// running and shutting them down again afterwards.
+ pub fn run_cluster_script(&self, script: &str, cluster: &str) -> Result<(), Error> {
+ let recorded = self
+ .state
+ .clusters
+ .as_deref()
+ .unwrap_or_default()
+ .iter()
+ .find(|recorded| recorded.name == cluster)
+ .with_context(|| format!("no cluster '{cluster}' in inventory"))?;
+
+ let members = self.cluster_instances(&Cluster {
+ name: recorded.name.clone(),
+ nodes: Some(recorded.nodes.clone()),
+ post_cluster: Vec::new(),
+ })?;
+ let instances = self.instance_names_for_nodes(&recorded.nodes)?;
+
+ self.with_started_instances(&instances, &None, || {
+ for instance in &instances {
+ // Nodes may just have been booted, so overdue package timers could hold the apt
+ // lock the script needs.
+ self.disable_package_management(instance)?;
+ }
+
+ let data = self.cluster_hook_data(&recorded.name, &members)?;
+ self.run_command(script, None, &format!("cluster {}", recorded.name), &data)
+ })
+ }
+
/// Form the cluster and return its actual membership for the inventory.
pub fn create_cluster(&mut self, cluster: &Cluster) -> Result<TestInstanceCluster, Error> {
let runtime = proxmox_async::runtime::get_runtime();
@@ -1148,10 +1179,25 @@ systemctl list-unit-files --type=timer --state=enabled --no-legend | grep daily
self.disable_package_management(instance)?;
}
- let runtime_config = ClusterHookRuntimeConfig {
+ let data = self.cluster_hook_data(&cluster.name, members)?;
+ let target = format!("cluster {}", cluster.name);
+
+ for hook in &cluster.post_cluster {
+ self.run_command(&hook.command(plan_dir)?, None, &target, &data)?;
+ }
+ Ok(())
+ }
+
+ /// Returns the `$CONFIG_PATH` contents of a script run once for a whole cluster.
+ fn cluster_hook_data(
+ &self,
+ cluster: &str,
+ members: &[TestInstance],
+ ) -> Result<serde_json::Value, Error> {
+ Ok(serde_json::to_value(ClusterHookRuntimeConfig {
ssh_private_keyfile: self.config.ssh_private_keyfile.clone(),
ssh_user: "root".into(),
- cluster: cluster.name.clone(),
+ cluster: cluster.to_string(),
nodes: members
.iter()
.map(|member| ClusterHookNode {
@@ -1159,14 +1205,7 @@ systemctl list-unit-files --type=timer --state=enabled --no-legend | grep daily
host: member.ip.clone(),
})
.collect(),
- };
- let data = serde_json::to_value(runtime_config)?;
- let target = format!("cluster {}", cluster.name);
-
- for hook in &cluster.post_cluster {
- self.run_command(&hook.command(plan_dir)?, None, &target, &data)?;
- }
- Ok(())
+ })?)
}
/// Record disjoint topology, or confirm an identical planned cluster without duplicating it.
@@ -1934,4 +1973,63 @@ mod tests {
.is_err()
);
}
+
+ #[test]
+ fn cluster_script_uses_recorded_members_in_ip_order() {
+ let config: Config = ron::from_str(
+ r#"Config(
+ test_host_url: "https://127.0.0.1:1", test_host_userid: "root@pam!test",
+ test_host_token: Some("test"), control_ip: "127.0.0.1",
+ default_storage: "local", default_bridge: "ttvnet", vmid_range: (6000, 6010),
+ ssh_private_keyfile: "/dev/null", ssh_public_keyfile: "/dev/null",
+ )"#,
+ )
+ .unwrap();
+ let resolver = SecretResolver::default();
+ let mut manager =
+ InstanceManager::new(&config, &resolver, Arc::new(AtomicBool::new(false))).unwrap();
+ // The IPs sort differently as strings, so this also checks that members are ordered by
+ // address, as the README promises.
+ manager.state.instances = ron::from_str(r#"{
+ "first": (nodename: "pve1", virt: Qemu(vmid: 6000), ip: "10.0.0.10", root_password: Inline("test"), ssh_private_keyfile: "/dev/null", additional_disks: []),
+ "second": (nodename: "pve2", virt: Qemu(vmid: 6001), ip: "10.0.0.9", root_password: Inline("test"), ssh_private_keyfile: "/dev/null", additional_disks: []),
+ }"#).unwrap();
+ manager.state.clusters = Some(vec![
+ TestInstanceCluster {
+ name: "pvecluster".into(),
+ nodes: vec!["pve1".into(), "pve2".into()],
+ },
+ TestInstanceCluster {
+ name: "stale".into(),
+ nodes: vec!["pve3".into()],
+ },
+ ]);
+
+ // No test host required, both fail before any node is powered on.
+ let error = manager.run_cluster_script("true", "missing").unwrap_err();
+ assert!(
+ error
+ .to_string()
+ .contains("no cluster 'missing' in inventory")
+ );
+ let error = manager.run_cluster_script("true", "stale").unwrap_err();
+ assert!(error.to_string().contains("not in the inventory: pve3"));
+
+ let members = manager
+ .cluster_instances(&Cluster {
+ name: "pvecluster".into(),
+ nodes: Some(vec!["pve1".into(), "pve2".into()]),
+ post_cluster: Vec::new(),
+ })
+ .unwrap();
+ let data = manager.cluster_hook_data("pvecluster", &members).unwrap();
+ assert_eq!(data["cluster"], "pvecluster");
+ assert_eq!(
+ data["nodes"],
+ serde_json::json!([
+ { "name": "pve2", "host": "10.0.0.9" },
+ { "name": "pve1", "host": "10.0.0.10" },
+ ])
+ );
+ }
}
--
2.47.3
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH test-tools 6/8] instance: add a builtin hook to set up a Ceph cluster
2026-12-01 14:58 [PATCH e2e-tests/test-tools 0/8] instance: rework hooks and set up Ceph as a cluster hook Michael Köppl
` (4 preceding siblings ...)
2026-12-01 14:58 ` [PATCH test-tools 5/8] instance: cli: run a script once for a whole cluster Michael Köppl
@ 2026-12-01 14:58 ` Michael Köppl
2026-12-01 14:58 ` [PATCH e2e-tests 7/8] plans: use the hook scripts shipped with proxmox-test-instance Michael Köppl
2026-12-01 14:58 ` [PATCH e2e-tests 8/8] scripts: drop the scripts now shipped by proxmox-test-instance Michael Köppl
7 siblings, 0 replies; 9+ messages in thread
From: Michael Köppl @ 2026-12-01 14:58 UTC (permalink / raw)
To: pve-devel
The setup-ceph builtin installs Ceph on all nodes in parallel,
configures the Ceph networks on a spare NIC, and creates a monitor,
a manager and OSDs on every node, optionally with a pool and an RBD
storage. It looks up all OSD disks and addresses before changing
anything, so a missing disk or a bad network fails early.
To fit test nodes, the OSD memory target is lowered to 1 GiB, and the
pool is created with 32 placement groups instead of 128, which would
leave the cluster in HEALTH_WARN.
Signed-off-by: Michael Köppl <m.koeppl@proxmox.com>
---
README.md | 27 +++++
scripts/setup-ceph.sh | 234 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 261 insertions(+)
create mode 100755 scripts/setup-ceph.sh
diff --git a/README.md b/README.md
index fe727133..47907f5e 100644
--- a/README.md
+++ b/README.md
@@ -196,6 +196,7 @@ naming a script, followed by its arguments, which are passed through the shell:
| `install-ceph` | `<version> <repository>` | Install the Ceph packages, without setting up a Ceph cluster |
| `setup-zfs-storage` | `<disk-serial> <name>` | Create a ZFS pool on the additional disk with the given serial and add it as a storage of the same name |
| `setup-frr` | | Install and enable FRR |
+| `setup-ceph` | `[<options>]` | Set up a hyper-converged Ceph cluster. Only works as a cluster hook, see [Cluster hooks](#cluster-hooks) |
Setup hooks for assets are also provided with the asset configuration via a JSON configuration file,
located at `$CONFIG_PATH`. This allows to use the same hook script for multiple assets.
@@ -245,6 +246,32 @@ address. The first node is the one the cluster was created on.
}
```
+The builtin `setup-ceph` sets up a hyper-converged Ceph cluster, with a monitor, a manager and OSDs
+on every node:
+
+```ron
+post_cluster: [
+ Builtin("setup-ceph --pool rbd"),
+],
+```
+
+The nodes need an unconfigured second NIC for the Ceph networks (an entry in `additional_nics`
+without `cidr`) and disks for the OSDs (`additional_disks` with the serials `ceph0`, `ceph1`, ...).
+With the default pool size of 3, at least three nodes need OSDs for the cluster to become healthy.
+The options of `setup-ceph` and their defaults are:
+ - `--version`: Ceph release to install, for example `tentacle` (the default release of `pveceph`)
+ - `--repository`: repository to install Ceph from, as accepted by `pveceph install`
+ (`no-subscription`)
+ - `--nic`: the NIC for the Ceph networks (`ens19`)
+ - `--public-network`: Ceph public network, in which the n-th node gets the n-th host address
+ (`10.250.240.0/24`)
+ - `--cluster-network`: Ceph cluster network for replication, addressed like the public network,
+ or `''` to replicate over the public network (`10.250.241.0/24`)
+ - `--osd-serial-prefix`: OSDs are created on the disks whose serial starts with this prefix
+ (`ceph`)
+ - `--pool`: name of a replicated pool to create together with an RBD storage of the same name
+ (none)
+
Clusters formed manually (`setup --no-cluster` followed by `create-cluster`) do not run
`post_cluster` hooks. Once such a cluster is formed, `run-script --cluster` runs a script once for
it, with the same `$CONFIG_PATH`. As with other `run-script` calls, the script path is relative to
diff --git a/scripts/setup-ceph.sh b/scripts/setup-ceph.sh
new file mode 100755
index 00000000..df67a6d3
--- /dev/null
+++ b/scripts/setup-ceph.sh
@@ -0,0 +1,234 @@
+#!/bin/bash
+# Set up a hyper-converged Ceph cluster on all nodes of a PVE cluster, with a monitor, a manager
+# and OSDs on every node. It needs all nodes at once, so it is meant as a post_cluster hook.
+#
+# Usage: setup-ceph.sh [--version <release>] [--repository <repository>] [--nic <nic>]
+# [--public-network <cidr>] [--cluster-network <cidr>|''] [--osd-serial-prefix <prefix>]
+# [--pool <name>]
+#
+# The n-th node gets the n-th host address of each network on <nic>, which must be left
+# unconfigured (`iface <nic> inet manual`). OSDs are created on all disks whose serial starts with
+# the prefix. An empty cluster network replicates over the public network.
+
+set -euo pipefail
+
+VERSION=""
+REPOSITORY=no-subscription
+NIC=ens19
+PUBLIC_NETWORK=10.250.240.0/24
+CLUSTER_NETWORK=10.250.241.0/24
+OSD_SERIAL_PREFIX=ceph
+POOL=""
+
+# Lower the OSD memory target from the default of 4 GiB, which would leave the nodes without memory
+# for anything else.
+OSD_MEMORY_TARGET=1073741824
+
+die() {
+ echo "$*" >&2
+ exit 1
+}
+
+log() {
+ echo "Ceph: $*"
+}
+
+while (($#)); do
+ case $1 in
+ --version) VERSION=${2?"missing value for $1"} ;;
+ --repository) REPOSITORY=${2?"missing value for $1"} ;;
+ --nic) NIC=${2?"missing value for $1"} ;;
+ --public-network) PUBLIC_NETWORK=${2?"missing value for $1"} ;;
+ --cluster-network) CLUSTER_NETWORK=${2?"missing value for $1"} ;;
+ --osd-serial-prefix) OSD_SERIAL_PREFIX=${2?"missing value for $1"} ;;
+ --pool) POOL=${2?"missing value for $1"} ;;
+ *) die "unknown option '$1'" ;;
+ esac
+ shift 2
+done
+
+# Every serial starts with an empty prefix, so the root disk would become an OSD.
+[[ -n $OSD_SERIAL_PREFIX ]] || die "--osd-serial-prefix must not be empty"
+
+SSH_KEY=$(jq -r '.ssh_private_keyfile' "$CONFIG_PATH")
+SSH_USER=$(jq -r '.ssh_user' "$CONFIG_PATH")
+mapfile -t NAMES < <(jq -r '.nodes[].name' "$CONFIG_PATH")
+mapfile -t HOSTS < <(jq -r '.nodes[].host' "$CONFIG_PATH")
+# A failing jq in the process substitution would not stop the script, so check the result.
+((${#HOSTS[@]} > 0)) || die "no cluster nodes in $CONFIG_PATH"
+
+on_node() {
+ local host=$1
+ shift
+ ssh -i "$SSH_KEY" -o StrictHostKeyChecking=no "$SSH_USER@$host" "$@"
+}
+
+# Prints the n-th host address of the network <cidr>, with the prefix length of the network.
+nth_host() {
+ local cidr=$1 n=$2 octet prefix base mask address
+ [[ $cidr =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)/([0-9]+)$ ]] ||
+ die "'$cidr' is not an IPv4 network in CIDR notation"
+ base=0
+ for octet in "${BASH_REMATCH[@]:1:4}"; do
+ ((octet <= 255)) || die "'$cidr' is not an IPv4 network"
+ base=$(((base << 8) | octet))
+ done
+ prefix=${BASH_REMATCH[5]}
+ ((prefix >= 1 && prefix <= 30)) ||
+ die "network '$cidr' must have a prefix length between 1 and 30"
+ mask=$(((1 << (32 - prefix)) - 1))
+ (((base & mask) == 0)) || die "'$cidr' is not a network address"
+ ((n > 0 && n < mask)) || die "network '$cidr' has no host address number $n"
+ address=$((base + n))
+ printf '%d.%d.%d.%d/%d\n' $((address >> 24 & 255)) $((address >> 16 & 255)) \
+ $((address >> 8 & 255)) $((address & 255)) "$prefix"
+}
+
+# Polls `ceph status` on the first node until the jq filter holds. Arguments after the filter are
+# passed to jq.
+wait_for_status() {
+ local what=$1 timeout=$2 filter=$3 deadline=$((SECONDS + $2)) status=""
+ shift 3
+ until status=$(on_node "${HOSTS[0]}" ceph status --format json 2>/dev/null) &&
+ jq -e "$@" "$filter" <<<"$status" >/dev/null; do
+ if ((SECONDS >= deadline)); then
+ die "timed out after ${timeout}s waiting for $what, last health:" \
+ "$(jq -r '.health.status // "unknown"' <<<"$status" 2>/dev/null || echo unknown)"
+ fi
+ sleep 5
+ done
+}
+
+# At least $osds OSDs, all up and in, and all placement groups clean.
+# shellcheck disable=SC2016 # $o and $osds are jq variables
+READY='.osdmap as $o
+ | $o.num_osds >= $osds and $o.num_up_osds == $o.num_osds and $o.num_in_osds == $o.num_osds
+ and ([.pgmap.pgs_by_state[]?
+ | select(.state_name | IN("active+clean", "active+clean+scrubbing",
+ "active+clean+scrubbing+deep"))
+ | .count] | add // 0) == .pgmap.num_pgs'
+
+# Look up all disks and addresses first, so that a missing one fails the setup before anything on
+# the nodes is changed.
+OSD_NODES=()
+OSD_DEVICES=()
+for i in "${!HOSTS[@]}"; do
+ disks=$(on_node "${HOSTS[i]}" lsblk --nodeps --noheadings --raw --output SERIAL,PATH)
+ while read -r dev; do
+ OSD_NODES+=("$i")
+ OSD_DEVICES+=("$dev")
+ done < <(awk -v prefix="$OSD_SERIAL_PREFIX" \
+ 'index($1, prefix) == 1 && $2 ~ "^/dev/" { print $2 }' <<<"$disks")
+done
+((${#OSD_DEVICES[@]} > 0)) ||
+ die "no disks with a serial starting with '$OSD_SERIAL_PREFIX' to create OSDs on"
+
+PUBLIC_ADDRESSES=()
+CLUSTER_ADDRESSES=()
+for i in "${!HOSTS[@]}"; do
+ PUBLIC_ADDRESSES[i]=$(nth_host "$PUBLIC_NETWORK" $((i + 1)))
+ [[ -z $CLUSTER_NETWORK ]] || CLUSTER_ADDRESSES[i]=$(nth_host "$CLUSTER_NETWORK" $((i + 1)))
+done
+
+install_ceph() {
+ on_node "${HOSTS[$1]}" \
+ "yes | pveceph install --repository $REPOSITORY${VERSION:+ --version $VERSION}" 2>&1 |
+ sed -u "s/^/[${NAMES[$1]}] /"
+}
+
+# Every node downloads the packages on its own, so install them on all nodes at once.
+log "installing on all nodes"
+pids=()
+for i in "${!HOSTS[@]}"; do
+ install_ceph "$i" &
+ pids+=($!)
+done
+failed=0
+for pid in "${pids[@]}"; do
+ wait "$pid" || failed=1
+done
+((failed == 0)) || die "installing Ceph failed"
+
+for i in "${!HOSTS[@]}"; do
+ log "configuring $NIC on node ${NAMES[i]}"
+ on_node "${HOSTS[i]}" bash -s -- "$NIC" "${PUBLIC_ADDRESSES[i]}" \
+ ${CLUSTER_ADDRESSES[i]:+"${CLUSTER_ADDRESSES[i]}"} <<'EOF'
+set -e
+nic=$1
+shift
+if ! grep -qx "iface $nic inet manual" /etc/network/interfaces; then
+ echo "$nic is not an unconfigured interface in /etc/network/interfaces" >&2
+ exit 1
+fi
+stanza="auto $nic\niface $nic inet static"
+for cidr; do
+ stanza+="\n\taddress $cidr"
+done
+sed -i -e "/^auto $nic\$/d" -e "s|^iface $nic inet manual\$|$stanza|" /etc/network/interfaces
+ifreload -a
+EOF
+done
+
+for i in "${!HOSTS[@]}"; do
+ others=()
+ for j in "${!HOSTS[@]}"; do
+ ((i == j)) && continue
+ others+=("${PUBLIC_ADDRESSES[j]%/*}")
+ [[ -z ${CLUSTER_ADDRESSES[j]:-} ]] || others+=("${CLUSTER_ADDRESSES[j]%/*}")
+ done
+ on_node "${HOSTS[i]}" bash -s -- "${others[@]}" <<'EOF'
+for address; do
+ for attempt in $(seq 30); do
+ ping -c 1 -W 1 "$address" >/dev/null && break
+ if [ "$attempt" -eq 30 ]; then
+ echo "cannot reach $address from $(hostname)" >&2
+ exit 1
+ fi
+ sleep 1
+ done
+done
+EOF
+done
+
+first=${HOSTS[0]}
+
+log "initializing on node ${NAMES[0]}"
+on_node "$first" pveceph init --network "$PUBLIC_NETWORK" \
+ ${CLUSTER_NETWORK:+--cluster-network "$CLUSTER_NETWORK"}
+
+for i in "${!HOSTS[@]}"; do
+ log "creating monitor on node ${NAMES[i]}"
+ on_node "${HOSTS[i]}" pveceph mon create
+ # shellcheck disable=SC2016 # $node is a jq variable
+ wait_for_status "monitor '${NAMES[i]}' to join the quorum" 120 \
+ 'any(.quorum_names[]?; . == $node)' --arg node "${NAMES[i]}"
+done
+
+# The first monitor already came with a manager.
+for i in "${!HOSTS[@]}"; do
+ ((i == 0)) && continue
+ log "creating manager on node ${NAMES[i]}"
+ on_node "${HOSTS[i]}" pveceph mgr create
+done
+
+on_node "$first" ceph config set osd osd_memory_target "$OSD_MEMORY_TARGET"
+
+for k in "${!OSD_DEVICES[@]}"; do
+ i=${OSD_NODES[k]}
+ log "creating OSD on node ${NAMES[i]} on ${OSD_DEVICES[k]}"
+ on_node "${HOSTS[i]}" pveceph osd create "${OSD_DEVICES[k]}"
+done
+
+wait_for_status "${#OSD_DEVICES[@]} OSDs to be up and in and all placement groups to be clean" \
+ 600 "$READY" --argjson osds "${#OSD_DEVICES[@]}"
+
+if [[ -n $POOL ]]; then
+ log "creating pool '$POOL' with an RBD storage"
+ # The default of 128 placement groups is more than the autoscaler recommends for the few OSDs
+ # of a test cluster, which would leave the cluster in HEALTH_WARN.
+ on_node "$first" pveceph pool create "$POOL" --add_storages 1 --pg_num 32
+ wait_for_status "the placement groups of pool '$POOL' to be clean" \
+ 600 "$READY" --argjson osds "${#OSD_DEVICES[@]}"
+fi
+
+log "ready with ${#HOSTS[@]} monitors and ${#OSD_DEVICES[@]} OSDs"
--
2.47.3
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH e2e-tests 7/8] plans: use the hook scripts shipped with proxmox-test-instance
2026-12-01 14:58 [PATCH e2e-tests/test-tools 0/8] instance: rework hooks and set up Ceph as a cluster hook Michael Köppl
` (5 preceding siblings ...)
2026-12-01 14:58 ` [PATCH test-tools 6/8] instance: add a builtin hook to set up a Ceph cluster Michael Köppl
@ 2026-12-01 14:58 ` Michael Köppl
2026-12-01 14:58 ` [PATCH e2e-tests 8/8] scripts: drop the scripts now shipped by proxmox-test-instance Michael Köppl
7 siblings, 0 replies; 9+ messages in thread
From: Michael Köppl @ 2026-12-01 14:58 UTC (permalink / raw)
To: pve-devel
proxmox-test-instance now ships the generic hook scripts itself and no
longer accepts hooks given as command lines. Those ran relative to the
current dir of proxmox-test-instance, so the plans only found their
scripts when it was run from the root of this repository.
Use the builtins for updating packages, downloading images, installing
Ceph, and setting up ZFS storages as well as FRR. Reference the scripts
specific to these tests relative to the plan, so they are found from
anywhere, including the installed copy under
/usr/share/proxmox-e2e-tests.
This changes the setup digest of all plans, so for existing setups,
their next setup starts from scratch.
The comment explaining the replication test in more detail also
mentioned the ZFS setup script explicitly. Replace this by mentioning
the new hook to avoid confusion.
Signed-off-by: Michael Köppl <m.koeppl@proxmox.com>
---
plans/complete.ron | 46 ++++++++++++++++++++--------------------
plans/pbs.ron | 6 +++---
plans/sdn.ron | 18 ++++++++--------
tests/pve_replication.pl | 2 +-
4 files changed, 36 insertions(+), 36 deletions(-)
diff --git a/plans/complete.ron b/plans/complete.ron
index 3210ac4..56c7417 100644
--- a/plans/complete.ron
+++ b/plans/complete.ron
@@ -13,11 +13,11 @@ Plan(
root_password: Ref("default"),
),
post_setup: [
- "./scripts/update-packages.sh pve staging",
- "./scripts/download-container-image.sh local debian-12-standard_12.12-1_amd64.tar.zst",
- "./scripts/build-oci-image.sh local e2e-oci",
- "./scripts/download-cloud-image.sh local https://cloud.debian.org/images/cloud/trixie/20261017-2634/debian-13-genericcloud-amd64-20261017-2634.qcow2 debian-13-genericcloud-amd64.qcow2 ec584ccabfef7120b4c4f7482adf0e615894d9292cedec446b64194b951ebe5dd97c336b5dcbae458333764b0edd516334506017f33c4f2020ef8d38b569ffe3",
- "./scripts/setup-pebble.sh",
+ Builtin("update-packages pve staging"),
+ Builtin("download-container-image local debian-12-standard_12.12-1_amd64.tar.zst"),
+ File("../scripts/build-oci-image.sh local e2e-oci"),
+ Builtin("download-cloud-image local https://cloud.debian.org/images/cloud/trixie/20261017-2634/debian-13-genericcloud-amd64-20261017-2634.qcow2 debian-13-genericcloud-amd64.qcow2 ec584ccabfef7120b4c4f7482adf0e615894d9292cedec446b64194b951ebe5dd97c336b5dcbae458333764b0edd516334506017f33c4f2020ef8d38b569ffe3"),
+ File("../scripts/setup-pebble.sh"),
],
),
SetupInstance(
@@ -32,7 +32,7 @@ Plan(
root_password: Ref("default"),
),
post_setup: [
- "./scripts/update-packages.sh pbs staging",
+ Builtin("update-packages pbs staging"),
],
playbook: "./scripts/setup-ldap.yml"
),
@@ -48,7 +48,7 @@ Plan(
root_password: Ref("default"),
),
post_setup: [
- "./scripts/update-packages.sh pbs staging",
+ Builtin("update-packages pbs staging"),
],
),
SetupInstance(
@@ -61,7 +61,7 @@ Plan(
root_password: Ref("default"),
),
post_setup: [
- "./scripts/setup-s3.sh",
+ File("../scripts/setup-s3.sh"),
],
),
SetupInstance(
@@ -96,10 +96,10 @@ Plan(
],
),
post_setup: [
- "./scripts/update-packages.sh pve staging",
- "./scripts/download-container-image.sh local debian-12-standard_12.12-1_amd64.tar.zst",
- "./scripts/setup-zfs-storage.sh zfs0 zfstest",
- "./scripts/install-ceph.sh tentacle test",
+ Builtin("update-packages pve staging"),
+ Builtin("download-container-image local debian-12-standard_12.12-1_amd64.tar.zst"),
+ Builtin("setup-zfs-storage zfs0 zfstest"),
+ Builtin("install-ceph tentacle test"),
],
),
SetupInstance(
@@ -134,10 +134,10 @@ Plan(
],
),
post_setup: [
- "./scripts/update-packages.sh pve staging",
- "./scripts/download-container-image.sh local debian-12-standard_12.12-1_amd64.tar.zst",
- "./scripts/setup-zfs-storage.sh zfs0 zfstest",
- "./scripts/install-ceph.sh tentacle test",
+ Builtin("update-packages pve staging"),
+ Builtin("download-container-image local debian-12-standard_12.12-1_amd64.tar.zst"),
+ Builtin("setup-zfs-storage zfs0 zfstest"),
+ Builtin("install-ceph tentacle test"),
],
),
SetupInstance(
@@ -172,10 +172,10 @@ Plan(
],
),
post_setup: [
- "./scripts/update-packages.sh pve staging",
- "./scripts/download-container-image.sh local debian-12-standard_12.12-1_amd64.tar.zst",
- "./scripts/setup-zfs-storage.sh zfs0 zfstest",
- "./scripts/install-ceph.sh tentacle test",
+ Builtin("update-packages pve staging"),
+ Builtin("download-container-image local debian-12-standard_12.12-1_amd64.tar.zst"),
+ Builtin("setup-zfs-storage zfs0 zfstest"),
+ Builtin("install-ceph tentacle test"),
],
),
SetupInstance(
@@ -189,7 +189,7 @@ Plan(
root_password: Ref("default"),
),
post_setup: [
- "./scripts/setup-frr.sh",
+ Builtin("setup-frr"),
],
),
SetupInstance(
@@ -203,7 +203,7 @@ Plan(
root_password: Ref("default"),
),
post_setup: [
- "./scripts/setup-frr.sh",
+ Builtin("setup-frr"),
],
),
SetupInstance(
@@ -217,7 +217,7 @@ Plan(
root_password: Ref("default"),
),
post_setup: [
- "./scripts/setup-frr.sh",
+ Builtin("setup-frr"),
],
),
],
diff --git a/plans/pbs.ron b/plans/pbs.ron
index 43cdd3a..0ac7bd2 100644
--- a/plans/pbs.ron
+++ b/plans/pbs.ron
@@ -13,7 +13,7 @@ Plan(
root_password: Ref("default"),
),
post_setup: [
- "./scripts/update-packages.sh pve staging",
+ Builtin("update-packages pve staging"),
],
),
SetupInstance(
@@ -28,7 +28,7 @@ Plan(
root_password: Ref("default"),
),
post_setup: [
- "./scripts/update-packages.sh pbs staging",
+ Builtin("update-packages pbs staging"),
],
),
SetupInstance(
@@ -41,7 +41,7 @@ Plan(
root_password: Ref("default"),
),
post_setup: [
- "./scripts/setup-s3.sh",
+ File("../scripts/setup-s3.sh"),
],
),
]
diff --git a/plans/sdn.ron b/plans/sdn.ron
index 887b6a0..5d6ca1d 100644
--- a/plans/sdn.ron
+++ b/plans/sdn.ron
@@ -18,8 +18,8 @@ Plan(
],
),
post_setup: [
- "./scripts/update-packages.sh pve staging",
- "./scripts/download-container-image.sh local debian-12-standard_12.12-1_amd64.tar.zst",
+ Builtin("update-packages pve staging"),
+ Builtin("download-container-image local debian-12-standard_12.12-1_amd64.tar.zst"),
],
),
SetupInstance(
@@ -38,8 +38,8 @@ Plan(
],
),
post_setup: [
- "./scripts/update-packages.sh pve staging",
- "./scripts/download-container-image.sh local debian-12-standard_12.12-1_amd64.tar.zst",
+ Builtin("update-packages pve staging"),
+ Builtin("download-container-image local debian-12-standard_12.12-1_amd64.tar.zst"),
],
),
SetupInstance(
@@ -58,8 +58,8 @@ Plan(
],
),
post_setup: [
- "./scripts/update-packages.sh pve staging",
- "./scripts/download-container-image.sh local debian-12-standard_12.12-1_amd64.tar.zst",
+ Builtin("update-packages pve staging"),
+ Builtin("download-container-image local debian-12-standard_12.12-1_amd64.tar.zst"),
],
),
SetupInstance(
@@ -73,7 +73,7 @@ Plan(
root_password: Ref("default"),
),
post_setup: [
- "./scripts/setup-frr.sh",
+ Builtin("setup-frr"),
],
),
SetupInstance(
@@ -87,7 +87,7 @@ Plan(
root_password: Ref("default"),
),
post_setup: [
- "./scripts/setup-frr.sh",
+ Builtin("setup-frr"),
],
),
SetupInstance(
@@ -101,7 +101,7 @@ Plan(
root_password: Ref("default"),
),
post_setup: [
- "./scripts/setup-frr.sh",
+ Builtin("setup-frr"),
],
),
],
diff --git a/tests/pve_replication.pl b/tests/pve_replication.pl
index 158828d..79211d4 100755
--- a/tests/pve_replication.pl
+++ b/tests/pve_replication.pl
@@ -11,7 +11,7 @@ use Proxmox::Test::Testcase;
# Tests storage replication job CRUD between two cluster nodes.
#
# Requires the three-node cluster from plans/complete.ron, whose nodes carry the 'zfstest'
-# storage that scripts/setup-zfs-storage.sh sets up on an extra disk. Any ZFS-backed storage
+# storage that the setup-zfs-storage hook sets up on an extra disk. Any ZFS-backed storage
# configured with the same ID across the nodes works. If none is present, the test skips.
#
# Verifies:
--
2.47.3
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH e2e-tests 8/8] scripts: drop the scripts now shipped by proxmox-test-instance
2026-12-01 14:58 [PATCH e2e-tests/test-tools 0/8] instance: rework hooks and set up Ceph as a cluster hook Michael Köppl
` (6 preceding siblings ...)
2026-12-01 14:58 ` [PATCH e2e-tests 7/8] plans: use the hook scripts shipped with proxmox-test-instance Michael Köppl
@ 2026-12-01 14:58 ` Michael Köppl
7 siblings, 0 replies; 9+ messages in thread
From: Michael Köppl @ 2026-12-01 14:58 UTC (permalink / raw)
To: pve-devel
proxmox-test-instance ships the removed scripts as builtin hooks and the
plan files use those since the previous commit. Removing the scripts
here entirely avoids the builtin scripts and these scripts drifting
apart.
The scripts specific to these tests stay, as they're not useful to
testing setups in general, but only for specific scenarios.
Signed-off-by: Michael Köppl <m.koeppl@proxmox.com>
---
scripts/download-cloud-image.sh | 21 ---------
scripts/download-container-image.sh | 22 ---------
scripts/install-ceph.sh | 13 ------
scripts/setup-frr.sh | 18 --------
scripts/setup-zfs-storage.sh | 65 ---------------------------
scripts/update-packages.sh | 69 -----------------------------
6 files changed, 208 deletions(-)
delete mode 100755 scripts/download-cloud-image.sh
delete mode 100755 scripts/download-container-image.sh
delete mode 100755 scripts/install-ceph.sh
delete mode 100755 scripts/setup-frr.sh
delete mode 100755 scripts/setup-zfs-storage.sh
delete mode 100755 scripts/update-packages.sh
diff --git a/scripts/download-cloud-image.sh b/scripts/download-cloud-image.sh
deleted file mode 100755
index e3514d0..0000000
--- a/scripts/download-cloud-image.sh
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/usr/bin/bash
-# Downloads a VM disk image to the import content of a storage, so that VMs can be created from it
-# with 'import-from'. The download is only kept if it matches the given SHA-512 checksum.
-SSH_KEY=$(jq -r '.ssh_private_keyfile' "$CONFIG_PATH")
-HOST=$(jq -r '.host' "$CONFIG_PATH")
-USER=$(jq -r '.ssh_user' "$CONFIG_PATH")
-
-STORAGE=$1
-URL=$2
-FILENAME=$3
-SHA512=$4
-
-ssh -i "$SSH_KEY" "$USER"@"$HOST" -o StrictHostKeyChecking=no <<EOF
-set -e
-
-pvesh create /nodes/localhost/storage/$STORAGE/download-url --content import \
- --url '$URL' --filename '$FILENAME' --checksum $SHA512 --checksum-algorithm sha512
-# Check the file itself. pvesh exits with 0 even if the download failed, which leaves a file that
-# already exists in place, whatever its content.
-echo "$SHA512 \$(pvesm path $STORAGE:import/$FILENAME)" | sha512sum --check --quiet
-EOF
diff --git a/scripts/download-container-image.sh b/scripts/download-container-image.sh
deleted file mode 100755
index 5db8af8..0000000
--- a/scripts/download-container-image.sh
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/usr/bin/bash
-SSH_KEY=$(jq -r '.ssh_private_keyfile' $CONFIG_PATH)
-HOST=$(jq -r '.host' $CONFIG_PATH)
-USER=$(jq -r '.ssh_user' $CONFIG_PATH)
-
-STORAGE=$1
-IMAGE=$2
-
-ssh -i $SSH_KEY $USER@$HOST -o StrictHostKeyChecking=no <<EOF
-set -e
-
-path=\$(pvesm path $STORAGE:vztmpl/$IMAGE)
-# Sometimes requests are rejected with 503, to try again after a while.
-for attempt in 1 2 3 4 5; do
- pveam download $STORAGE $IMAGE || true
- # Explicitly check for the path, since download will still return 0 if it fails.
- [ -e "\$path" ] && exit 0
- sleep \$((attempt * 10))
-done
-echo "downloading $IMAGE to $STORAGE failed" >&2
-exit 1
-EOF
diff --git a/scripts/install-ceph.sh b/scripts/install-ceph.sh
deleted file mode 100755
index 2ca2d91..0000000
--- a/scripts/install-ceph.sh
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/usr/bin/bash
-SSH_KEY=$(jq -r '.ssh_private_keyfile' $CONFIG_PATH)
-HOST=$(jq -r '.host' $CONFIG_PATH)
-USER=$(jq -r '.ssh_user' $CONFIG_PATH)
-
-VERSION=$1
-REPOSITORY=$2
-
-ssh -i $SSH_KEY $USER@$HOST -o StrictHostKeyChecking=no <<EOT
-set -e
-
-yes | pveceph install --version $VERSION --repository $REPOSITORY
-EOT
diff --git a/scripts/setup-frr.sh b/scripts/setup-frr.sh
deleted file mode 100755
index b647345..0000000
--- a/scripts/setup-frr.sh
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/usr/bin/bash
-SSH_KEY=$(jq -r '.ssh_private_keyfile' $CONFIG_PATH)
-HOST=$(jq -r '.host' $CONFIG_PATH)
-USER=$(jq -r '.ssh_user' $CONFIG_PATH)
-
-ssh -i $SSH_KEY $USER@$HOST -o StrictHostKeyChecking=no <<'EOF'
-set -e
-
-echo -e "LANG=C\nLC_ALL=C" | tee /etc/default/locale /etc/environment
-export LANG=C LC_ALL=C
-
-export DEBIAN_FRONTEND=noninteractive
-apt-get -y update
-apt-get -y dist-upgrade
-apt-get -y install frr vlan
-
-systemctl enable --now frr
-EOF
diff --git a/scripts/setup-zfs-storage.sh b/scripts/setup-zfs-storage.sh
deleted file mode 100755
index 79e3cb1..0000000
--- a/scripts/setup-zfs-storage.sh
+++ /dev/null
@@ -1,65 +0,0 @@
-#!/usr/bin/bash
-# Create a ZFS pool on an additional disk of a PVE node and register it as a zfspool storage, so
-# tests that need ZFS-backed guest images (storage replication) find one.
-#
-# Usage: setup-zfs-storage.sh <disk-serial> <name>
-#
-# The cluster nodes of plans/complete.ron install on XFS. The ZFS pool lives on an extra disk, found
-# by the serial the plan assigned to it. The name is used both for the pool and for the storage id.
-# The disk is looked up by ID_SCSI_SERIAL.
-#
-# Enabling zfs-import@<pool> is what makes the pool come back after the node is powered down at
-# the end of the setup.
-
-set -euo pipefail
-
-SSH_KEY=$(jq -r '.ssh_private_keyfile' $CONFIG_PATH)
-HOST=$(jq -r '.host' $CONFIG_PATH)
-USER=$(jq -r '.ssh_user' $CONFIG_PATH)
-
-SERIAL=$1
-POOL=$2
-
-ssh -i $SSH_KEY $USER@$HOST -o StrictHostKeyChecking=no bash -s -- "$SERIAL" "$POOL" <<'EOF'
-set -e
-
-serial=$1
-pool=$2
-
-dev=""
-for disk in /dev/sd?; do
- udevadm info --query=property --name="$disk" | grep -qx "ID_SCSI_SERIAL=$serial" || continue
- dev="$disk"
- break
-done
-
-if [ -z "$dev" ]; then
- echo "no disk with SCSI serial '$serial' on $(hostname); disks on this node:" >&2
- for disk in /dev/sd?; do
- echo " $disk $(udevadm info --query=property --name="$disk" \
- | grep '^ID_SCSI_SERIAL=' || echo 'ID_SCSI_SERIAL=')" >&2
- done
- exit 1
-fi
-
-# Prefer the persistent link, as PVE's disk management does, and fall back to the device node
-# for a disk udev created no such link for.
-if link=$(udevadm info --query=symlink --name="$dev" | tr ' ' '\n' | grep -m1 '^disk/by-id/scsi-')
-then
- dev="/dev/$link"
-fi
-
-if ! zpool list -H "$pool" >/dev/null 2>&1; then
- zpool create -o ashift=12 "$pool" "$dev"
- zfs set compression=on "$pool"
-fi
-
-if [ -e /lib/systemd/system/zfs-import@.service ]; then
- systemctl enable "zfs-import@$pool.service"
-fi
-
-# The storage is what the tests look for, so it needs the content types for guest images.
-if ! pvesm status --storage "$pool" >/dev/null 2>&1; then
- pvesm add zfspool "$pool" --pool "$pool" --content images,rootdir --sparse 1
-fi
-EOF
diff --git a/scripts/update-packages.sh b/scripts/update-packages.sh
deleted file mode 100755
index eb96594..0000000
--- a/scripts/update-packages.sh
+++ /dev/null
@@ -1,69 +0,0 @@
-#!/usr/bin/bash
-SSH_KEY=$(jq -r '.ssh_private_keyfile' $CONFIG_PATH)
-HOST=$(jq -r '.host' $CONFIG_PATH)
-USER=$(jq -r '.ssh_user' $CONFIG_PATH)
-
-product=$1
-repo=$2
-
-case $product in
- "pve")
- maj=9
- ;;
- "pmg")
- maj=9
- ;;
- "pbs")
- maj=4
- ;;
- "pdm")
- maj=1
- ;;
- *)
- echo "unknown product: $product"
- exit 1
- ;;
-esac
-
-case $repo in
- "staging")
- full_repo="Types: deb
-URIs: http://repo.intra.proxmox.com/staging/${product}
-Suites: trixie
-Components: ${product}-${maj}
-Signed-By: /usr/share/keyrings/proxmox-archive-keyring.gpg"
- ;;
- "no-subscription")
- full_repo="Types: deb
-URIs: http://download.proxmox.com/debian/${product}
-Suites: trixie
-Components: ${product}-no-subscription
-Signed-By: /usr/share/keyrings/proxmox-archive-keyring.gpg"
- ;;
- "test")
- full_repo="Types: deb
-URIs: http://download.proxmox.com/debian/${product}
-Suites: trixie
-Components: ${product}-test
-Signed-By: /usr/share/keyrings/proxmox-archive-keyring.gpg"
- ;;
-esac
-
-ssh -i $SSH_KEY $USER@$HOST -o StrictHostKeyChecking=no <<EOF
-set -e
-
-echo "Update packages hook running"
-
-tee > /etc/apt/sources.list.d/pve-$repo.sources <<EOT
-$full_repo
-EOT
-
-rm -f /etc/apt/sources.list.d/pve-enterprise.sources
-rm -f /etc/apt/sources.list.d/pbs-enterprise.sources
-rm -f /etc/apt/sources.list.d/pmg-enterprise.sources
-rm -f /etc/apt/sources.list.d/ceph.sources
-
-export DEBIAN_FRONTEND=noninteractive
-apt-get update -y
-apt-get dist-upgrade -y
-EOF
--
2.47.3
^ permalink raw reply related [flat|nested] 9+ messages in thread
end of thread, other threads:[~2026-12-01 14:59 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 14:58 [PATCH e2e-tests/test-tools 0/8] instance: rework hooks and set up Ceph as a cluster hook Michael Köppl
2026-12-01 14:58 ` [PATCH test-tools 1/8] readme: drop token fields from the hook config example Michael Köppl
2026-12-01 14:58 ` [PATCH test-tools 2/8] instance: ship generic hook scripts Michael Köppl
2026-12-01 14:58 ` [PATCH test-tools 3/8] instance: distinguish builtin hooks from hook files Michael Köppl
2026-12-01 14:58 ` [PATCH test-tools 4/8] instance: add hooks that run once a cluster is formed Michael Köppl
2026-12-01 14:58 ` [PATCH test-tools 5/8] instance: cli: run a script once for a whole cluster Michael Köppl
2026-12-01 14:58 ` [PATCH test-tools 6/8] instance: add a builtin hook to set up a Ceph cluster Michael Köppl
2026-12-01 14:58 ` [PATCH e2e-tests 7/8] plans: use the hook scripts shipped with proxmox-test-instance Michael Köppl
2026-12-01 14:58 ` [PATCH e2e-tests 8/8] scripts: drop the scripts now shipped by proxmox-test-instance Michael Köppl
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.