From patchwork Thu Nov 9 17:44:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alassane Yattara X-Patchwork-Id: 34203 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 32DBDC4167B for ; Thu, 9 Nov 2023 17:44:28 +0000 (UTC) Received: from mail.savoirfairelinux.com (mail.savoirfairelinux.com [208.88.110.44]) by mx.groups.io with SMTP id smtpd.web10.328.1699551859169055009 for ; Thu, 09 Nov 2023 09:44:19 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@savoirfairelinux.com header.s=DFC430D2-D198-11EC-948E-34200CB392D2 header.b=F+NeD6jR; 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 D2A3A9C328E for ; Thu, 9 Nov 2023 12:44:17 -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 moJw3qsElpAe; Thu, 9 Nov 2023 12:44:17 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id ED3849C2D22; Thu, 9 Nov 2023 12:44:16 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.savoirfairelinux.com ED3849C2D22 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=savoirfairelinux.com; s=DFC430D2-D198-11EC-948E-34200CB392D2; t=1699551856; bh=rL98L0nIK6koI42KdGty25TeIxeF2lZG8hCiGBuuwrA=; h=From:To:Date:Message-Id:MIME-Version; b=F+NeD6jR0lK97uxyh9Xgc1r+svoSpr3Ui3JMpYd4ifO/58QXhe4duepGqGTs0ENN5 p3ibqMPGDEjdn5f4pT1g3SM0jCb9f1EjhCkxcDSgubsRtiOy51prviCXLsEikWjeEk 1Uk1r8dnLy842sjp82IDoRGLvI0M2+7DLpLgCO6V/CtCHZvMGZ1S2fE0oVjLrNAHmv 0J8IaDWvL48hovILrQF8oDe3aFMPPiVr1f7PWL17KiGEU1fukRrufQI/UNGLxQR8s5 Qw5rA0LLjjCvcA5XrJH+Pjqd5LHHawoDlI+7/LdwXZxOQXaDy5drVDvazH4xu0BXhV N/JhbLbG1M8cA== 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 9Yq1HdS9Cn-y; Thu, 9 Nov 2023 12:44:16 -0500 (EST) Received: from jedi.. (unknown [196.127.183.75]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id 26CB19C2CD7; Thu, 9 Nov 2023 12:44:16 -0500 (EST) From: Alassane Yattara To: bitbake-devel@lists.openembedded.org Cc: Alassane Yattara Subject: [PATCH v5 1/6] Toaster: Update toaster-requirements.txt and Added pytest.ini Date: Thu, 9 Nov 2023 18:44:07 +0100 Message-Id: <20231109174412.257199-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:44:28 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/15478 *** 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 +++++++++++++++++++ .../tests/toaster-tests-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/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 From patchwork Thu Nov 9 17:44:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alassane Yattara X-Patchwork-Id: 34205 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 44651C001B2 for ; Thu, 9 Nov 2023 17:44:28 +0000 (UTC) Received: from mail.savoirfairelinux.com (mail.savoirfairelinux.com [208.88.110.44]) by mx.groups.io with SMTP id smtpd.web10.329.1699551859224159627 for ; Thu, 09 Nov 2023 09:44:19 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@savoirfairelinux.com header.s=DFC430D2-D198-11EC-948E-34200CB392D2 header.b=Qic4FySM; 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 90E879C327A for ; Thu, 9 Nov 2023 12:44:18 -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 kWRtYsMar-gt; Thu, 9 Nov 2023 12:44:18 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 13D869C2CF2; Thu, 9 Nov 2023 12:44:18 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.savoirfairelinux.com 13D869C2CF2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=savoirfairelinux.com; s=DFC430D2-D198-11EC-948E-34200CB392D2; t=1699551858; bh=+m/KNy2AMqWB1h1tnjZcHiD38duvHCRhaP6gbInNBKI=; h=From:To:Date:Message-Id:MIME-Version; b=Qic4FySM9Gyz78W4dLx4oz6FdoUvitKQgrXZirwaRltP4/RIMEd5sqGjg3B4FrSAr pHAcc/7IPAmHJsLkBRWbj24/Cyy5Ok7M+ZVpWmxreoMGZFk2cKGeCxI+jCzg4FvzOo FwnuCdoQNW+eiLim0FYn5bRruoexEVkJ9kyphjm5m2yPszQEkS518gCZXFZldie7kp yTFb4LvZxpjTTazEvnF/VFOvPIalmnu+0tnqIBlyODMInvZQpz81xyo6YySTKLkKLQ CxaR25f0OMGSL88phiMFqI7KATwFIoOG8bmuQLuMSekH1KQ65PhaJloLCLwQQ5bvSN u2CLwxtfBfsew== 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 xFUCc59Et6fQ; Thu, 9 Nov 2023 12:44:18 -0500 (EST) Received: from jedi.. (unknown [196.127.183.75]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id 2AF319C2CD7; Thu, 9 Nov 2023 12:44:17 -0500 (EST) From: Alassane Yattara To: bitbake-devel@lists.openembedded.org Cc: Alassane Yattara Subject: [PATCH v5 2/6] Toaster: Update orm.models to catch error ProcessLookupError Date: Thu, 9 Nov 2023 18:44:08 +0100 Message-Id: <20231109174412.257199-2-alassane.yattara@savoirfairelinux.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231109174412.257199-1-alassane.yattara@savoirfairelinux.com> References: <20231109174412.257199-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:44:28 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/15479 - 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:44:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alassane Yattara X-Patchwork-Id: 34208 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 4E05CC4167D for ; Thu, 9 Nov 2023 17:44:28 +0000 (UTC) Received: from mail.savoirfairelinux.com (mail.savoirfairelinux.com [208.88.110.44]) by mx.groups.io with SMTP id smtpd.web11.368.1699551860465831538 for ; Thu, 09 Nov 2023 09:44:20 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@savoirfairelinux.com header.s=DFC430D2-D198-11EC-948E-34200CB392D2 header.b=pWuB/A0C; 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 C1C039C2CD7 for ; Thu, 9 Nov 2023 12:44: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 27A82z5-kEC8; Thu, 9 Nov 2023 12:44:19 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 476E69C34BD; Thu, 9 Nov 2023 12:44:19 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.savoirfairelinux.com 476E69C34BD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=savoirfairelinux.com; s=DFC430D2-D198-11EC-948E-34200CB392D2; t=1699551859; bh=GesLj5+Tfp6+cElUD4N1oiRTqPVAwnFMvCqk+qYl7BU=; h=From:To:Date:Message-Id:MIME-Version; b=pWuB/A0CTHPwFRlHmDv4jb5be0SI/FtrDQHUU5clu153eTutXKbXs5VNlcFmf+h0+ pL5T8q8Q0WnrL59X6sLEad2ZB/izfsSYGfCsVSOG+p4JLxFje9lFWJhf4SjguYc6EX cn2b1I1nnKR+gpZA858EttXlaHH0qraz6PmFrg1wazV8JWnLnoD7jsK7xbXvm6tFAB yu7CoLPTrCUP7GpO4O+BYyuzVuoWgTQZKQ+shHSAl5zJppH1P7EQOCGw1g6ZLxQWMm 6Cj2scdGv4wfabRarzRCoJ0F/I0h9j8xw49nV7MnfVnTELV0zFlBrI4HX1wf7CKGiV oL6r2ooMnm+hg== 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 T5hYskwqSAvV; Thu, 9 Nov 2023 12:44:19 -0500 (EST) Received: from jedi.. (unknown [196.127.183.75]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id 62CD29C2CD7; Thu, 9 Nov 2023 12:44:18 -0500 (EST) From: Alassane Yattara To: bitbake-devel@lists.openembedded.org Cc: Alassane Yattara Subject: [PATCH v5 3/6] Toaster: Bug-fix pytest and Failed: Database access not allowed Date: Thu, 9 Nov 2023 18:44:09 +0100 Message-Id: <20231109174412.257199-3-alassane.yattara@savoirfairelinux.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231109174412.257199-1-alassane.yattara@savoirfairelinux.com> References: <20231109174412.257199-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:44:28 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/15480 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:44:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alassane Yattara X-Patchwork-Id: 34206 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 5E101C04E85 for ; Thu, 9 Nov 2023 17:44:28 +0000 (UTC) Received: from mail.savoirfairelinux.com (mail.savoirfairelinux.com [208.88.110.44]) by mx.groups.io with SMTP id smtpd.web10.333.1699551862124316370 for ; Thu, 09 Nov 2023 09:44:22 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@savoirfairelinux.com header.s=DFC430D2-D198-11EC-948E-34200CB392D2 header.b=Y+NwjNrQ; 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 179099C34BF for ; Thu, 9 Nov 2023 12:44:21 -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 BA_S5W9hNYv9; Thu, 9 Nov 2023 12:44:20 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 7E5769C328E; Thu, 9 Nov 2023 12:44:20 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.savoirfairelinux.com 7E5769C328E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=savoirfairelinux.com; s=DFC430D2-D198-11EC-948E-34200CB392D2; t=1699551860; bh=wIHbE11BWKitYZkfAFNEA6bXcaZDEe9cTiCXpyD4qwk=; h=From:To:Date:Message-Id:MIME-Version; b=Y+NwjNrQsM3KwNrbtOeIlfEItMq1YKGElGu4BLDdobw7xDs1kNbP01pX1tBh3wFr9 Oc1Hc2FF0BlB9I3HPxlRkDCTYr/Z9EyGpf/iTXi0kYHm1oglZ8j9oDwDJTir11lIbs sQfV9thEKgkw1oM1nL6R9zC7H5r1D8CcQWUZRikV33r6deOUZegqKtDVn1WoMd48Iy h9D43vvokBd3d/adRTqktMtYKhjdXkE9PKhE18aNLU/2wCzcAdcG2FVSDT/cOr+GjW qks7o1cp9T1RTfRftGEfnbH/Ks4cTuHOOIAHEJVbqWawnKyT4B4gzYhIYLINTVJYgw 5MO6kjreKM0aw== 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 3TrpI1Wuby5K; Thu, 9 Nov 2023 12:44:20 -0500 (EST) Received: from jedi.. (unknown [196.127.183.75]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id 9ABFE9C327A; Thu, 9 Nov 2023 12:44:19 -0500 (EST) From: Alassane Yattara To: bitbake-devel@lists.openembedded.org Cc: Alassane Yattara Subject: [PATCH v5 4/6] Toaster: fixed pytest error: Database access not allowed, use the "django_db" Date: Thu, 9 Nov 2023 18:44:10 +0100 Message-Id: <20231109174412.257199-4-alassane.yattara@savoirfairelinux.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231109174412.257199-1-alassane.yattara@savoirfairelinux.com> References: <20231109174412.257199-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:44:28 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/15481 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:44:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alassane Yattara X-Patchwork-Id: 34207 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 67101C41535 for ; Thu, 9 Nov 2023 17:44:28 +0000 (UTC) Received: from mail.savoirfairelinux.com (mail.savoirfairelinux.com [208.88.110.44]) by mx.groups.io with SMTP id smtpd.web10.334.1699551862793254977 for ; Thu, 09 Nov 2023 09:44:22 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@savoirfairelinux.com header.s=DFC430D2-D198-11EC-948E-34200CB392D2 header.b=ItCCpgc1; 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 1F8149C34CD for ; Thu, 9 Nov 2023 12:44: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 UjCH5GZRPint; Thu, 9 Nov 2023 12:44:21 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id ADF0E9C2D22; Thu, 9 Nov 2023 12:44:21 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.savoirfairelinux.com ADF0E9C2D22 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=savoirfairelinux.com; s=DFC430D2-D198-11EC-948E-34200CB392D2; t=1699551861; bh=p2J+od2B1eMImjzJ6UqaVnL/r0kbwNU9wZ1YSW48g4U=; h=From:To:Date:Message-Id:MIME-Version; b=ItCCpgc1eomxaWhSiWcFtlluPOrFKB0tvpMvbinpR2lToNogHNVuP18TllgAXAfsC 6NCMBxNq1OU8BgTjuuco44NdE/wKRQIiioDJlNEEIOO0NT/yfNbViunqBQK/gNq1EA F0RN9DbgthfoJNhbA/lM8UV6zaaR8se0figw77NfzGkTuEgMO5zvICX5PirgrZ5h7G /3Odfs6sJv8kbZMnwL7rcryV7eJfm/zB/HUd54vsCEwp++EiBE+w9oKcfpVPXMU+03 ztlXPz9+ViHU4zpVmGkzUpcRCEi6N8MqRfx81GkvV8icqpukpUaranxV6E4wTPzCQc SreOSQkL+n2ww== 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 NkfRLFJLObnu; Thu, 9 Nov 2023 12:44:21 -0500 (EST) Received: from jedi.. (unknown [196.127.183.75]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id D28959C2CD7; Thu, 9 Nov 2023 12:44:20 -0500 (EST) From: Alassane Yattara To: bitbake-devel@lists.openembedded.org Cc: Alassane Yattara Subject: [PATCH v5 5/6] Toaster: Bug-fix django.db.utils.IntegrityError: Problem installing fixture Date: Thu, 9 Nov 2023 18:44:11 +0100 Message-Id: <20231109174412.257199-5-alassane.yattara@savoirfairelinux.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231109174412.257199-1-alassane.yattara@savoirfairelinux.com> References: <20231109174412.257199-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:44:28 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/15482 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:44:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alassane Yattara X-Patchwork-Id: 34204 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 31504C4332F for ; Thu, 9 Nov 2023 17:44:28 +0000 (UTC) Received: from mail.savoirfairelinux.com (mail.savoirfairelinux.com [208.88.110.44]) by mx.groups.io with SMTP id smtpd.web10.336.1699551864156629588 for ; Thu, 09 Nov 2023 09:44:24 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@savoirfairelinux.com header.s=DFC430D2-D198-11EC-948E-34200CB392D2 header.b=P5uykXOG; 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 7E1DC9C327A for ; Thu, 9 Nov 2023 12:44: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 fRaHDRc3iJwm; Thu, 9 Nov 2023 12:44:23 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id E4ED19C34C5; Thu, 9 Nov 2023 12:44:22 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.savoirfairelinux.com E4ED19C34C5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=savoirfairelinux.com; s=DFC430D2-D198-11EC-948E-34200CB392D2; t=1699551862; bh=+5uZZBBn17ErJhYtUSTuu9jVZ2vwwTzGT4O4Jw8pWWc=; h=From:To:Date:Message-Id:MIME-Version; b=P5uykXOG7C5Zzq4eN53N6A+Q6v6I5uYKf7lZyzsq0b0MyZdHs3JhTkLIe8rH7vlac Bh1u4uhnsMCZmTsneU4WW1tw0JGO3YlUyty7hUtVJV15Zrd/YUo9vOdiVxa6RT9iHW ViFPnn2vGmg1nDn4bySemoWE7efIZBrAFgD5b3ru+w/SjqWkk6b2THDIC2YwFZgWJ1 C5KXziryjrBp0vqa0ZkgaXOPSlNDLbxHHhimkcOp7+T5kP3woEQoh3jThTJ9h+1FUf eSbGZYMjRVA5WIYn4jwwy10LullPQeekWtpxHtPxAjr6YV8D8wjUxhILTBhW6fcE1Q z5DYR/+oWXkrg== 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 YGbzBIZvyGpv; Thu, 9 Nov 2023 12:44:22 -0500 (EST) Received: from jedi.. (unknown [196.127.183.75]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id 16C8D9C34BD; Thu, 9 Nov 2023 12:44:21 -0500 (EST) From: Alassane Yattara To: bitbake-devel@lists.openembedded.org Cc: Alassane Yattara Subject: [PATCH v5 6/6] Toaster: fixed: Tests fail when executed one after the other out of sequence Date: Thu, 9 Nov 2023 18:44:12 +0100 Message-Id: <20231109174412.257199-6-alassane.yattara@savoirfairelinux.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231109174412.257199-1-alassane.yattara@savoirfairelinux.com> References: <20231109174412.257199-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:44:28 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/15483 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."""