Subject: uitests: Handle slow app launch on fedora 39 From: Cole Robinson crobinso@redhat.com Sun Mar 3 10:17:02 2024 -0500 Date: Sun Mar 3 10:43:30 2024 -0500: Git: 0c899a7ccd246a6e444c6827e85bbc49fb186362 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 diff --git a/tests/uitests/lib/app.py b/tests/uitests/lib/app.py index 672b5ced..9c4bfbf5 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 80ed3773..fdeac0a7 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