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 7997B1FF0C0 for ; Wed, 04 Nov 2026 20:04:42 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 68104216B5; Wed, 04 Nov 2026 20:03:59 +0100 (CET) From: =?UTF-8?q?Michael=20K=C3=B6ppl?= To: pve-devel@lists.proxmox.com Subject: [PATCH e2e-tests 07/38] lib: pveinstance: add helper to find a task started by another task Date: Wed, 4 Nov 2026 20:03:14 +0100 Message-ID: <20261104190345.2573464-8-m.koeppl@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261104190345.2573464-1-m.koeppl@proxmox.com> References: <20261104190345.2573464-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: 1793819033885 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.225 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) 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: O7YQHSCNHH3RBK34RU75ZEJAOMRK4FRT X-Message-ID-Hash: O7YQHSCNHH3RBK34RU75ZEJAOMRK4FRT 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: Some tasks start another task for the same guest and finish before it does (e.g. a container rollback with 'start' set runs the start in a separate 'vzstart' task). A test that only waits for the first task then races against the second one. Add a helper that finds such a task through the node's task list, so tests can wait for it and check its result. Signed-off-by: Michael Köppl --- Proxmox/Test/PVEInstance.pm | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Proxmox/Test/PVEInstance.pm b/Proxmox/Test/PVEInstance.pm index dc40489..646ff48 100644 --- a/Proxmox/Test/PVEInstance.pm +++ b/Proxmox/Test/PVEInstance.pm @@ -109,6 +109,36 @@ sub destroy_volume { return $ok; } +# Return the UPID of the task of $type that the task $upid started for the same guest, such as the +# 'vzstart' task of a rollback with 'start' set. Such a task runs separately and can still be +# running, or not have started yet, when $upid has finished. Dies if no such task shows up within +# $timeout seconds (default 60). +sub find_spawned_task { + my ($self, $upid, $type, $timeout) = @_; + + my (undef, $node, undef, undef, $starttime, undef, $vmid) = split(/:/, $upid); + die "cannot parse UPID '$upid'\n" if !defined($vmid) || $vmid eq ''; + + return poll_until( + sub { + my $tasks = $self->client()->get( + "/nodes/$node/tasks", + { + vmid => $vmid, + typefilter => $type, + since => hex($starttime), + source => 'all', + }, + ); + my ($task) = grep { $_->{upid} ne $upid } $tasks->@*; + return $task ? $task->{upid} : undef; + }, + timeout => $timeout // 60, + interval => 2, + description => "a '$type' task for guest $vmid started by $upid", + ); +} + sub wait_for_qga { my ($self, $vmid, $timeout) = @_; return $self->wait_for_qga_on($self->get_nodename(), $vmid, $timeout); -- 2.47.3