From patchwork Thu Nov 9 17:15:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alassane Yattara X-Patchwork-Id: 34182 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 E5AB9C4332F for ; Thu, 9 Nov 2023 17:15:43 +0000 (UTC) Received: from mail.savoirfairelinux.com (mail.savoirfairelinux.com [208.88.110.44]) by mx.groups.io with SMTP id smtpd.web10.1094.1699550142360855026 for ; Thu, 09 Nov 2023 09:15:42 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@savoirfairelinux.com header.s=DFC430D2-D198-11EC-948E-34200CB392D2 header.b=rla2TpdZ; 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 9A99B9C34BF for ; Thu, 9 Nov 2023 12:15:41 -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 ShiwucQ70XH2; Thu, 9 Nov 2023 12:15:40 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id CBAB09C2CD7; Thu, 9 Nov 2023 12:15:40 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.savoirfairelinux.com CBAB09C2CD7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=savoirfairelinux.com; s=DFC430D2-D198-11EC-948E-34200CB392D2; t=1699550140; bh=UIGNNkOZkPdPaITzoMQaeJ4ltHASOcVfYHdjJYH72BE=; h=From:To:Date:Message-Id:MIME-Version; b=rla2TpdZmswJl2UzOiHlZNcyiakOPpyzpCQl0iH2XlH6C6ZfKdnXY9ZCpBpk1tR7N hOHQbsF1fZX0z9nVVLiDchIGQ0raoRs1Kqble9h+gmxzgvboc+EcLDs/e1IPTb9HME YkBYjfdKy1O3K9wC083JaTjn8XV7MOR59cCRI6ExTH8WSnWeZSZkulq4V3mtwSaUaS eB+337FsJuCgQ7dX4Ts58Ak3I6FwFRSuasOlYD0CuQbRv3ZPPOwF/O5WpjJiEPalqJ Vt/M6ER22+0KQcA0ovBx//P/qe3x0TuCBXzajyGPhtW4OPGF2T3onBomWkcq9Zkw07 39Acg5phh34Rg== 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 qQV_OX9xE9bV; Thu, 9 Nov 2023 12:15:40 -0500 (EST) Received: from jedi.. (unknown [196.127.183.75]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id E18FF9C33AB; Thu, 9 Nov 2023 12:15:39 -0500 (EST) From: Alassane Yattara To: toaster@lists.yoctoproject.org Cc: Alassane Yattara Subject: [PATCH v4 1/7] Toaster: Update toaster-requirements.txt and Added pytest.ini Date: Thu, 9 Nov 2023 18:15:29 +0100 Message-Id: <20231109171535.207464-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:43 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/toaster/message/5961 *** 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:15:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alassane Yattara X-Patchwork-Id: 34183 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 E90F3C4167D for ; Thu, 9 Nov 2023 17:15:53 +0000 (UTC) Received: from mail.savoirfairelinux.com (mail.savoirfairelinux.com [208.88.110.44]) by mx.groups.io with SMTP id smtpd.web11.1013.1699550143812681525 for ; Thu, 09 Nov 2023 09:15:44 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@savoirfairelinux.com header.s=DFC430D2-D198-11EC-948E-34200CB392D2 header.b=kikMCXG/; 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 CBB349C34BF for ; Thu, 9 Nov 2023 12:15:42 -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 C6lS-VpiBBQ4; Thu, 9 Nov 2023 12:15:42 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 040809C2CD7; Thu, 9 Nov 2023 12:15:42 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.savoirfairelinux.com 040809C2CD7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=savoirfairelinux.com; s=DFC430D2-D198-11EC-948E-34200CB392D2; t=1699550142; bh=+m/KNy2AMqWB1h1tnjZcHiD38duvHCRhaP6gbInNBKI=; h=From:To:Date:Message-Id:MIME-Version; b=kikMCXG/VLhtqIKio2qsOYcDma5X7O8jq3t7YwcX8xje5Ffa1GhsJQ+Dux8l/LkPv mNxC3kRzpRiPdNOXAtSZfTcxYLSoBXgpcJvnm82h4SovhOFnGHqW0epDZAz9M77CR8 7SIGHRcjfw64P7KhlAJHXqqaYOVLsfy34jfQa+x5aa1fLb+MXWBcmWZW2p/kcZiSR0 W1VcDY9dBwq9co1LlWVgmXX/fI1aBx0MSOG4d54f5ni8yStce9H5jUcyn9lSlPsH0F /g2oaRpNdYUPoT9AKucvse9t3dpiDNi90FYLhuPEh7ncRLxwwtg3dnrdT8YIoYqPGy vVHKSbwJhKVSg== 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 vojp7l7oRqFG; Thu, 9 Nov 2023 12:15:41 -0500 (EST) Received: from jedi.. (unknown [196.127.183.75]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id 2364B9C33AB; Thu, 9 Nov 2023 12:15:40 -0500 (EST) From: Alassane Yattara To: toaster@lists.yoctoproject.org Cc: Alassane Yattara Subject: [PATCH v4 2/7] Toaster: Update orm.models to catch error ProcessLookupError Date: Thu, 9 Nov 2023 18:15:30 +0100 Message-Id: <20231109171535.207464-2-alassane.yattara@savoirfairelinux.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231109171535.207464-1-alassane.yattara@savoirfairelinux.com> References: <20231109171535.207464-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:53 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/toaster/message/5962 - 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:15:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alassane Yattara X-Patchwork-Id: 34184 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 03861C4167B for ; Thu, 9 Nov 2023 17:15:54 +0000 (UTC) Received: from mail.savoirfairelinux.com (mail.savoirfairelinux.com [208.88.110.44]) by mx.groups.io with SMTP id smtpd.web11.1014.1699550144811154865 for ; Thu, 09 Nov 2023 09:15:45 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@savoirfairelinux.com header.s=DFC430D2-D198-11EC-948E-34200CB392D2 header.b=U9ZqPzLq; 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 C8E459C34CB for ; Thu, 9 Nov 2023 12:15:43 -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 2N1geeWlYC4I; Thu, 9 Nov 2023 12:15:43 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 44E2F9C2CD7; Thu, 9 Nov 2023 12:15:43 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.savoirfairelinux.com 44E2F9C2CD7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=savoirfairelinux.com; s=DFC430D2-D198-11EC-948E-34200CB392D2; t=1699550143; bh=GesLj5+Tfp6+cElUD4N1oiRTqPVAwnFMvCqk+qYl7BU=; h=From:To:Date:Message-Id:MIME-Version; b=U9ZqPzLqWf4k1jeP41ay0hhJs7oTPstW+YShsI4grwCs/4mb3aT6mJiyAUI23DRZT QphHS0QBtf5kD8tbqzeEEpcNRiDpXG6cV5x1ZDqkXBOMTYdokdUawrlF6IFuPkrT8n vtmclXqyu7DkEcl9wBjY7+O0FEGBQwYzfftibTOQcdQvFoTWjay+h70564rErw2ve/ APS2481quEgVFCFs0ReFQFnehVsGNXHV0YS/COVAbGJd2bpWRAEix740NCLpIXtkj3 aW3MBPk7J3FxpTEcJ7VWq6z1LHD9zpM/mHNgLWSU9jHMWj/jkmf1zwnnUnS2dgAalF JBTvvJMRubHKQ== 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 Q627TCv7vYWl; Thu, 9 Nov 2023 12:15:43 -0500 (EST) Received: from jedi.. (unknown [196.127.183.75]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id 5B5B39C34B1; Thu, 9 Nov 2023 12:15:42 -0500 (EST) From: Alassane Yattara To: toaster@lists.yoctoproject.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:15:31 +0100 Message-Id: <20231109171535.207464-3-alassane.yattara@savoirfairelinux.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231109171535.207464-1-alassane.yattara@savoirfairelinux.com> References: <20231109171535.207464-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:54 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/toaster/message/5963 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:15:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alassane Yattara X-Patchwork-Id: 34185 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 0B935C001B2 for ; Thu, 9 Nov 2023 17:15:54 +0000 (UTC) Received: from mail.savoirfairelinux.com (mail.savoirfairelinux.com [208.88.110.44]) by mx.groups.io with SMTP id smtpd.web11.1015.1699550145556844869 for ; Thu, 09 Nov 2023 09:15:45 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@savoirfairelinux.com header.s=DFC430D2-D198-11EC-948E-34200CB392D2 header.b=a8jx9KnZ; 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 DCC109C34CF for ; Thu, 9 Nov 2023 12:15:44 -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 lXcXehwTPwfc; Thu, 9 Nov 2023 12:15:44 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 40D1B9C2CD7; Thu, 9 Nov 2023 12:15:44 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.savoirfairelinux.com 40D1B9C2CD7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=savoirfairelinux.com; s=DFC430D2-D198-11EC-948E-34200CB392D2; t=1699550144; bh=wIHbE11BWKitYZkfAFNEA6bXcaZDEe9cTiCXpyD4qwk=; h=From:To:Date:Message-Id:MIME-Version; b=a8jx9KnZgf/Gf1WF0l5THJytzbpqNRlFtjyKXBnb0hdR2q8Na+B+ObSR/eomCOlbz GYm1JwCKs4r78fdOloCjh7USn5sldg7mb4GYfYu6hHh02Xdbv6k6X9w8l0K843kXwV qZKrSuSNqIXnCHodhOkD0WZnyOUvSnGqrLaSAirsk9e8uQDqzE1ijq+1y9Qnr81n/a 0GgwOgBQ7Hu4W21xGThL5nm7FWAn1FBwy5uPRjY96fvtdd/mCD3bqt4ZBUOX5idRuq JcRDBTL85CBXpXpTbBOgbMDysfy3b+i6CUKYiHg29EBHuBvFnQI9bSRSqptVEUtz/O 5wzP16f3CKn7g== 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 5l_xwtOmRYS5; Thu, 9 Nov 2023 12:15:44 -0500 (EST) Received: from jedi.. (unknown [196.127.183.75]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id 9312F9C34CA; Thu, 9 Nov 2023 12:15:43 -0500 (EST) From: Alassane Yattara To: toaster@lists.yoctoproject.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:15:32 +0100 Message-Id: <20231109171535.207464-4-alassane.yattara@savoirfairelinux.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231109171535.207464-1-alassane.yattara@savoirfairelinux.com> References: <20231109171535.207464-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:54 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/toaster/message/5964 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:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alassane Yattara X-Patchwork-Id: 34188 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 21EE1C04E85 for ; Thu, 9 Nov 2023 17:15:54 +0000 (UTC) Received: from mail.savoirfairelinux.com (mail.savoirfairelinux.com [208.88.110.44]) by mx.groups.io with SMTP id smtpd.web11.1017.1699550146977562665 for ; Thu, 09 Nov 2023 09:15:47 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@savoirfairelinux.com header.s=DFC430D2-D198-11EC-948E-34200CB392D2 header.b=orRa/N/o; 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 DD70B9C3471 for ; Thu, 9 Nov 2023 12:15:45 -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 6n5aKLYb01ue; Thu, 9 Nov 2023 12:15:45 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 7884E9C2CD7; Thu, 9 Nov 2023 12:15:45 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.savoirfairelinux.com 7884E9C2CD7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=savoirfairelinux.com; s=DFC430D2-D198-11EC-948E-34200CB392D2; t=1699550145; bh=p2J+od2B1eMImjzJ6UqaVnL/r0kbwNU9wZ1YSW48g4U=; h=From:To:Date:Message-Id:MIME-Version; b=orRa/N/oTIZkxmED1Bfy6hS134heSt4xWSoudva7CzqsqO4fQRk1ACb7DtE9cEzXb tWpjZnaPVTMv7fBS7+zuavh8sc3kDHF6bUGwx/vQa/Vj5Xc+JTJxH7QLvydXgnK9YB XjYsR4TQEvcZGjzLP4Aa2PDkA5XFsd/NaDYhpBKUPufQQ+EnmZCbWm5iHCjsL5jFr5 cVtRqHPcfTYvZW5P7hpn5l/Lhn9t1J9vp1AdEsDorrIzZg8c5vZjSdtXAok3EoAXiH FL9WFPox9a+05dO5OZSlC34PcojbixlZ9b9iHji4zj48iHo0Pmvz9XzDCEkMOdZYtI FV/yvZhpVyj0A== 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 DxPbWvH1_n3O; Thu, 9 Nov 2023 12:15:45 -0500 (EST) Received: from jedi.. (unknown [196.127.183.75]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id 98D6D9C34BF; Thu, 9 Nov 2023 12:15:44 -0500 (EST) From: Alassane Yattara To: toaster@lists.yoctoproject.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:33 +0100 Message-Id: <20231109171535.207464-5-alassane.yattara@savoirfairelinux.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231109171535.207464-1-alassane.yattara@savoirfairelinux.com> References: <20231109171535.207464-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:54 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/toaster/message/5965 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:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alassane Yattara X-Patchwork-Id: 34186 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 30A2FC04FDE for ; Thu, 9 Nov 2023 17:15:54 +0000 (UTC) Received: from mail.savoirfairelinux.com (mail.savoirfairelinux.com [208.88.110.44]) by mx.groups.io with SMTP id smtpd.web10.1096.1699550148195356089 for ; Thu, 09 Nov 2023 09:15:48 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@savoirfairelinux.com header.s=DFC430D2-D198-11EC-948E-34200CB392D2 header.b=hSq95UQL; 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 22FD09C34BF for ; Thu, 9 Nov 2023 12:15:47 -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 UbBY1MKsmcUM; Thu, 9 Nov 2023 12:15:46 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id B0D9D9C328E; Thu, 9 Nov 2023 12:15:46 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.savoirfairelinux.com B0D9D9C328E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=savoirfairelinux.com; s=DFC430D2-D198-11EC-948E-34200CB392D2; t=1699550146; bh=9ZmjA4jVXRKl7D0tU2mh3T4CRmbXyy0ig+56aOGFxaw=; h=From:To:Date:Message-Id:MIME-Version; b=hSq95UQLhNIJ7UzlWPPQG4i2nPv6zelO/1YiJegh7reeU+XjOOFTAJIkD6ZCc+54m AhP7fmx2IJOP16qQ4Qp8Df789blAEPzRLhOFC3qcWERNQ4earFm36lBJ1rBw427pel LNYITKRqdwWuK9dJQ5DqjnItqeqnTFYKOpCBwH02KS+HVtaR3sNbwe80sVRRCKBFfp NLw3z/cEBGx99CmYFE8lH7GPvZEVRyt7UzM/EKPbavrsRX84oxLr3gU4Z2FCcNPmc5 s9+XA/XpWO9EBhEkVbNNr0ckse1B3pRob3q/V/byxbsHcxdZB9faXDtkwc88GnNSUo fUJ/rWpnHETQA== 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 0g3XYFKcrsac; Thu, 9 Nov 2023 12:15:46 -0500 (EST) Received: from jedi.. (unknown [196.127.183.75]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id D42DB9C3279; Thu, 9 Nov 2023 12:15:45 -0500 (EST) From: Alassane Yattara To: toaster@lists.yoctoproject.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:34 +0100 Message-Id: <20231109171535.207464-6-alassane.yattara@savoirfairelinux.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231109171535.207464-1-alassane.yattara@savoirfairelinux.com> References: <20231109171535.207464-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:54 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/toaster/message/5966 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:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alassane Yattara X-Patchwork-Id: 34187 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 E912DC41535 for ; Thu, 9 Nov 2023 17:15:53 +0000 (UTC) Received: from mail.savoirfairelinux.com (mail.savoirfairelinux.com [208.88.110.44]) by mx.groups.io with SMTP id smtpd.web11.1019.1699550150671850414 for ; Thu, 09 Nov 2023 09:15:52 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@savoirfairelinux.com header.s=DFC430D2-D198-11EC-948E-34200CB392D2 header.b=DXUrBTyc; 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 849DF9C328E for ; Thu, 9 Nov 2023 12:15:48 -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 8-F6h5OaR8II; Thu, 9 Nov 2023 12:15:48 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id E7F239C2CF2; Thu, 9 Nov 2023 12:15:47 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.savoirfairelinux.com E7F239C2CF2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=savoirfairelinux.com; s=DFC430D2-D198-11EC-948E-34200CB392D2; t=1699550147; bh=+5uZZBBn17ErJhYtUSTuu9jVZ2vwwTzGT4O4Jw8pWWc=; h=From:To:Date:Message-Id:MIME-Version; b=DXUrBTycVL850Lam8E2XVw5lBeh1pNMx9HSpc9wtpnK5bTh4u5hydip7+iHaUlK1i bGuU9uivRiiZPZal3RX1IZ/Wz7cPWfNsCGQWMSt8cj/xNV2iVSc9N3/OXTiTvEs0b/ tqIpEOVEEthmK8tQ9DiAU470h6z1hyuYaUQnP+B6uRGCSLz0u9zmTNwP7MQiV2+Spa PZcY3PxcNYuoexRiI2As5uUFnRbSAjdhnhSRQmq20VkjScJLwKey+S2hBq9LJEIHBE lzNE79eb4UjIWDMMlvvjZ4tdMuJxPm5eJrQfzCntwHoBZrXqwTJoGJcVzaMz8N0s8M O8zbSihxnUD5g== 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 Sdo7kyPUpT87; Thu, 9 Nov 2023 12:15:47 -0500 (EST) Received: from jedi.. (unknown [196.127.183.75]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id 14A299C32C5; Thu, 9 Nov 2023 12:15:46 -0500 (EST) From: Alassane Yattara To: toaster@lists.yoctoproject.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:35 +0100 Message-Id: <20231109171535.207464-7-alassane.yattara@savoirfairelinux.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231109171535.207464-1-alassane.yattara@savoirfairelinux.com> References: <20231109171535.207464-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:53 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/toaster/message/5967 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."""