From patchwork Thu Nov 9 17:14:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alassane Yattara X-Patchwork-Id: 34189 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 C4B84C41535 for ; Thu, 9 Nov 2023 17:15:23 +0000 (UTC) Received: from mail.savoirfairelinux.com (mail.savoirfairelinux.com [208.88.110.44]) by mx.groups.io with SMTP id smtpd.web10.1082.1699550121091804461 for ; Thu, 09 Nov 2023 09:15:21 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@savoirfairelinux.com header.s=DFC430D2-D198-11EC-948E-34200CB392D2 header.b=Dy7fE2UE; spf=pass (domain: savoirfairelinux.com, ip: 208.88.110.44, mailfrom: alassane.yattara@savoirfairelinux.com) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 579829C34CB for ; Thu, 9 Nov 2023 12:15:19 -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 7DNx4tUDwVH9; Thu, 9 Nov 2023 12:15:18 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 8F8369C34C9; Thu, 9 Nov 2023 12:15:18 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.savoirfairelinux.com 8F8369C34C9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=savoirfairelinux.com; s=DFC430D2-D198-11EC-948E-34200CB392D2; t=1699550118; bh=UIGNNkOZkPdPaITzoMQaeJ4ltHASOcVfYHdjJYH72BE=; h=From:To:Date:Message-Id:MIME-Version; b=Dy7fE2UEAZJqb0pHkqygicBTZDwthYVQsrgId890fTo7HiwDfAQU8/8U4Ft2xmJNS Tyy1ng7mKZ2PdsUOISCYK1HeED1oARLuALULWrytelalppxVgDqXO5PsCr/IyuplWW VKyDsUEB8MIrLVYBSbzDB6XVEPKvkHbqzp67oanVzN/csrIW8H1eqYIqrt0ZdPEhIj yakpxlm/w0I2nA7rpHliSzurEtImnHOOFOHoWso6oMYF5Iowy/1pbp3+w03qOKkI6B qI6+dq6WMtj0gsKWVXjsTxHr9WhbiN5Lyb876TNc0dRZSr9eXC9t6lZqpCyzcfPGnl TmRmOJsioj2pg== 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 LOKbtLoC77zQ; Thu, 9 Nov 2023 12:15:18 -0500 (EST) Received: from jedi.. (unknown [196.127.183.75]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id ABD8F9C3290; Thu, 9 Nov 2023 12:15:17 -0500 (EST) From: Alassane Yattara To: bitbake-devel@lists.openembedded.org Cc: Alassane Yattara Subject: [PATCH v4 1/7] Toaster: Update toaster-requirements.txt and Added pytest.ini Date: Thu, 9 Nov 2023 18:14:56 +0100 Message-Id: <20231109171502.205787-1-alassane.yattara@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 ; Thu, 09 Nov 2023 17:15:23 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/15471 *** Update toaster-requirements.txt *** Add pytest and some plugin's - Pytest-html is a plugin for pytest that generates a HTML report for test results. - Pytest-django allows us to test Django project/applications with the pytest testing tool. - Pytest-env is a pytest plugin that enables us to set environment variables in a pytest.ini or pyproject.toml file - Pytest-metadata is a plugin for pytest that provides access to test session metadata, required by pytest-html plugin to provides metadata information in the HTML report like below: Python 3.10.12 Platform Linux-6.2.0-35-generic-x86_64-with-glibc2.35 Packages: - pytest: 7.4.2 - pluggy: 1.3.0 Plugins : - django: 4.5.2 - metadata: 3.0.0 - order: 1.1.0 - html: 4.0.2 - env: 1.1.0 *** Added pytest.ini file *** The main reason for using pytest is to be able to generate a positive test report using the pytest-html plugin. Integrating Pytest with Tox is a straightforward process, this can be done using tox.ini instead of pytest.ini used to configure pytest, that is another reason for using pytest. Tox is a tool that automates testing across different virtual environments, it can help ensure application will be tested against multiple Python versions and environments. https://github.com/pytest-dev/pytest/blob/main/tox.ini Generated reports create a historical record of test results over time. This can help track the progress of the application's stability and quality Documentation and Transparency: Test reports provide us a clear and detailed documentation of the test results. They show what tests were executed, which ones passed, and which ones failed. This transparency is critical for understanding the current state of the application and its test coverage. Communication: Test reports are an effective means of communication among community to understand the testing progress and results. Debugging, Troubleshooting Historical Tracking and Regression Testing: In case of test failures, a detailed test report can be invaluable for debugging. It provides information about the specific test case that failed, the input data used, and any error messages. Signed-off-by: Alassane Yattara --- lib/toaster/pytest.ini | 19 +++++++++++++++++++ toaster-requirements.txt | 5 +++++ 2 files changed, 24 insertions(+) create mode 100644 lib/toaster/pytest.ini diff --git a/lib/toaster/pytest.ini b/lib/toaster/pytest.ini new file mode 100644 index 00000000..f07076b7 --- /dev/null +++ b/lib/toaster/pytest.ini @@ -0,0 +1,19 @@ +# -- FILE: pytest.ini (or tox.ini) +[pytest] +DJANGO_SETTINGS_MODULE = toastermain.settings_test + +python_files = db/test_*.py commands/test_*.py views/test_*.py browser/test_*.py functional/test_*.py + +# --create-db - force re creation of the test database +# https://pytest-django.readthedocs.io/en/latest/database.html#create-db-force-re-creation-of-the-test-database + +# --html=report.html --self-contained-html +# https://docs.pytest.org/en/latest/usage.html#creating-html-reports +# https://pytest-html.readthedocs.io/en/latest/user_guide.html#creating-a-self-contained-report +addopts = --create-db --html="Toaster Tests Report.html" --self-contained-html + +# Define environment variables using pytest-env +# A pytest plugin that enables you to set environment variables in the pytest.ini file. +# https://pypi.org/project/pytest-env/ +env = + TOASTER_BUILDSERVER=1 diff --git a/toaster-requirements.txt b/toaster-requirements.txt index d8e48b7f..19bf6fd2 100644 --- a/toaster-requirements.txt +++ b/toaster-requirements.txt @@ -2,3 +2,8 @@ Django>4.2,<4.3 beautifulsoup4>=4.4.0 pytz django-log-viewer==1.1.7 +pytest==7.4.2 +pytest-django==4.5.2 +pytest-env==1.1.0 +pytest-html==4.0.2 +pytest-metadata==3.0.0 From patchwork Thu Nov 9 17:14:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alassane Yattara X-Patchwork-Id: 34191 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 E719EC4167B for ; Thu, 9 Nov 2023 17:15:23 +0000 (UTC) Received: from mail.savoirfairelinux.com (mail.savoirfairelinux.com [208.88.110.44]) by mx.groups.io with SMTP id smtpd.web11.1000.1699550121355275285 for ; Thu, 09 Nov 2023 09:15:22 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@savoirfairelinux.com header.s=DFC430D2-D198-11EC-948E-34200CB392D2 header.b=ueSqEAUf; spf=pass (domain: savoirfairelinux.com, ip: 208.88.110.44, mailfrom: alassane.yattara@savoirfairelinux.com) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 3C20C9C34CD for ; Thu, 9 Nov 2023 12:15:20 -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 x38LDxwbA3pp; Thu, 9 Nov 2023 12:15:19 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id C25299C34C9; Thu, 9 Nov 2023 12:15:19 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.savoirfairelinux.com C25299C34C9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=savoirfairelinux.com; s=DFC430D2-D198-11EC-948E-34200CB392D2; t=1699550119; bh=+m/KNy2AMqWB1h1tnjZcHiD38duvHCRhaP6gbInNBKI=; h=From:To:Date:Message-Id:MIME-Version; b=ueSqEAUf1cV1ISeodsxywLUSTlgw04iQh4RI3yFBPFxoaoy++WtZmKpV83vkrPT/s utqNfYtZiAI4jPuBrGYwUcdLyOVX2uBS4YHFBMq/F11m3sfGfZcfgXRHjSQmQqHMF5 gVH9KoF/oPYF6ci218oYuwfD7OPXTdswd+HVLYRq83EmKUs1NLPNYqwx44311tiCdc owIkTHZs6+puzZx1IUER07AB/vb3Wk73jYCzqBALM0+7k03KdiQrE7yjvf93GpZ5T4 uAZWP230pTyvojGpwujmf0IwqUPt5DfUCtzZ8rRB6UwYrNWo0Es4WTdyiXe05RyTMX qR8WtdYl8LeBw== 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 6Bc06M6vLDSS; Thu, 9 Nov 2023 12:15:19 -0500 (EST) Received: from jedi.. (unknown [196.127.183.75]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id E24029C3290; Thu, 9 Nov 2023 12:15:18 -0500 (EST) From: Alassane Yattara To: bitbake-devel@lists.openembedded.org Cc: Alassane Yattara Subject: [PATCH v4 2/7] Toaster: Update orm.models to catch error ProcessLookupError Date: Thu, 9 Nov 2023 18:14:57 +0100 Message-Id: <20231109171502.205787-2-alassane.yattara@savoirfairelinux.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231109171502.205787-1-alassane.yattara@savoirfairelinux.com> References: <20231109171502.205787-1-alassane.yattara@savoirfairelinux.com> 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 ; Thu, 09 Nov 2023 17:15:23 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/15472 - catch error ProcessLookupError and logs it Signed-off-by: Alassane Yattara --- lib/toaster/orm/models.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/toaster/orm/models.py b/lib/toaster/orm/models.py index 0d503a51..1098ad3f 100644 --- a/lib/toaster/orm/models.py +++ b/lib/toaster/orm/models.py @@ -1389,9 +1389,6 @@ class Machine(models.Model): return "Machine " + self.name + "(" + self.description + ")" - - - class BitbakeVersion(models.Model): name = models.CharField(max_length=32, unique = True) @@ -1853,6 +1850,8 @@ def signal_runbuilds(): os.kill(int(pidf.read()), SIGUSR1) except FileNotFoundError: logger.info("Stopping existing runbuilds: no current process found") + except ProcessLookupError: + logger.warning("Stopping existing runbuilds: process lookup not found") class Distro(models.Model): search_allowed_fields = ["name", "description", "layer_version__layer__name"] From patchwork Thu Nov 9 17:14:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alassane Yattara X-Patchwork-Id: 34190 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 C4AD4C4167D for ; Thu, 9 Nov 2023 17:15:23 +0000 (UTC) Received: from mail.savoirfairelinux.com (mail.savoirfairelinux.com [208.88.110.44]) by mx.groups.io with SMTP id smtpd.web10.1085.1699550123154709720 for ; Thu, 09 Nov 2023 09:15:23 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@savoirfairelinux.com header.s=DFC430D2-D198-11EC-948E-34200CB392D2 header.b=T5mCo+Bo; spf=pass (domain: savoirfairelinux.com, ip: 208.88.110.44, mailfrom: alassane.yattara@savoirfairelinux.com) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 146AA9C3474 for ; Thu, 9 Nov 2023 12:15:22 -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 v2dUT-gHOyUZ; Thu, 9 Nov 2023 12:15:20 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id C85639C34C9; Thu, 9 Nov 2023 12:15:20 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.savoirfairelinux.com C85639C34C9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=savoirfairelinux.com; s=DFC430D2-D198-11EC-948E-34200CB392D2; t=1699550120; bh=GesLj5+Tfp6+cElUD4N1oiRTqPVAwnFMvCqk+qYl7BU=; h=From:To:Date:Message-Id:MIME-Version; b=T5mCo+BoI7A+DeCeaJrXJiEU6GsZ/vGeAwe7WI1M3hYEF8E/F9lDLnR9aOsNuL0qB tScVA0vTUejq7oZcnARPoi23A9wUPIw4uBDQf9fEZtH6pUAuUPUTslU30pqtNAZ9bn SKKtQRjPTHThdJzjJjak8eX/u61TPY7LPdjmbAAD9dAtTR8xWDsCEGUEOfbLP1FgZ6 WnPmQBZfoTTAUmlA6hz8wPGsCCcm9ni0cQmzvr/OoJQXv/5ulxHyIzik2Ih2L58v7M +iXJxM5qQFJnH0n/cHfsGHYJT1SNGs3mupHTNlha1P1JTqtzOTZgnC6srd9wItafvY j1XNdL7B+BJtA== 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 ujRF2YQ1oNpr; Thu, 9 Nov 2023 12:15:20 -0500 (EST) Received: from jedi.. (unknown [196.127.183.75]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id 02EBC9C3290; Thu, 9 Nov 2023 12:15:19 -0500 (EST) From: Alassane Yattara To: bitbake-devel@lists.openembedded.org Cc: Alassane Yattara Subject: [PATCH v4 3/7] Toaster: Bug-fix pytest and Failed: Database access not allowed Date: Thu, 9 Nov 2023 18:14:58 +0100 Message-Id: <20231109171502.205787-3-alassane.yattara@savoirfairelinux.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231109171502.205787-1-alassane.yattara@savoirfairelinux.com> References: <20231109171502.205787-1-alassane.yattara@savoirfairelinux.com> 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 ; Thu, 09 Nov 2023 17:15:23 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/15473 Remove load and create build environment from tests/functional/functional_helpers - Testcases in the FunctionalTestCase do not require a build process, - Also marked setUpClass or class with pytest django_db, db ... not working, as declared above of file functional_helpers.py, The database access process runs as an external process, separate from the test case process and outside the context of pytest. Signed-off-by: Alassane Yattara --- lib/toaster/tests/functional/functional_helpers.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib/toaster/tests/functional/functional_helpers.py b/lib/toaster/tests/functional/functional_helpers.py index c3191f66..b80d403b 100644 --- a/lib/toaster/tests/functional/functional_helpers.py +++ b/lib/toaster/tests/functional/functional_helpers.py @@ -15,8 +15,6 @@ import time import re from tests.browser.selenium_helpers_base import SeleniumTestCaseBase -from tests.builds.buildtest import load_build_environment -from bldcontrol.models import BuildEnvironment from selenium.webdriver.common.by import By from selenium.common.exceptions import NoSuchElementException @@ -33,10 +31,6 @@ class SeleniumFunctionalTestCase(SeleniumTestCaseBase): raise RuntimeError("Please initialise django with the tests settings: " \ "DJANGO_SETTINGS_MODULE='toastermain.settings_test'") - if BuildEnvironment.objects.count() == 0: - BuildEnvironment.objects.create(betype=BuildEnvironment.TYPE_LOCAL) - load_build_environment() - # start toaster cmd = "bash -c 'source toaster start'" p = subprocess.Popen( From patchwork Thu Nov 9 17:14:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alassane Yattara X-Patchwork-Id: 34192 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 D7DBDC4167B for ; Thu, 9 Nov 2023 17:15:33 +0000 (UTC) Received: from mail.savoirfairelinux.com (mail.savoirfairelinux.com [208.88.110.44]) by mx.groups.io with SMTP id smtpd.web11.1002.1699550123948453454 for ; Thu, 09 Nov 2023 09:15:24 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@savoirfairelinux.com header.s=DFC430D2-D198-11EC-948E-34200CB392D2 header.b=LhhtwrBV; spf=pass (domain: savoirfairelinux.com, ip: 208.88.110.44, mailfrom: alassane.yattara@savoirfairelinux.com) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 899349C34C9 for ; Thu, 9 Nov 2023 12:15:22 -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 BM_oj3I88g0d; Thu, 9 Nov 2023 12:15:22 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 0CF539C3290; Thu, 9 Nov 2023 12:15:22 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.savoirfairelinux.com 0CF539C3290 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=savoirfairelinux.com; s=DFC430D2-D198-11EC-948E-34200CB392D2; t=1699550122; bh=wIHbE11BWKitYZkfAFNEA6bXcaZDEe9cTiCXpyD4qwk=; h=From:To:Date:Message-Id:MIME-Version; b=LhhtwrBVo6+xhnzzWxI0nGp+MyzdRi6hGSeWA7z9C9SbfiZAfpe3QgXV+Nf2i+u3I xw6H2Us6HbtQVBAJWuIrdsmcbxNrRoGAmeXEo5UYa35n0UgYB4kRgRBcV+7V012zZL tibMDNNXT3cw0wwG6lRfnVOmrHSzImPPOd6BJKgxA5fQ1f2rpEQvHxhi26zeQN9Cy6 +1tQ2FNZy8wAooHS0MZMx4DHGUZvd5pyPm99FczZwyWtcI9g6m0Z0jq6YV21DUsWcP GH9wdV4T7sla9Hn0NidJ8l1VbSBgrEsbuly7G/xWBerHU7yjPEdofrARxJAWVVzTCX gQOMScmcjpptg== 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 aZQwWRP1v-IR; Thu, 9 Nov 2023 12:15:22 -0500 (EST) Received: from jedi.. (unknown [196.127.183.75]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id 2BCF89C326C; Thu, 9 Nov 2023 12:15:20 -0500 (EST) From: Alassane Yattara To: bitbake-devel@lists.openembedded.org Cc: Alassane Yattara Subject: [PATCH v4 4/7] Toaster: fixed pytest error: Database access not allowed, use the "django_db" Date: Thu, 9 Nov 2023 18:14:59 +0100 Message-Id: <20231109171502.205787-4-alassane.yattara@savoirfairelinux.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231109171502.205787-1-alassane.yattara@savoirfairelinux.com> References: <20231109171502.205787-1-alassane.yattara@savoirfairelinux.com> 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 ; Thu, 09 Nov 2023 17:15:33 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/15474 Pytest failed on functional/test_functional_basic because database access not allowed - we should use "django_db" fixture to allowed db access Note: Pytest-django takes a conservative approach to enabling database access. By default your tests will fail if they try to access the database. Only if you explicitly request database access will this be allowed. https://pytest-django.readthedocs.io/en/latest/helpers.html#pytest-mark-django-db-request-database-access Signed-off-by: Alassane Yattara --- lib/toaster/tests/functional/test_functional_basic.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/toaster/tests/functional/test_functional_basic.py b/lib/toaster/tests/functional/test_functional_basic.py index b0def544..7e9be91c 100644 --- a/lib/toaster/tests/functional/test_functional_basic.py +++ b/lib/toaster/tests/functional/test_functional_basic.py @@ -8,6 +8,7 @@ # import re, time +import pytest from django.urls import reverse from tests.functional.functional_helpers import SeleniumFunctionalTestCase from orm.models import Project @@ -16,6 +17,7 @@ from selenium.webdriver.common.by import By class FuntionalTestBasic(SeleniumFunctionalTestCase): # testcase (1514) + @pytest.mark.django_db def test_create_slenium_project(self): project_name = 'selenium-project' self.get(reverse('newproject')) From patchwork Thu Nov 9 17:15:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alassane Yattara X-Patchwork-Id: 34193 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 D2404C4332F for ; Thu, 9 Nov 2023 17:15:33 +0000 (UTC) Received: from mail.savoirfairelinux.com (mail.savoirfairelinux.com [208.88.110.44]) by mx.groups.io with SMTP id smtpd.web10.1086.1699550124509452278 for ; Thu, 09 Nov 2023 09:15:24 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@savoirfairelinux.com header.s=DFC430D2-D198-11EC-948E-34200CB392D2 header.b=sGyEwJjN; spf=pass (domain: savoirfairelinux.com, ip: 208.88.110.44, mailfrom: alassane.yattara@savoirfairelinux.com) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id B7D0B9C3474 for ; Thu, 9 Nov 2023 12:15:23 -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 OKzMYj1QcF2C; Thu, 9 Nov 2023 12:15:23 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 445C49C3290; Thu, 9 Nov 2023 12:15:23 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.savoirfairelinux.com 445C49C3290 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=savoirfairelinux.com; s=DFC430D2-D198-11EC-948E-34200CB392D2; t=1699550123; bh=p2J+od2B1eMImjzJ6UqaVnL/r0kbwNU9wZ1YSW48g4U=; h=From:To:Date:Message-Id:MIME-Version; b=sGyEwJjNcnlLJEl7SmERP9nS2iJTdcPlfc5J7NZTvVClajUndBMWUWAtVf83+fKsj JHrrXnjHNXMEjAGFsoia14k/ET9DS07VsmuHIU9Wsp2V1Jj9Au5mgF8T8VdA8Mb4Cw qcvXLuNwWv0Yv5QbtAqp1JSkg+jQDE2vMmrWZhDqg2lCwbAFWzMklLDLT3OdGXY+p/ /CdNg8+CrrW8xZiF2VTMWGJ3qw2XOVnE1myAupvrv4gpPyXsgZYPER+rvtpXrX30Ex 1V9l4CoOs1zjfxjRkUP36ynZg/TLKbtd4fJ/pdaZRNJm43Y8CJNhMK7m2cO2FKAQ6t /ZRHOXYQc67Cg== 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 Qcop0xAnApb7; Thu, 9 Nov 2023 12:15:23 -0500 (EST) Received: from jedi.. (unknown [196.127.183.75]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id 63B6F9C326C; Thu, 9 Nov 2023 12:15:22 -0500 (EST) From: Alassane Yattara To: bitbake-devel@lists.openembedded.org Cc: Alassane Yattara Subject: [PATCH v4 5/7] Toaster: Bug-fix django.db.utils.IntegrityError: Problem installing fixture Date: Thu, 9 Nov 2023 18:15:00 +0100 Message-Id: <20231109171502.205787-5-alassane.yattara@savoirfairelinux.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231109171502.205787-1-alassane.yattara@savoirfairelinux.com> References: <20231109171502.205787-1-alassane.yattara@savoirfairelinux.com> 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 ; Thu, 09 Nov 2023 17:15:33 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/15475 toastergui-unittest-data.xml fixture contains a release objects with name="master" or an release with same name seem existing - Change release name and fix bitbakeversion instead of bitbake_version Signed-off-by: Alassane Yattara --- lib/toaster/toastergui/fixtures/toastergui-unittest-data.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/toaster/toastergui/fixtures/toastergui-unittest-data.xml b/lib/toaster/toastergui/fixtures/toastergui-unittest-data.xml index 1d522f88..df106934 100644 --- a/lib/toaster/toastergui/fixtures/toastergui-unittest-data.xml +++ b/lib/toaster/toastergui/fixtures/toastergui-unittest-data.xml @@ -19,9 +19,9 @@ poky_distro2 description - master + foo_master master project - 1 + 1 a test project From patchwork Thu Nov 9 17:15:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alassane Yattara X-Patchwork-Id: 34194 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 E2231C04E85 for ; Thu, 9 Nov 2023 17:15:33 +0000 (UTC) Received: from mail.savoirfairelinux.com (mail.savoirfairelinux.com [208.88.110.44]) by mx.groups.io with SMTP id smtpd.web10.1088.1699550126793172939 for ; Thu, 09 Nov 2023 09:15:26 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@savoirfairelinux.com header.s=DFC430D2-D198-11EC-948E-34200CB392D2 header.b=yR/qsVDp; spf=pass (domain: savoirfairelinux.com, ip: 208.88.110.44, mailfrom: alassane.yattara@savoirfairelinux.com) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 796379C34D2 for ; Thu, 9 Nov 2023 12:15:25 -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 0TYpyUYXQDnZ; Thu, 9 Nov 2023 12:15:24 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 7CF819C34CB; Thu, 9 Nov 2023 12:15:24 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.savoirfairelinux.com 7CF819C34CB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=savoirfairelinux.com; s=DFC430D2-D198-11EC-948E-34200CB392D2; t=1699550124; bh=9ZmjA4jVXRKl7D0tU2mh3T4CRmbXyy0ig+56aOGFxaw=; h=From:To:Date:Message-Id:MIME-Version; b=yR/qsVDpNfH/LGJRMEpPK6yeWeZmWmoZBc/Ma66XmYwdxmsRxXttOA2vf0if2sqL6 L1KEGEsF5h6GAZDxYa30xKtEKKQq4w1A8UJRvJCR2qeshZ5bxqcwcv6+1Xv2GWrrgl 8z40Ju+Mw5vuoC30u1TNu0ml3I2pwaXskBrV1eZyG7ccbIhaaRlqoz2r8AHNeiXVgt stRTQZU5YmMubhLuSOkMiMg36UEnz9GWEfxPvcVtTv+jjBsY5YMzahVuKCX/iezGDl biT1sDJG9y5emDl0XXBR+OxY13s0sM6PD9wuackQ7SyCDC75+4illRiQWVEGdqIxmF e0DBGW/JHMFRw== 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 GvIB4Xaqxg9p; Thu, 9 Nov 2023 12:15:24 -0500 (EST) Received: from jedi.. (unknown [196.127.183.75]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id 9BB7B9C326C; Thu, 9 Nov 2023 12:15:23 -0500 (EST) From: Alassane Yattara To: bitbake-devel@lists.openembedded.org Cc: Alassane Yattara Subject: [PATCH v4 6/7] Toaster: Move toaster tests requirements in bitbake/lib/toaster/toaster-tests-requirements Date: Thu, 9 Nov 2023 18:15:01 +0100 Message-Id: <20231109171502.205787-6-alassane.yattara@savoirfairelinux.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231109171502.205787-1-alassane.yattara@savoirfairelinux.com> References: <20231109171502.205787-1-alassane.yattara@savoirfairelinux.com> 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 ; Thu, 09 Nov 2023 17:15:33 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/15476 To make difference between bitbake and toaster python requirements, a dedicated requirements file is created for toaster in root of toaster dir. Signed-off-by: Alassane Yattara --- lib/toaster/tests/toaster-tests-requirements.txt | 5 +++++ toaster-requirements.txt | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/toaster/tests/toaster-tests-requirements.txt b/lib/toaster/tests/toaster-tests-requirements.txt index f30ac070..7109c625 100644 --- a/lib/toaster/tests/toaster-tests-requirements.txt +++ b/lib/toaster/tests/toaster-tests-requirements.txt @@ -1 +1,6 @@ selenium>=4.13.0 +pytest==7.4.2 +pytest-django==4.5.2 +pytest-env==1.1.0 +pytest-html==4.0.2 +pytest-metadata==3.0.0 diff --git a/toaster-requirements.txt b/toaster-requirements.txt index 19bf6fd2..d8e48b7f 100644 --- a/toaster-requirements.txt +++ b/toaster-requirements.txt @@ -2,8 +2,3 @@ Django>4.2,<4.3 beautifulsoup4>=4.4.0 pytz django-log-viewer==1.1.7 -pytest==7.4.2 -pytest-django==4.5.2 -pytest-env==1.1.0 -pytest-html==4.0.2 -pytest-metadata==3.0.0 From patchwork Thu Nov 9 17:15:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alassane Yattara X-Patchwork-Id: 34195 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 E8970C001B2 for ; Thu, 9 Nov 2023 17:15:33 +0000 (UTC) Received: from mail.savoirfairelinux.com (mail.savoirfairelinux.com [208.88.110.44]) by mx.groups.io with SMTP id smtpd.web11.1004.1699550127000078375 for ; Thu, 09 Nov 2023 09:15:27 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@savoirfairelinux.com header.s=DFC430D2-D198-11EC-948E-34200CB392D2 header.b=rnCAd4lh; spf=pass (domain: savoirfairelinux.com, ip: 208.88.110.44, mailfrom: alassane.yattara@savoirfairelinux.com) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 526969C3474 for ; Thu, 9 Nov 2023 12:15:26 -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 Mete5IKd_eV5; Thu, 9 Nov 2023 12:15:25 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id A674E9C34CE; Thu, 9 Nov 2023 12:15:25 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.savoirfairelinux.com A674E9C34CE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=savoirfairelinux.com; s=DFC430D2-D198-11EC-948E-34200CB392D2; t=1699550125; bh=+5uZZBBn17ErJhYtUSTuu9jVZ2vwwTzGT4O4Jw8pWWc=; h=From:To:Date:Message-Id:MIME-Version; b=rnCAd4lh2XJb+cuwuHBnsr0xlzpRUWbIqNXCWXiHtKR4yuyY6qmAXfO/MdmJn6bmF qiC2XUNxtmSAW6VfYkM4ImuOcx73d/IWQAdTiqveKashA3EIAR/QHI03xStcO1XaB2 gbbNJn8FnV6S9b+1Ljx5S/QlYF5aw/+2GAT+TqqjI4wn7nfEK5HKfRhWuBMEBc7gTt USTfeTB8tFHAdBQc8/Ss5i3Py1LGz0Eyiy/MAMX0OGvzz8wizSs0GVCbj+atBPSiWw IFrPXD7xEBayDomsJbthY/fQxeTarH8l3QQ8xlfifPvvK51oFusyngcTooPd8UtlA3 GbIPPvbvUEaYw== 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 UeDXlqAxcfnd; Thu, 9 Nov 2023 12:15:25 -0500 (EST) Received: from jedi.. (unknown [196.127.183.75]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id C118A9C3474; Thu, 9 Nov 2023 12:15:24 -0500 (EST) From: Alassane Yattara To: bitbake-devel@lists.openembedded.org Cc: Alassane Yattara Subject: [PATCH v4 7/7] Toaster: fixed: Tests fail when executed one after the other out of sequence Date: Thu, 9 Nov 2023 18:15:02 +0100 Message-Id: <20231109171502.205787-7-alassane.yattara@savoirfairelinux.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231109171502.205787-1-alassane.yattara@savoirfairelinux.com> References: <20231109171502.205787-1-alassane.yattara@savoirfairelinux.com> 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 ; Thu, 09 Nov 2023 17:15:33 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/15477 As mentionned in earlier commit, pytest-django takes a conservative approach to enabling database access. By default our tests will fail if they try to access the database, Only if we explicitly request database access will this be allowed, using pytest marks to tell pytest-django our test needs database access. A side effect of pytest mark, is test_case method marked is execute out of scope of its module class, which create an inconsistance sequence and make fails followings tests. The scope of the ordering is global per default, e.g. tests with lower ordinal numbers are always executed before tests with higher numbers in the same test session, regardless of the module and class they reside in. This can be changed by using the --order-scope option from module pytest-order. To fix that i added execution order to tests suite using pytest-order. Signed-off-by: Alassane Yattara --- lib/toaster/tests/functional/test_functional_basic.py | 4 +++- lib/toaster/tests/toaster-tests-requirements.txt | 1 + lib/toaster/tests/views/test_views.py | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/toaster/tests/functional/test_functional_basic.py b/lib/toaster/tests/functional/test_functional_basic.py index 7e9be91c..f558cce8 100644 --- a/lib/toaster/tests/functional/test_functional_basic.py +++ b/lib/toaster/tests/functional/test_functional_basic.py @@ -8,12 +8,14 @@ # import re, time -import pytest from django.urls import reverse +import pytest from tests.functional.functional_helpers import SeleniumFunctionalTestCase from orm.models import Project from selenium.webdriver.common.by import By + +@pytest.mark.order("last") class FuntionalTestBasic(SeleniumFunctionalTestCase): # testcase (1514) diff --git a/lib/toaster/tests/toaster-tests-requirements.txt b/lib/toaster/tests/toaster-tests-requirements.txt index 7109c625..71cc0834 100644 --- a/lib/toaster/tests/toaster-tests-requirements.txt +++ b/lib/toaster/tests/toaster-tests-requirements.txt @@ -4,3 +4,4 @@ pytest-django==4.5.2 pytest-env==1.1.0 pytest-html==4.0.2 pytest-metadata==3.0.0 +pytest-order==1.1.0 diff --git a/lib/toaster/tests/views/test_views.py b/lib/toaster/tests/views/test_views.py index 06bf6c20..349881eb 100644 --- a/lib/toaster/tests/views/test_views.py +++ b/lib/toaster/tests/views/test_views.py @@ -9,6 +9,7 @@ """Test cases for Toaster GUI and ReST.""" +import pytest from django.test import TestCase from django.test.client import RequestFactory from django.urls import reverse @@ -33,6 +34,7 @@ PROJECT_NAME2 = "test project 2" CLI_BUILDS_PROJECT_NAME = 'Command line builds' +@pytest.mark.order(1) class ViewTests(TestCase): """Tests to verify view APIs."""