From patchwork Tue Oct 31 17:42: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: 33203 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 601A6C4332F for ; Tue, 31 Oct 2023 17:42:53 +0000 (UTC) Received: from mail.savoirfairelinux.com (mail.savoirfairelinux.com [208.88.110.44]) by mx.groups.io with SMTP id smtpd.web10.2169.1698774170868238958 for ; Tue, 31 Oct 2023 10:42:51 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@savoirfairelinux.com header.s=DFC430D2-D198-11EC-948E-34200CB392D2 header.b=bi8Kf2GQ; 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 F317D9C2BF6 for ; Tue, 31 Oct 2023 13:42:49 -0400 (EDT) Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavis, port 10032) with ESMTP id j3mX_KNmi9mx; Tue, 31 Oct 2023 13:42:49 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 8154D9C2BE3; Tue, 31 Oct 2023 13:42:49 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.savoirfairelinux.com 8154D9C2BE3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=savoirfairelinux.com; s=DFC430D2-D198-11EC-948E-34200CB392D2; t=1698774169; bh=HNEwh15gbBG152j7VR387hSlJFFLpMZTQmE/+2V/VmU=; h=From:To:Date:Message-Id:MIME-Version; b=bi8Kf2GQh4Oy9Xr5bTp5kZIiDeNxycUBq8mdrHiB+uUzdiGYoo0pv92Sy7bQnykdB FFsfjV0eRmfQxU9rdXmBbFD+ESRQj6/+DWLmau1+vGNzWd3QZZWfUkJkEYKj3H7ka+ vMUx4Lg9Fl5XXBdJqY3QaSOJTS7cUeJoGy/Kwle2rnH0VSuZJspMW7mz1dEg2HpbJC pUGOAOpzVr6DcPtO2o4mnL5t9v0Tw4NKrNqVtAHczddOIhd5LT/ED46sqxCOjOGgaT GFpw8FF/d9BtbqI58vX+yFSE+bKkctei9jXoVtV+b1SHyenqllrBPZS5M+kPdU4Cl+ E5rzg8EoRl/Aw== 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 HvZoQHffvdPJ; Tue, 31 Oct 2023 13:42:49 -0400 (EDT) Received: from jedi.. (unknown [196.127.183.75]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id A03869C279F; Tue, 31 Oct 2023 13:42:48 -0400 (EDT) From: Alassane Yattara To: toaster@lists.yoctoproject.org Cc: Alassane Yattara Subject: [PATCH v2 1/8] Toaster: Update toaster-requirements.txt to add pytest and some plugin's Date: Tue, 31 Oct 2023 18:42:32 +0100 Message-Id: <20231031174235.699923-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 ; Tue, 31 Oct 2023 17:42:53 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/toaster/message/5927 The pytest framework makes it easy to write small, readable tests, and can scale to support complex functional testing for applications and libraries. - 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 Signed-off-by: Alassane Yattara --- toaster-requirements.txt | 5 +++++ 1 file changed, 5 insertions(+) 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 Tue Oct 31 17:42: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: 33204 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 6DE90C00142 for ; Tue, 31 Oct 2023 17:42:53 +0000 (UTC) Received: from mail.savoirfairelinux.com (mail.savoirfairelinux.com [208.88.110.44]) by mx.groups.io with SMTP id smtpd.web10.2170.1698774171954894706 for ; Tue, 31 Oct 2023 10:42:52 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@savoirfairelinux.com header.s=DFC430D2-D198-11EC-948E-34200CB392D2 header.b=u4rpzdCr; 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 53E9C9C279F for ; Tue, 31 Oct 2023 13:42:51 -0400 (EDT) Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavis, port 10032) with ESMTP id Kr7lCFQ2vcmt; Tue, 31 Oct 2023 13:42:50 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id B64899C2BE3; Tue, 31 Oct 2023 13:42:50 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.savoirfairelinux.com B64899C2BE3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=savoirfairelinux.com; s=DFC430D2-D198-11EC-948E-34200CB392D2; t=1698774170; bh=JhLwEPCsmDfLpE/oLx8JWsAus2WbbiL787g0liGl4FI=; h=From:To:Date:Message-Id:MIME-Version; b=u4rpzdCrKu+Psov0oTqyQsyd6IBm0KkRXXpsdljUmWj5xLHprFFeyIaU4ZHSPZNMr o0YEFDFQYpSnMIXR2qrw48USAeQ1IJe9MuCy/zUP9GlzTZnIXvzyUmBl3Jp0NAXXgm Ijdn6/+/FNZnLZHCtF+vpyYV5+QiJlnvGR6HyGiE1cGPcKBOZz9+oKIOZF6NO7rQDC h0VhNpXlGbQ0jDayDvjsAe/sqTJq27f4PKOX9fI9mZUQVCZQm405nDOH/uP76OKyz3 p10Ei3Wy2v/RQwEvcKjSiIt9AU17WFZmwsk9PB3OjXo/tMU8YkQcvyl0YCEEiv+ReV YFPWKpcuGOtvA== 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 l5GT-kz1l8ya; Tue, 31 Oct 2023 13:42:50 -0400 (EDT) Received: from jedi.. (unknown [196.127.183.75]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id D67F79C279F; Tue, 31 Oct 2023 13:42:49 -0400 (EDT) From: Alassane Yattara To: toaster@lists.yoctoproject.org Cc: Alassane Yattara Subject: [PATCH v2 2/8] Toaster: Update orm.models to catch error ProcessLookupError Date: Tue, 31 Oct 2023 18:42:33 +0100 Message-Id: <20231031174235.699923-2-alassane.yattara@savoirfairelinux.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231031174235.699923-1-alassane.yattara@savoirfairelinux.com> References: <20231031174235.699923-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 ; Tue, 31 Oct 2023 17:42:53 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/toaster/message/5928 - Remove extra line to keep standart in file. Yes, there are PEP8 style guide: - Two blank lines between each function, class declaration W'll update whole file for PEP8 standard style guide when need. - Added logs for catched ProcessLookupError 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 Tue Oct 31 17:42: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: 33205 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 66E21C4167B for ; Tue, 31 Oct 2023 17:42:53 +0000 (UTC) Received: from mail.savoirfairelinux.com (mail.savoirfairelinux.com [208.88.110.44]) by mx.groups.io with SMTP id smtpd.web10.2171.1698774173055954120 for ; Tue, 31 Oct 2023 10:42:53 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@savoirfairelinux.com header.s=DFC430D2-D198-11EC-948E-34200CB392D2 header.b=UDjhWFUr; 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 6EB5B9C279F for ; Tue, 31 Oct 2023 13:42:52 -0400 (EDT) Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavis, port 10032) with ESMTP id gCw0xSwBn9BF; Tue, 31 Oct 2023 13:42:51 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id D52CB9C0B9B; Tue, 31 Oct 2023 13:42:51 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.savoirfairelinux.com D52CB9C0B9B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=savoirfairelinux.com; s=DFC430D2-D198-11EC-948E-34200CB392D2; t=1698774171; bh=GesLj5+Tfp6+cElUD4N1oiRTqPVAwnFMvCqk+qYl7BU=; h=From:To:Date:Message-Id:MIME-Version; b=UDjhWFUrVa9BdS/TR4723z1gMVK14EMFCDeSayywbKHjFj+uDMv2XkI2+Xn846fa7 1/rzF1C15K+i79QiT1yzAEOiacR28ODUtXiXtzS0K3syaPYw1oXUp9HW94sgTJ1keA oFkTLzQE5P1hWPuAtCHV+iESs8HLCo+qixn9JiigsLg53rOJaafBqdoVlfBiJRB57o BmSvgbUzl7sOqqJWS+3OpaLPkoSORdKGQCMD3ghEtRMAUqoAZgU5Rb5t8njyK/sB5b iZKFEzdqBa89AWFVzsEdeiUSvjoHjG+b6/mHWpccufJlBqzWNO4vw2JUrj3H+0mFEa IMoWGgQk194dQ== 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 aqGSynKuapen; Tue, 31 Oct 2023 13:42:51 -0400 (EDT) Received: from jedi.. (unknown [196.127.183.75]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id 1A28E9C08AD; Tue, 31 Oct 2023 13:42:50 -0400 (EDT) From: Alassane Yattara To: toaster@lists.yoctoproject.org Cc: Alassane Yattara Subject: [PATCH v2 3/8] Toaster: Bug-fix pytest and Failed: Database access not allowed Date: Tue, 31 Oct 2023 18:42:34 +0100 Message-Id: <20231031174235.699923-3-alassane.yattara@savoirfairelinux.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231031174235.699923-1-alassane.yattara@savoirfairelinux.com> References: <20231031174235.699923-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 ; Tue, 31 Oct 2023 17:42:53 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/toaster/message/5929 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 Tue Oct 31 17:42: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: 33206 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 5F000C4332F for ; Tue, 31 Oct 2023 17:43:03 +0000 (UTC) Received: from mail.savoirfairelinux.com (mail.savoirfairelinux.com [208.88.110.44]) by mx.groups.io with SMTP id smtpd.web10.2173.1698774174146015070 for ; Tue, 31 Oct 2023 10:42:54 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@savoirfairelinux.com header.s=DFC430D2-D198-11EC-948E-34200CB392D2 header.b=hHp/V92D; 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 83FC79C0B9B for ; Tue, 31 Oct 2023 13:42:53 -0400 (EDT) Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavis, port 10032) with ESMTP id WyjQ7vbUujeN; Tue, 31 Oct 2023 13:42:53 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 056D89C2C3E; Tue, 31 Oct 2023 13:42:53 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.savoirfairelinux.com 056D89C2C3E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=savoirfairelinux.com; s=DFC430D2-D198-11EC-948E-34200CB392D2; t=1698774173; bh=wIHbE11BWKitYZkfAFNEA6bXcaZDEe9cTiCXpyD4qwk=; h=From:To:Date:Message-Id:MIME-Version; b=hHp/V92D60GKi0m+AACKQ2nIOftFzrFRkiECwGiVybNmX1BRBiheVx+Lk2PqJHixU SmJNOsP6wnQoGjtxAtwYelIi/qSj2yfIfLJlS3EehCASLdFZdvLJxhxeZaSUYllTHf OvkX/yyjPr6E9GBCFVM1k3QjNXbL6RSYtlgkwlY7kKnpHs0XoTM8NsOtjs1hTStMu7 EIgT53rE33pFcfnBtEDh0dNbGLHAUBfa6iPeu7d2H8QawWSqEmbCY0tqhm0o8gSAoX rfXuUhYctIkdBWMOFdE7173lCc7j4NCYFA1gyuECE8kH/QQ/eClcwdaArvu5GXi2Nf 9aLZvw63lU0CQ== 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 0bzSDlihe9O8; Tue, 31 Oct 2023 13:42:52 -0400 (EDT) Received: from jedi.. (unknown [196.127.183.75]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id 390AF9C08AD; Tue, 31 Oct 2023 13:42:52 -0400 (EDT) From: Alassane Yattara To: toaster@lists.yoctoproject.org Cc: Alassane Yattara Subject: [PATCH v2 4/8] Toaster: fixed pytest error: Database access not allowed, use the "django_db" Date: Tue, 31 Oct 2023 18:42:35 +0100 Message-Id: <20231031174235.699923-4-alassane.yattara@savoirfairelinux.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231031174235.699923-1-alassane.yattara@savoirfairelinux.com> References: <20231031174235.699923-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 ; Tue, 31 Oct 2023 17:43:03 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/toaster/message/5930 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'))