Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Commit b8a1d19

Browse files
committed
system update: test with two image recipes
With OSTree it is fairly easy to build original and update in different image recipes. This makes it easier to debug the test, because both build directories are preserved. It might also speed up running the tests repeatedly, because the rootfs should be reusable. TODO: in practice, we still need to rebuild. Check why. The base infrastructure could be used to test switching between different images with OSTree. Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
1 parent cad48a7 commit b8a1d19

2 files changed

Lines changed: 46 additions & 10 deletions

File tree

meta-refkit-core/lib/oeqa/selftest/cases/refkit_ostree.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ class RefkitOSTreeUpdateBase(SystemUpdateBase):
1717
# We test the normal refkit-image-common with
1818
# OSTree system update enabled.
1919
IMAGE_PN = 'refkit-image-common'
20+
IMAGE_PN_UPDATE = IMAGE_PN
2021
IMAGE_BBAPPEND = 'refkit-image-common.bbappend'
22+
IMAGE_BBAPPEND_UPDATE = IMAGE_BBAPPEND
2123
IMAGE_CONFIG = '''
2224
IMAGE_FEATURES_append = " ostree"
2325
'''
@@ -146,3 +148,28 @@ def test(self):
146148

147149
class RefkitOSTreeUpdateTestIndividual(RefkitOSTreeUpdateBase, metaclass=RefkitOSTreeUpdateMeta):
148150
pass
151+
152+
class RefkitOSTreeUpdateTestDev(RefkitOSTreeUpdateTestAll, metaclass=RefkitOSTreeUpdateMeta):
153+
"""
154+
This class avoids rootfs rebuilding by using two separate image
155+
recipes. It's using slight tricks like overriding the OSTREE_BRANCH,
156+
so the other tests are more realistic. Use this one when debugging problems.
157+
"""
158+
159+
IMAGE_PN = 'refkit-image-update-test-a'
160+
IMAGE_PN_UPDATE = 'refkit-image-update-test-b'
161+
IMAGE_BBAPPEND = 'refkit-image-update-test-a.bbappend'
162+
IMAGE_BBAPPEND_UPDATE = 'refkit-image-update-test-b.bbappend'
163+
164+
def setUpLocal(self):
165+
super().setUpLocal()
166+
def create_image_bb(pn):
167+
bb = pn + '.bb'
168+
self.track_for_cleanup(bb)
169+
self.append_config('BBFILES_append = " %s"' % os.path.abspath(bb))
170+
with open(bb, 'w') as f:
171+
f.write('require ${META_REFKIT_CORE_BASE}/recipes-images/images/refkit-image-common.bb\n')
172+
f.write('OSTREE_BRANCHNAME = "${DISTRO}/${MACHINE}/%s"\n' % self.IMAGE_PN)
173+
f.write('''IMAGE_FEATURES_append = "${@ bb.utils.filter('DISTRO_FEATURES', 'stateless', d)}"\n''')
174+
create_image_bb(self.IMAGE_PN)
175+
create_image_bb(self.IMAGE_PN_UPDATE)

meta-refkit-core/lib/oeqa/selftest/systemupdate/systemupdatebase.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -220,12 +220,18 @@ class SystemUpdateBase(OESelftestTestCase):
220220
# The image that will get built, booted and updated.
221221
IMAGE_PN = 'core-image-minimal'
222222

223-
# The .bbappend name which matches IMAGE_PN.
223+
# The image used for preparing the update. Usually
224+
# the same, but some update mechanisms may also
225+
# support switching between images.
226+
IMAGE_PN_UPDATE = IMAGE_PN
227+
228+
# The .bbappend name which matches IMAGE_PN resp. IMAGE_PN_UPDATE.
224229
# For example, OSTree might build and boot "core-image-minimal-ostree",
225230
# but the actual image recipe is "core-image-minimal" and thus
226231
# we would need "core-image-minimal.bbappend". Also allows to handle
227232
# cases where the bbappend file name must have a wildcard.
228233
IMAGE_BBAPPEND = 'core-image-minimal.bbappend'
234+
IMAGE_BBAPPEND_UPDATE = IMAGE_BBAPPEND
229235

230236
# Additional image settings that will get written into the IMAGE_BBAPPEND.
231237
IMAGE_CONFIG = ''
@@ -271,8 +277,10 @@ def create_image_bbappend(is_update):
271277
applied also to image variants.
272278
"""
273279

274-
self.track_for_cleanup(self.IMAGE_BBAPPEND)
275-
with open(self.IMAGE_BBAPPEND, 'w') as f:
280+
bbappend = self.IMAGE_BBAPPEND_UPDATE if is_update else self.IMAGE_BBAPPEND
281+
self.append_config('BBFILES_append = " %s"' % os.path.abspath(bbappend))
282+
self.track_for_cleanup(bbappend)
283+
with open(bbappend, 'w') as f:
276284
f.write('''
277285
python system_update_test_modify () {
278286
import base64
@@ -295,7 +303,7 @@ def create_image_bbappend(is_update):
295303
self.IMAGE_MODIFY.modify_image_build(testname, updates, is_update)))
296304

297305
# Creating a .bbappend for the image will trigger a rebuild.
298-
self.write_config('BBFILES_append = " %s"' % os.path.abspath(self.IMAGE_BBAPPEND))
306+
# To avoid this, use separate image recipes.
299307
create_image_bbappend(False)
300308
self.logger.info('Building base image')
301309
result = bitbake(self.IMAGE_PN, output_log=self.logger)
@@ -307,12 +315,6 @@ def create_image_bbappend(is_update):
307315
# self.track_for_cleanup(self.image_dir_test)
308316
oe.path.copyhardlinktree(self.image_dir, self.image_dir_test)
309317

310-
# Now we change our .bbappend so that the updated state is generated
311-
# during the next rebuild.
312-
create_image_bbappend(True)
313-
self.logger.info('Building updated image')
314-
bitbake(self.IMAGE_PN, output_log=self.logger)
315-
316318
# Change DEPLOY_DIR_IMAGE so that we use our copy of the
317319
# images from before the update. Further customizations for booting can
318320
# be done by rewriting self.image_dir_test/IMAGE_PN-MACHINE.qemuboot.conf
@@ -323,6 +325,13 @@ def create_image_bbappend(is_update):
323325
# Boot image, verify before and after update.
324326
with self.boot_image(overrides) as qemu:
325327
self.verify_image(testname, False, qemu, updates)
328+
329+
# Now we change our .bbappend so that the updated state is generated
330+
# during the next rebuild.
331+
create_image_bbappend(True)
332+
self.logger.info('Building updated image')
333+
bitbake(self.IMAGE_PN_UPDATE, output_log=self.logger)
334+
326335
reboot = self.update_image(qemu)
327336
if not reboot:
328337
self.verify_image(testname, True, qemu, updates)

0 commit comments

Comments
 (0)