From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id A31191FF09F for ; Tue, 01 Dec 2026 15:59:21 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 6B2EC217B2; Tue, 01 Dec 2026 15:58:32 +0100 (CET) From: =?UTF-8?q?Michael=20K=C3=B6ppl?= To: pve-devel@lists.proxmox.com Subject: [PATCH test-tools 2/8] instance: ship generic hook scripts Date: Tue, 1 Dec 2026 15:58:11 +0100 Message-ID: <20261201145817.894414-3-m.koeppl@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261201145817.894414-1-m.koeppl@proxmox.com> References: <20261201145817.894414-1-m.koeppl@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1796137099260 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.030 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) KAM_SHORT 0.001 Use of a URL Shortener for very short URL POISEN_SPAM_PILL 0.1 Meta: its spam POISEN_SPAM_PILL_1 0.1 random spam to be learned in bayes POISEN_SPAM_PILL_3 0.1 random spam to be learned in bayes PROLO_LEO1 0.1 Meta Catches all Leo drug variations so far RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: MUIPK4XBNLXC5BPBB3Z6VFZVFLBHYPDT X-Message-ID-Hash: MUIPK4XBNLXC5BPBB3Z6VFZVFLBHYPDT X-MailFrom: m.koeppl@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 --- 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 <&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 < +# +# 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@ 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 < /etc/apt/sources.list.d/pve-$repo.sources <