From patchwork Tue Dec 12 16:38:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lussier-Cullen X-Patchwork-Id: 36111 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B8D8C4332F for ; Tue, 12 Dec 2023 16:39:15 +0000 (UTC) Received: from mail.savoirfairelinux.com (mail.savoirfairelinux.com [208.88.110.44]) by mx.groups.io with SMTP id smtpd.web11.1096.1702399153290196733 for ; Tue, 12 Dec 2023 08:39:14 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@savoirfairelinux.com header.s=DFC430D2-D198-11EC-948E-34200CB392D2 header.b=xsB/vbMw; spf=pass (domain: savoirfairelinux.com, ip: 208.88.110.44, mailfrom: alexander.lussier-cullen@savoirfairelinux.com) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id EEE7D9C27A3 for ; Tue, 12 Dec 2023 11:39:11 -0500 (EST) Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavis, port 10032) with ESMTP id hkMihzIOGMfn; Tue, 12 Dec 2023 11:39:11 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 274BA9C32E1; Tue, 12 Dec 2023 11:39:11 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.savoirfairelinux.com 274BA9C32E1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=savoirfairelinux.com; s=DFC430D2-D198-11EC-948E-34200CB392D2; t=1702399151; bh=1j71pBXaV4gEq4yRHeME9nE8fTZ+ZzFbw+SNJCdNyH0=; h=From:To:Date:Message-Id:MIME-Version; b=xsB/vbMwMX7qeSaO52vka328bFaGgYQcePA93GuyfPq6Svdo02Ksba7Gift8HfyTd qf1cEXN/90z/4XOGPMB3fztA/5dLKoeaCkUnqfohbOpHO/V5IRuqREZC7w2GTaG8hv wHYIZl4klu8C4tqjiW6Iiqqbl6Pb2j6fI8JgGWXRQYvthhvoNL0J/47yASPpY2iBeQ UoMXmKiMPMD/yO4GkvIxw4Q9RIlGhC95UHbJsQF7AqgJhY8ss3SIsR9qEyjYBOPutl df7zOEqpu614TpK/Bt16/j6itrhhKZaRgyoPAIqrMSdP9buv7s9hqTmB2Iv5pHbeL1 PeDhMydmWfKjw== X-Virus-Scanned: amavis at mail.savoirfairelinux.com Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavis, port 10026) with ESMTP id I9uyhBlr2jrp; Tue, 12 Dec 2023 11:39:11 -0500 (EST) Received: from alctower.mtl.sfl (unknown [192.168.51.254]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id 16B559C27A3; Tue, 12 Dec 2023 11:39:11 -0500 (EST) From: Alexander Lussier-Cullen To: toaster@lists.yoctoproject.org Cc: Alexander Lussier-Cullen Subject: [PATCH] bitbake: toaster: Exit tests on chromedriver creation failure Date: Tue, 12 Dec 2023 11:38:50 -0500 Message-Id: <20231212163850.99645-1-alexander.lussier-cullen@savoirfairelinux.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Tue, 12 Dec 2023 16:39:15 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/toaster/message/6085 When failing to create the web driver session for selenium tests, a cascade of erroring tests will follow. To avoid processing these unnecessarily, exit the tests completely in this case. Signed-off-by: Alexander Lussier-Cullen --- .../toaster/tests/browser/selenium_helpers_base.py | 14 ++++++++------ run-toaster-tests | 0 2 files changed, 8 insertions(+), 6 deletions(-) create mode 100644 run-toaster-tests diff --git a/bitbake/lib/toaster/tests/browser/selenium_helpers_base.py b/bitbake/lib/toaster/tests/browser/selenium_helpers_base.py index 46ced5a167..b32e89d7f3 100644 --- a/bitbake/lib/toaster/tests/browser/selenium_helpers_base.py +++ b/bitbake/lib/toaster/tests/browser/selenium_helpers_base.py @@ -19,6 +19,7 @@ import os import time import unittest +import pytest from selenium import webdriver from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.common.by import By @@ -43,22 +44,23 @@ def create_selenium_driver(cls,browser='chrome'): try: return webdriver.Chrome(options=options) except SessionNotCreatedException as e: + exit_message = "Halting tests prematurely to avoid cascading errors." # check if chrome / chromedriver exists chrome_path = os.popen("find ~/.cache/selenium/chrome/ -name 'chrome' -type f -print -quit").read().strip() if not chrome_path: - raise SessionNotCreatedException("Failed to install/find chrome") + pytest.exit(f"Failed to install/find chrome.\n{exit_message}") chromedriver_path = os.popen("find ~/.cache/selenium/chromedriver/ -name 'chromedriver' -type f -print -quit").read().strip() if not chromedriver_path: - raise SessionNotCreatedException("Failed to install/find chromedriver") + pytest.exit(f"Failed to install/find chromedriver.\n{exit_message}") # check if depends on each are fulfilled depends_chrome = os.popen(f"ldd {chrome_path} | grep 'not found'").read().strip() if depends_chrome: - raise SessionNotCreatedException(f"Missing chrome dependencies\n{depends_chrome}") + pytest.exit(f"Missing chrome dependencies.\n{depends_chrome}\n{exit_message}") depends_chromedriver = os.popen(f"ldd {chromedriver_path} | grep 'not found'").read().strip() if depends_chromedriver: - raise SessionNotCreatedException(f"Missing chrome dependencies\n{depends_chromedriver}") - # raise original error otherwise - raise e + pytest.exit(f"Missing chromedriver dependencies.\n{depends_chromedriver}\n{exit_message}") + # print original error otherwise + pytest.exit(f"Failed to start chromedriver.\n{e}\n{exit_message}") elif browser == 'firefox': return webdriver.Firefox() elif browser == 'marionette': diff --git a/run-toaster-tests b/run-toaster-tests new file mode 100644 index 0000000000..e69de29bb2