public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Uladzimir Bely <ubely@ilbers.de>
To: isar-users@googlegroups.com
Subject: [RFC v2 3/3] ci: Added test for isar-apt reuse functionality
Date: Mon, 13 Jun 2022 09:07:59 +0200	[thread overview]
Message-ID: <20220613070759.16949-4-ubely@ilbers.de> (raw)
In-Reply-To: <20220613070759.16949-1-ubely@ilbers.de>

Test makes clean build of "libhello" package that is placed to local
isar-apt repo outside of 'tmp'.

Second build with cleaned 'tmp' should use previously built package
that is detected by missing Makefile in source directory.

Signed-off-by: Uladzimir Bely <ubely@ilbers.de>
---
 testsuite/cibase.py    | 42 ++++++++++++++++++++++++++++++++++++++++++
 testsuite/cibuilder.py |  7 ++++++-
 testsuite/citest.py    | 12 ++++++++++++
 3 files changed, 60 insertions(+), 1 deletion(-)

diff --git a/testsuite/cibase.py b/testsuite/cibase.py
index 2ffb8191..9ef9d247 100755
--- a/testsuite/cibase.py
+++ b/testsuite/cibase.py
@@ -73,6 +73,48 @@ class CIBaseTest(CIBuilder):
         self.delete_from_build_dir('tmp')
         self.delete_from_build_dir('ccache')
 
+    def perform_isarapt_test(self, package_target, **kwargs):
+        def check_compiled(package_name):
+            # Makefile should exist if there was compilation
+            makefile = glob.glob(f'{self.build_dir}/tmp/work/*/{package_name}/*/{package_name}-*/Makefile')
+            if makefile:
+                self.log.info("Makefile was generated")
+                return True
+
+            self.log.info("Makefile was not generated")
+            return False
+
+        self.configure(isar_apt_reuse=True, **kwargs)
+
+        package_name = package_target.split(':')[-1]
+
+        # Cleanup sstate and tmp before test`
+        self.delete_from_build_dir('tmp')
+        self.delete_from_build_dir('sstate-cache')
+        self.delete_from_build_dir('isar-apt')
+
+        self.log.info('Start build and populate isar-apt...')
+        self.bitbake(package_target, **kwargs)
+        compiled1 = check_compiled(package_name)
+
+        if not compiled1:
+            self.fail('isar-apt repo used at first build')
+
+        # Cleanup build stuff
+        self.delete_from_build_dir('tmp')
+        self.delete_from_build_dir('sstate-cache')
+
+        self.log.info('Starting build and reuse isar-apt repo...')
+        self.bitbake(package_target, **kwargs)
+        compiled2 = check_compiled(package_name)
+
+        if compiled2:
+            self.fail('isar-apt repo not used at second build')
+
+        # Cleanup
+        self.delete_from_build_dir('tmp')
+        self.delete_from_build_dir('sstate-cache')
+
     def perform_sstate_test(self, image_target, package_target, **kwargs):
         def check_executed_tasks(target, expected):
             taskorder_file = glob.glob(f'{self.build_dir}/tmp/work/*/{target}/*/temp/log.task_order')
diff --git a/testsuite/cibuilder.py b/testsuite/cibuilder.py
index bc48d47f..42e344a3 100755
--- a/testsuite/cibuilder.py
+++ b/testsuite/cibuilder.py
@@ -54,7 +54,7 @@ class CIBuilder(Test):
 
     def configure(self, compat_arch=True, cross=None, debsrc_cache=False,
                   container=False, ccache=False, sstate=False, offline=False,
-                  gpg_pub_key=None, **kwargs):
+                  isar_apt_reuse=False, gpg_pub_key=None, **kwargs):
         # write configuration file and set bitbake_args
         # can run multiple times per test case
         self.check_init()
@@ -76,6 +76,7 @@ class CIBuilder(Test):
                       f'  container = {container}\n'
                       f'  ccache = {ccache}\n'
                       f'  sstate = {sstate}\n'
+                      f'  isar_apt_reuse = {isar_apt_reuse}\n'
                       f'  gpg_pub_key = {gpg_pub_key}\n'
                       f'===================================================')
 
@@ -107,6 +108,10 @@ class CIBuilder(Test):
                 f.write('BASE_REPO_KEY="file://' + gpg_pub_key + '"\n')
             if distro_apt_premir:
                 f.write('DISTRO_APT_PREMIRRORS = "%s"\n' % distro_apt_premir)
+            if isar_apt_reuse:
+                f.write('ISAR_APT_REUSE = "1"\n')
+                f.write('REPO_ISAR_DIR = "${TOPDIR}/isar-apt/${DISTRO}-${DISTRO_ARCH}/apt"\n')
+                f.write('REPO_ISAR_DB_DIR = "${TOPDIR}/isar-apt/${DISTRO}-${DISTRO_ARCH}/db"\n')
 
         # include ci_build.conf in local.conf
         with open(self.build_dir + '/conf/local.conf', 'r+') as f:
diff --git a/testsuite/citest.py b/testsuite/citest.py
index 16e38d07..7545d9e6 100755
--- a/testsuite/citest.py
+++ b/testsuite/citest.py
@@ -60,6 +60,18 @@ class CcacheTest(CIBaseTest):
         self.init()
         self.perform_ccache_test(targets)
 
+class IsarAptTest(CIBaseTest):
+
+    """
+    Test rebuild speed improve with isar-apt reuse enabled
+
+    :avocado: tags=isarapt,full
+    """
+    def test_isarapt_reuse(self):
+        target = 'mc:qemuamd64-bullseye:libhello'
+        self.init()
+        self.perform_isarapt_test(target)
+
 class CrossTest(CIBaseTest):
 
     """
-- 
2.20.1


      parent reply	other threads:[~2022-06-13  7:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-13  7:07 [RFC v2 0/3] PoC for isar-apt repo reusing Uladzimir Bely
2022-06-13  7:07 ` [RFC v2 1/3] meta: Reuse existing local isar-apt repo in new builds Uladzimir Bely
2022-06-13  7:07 ` [RFC v2 2/3] doc: Add section for isar-apt reuse functionality Uladzimir Bely
2022-06-13  7:07 ` Uladzimir Bely [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220613070759.16949-4-ubely@ilbers.de \
    --to=ubely@ilbers.de \
    --cc=isar-users@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox