diff mbox series

bitbake: toaster: fix pytest build test execution and test discovery

Message ID 20231130135943.3775-1-alexander.lussier-cullen@savoirfairelinux.com
State New
Headers show
Series bitbake: toaster: fix pytest build test execution and test discovery | expand

Commit Message

Alexander Lussier-Cullen Nov. 30, 2023, 1:59 p.m. UTC
Signed-off-by: Alexander Lussier-Cullen <alexander.lussier-cullen@savoirfairelinux.com>
---
 bitbake/lib/toaster/pytest.ini                          | 5 +----
 bitbake/lib/toaster/tests/builds/test_core_image_min.py | 2 ++
 2 files changed, 3 insertions(+), 4 deletions(-)

Comments

Richard Purdie Nov. 30, 2023, 10:57 p.m. UTC | #1
Hi Alexander,

On Thu, 2023-11-30 at 08:59 -0500, Alexander Lussier-Cullen wrote:
> Signed-off-by: Alexander Lussier-Cullen <alexander.lussier-cullen@savoirfairelinux.com>
> ---
>  bitbake/lib/toaster/pytest.ini                          | 5 +----
>  bitbake/lib/toaster/tests/builds/test_core_image_min.py | 2 ++
>  2 files changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/bitbake/lib/toaster/pytest.ini b/bitbake/lib/toaster/pytest.ini
> index f07076b7ea..071c65fcd5 100644
> --- a/bitbake/lib/toaster/pytest.ini
> +++ b/bitbake/lib/toaster/pytest.ini
> @@ -1,9 +1,5 @@
>  # -- 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
>  
> @@ -17,3 +13,4 @@ addopts = --create-db --html="Toaster Tests Report.html" --self-contained-html
>  # https://pypi.org/project/pytest-env/
>  env =
>      TOASTER_BUILDSERVER=1
> +    DJANGO_SETTINGS_MODULE=toastermain.settings_test

I tested this patch and it definitely seems to help.

https://autobuilder.yoctoproject.org/typhoon/#/builders/161/builds/12/steps/11/logs/stdio

I replied to Alassane earlier about some of the failures in test run
but I think this did fix several of them.

Can I ask that you tweak the commit message to explain what is being
fixed here, just so we have the context in the commit logs please.


> diff --git a/bitbake/lib/toaster/tests/builds/test_core_image_min.py b/bitbake/lib/toaster/tests/builds/test_core_image_min.py
> index 9cdaa15f98..ca388eabe7 100644
> --- a/bitbake/lib/toaster/tests/builds/test_core_image_min.py
> +++ b/bitbake/lib/toaster/tests/builds/test_core_image_min.py
> @@ -10,6 +10,7 @@
>  # Ionut Chisanovici, Paul Eggleton and Cristian Iorga
>  
>  import os
> +import pytest
>  
>  from django.db.models import Q
>  
> @@ -21,6 +22,7 @@ from orm.models import CustomImagePackage
>  from tests.builds.buildtest import BuildTest
>  
>  
> +@pytest.mark.django_db(True)
>  class BuildCoreImageMinimal(BuildTest):
>      """Build core-image-minimal and test the results"""
>  

I'd suggest this part of then change be split into a separate patch
with an explanation of what is being fixed. It does appear to fix the
database locked issues we were seeing which is great.

Cheers,

Richard
Alexander Lussier-Cullen Dec. 1, 2023, 2:56 p.m. UTC | #2
Hello, 

I've updated my commit messages and sent in the new patches. 
However, this patch is meant to fix pytest runs, which the autobuilder isn't using yet. 
You'll also need the update on the autobuilder end from [ https://patchwork.yoctoproject.org/project/yocto/patch/20231201144928.4191-1-alexander.lussier-cullen@savoirfairelinux.com/ | this ] patch to have it use pytest instead of the django tools. 

Thanks, 
Alex 



From: "Richard Purdie" <richard.purdie@linuxfoundation.org> 
To: "Alexander Lussier-Cullen" <alexander.lussier-cullen@savoirfairelinux.com>, toaster@lists.yoctoproject.org 
Sent: Thursday, November 30, 2023 5:57:39 PM 
Subject: Re: [Toaster] bitbake: toaster: fix pytest build test execution and test discovery 

Hi Alexander, 

On Thu, 2023-11-30 at 08:59 -0500, Alexander Lussier-Cullen wrote: 
> Signed-off-by: Alexander Lussier-Cullen <alexander.lussier-cullen@savoirfairelinux.com> 
> --- 
> bitbake/lib/toaster/pytest.ini | 5 +---- 
> bitbake/lib/toaster/tests/builds/test_core_image_min.py | 2 ++ 
> 2 files changed, 3 insertions(+), 4 deletions(-) 
> 
> diff --git a/bitbake/lib/toaster/pytest.ini b/bitbake/lib/toaster/pytest.ini 
> index f07076b7ea..071c65fcd5 100644 
> --- a/bitbake/lib/toaster/pytest.ini 
> +++ b/bitbake/lib/toaster/pytest.ini 
> @@ -1,9 +1,5 @@ 
> # -- 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 
> 
> @@ -17,3 +13,4 @@ addopts = --create-db --html="Toaster Tests Report.html" --self-contained-html 
> # https://pypi.org/project/pytest-env/ 
> env = 
> TOASTER_BUILDSERVER=1 
> + DJANGO_SETTINGS_MODULE=toastermain.settings_test 

I tested this patch and it definitely seems to help. 

https://autobuilder.yoctoproject.org/typhoon/#/builders/161/builds/12/steps/11/logs/stdio 

I replied to Alassane earlier about some of the failures in test run 
but I think this did fix several of them. 

Can I ask that you tweak the commit message to explain what is being 
fixed here, just so we have the context in the commit logs please. 


> diff --git a/bitbake/lib/toaster/tests/builds/test_core_image_min.py b/bitbake/lib/toaster/tests/builds/test_core_image_min.py 
> index 9cdaa15f98..ca388eabe7 100644 
> --- a/bitbake/lib/toaster/tests/builds/test_core_image_min.py 
> +++ b/bitbake/lib/toaster/tests/builds/test_core_image_min.py 
> @@ -10,6 +10,7 @@ 
> # Ionut Chisanovici, Paul Eggleton and Cristian Iorga 
> 
> import os 
> +import pytest 
> 
> from django.db.models import Q 
> 
> @@ -21,6 +22,7 @@ from orm.models import CustomImagePackage 
> from tests.builds.buildtest import BuildTest 
> 
> 
> +@pytest.mark.django_db(True) 
> class BuildCoreImageMinimal(BuildTest): 
> """Build core-image-minimal and test the results""" 
> 

I'd suggest this part of then change be split into a separate patch 
with an explanation of what is being fixed. It does appear to fix the 
database locked issues we were seeing which is great. 

Cheers, 

Richard
diff mbox series

Patch

diff --git a/bitbake/lib/toaster/pytest.ini b/bitbake/lib/toaster/pytest.ini
index f07076b7ea..071c65fcd5 100644
--- a/bitbake/lib/toaster/pytest.ini
+++ b/bitbake/lib/toaster/pytest.ini
@@ -1,9 +1,5 @@ 
 # -- 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
 
@@ -17,3 +13,4 @@  addopts = --create-db --html="Toaster Tests Report.html" --self-contained-html
 # https://pypi.org/project/pytest-env/
 env =
     TOASTER_BUILDSERVER=1
+    DJANGO_SETTINGS_MODULE=toastermain.settings_test
diff --git a/bitbake/lib/toaster/tests/builds/test_core_image_min.py b/bitbake/lib/toaster/tests/builds/test_core_image_min.py
index 9cdaa15f98..ca388eabe7 100644
--- a/bitbake/lib/toaster/tests/builds/test_core_image_min.py
+++ b/bitbake/lib/toaster/tests/builds/test_core_image_min.py
@@ -10,6 +10,7 @@ 
 # Ionut Chisanovici, Paul Eggleton and Cristian Iorga
 
 import os
+import pytest
 
 from django.db.models import Q
 
@@ -21,6 +22,7 @@  from orm.models import CustomImagePackage
 from tests.builds.buildtest import BuildTest
 
 
+@pytest.mark.django_db(True)
 class BuildCoreImageMinimal(BuildTest):
     """Build core-image-minimal and test the results"""