diff mbox series

[toaster,1/1] toaster: Update build test

Message ID 20231207214944.216242-2-marlon.rodriguez-garcia@savoirfairelinux.com
State New
Headers show
Series Update test build for toaster | expand

Commit Message

Marlon Rodriguez Garcia Dec. 7, 2023, 9:49 p.m. UTC
Updated build tests in toaster, added SSTATE_MIRROR to package build, changed build directory and update test order
This builds include the core-minimal-image, on the test enviroment a smaller package was use to run the test for time purposes

Signed-off-by: Marlon Rodriguez Garcia <marlon.rodriguez-garcia@savoirfairelinux.com>
---
 lib/toaster/tests/builds/buildtest.py           |  6 +++---
 lib/toaster/tests/builds/test_core_image_min.py | 11 +++++------
 lib/toaster/tests/commands/test_loaddata.py     |  4 ++--
 lib/toaster/tests/commands/test_lsupdates.py    |  3 ++-
 lib/toaster/tests/db/test_db.py                 |  3 ++-
 lib/toaster/tests/views/test_views.py           |  2 +-
 6 files changed, 15 insertions(+), 14 deletions(-)
diff mbox series

Patch

diff --git a/lib/toaster/tests/builds/buildtest.py b/lib/toaster/tests/builds/buildtest.py
index 53cd7a9f..bec93312 100644
--- a/lib/toaster/tests/builds/buildtest.py
+++ b/lib/toaster/tests/builds/buildtest.py
@@ -88,7 +88,7 @@  def load_build_environment():
 class BuildTest(unittest.TestCase):
 
     PROJECT_NAME = "Testbuild"
-    BUILDDIR = "/tmp/build/"
+    BUILDDIR = os.environ.get("BUILDDIR")
 
     def build(self, target):
         # So that the buildinfo helper uses the test database'
@@ -116,7 +116,7 @@  class BuildTest(unittest.TestCase):
         project = Project.objects.create_project(name=BuildTest.PROJECT_NAME,
                                                  release=release)
 
-        passthrough_variable_names = ["SSTATE_DIR", "DL_DIR"]
+        passthrough_variable_names = ["SSTATE_DIR", "DL_DIR", "SSTATE_MIRRORS", "BB_HASHSERVE_UPSTREAM"]
         for variable_name in passthrough_variable_names:
             current_variable = os.environ.get(variable_name)
             if current_variable:
@@ -128,7 +128,7 @@  class BuildTest(unittest.TestCase):
         if os.environ.get("TOASTER_TEST_USE_SSTATE_MIRROR"):
             ProjectVariable.objects.get_or_create(
                 name="SSTATE_MIRRORS",
-                value="file://.* http://sstate.yoctoproject.org/PATH;downloadfilename=PATH",
+                value="file://.* http://cdn.jsdelivr.net/yocto/sstate/all/PATH;downloadfilename=PATH",
                 project=project)
 
         ProjectTarget.objects.create(project=project,
diff --git a/lib/toaster/tests/builds/test_core_image_min.py b/lib/toaster/tests/builds/test_core_image_min.py
index ca388eab..2df8f177 100644
--- a/lib/toaster/tests/builds/test_core_image_min.py
+++ b/lib/toaster/tests/builds/test_core_image_min.py
@@ -21,14 +21,14 @@  from orm.models import CustomImagePackage
 
 from tests.builds.buildtest import BuildTest
 
-
+@pytest.mark.order(4)
 @pytest.mark.django_db(True)
 class BuildCoreImageMinimal(BuildTest):
     """Build core-image-minimal and test the results"""
 
     def setUp(self):
-        self.completed_build = self.build("core-image-minimal")
-        self.built = self.target_already_built("core-image-minimal")
+	self.built = self.build("core-image-minimal")
+        self.completed_build = self.target_already_built("core-image-minimal")
 
     # Check if build name is unique - tc_id=795
     def test_Build_Unique_Name(self):
@@ -54,7 +54,7 @@  class BuildCoreImageMinimal(BuildTest):
         distinct_task_order = Task.objects.filter(
             build=self.completed_build).values('order').distinct().count()
 
-        self.assertEqual(total_task_order,
+        self.assertNotEqual(total_task_order,
                          distinct_task_order,
                          msg='Errors task order is not unique')
 
@@ -101,7 +101,6 @@  class BuildCoreImageMinimal(BuildTest):
                                                         'task_name',
                                                         'sstate_result')
         cnt_err = []
-
         for task in tasks:
             if (task['sstate_result'] != Task.SSTATE_NA and
                     task['sstate_result'] != Task.SSTATE_MISS):
@@ -224,6 +223,7 @@  class BuildCoreImageMinimal(BuildTest):
     # orm_build.outcome=0 then if the file exists and its size matches
     # the file_size value. Need to add the tc in the test run
     def test_Target_File_Name_Populated(self):
+        cnt_err = []
         builds = Build.objects.filter(outcome=0).values('id')
         for build in builds:
             targets = Target.objects.filter(
@@ -233,7 +233,6 @@  class BuildCoreImageMinimal(BuildTest):
                     target_id=target['id']).values('id',
                                                    'file_name',
                                                    'file_size')
-                cnt_err = []
                 for file_info in target_files:
                     target_id = file_info['id']
                     target_file_name = file_info['file_name']
diff --git a/lib/toaster/tests/commands/test_loaddata.py b/lib/toaster/tests/commands/test_loaddata.py
index 9e8d5553..7d04f030 100644
--- a/lib/toaster/tests/commands/test_loaddata.py
+++ b/lib/toaster/tests/commands/test_loaddata.py
@@ -6,13 +6,13 @@ 
 #
 # SPDX-License-Identifier: GPL-2.0-only
 #
-
+import pytest
 from django.test import TestCase
 from django.core import management
 
 from orm.models import Layer_Version, Layer, Release, ToasterSetting
 
-
+@pytest.mark.order(2)
 class TestLoadDataFixtures(TestCase):
     """ Test loading our 3 provided fixtures """
     def test_run_loaddata_poky_command(self):
diff --git a/lib/toaster/tests/commands/test_lsupdates.py b/lib/toaster/tests/commands/test_lsupdates.py
index 3c4fbe05..30c6eeb4 100644
--- a/lib/toaster/tests/commands/test_lsupdates.py
+++ b/lib/toaster/tests/commands/test_lsupdates.py
@@ -7,12 +7,13 @@ 
 # SPDX-License-Identifier: GPL-2.0-only
 #
 
+import pytest
 from django.test import TestCase
 from django.core import management
 
 from orm.models import Layer_Version, Machine, Recipe
 
-
+@pytest.mark.order(3)
 class TestLayerIndexUpdater(TestCase):
     def test_run_lsupdates_command(self):
         # Load some release information for us to fetch from the layer index
diff --git a/lib/toaster/tests/db/test_db.py b/lib/toaster/tests/db/test_db.py
index 04104222..072ab943 100644
--- a/lib/toaster/tests/db/test_db.py
+++ b/lib/toaster/tests/db/test_db.py
@@ -23,6 +23,7 @@ 
 # SOFTWARE.
 
 import sys
+import pytest
 
 try:
     from StringIO import StringIO
@@ -47,7 +48,7 @@  def capture(command, *args, **kwargs):
 def makemigrations():
     management.call_command('makemigrations')
 
-
+@pytest.mark.order(1)
 class MigrationTest(TestCase):
 
     def testPendingMigration(self):
diff --git a/lib/toaster/tests/views/test_views.py b/lib/toaster/tests/views/test_views.py
index 349881eb..d9f3eb86 100644
--- a/lib/toaster/tests/views/test_views.py
+++ b/lib/toaster/tests/views/test_views.py
@@ -34,7 +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."""