From 0c899a7ccd246a6e444c6827e85bbc49fb186362 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Sun, 3 Mar 2024 10:17:02 -0500 Subject: [PATCH] uitests: Handle slow app launch on fedora 39 Not quite sure what's going on here, I think it has something to do with slowness when the accessibility bus is being polled. Add some infrastructure to increase the timeout while we wait for the app to pop up Signed-off-by: Cole Robinson --- tests/uitests/lib/app.py | 7 ++++++- tests/uitests/lib/utils.py | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/tests/uitests/lib/app.py b/tests/uitests/lib/app.py index 672b5ced0..9c4bfbf57 100644 --- a/tests/uitests/lib/app.py +++ b/tests/uitests/lib/app.py @@ -347,6 +347,11 @@ class VMMDogtailApp(object): if check_already_running: self.error_if_already_running() self._proc = subprocess.Popen(cmd, stdout=stdout, stderr=stderr) - if not will_fail: + if will_fail: + return + + with utils.dogtail_timeout(10): + # On Fedora 39 sometimes app launch from the test suite + # takes a while for reasons I can't quite figure self._root = dogtail.tree.root.application("virt-manager") self._topwin = self.find_window(window_name) diff --git a/tests/uitests/lib/utils.py b/tests/uitests/lib/utils.py index 80ed37736..fdeac0a77 100644 --- a/tests/uitests/lib/utils.py +++ b/tests/uitests/lib/utils.py @@ -3,6 +3,8 @@ import time +import dogtail.config + def check(func, timeout=2): """ @@ -19,6 +21,26 @@ def check(func, timeout=2): time.sleep(interval) +class dogtail_timeout: + """ + Context helper to run a specific check with custom timeout, in seconds + """ + def __init__(self, timeout): + backoff = dogtail.config.config.searchBackoffDuration + self._tmpval = int(timeout / backoff) + self._origval = dogtail.config.config.searchCutoffCount + + def _set(self, val): + dogtail.config.config.searchCutoffCount = val + + def __enter__(self): + self._set(self._tmpval) + return self + + def __exit__(self, exc_type, exc_val, exc_tb): + self._set(self._origval) + + def walkUIList(app, win, lst, error_cb, reverse=False): """ Toggle down through a UI list like addhardware, net/storage/iface