From b727f30ac686c575718006cac16682966a1c1689 Mon Sep 17 00:00:00 2001
From: Valentin Rothberg <vrothberg@redhat.com>
Date: Wed, 1 Mar 2023 13:43:29 +0100
Subject: [PATCH 1/2] auto-update test: wait for service to be ready

The symptoms in #17607 point to some race since it does not always flake
on Debian (and Debian only).  Hence, wait for the service to be ready
before building the image to make sure that the service is started with
the old image and that everything's in order.

Fixes: #17607
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
---
 test/system/255-auto-update.bats | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/test/system/255-auto-update.bats b/test/system/255-auto-update.bats
index f9446d94eb..5864b47a2e 100644
--- a/test/system/255-auto-update.bats
+++ b/test/system/255-auto-update.bats
@@ -239,11 +239,12 @@ function _confirm_update() {
 
 @test "podman auto-update - label io.containers.autoupdate=local" {
     generate_service localtest local
+    _wait_service_ready container-$cname.service
+
     image=quay.io/libpod/localtest:latest
     run_podman commit --change CMD=/bin/bash $cname $image
     run_podman image inspect --format "{{.ID}}" $image
 
-    _wait_service_ready container-$cname.service
     run_podman auto-update --dry-run --format "{{.Unit}},{{.Image}},{{.Updated}},{{.Policy}}"
     is "$output" ".*container-$cname.service,quay.io/libpod/localtest:latest,pending,local.*" "Image update is pending."
 

From 51cf2dd363de633b368206fdfeb7fca0bd282ce7 Mon Sep 17 00:00:00 2001
From: Valentin Rothberg <vrothberg@redhat.com>
Date: Wed, 1 Mar 2023 14:45:59 +0100
Subject: [PATCH 2/2] test/system/255-auto-update.bats: wait 10 for update to
 finish

10 seconds is used by most other tests as a timeout. Given the test
flakes on Debian use it.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
---
 test/system/255-auto-update.bats | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/system/255-auto-update.bats b/test/system/255-auto-update.bats
index 5864b47a2e..d6afa1b685 100644
--- a/test/system/255-auto-update.bats
+++ b/test/system/255-auto-update.bats
@@ -112,7 +112,7 @@ function _confirm_update() {
     local old_iid=$2
 
     # Image has already been pulled, so this shouldn't take too long
-    local timeout=5
+    local timeout=10
     while [[ $timeout -gt 0 ]]; do
         sleep 1
         run_podman '?' inspect --format "{{.Image}}" $cname