all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: "Michael Köppl" <m.koeppl@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH e2e-tests 5/6] tests: use random_vmid function for getting VMIDs
Date: Thu, 17 Sep 2026 18:23:23 +0200	[thread overview]
Message-ID: <20260917162324.1926056-6-m.koeppl@proxmox.com> (raw)
In-Reply-To: <20260917162324.1926056-1-m.koeppl@proxmox.com>

Signed-off-by: Michael Köppl <m.koeppl@proxmox.com>
---
 tests/pbs/test_pbs_s3_datastore.pl | 5 +++--
 tests/pve_backup_job.pl            | 3 ++-
 tests/pve_create_pool.pl           | 3 ++-
 tests/pve_create_vm.pl             | 4 ++--
 tests/pve_firewall.pl              | 4 ++--
 tests/pve_ha_resource_config.pl    | 3 ++-
 tests/pve_ha_resource_state.pl     | 4 ++--
 tests/pve_ha_rules_config.pl       | 5 +++--
 tests/pve_ha_status.pl             | 3 ++-
 tests/pve_migration.pl             | 4 ++--
 tests/pve_replication.pl           | 3 ++-
 tests/pve_storage_basic.pl         | 3 ++-
 12 files changed, 26 insertions(+), 18 deletions(-)

diff --git a/tests/pbs/test_pbs_s3_datastore.pl b/tests/pbs/test_pbs_s3_datastore.pl
index a35c6e9..8eb6bab 100755
--- a/tests/pbs/test_pbs_s3_datastore.pl
+++ b/tests/pbs/test_pbs_s3_datastore.pl
@@ -28,6 +28,7 @@ use lib '.';
 use Proxmox::Test::Helper qw(get_instance get_pbs_instance get_pve_instance);
 use Proxmox::Test::ProxmoxInstance;
 use Proxmox::Test::Testcase;
+use Proxmox::Test::Util qw(random_vmid);
 
 my $pve = get_pve_instance('pve1');
 my $pbs = get_pbs_instance('pbs1');
@@ -122,7 +123,7 @@ Proxmox::Test::Testcase->new('pbs_s3_datastore')->with([{}])->step(
 )->step(
     'create dummy VM with two 4 GB disks on PVE',
     sub {
-        $vmid = $pve->client()->get('/cluster/nextid');
+        $vmid = random_vmid($pve->client());
         my $upid = $pve->client()->post(
             "/nodes/$node/qemu",
             {
@@ -182,7 +183,7 @@ Proxmox::Test::Testcase->new('pbs_s3_datastore')->with([{}])->step(
 )->step(
     'restore VM on PVE from PBS backup',
     sub {
-        $restore_vmid = $pve->client()->get('/cluster/nextid');
+        $restore_vmid = random_vmid($pve->client());
         my $upid = $pve->client()->post(
             "/nodes/$node/qemu",
             {
diff --git a/tests/pve_backup_job.pl b/tests/pve_backup_job.pl
index 6ba59eb..c3699e2 100755
--- a/tests/pve_backup_job.pl
+++ b/tests/pve_backup_job.pl
@@ -6,6 +6,7 @@ use Test::More;
 
 use lib '.';
 use Proxmox::Test::Helper qw(get_pve_instance);
+use Proxmox::Test::Util qw(random_vmid);
 
 # Tests scheduled backup job CRUD and an immediate vzdump run.
 #
@@ -23,7 +24,7 @@ my $pve = get_pve_instance('pve1');
 my $node = $pve->get_nodename();
 
 # Create a test VM to target with the backup job and the immediate vzdump run.
-my $vmid = $pve->client()->get('/cluster/nextid');
+my $vmid = random_vmid($pve->client());
 my $upid = $pve->client()->post(
     "/nodes/$node/qemu",
     {
diff --git a/tests/pve_create_pool.pl b/tests/pve_create_pool.pl
index fa8b351..e54bf8d 100755
--- a/tests/pve_create_pool.pl
+++ b/tests/pve_create_pool.pl
@@ -6,6 +6,7 @@ use Test::More;
 
 use lib '.';
 use Proxmox::Test::Helper qw(get_pve_instance);
+use Proxmox::Test::Util qw(random_vmid);
 
 # Tests resource pools end to end: a pool is not just a named config entry, it actually groups
 # guests and is reflected in the cluster resource view. Beyond create/update/delete this adds a
@@ -27,7 +28,7 @@ my $res = $client->get("/pools/$pool_id", {});
 is($res->{comment}, 'Created by automated test', 'pool created with the given comment');
 
 # Create a VM and actually put it into the pool.
-my $vmid = $client->get('/cluster/nextid');
+my $vmid = random_vmid($client);
 my $upid = $client->post("/nodes/$node/qemu", { vmid => $vmid, name => 'e2e-pool-test' });
 is($pve->wait_for_task($upid), 'OK', 'test VM created');
 
diff --git a/tests/pve_create_vm.pl b/tests/pve_create_vm.pl
index 9954b09..3d0ced1 100755
--- a/tests/pve_create_vm.pl
+++ b/tests/pve_create_vm.pl
@@ -6,12 +6,12 @@ use Test::More;
 
 use lib '.';
 use Proxmox::Test::Helper qw(get_pve_instance);
-use Proxmox::Test::Util qw(poll_until);
+use Proxmox::Test::Util qw(random_vmid poll_until);
 use Data::Dumper;
 
 my $instance = get_pve_instance("pve1");
 
-my $vmid = $instance->client()->get("/cluster/nextid");
+my $vmid = random_vmid($instance->client());
 
 my $upid;
 
diff --git a/tests/pve_firewall.pl b/tests/pve_firewall.pl
index e1f6ec2..ed4e2fc 100755
--- a/tests/pve_firewall.pl
+++ b/tests/pve_firewall.pl
@@ -6,7 +6,7 @@ use Test::More;
 
 use lib '.';
 use Proxmox::Test::Helper qw(get_pve_instance);
-use Proxmox::Test::Util qw(poll_until);
+use Proxmox::Test::Util qw(random_vmid poll_until);
 use Proxmox::Test::SDN qw(CONTAINER_TEMPLATE);
 
 # End-to-end test of the PVE firewall: verifies a rule actually affects the dataplane, rather than
@@ -31,7 +31,7 @@ my $pve = get_pve_instance('pve1');
 my $node = $pve->get_nodename();
 my $client = $pve->client();
 
-my $vmid = $client->get('/cluster/nextid');
+my $vmid = random_vmid($client);
 my $ct_ip = '10.250.250.10';
 my $node_ip = '10.250.250.1';
 
diff --git a/tests/pve_ha_resource_config.pl b/tests/pve_ha_resource_config.pl
index ffadc64..6bd9348 100755
--- a/tests/pve_ha_resource_config.pl
+++ b/tests/pve_ha_resource_config.pl
@@ -6,6 +6,7 @@ use Test::More;
 
 use lib '.';
 use Proxmox::Test::Helper qw(get_pve_instance);
+use Proxmox::Test::Util qw(random_vmid);
 
 # Tests HA resource configuration CRUD operations.
 #
@@ -19,7 +20,7 @@ my $pve = get_pve_instance('pve1-cluster');
 my $node = $pve->get_nodename();
 
 # We need a VM to register as an HA resource. Create a minimal one first.
-my $vmid = $pve->client()->get("/cluster/nextid");
+my $vmid = random_vmid($pve->client());
 
 my $upid = $pve->client()->post("/nodes/localhost/qemu", {
         vmid => $vmid,
diff --git a/tests/pve_ha_resource_state.pl b/tests/pve_ha_resource_state.pl
index dddfb79..ab63ca0 100755
--- a/tests/pve_ha_resource_state.pl
+++ b/tests/pve_ha_resource_state.pl
@@ -6,7 +6,7 @@ use Test::More;
 
 use lib '.';
 use Proxmox::Test::Helper qw(get_pve_instance);
-use Proxmox::Test::Util qw(poll_until);
+use Proxmox::Test::Util qw(random_vmid poll_until);
 
 # End-to-end test of HA resource state: verifies the HA stack actually acts on the requested state
 # (the CRM/LRM start and stop the managed guest), rather than only checking that the requested
@@ -20,7 +20,7 @@ my $client = $pve->client();
 
 # Create a small VM to be HA-managed. It needs no disk: HA only has to bring the QEMU process up
 # for the service to be 'running'.
-my $vmid = $client->get('/cluster/nextid');
+my $vmid = random_vmid($client);
 my $upid =
     $client->post("/nodes/$node/qemu", { vmid => $vmid, memory => 256, name => 'e2e-ha-test' });
 is($pve->wait_for_task($upid), 'OK', 'test VM created');
diff --git a/tests/pve_ha_rules_config.pl b/tests/pve_ha_rules_config.pl
index 88ec3cc..328d55b 100755
--- a/tests/pve_ha_rules_config.pl
+++ b/tests/pve_ha_rules_config.pl
@@ -6,6 +6,7 @@ use Test::More;
 
 use lib '.';
 use Proxmox::Test::Helper qw(get_pve_instance);
+use Proxmox::Test::Util qw(random_vmid);
 
 # Based on the following simulation test scenarios:
 #   test-node-affinity-strict1/2:   node-affinity with strict=1
@@ -18,11 +19,11 @@ my $pve = get_pve_instance('pve1-cluster');
 my $node = $pve->get_nodename();
 
 # Create two test VMs to use as HA resources
-my $vmid1 = $pve->client()->get("/cluster/nextid");
+my $vmid1 = random_vmid($pve->client());
 my $upid = $pve->client()->post("/nodes/localhost/qemu", { vmid => $vmid1 });
 is($pve->wait_for_task($upid), "OK", "VM created successfully");
 
-my $vmid2 = $pve->client()->get("/cluster/nextid");
+my $vmid2 = random_vmid($pve->client());
 $upid = $pve->client()->post("/nodes/localhost/qemu", { vmid => $vmid2 });
 is($pve->wait_for_task($upid), "OK", "VM created successfully");
 
diff --git a/tests/pve_ha_status.pl b/tests/pve_ha_status.pl
index f4b4444..8e789e5 100755
--- a/tests/pve_ha_status.pl
+++ b/tests/pve_ha_status.pl
@@ -6,6 +6,7 @@ use Test::More;
 
 use lib '.';
 use Proxmox::Test::Helper qw(get_pve_instance);
+use Proxmox::Test::Util qw(random_vmid);
 
 # Tests the HA status API endpoints.
 #
@@ -59,7 +60,7 @@ if ($lrm_entry) {
 
 # Service appears in status after registration
 
-my $vmid = $pve->client()->get("/cluster/nextid");
+my $vmid = random_vmid($pve->client());
 my $upid = $pve->client()->post("/nodes/localhost/qemu", { vmid => $vmid });
 is($pve->wait_for_task($upid), "OK", "test VM created");
 
diff --git a/tests/pve_migration.pl b/tests/pve_migration.pl
index 5e0fe60..3997eda 100755
--- a/tests/pve_migration.pl
+++ b/tests/pve_migration.pl
@@ -6,7 +6,7 @@ use Test::More;
 
 use lib '.';
 use Proxmox::Test::Helper qw(get_pve_instance);
-use Proxmox::Test::Util qw(poll_until);
+use Proxmox::Test::Util qw(random_vmid poll_until);
 
 # Tests offline and online (live) migration of a guest between two cluster nodes.
 #
@@ -43,7 +43,7 @@ my $on_node = sub {
     return scalar(grep { $_->{vmid} == $vmid } @$list) > 0;
 };
 
-my $vmid = $a->client()->get('/cluster/nextid');
+my $vmid = random_vmid($a->client());
 
 # Create a small VM on node A. No disks on shared storage, so the offline migration moves the
 # guest config; an online migration of a diskless VM exercises the live-migration code path.
diff --git a/tests/pve_replication.pl b/tests/pve_replication.pl
index 158828d..0021dac 100755
--- a/tests/pve_replication.pl
+++ b/tests/pve_replication.pl
@@ -7,6 +7,7 @@ use Test::More;
 use lib '.';
 use Proxmox::Test::Helper qw(get_pve_instance);
 use Proxmox::Test::Testcase;
+use Proxmox::Test::Util qw(random_vmid);
 
 # Tests storage replication job CRUD between two cluster nodes.
 #
@@ -52,7 +53,7 @@ my $job_id;
 Proxmox::Test::Testcase->new('pve_replication')->with([{}])->step(
     'create ZFS-backed VM on node A',
     sub {
-        $vmid = $a->client()->get('/cluster/nextid');
+        $vmid = random_vmid($a->client());
         my $upid = $a->client()->post(
             "/nodes/$node_a/qemu",
             {
diff --git a/tests/pve_storage_basic.pl b/tests/pve_storage_basic.pl
index 6c17e28..50a7d9d 100755
--- a/tests/pve_storage_basic.pl
+++ b/tests/pve_storage_basic.pl
@@ -6,6 +6,7 @@ use Test::More;
 
 use lib '.';
 use Proxmox::Test::Helper qw(get_pve_instance);
+use Proxmox::Test::Util qw(random_vmid);
 
 # Tests storage end to end: a newly defined storage must actually be usable, so this allocates a
 # real volume on it and verifies the volume shows up in (and can be freed from) the storage
@@ -40,7 +41,7 @@ is($client->get("/storage/$storage_id", {})->{path}, '/var/tmp/testdir1', 'stora
 
 eval {
     # Allocate a real disk image on the new storage.
-    my $vmid = $client->get('/cluster/nextid');
+    my $vmid = random_vmid($client);
     my $volid = $client->post(
         "/nodes/$node/storage/$storage_id/content",
         {
-- 
2.47.3





  parent reply	other threads:[~2026-09-17 16:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-17 16:23 [PATCH test-tools,e2e-tests 0/6] randomly select VMIDs for test Michael Köppl
2026-09-17 16:23 ` [PATCH test-tools 1/6] runner: add vmid-range option for test guest VMIDs Michael Köppl
2026-09-17 16:23 ` [PATCH e2e-tests 2/6] lib: add function for drawing a random unused VMID Michael Köppl
2026-09-17 16:23 ` [PATCH e2e-tests 3/6] storage-plugin: use random_vmid function for getting VMIDs Michael Köppl
2026-09-17 16:23 ` [PATCH e2e-tests 4/6] hw-validation: " Michael Köppl
2026-09-17 16:23 ` Michael Köppl [this message]
2026-09-17 16:23 ` [PATCH e2e-tests 6/6] storage-plugin: README: document the vmid-range option Michael Köppl

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=20260917162324.1926056-6-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.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal