summaryrefslogtreecommitdiffstats
path: root/external/meta-updater/lib/oeqa/selftest/cases
diff options
context:
space:
mode:
authortakeshi_hoshina <takeshi_hoshina@mail.toyota.co.jp>2020-10-22 14:58:56 +0900
committertakeshi_hoshina <takeshi_hoshina@mail.toyota.co.jp>2020-10-22 14:58:56 +0900
commit4204309872da5cb401cbb2729d9e2d4869a87f42 (patch)
treec7415e8600205e40ff7e91e8e5f4c411f30329f2 /external/meta-updater/lib/oeqa/selftest/cases
parent5b80bfd7bffd4c20d80b7c70a7130529e9a755dd (diff)
Diffstat (limited to 'external/meta-updater/lib/oeqa/selftest/cases')
-rw-r--r--external/meta-updater/lib/oeqa/selftest/cases/testutils.py21
-rw-r--r--external/meta-updater/lib/oeqa/selftest/cases/updater_qemux86_64.py80
-rw-r--r--external/meta-updater/lib/oeqa/selftest/cases/updater_raspberrypi.py16
3 files changed, 83 insertions, 34 deletions
diff --git a/external/meta-updater/lib/oeqa/selftest/cases/testutils.py b/external/meta-updater/lib/oeqa/selftest/cases/testutils.py
index 8d618a68..3abfa5eb 100644
--- a/external/meta-updater/lib/oeqa/selftest/cases/testutils.py
+++ b/external/meta-updater/lib/oeqa/selftest/cases/testutils.py
@@ -33,6 +33,7 @@ def qemu_boot_image(imagename, **kwargs):
# subdirectory.
args.dir = 'tmp/deploy/images'
args.efi = kwargs.get('efi', False)
+ args.bootloader = kwargs.get('bootloader', None)
args.machine = kwargs.get('machine', None)
args.mem = kwargs.get('mem', '128M')
qemu_use_kvm = get_bb_var("QEMU_USE_KVM")
@@ -48,6 +49,7 @@ def qemu_boot_image(imagename, **kwargs):
args.overlay = kwargs.get('overlay', None)
args.dry_run = kwargs.get('dry_run', False)
args.secondary_network = kwargs.get('secondary_network', False)
+ args.uboot_enable = kwargs.get('uboot_enable', 'yes')
qemu = QemuCommand(args)
cmdline = qemu.command_line()
@@ -119,20 +121,29 @@ def verifyNotProvisioned(testInst, machine):
'Device already provisioned!? ' + stderr.decode() + stdout.decode())
-def verifyProvisioned(testInst, machine):
+def verifyProvisioned(testInst, machine, hwid=''):
# Verify that device HAS provisioned.
+ # First loop while waiting for the device to boot.
ran_ok = False
for delay in [5, 5, 5, 5, 10, 10, 10, 10]:
stdout, stderr, retcode = testInst.qemu_command('aktualizr-info')
- if retcode == 0 and stderr == b'' and stdout.decode().find('Fetched metadata: yes') >= 0:
+ if retcode == 0 and stderr == b'':
ran_ok = True
break
sleep(delay)
testInst.assertTrue(ran_ok, 'aktualizr-info failed: ' + stderr.decode() + stdout.decode())
-
+ # Then wait for aktualizr to provision.
+ if stdout.decode().find('Fetched metadata: yes') < 0:
+ stdout, stderr, retcode = testInst.qemu_command('aktualizr-info --wait-until-provisioned')
+ testInst.assertFalse(retcode, 'aktualizr-info failed: ' + stderr.decode() + stdout.decode())
+ testInst.assertEqual(stderr, b'', 'aktualizr-info failed: ' + stderr.decode() + stdout.decode())
testInst.assertIn(b'Device ID: ', stdout, 'Provisioning failed: ' + stderr.decode() + stdout.decode())
- testInst.assertIn(b'Primary ecu hardware ID: ' + machine.encode(), stdout,
- 'Provisioning failed: ' + stderr.decode() + stdout.decode())
+ if hwid == '':
+ testInst.assertIn(b'Primary ECU hardware ID: ' + machine.encode(), stdout,
+ 'Provisioning failed: ' + stderr.decode() + stdout.decode())
+ else:
+ testInst.assertIn(b'Primary ECU hardware ID: ' + hwid.encode(), stdout,
+ 'Provisioning failed: ' + stderr.decode() + stdout.decode())
testInst.assertIn(b'Fetched metadata: yes', stdout, 'Provisioning failed: ' + stderr.decode() + stdout.decode())
p = re.compile(r'Device ID: ([a-z0-9-]*)\n')
m = p.search(stdout.decode())
diff --git a/external/meta-updater/lib/oeqa/selftest/cases/updater_qemux86_64.py b/external/meta-updater/lib/oeqa/selftest/cases/updater_qemux86_64.py
index 2b4726cb..08220f4e 100644
--- a/external/meta-updater/lib/oeqa/selftest/cases/updater_qemux86_64.py
+++ b/external/meta-updater/lib/oeqa/selftest/cases/updater_qemux86_64.py
@@ -85,6 +85,7 @@ class SharedCredProvTests(OESelftestTestCase):
self.append_config('MACHINE = "qemux86-64"')
self.append_config('SOTA_CLIENT_PROV = " aktualizr-shared-prov "')
self.append_config('IMAGE_FSTYPES_remove = "ostreepush garagesign garagecheck"')
+ self.append_config('SOTA_HARDWARE_ID = "plain_reibekuchen_314"')
self.qemu, self.s = qemu_launch(machine='qemux86-64')
def tearDownLocal(self):
@@ -107,7 +108,34 @@ class SharedCredProvTests(OESelftestTestCase):
self.assertEqual(value, machine,
'MACHINE does not match hostname: ' + machine + ', ' + value)
- verifyProvisioned(self, machine)
+ hwid = get_bb_var('SOTA_HARDWARE_ID')
+ verifyProvisioned(self, machine, hwid)
+
+
+class SharedCredProvTestsNonOSTree(SharedCredProvTests):
+
+ def setUpLocal(self):
+ layer = "meta-updater-qemux86-64"
+ result = runCmd('bitbake-layers show-layers')
+ if re.search(layer, result.output) is None:
+ self.meta_qemu = metadir() + layer
+ runCmd('bitbake-layers add-layer "%s"' % self.meta_qemu)
+ else:
+ self.meta_qemu = None
+ self.append_config('MACHINE = "qemux86-64"')
+ self.append_config('SOTA_CLIENT_PROV = ""')
+ self.append_config('IMAGE_FSTYPES_remove = "ostreepush garagesign garagecheck"')
+ self.append_config('SOTA_HARDWARE_ID = "plain_reibekuchen_314"')
+
+ self.append_config('DISTRO = "poky"')
+ self.append_config('DISTRO_FEATURES_append = " systemd"')
+ self.append_config('VIRTUAL-RUNTIME_init_manager = "systemd"')
+ self.append_config('PREFERRED_RPROVIDER_virtual/network-configuration ??= "networkd-dhcp-conf"')
+ self.append_config('PACKAGECONFIG_pn-aktualizr = ""')
+ self.append_config('SOTA_DEPLOY_CREDENTIALS = "1"')
+ self.append_config('IMAGE_INSTALL_append += "aktualizr"')
+ self.append_config('IMAGE_INSTALL_append += " aktualizr-shared-prov"')
+ self.qemu, self.s = qemu_launch(machine='qemux86-64', uboot_enable='no')
class ManualControlTests(OESelftestTestCase):
@@ -358,17 +386,7 @@ class IpSecondaryTests(OESelftestTestCase):
self._test_ctx.append_config('SOTA_CLIENT_PROV = " aktualizr-shared-prov "')
def is_ecu_registered(self, ecu_id):
- max_number_of_tries = 40
- try_counter = 0
-
- # aktualizr-info is not always able to load ECU serials from DB
- # so, let's run it a few times until it actually succeeds
- while try_counter < max_number_of_tries:
- device_status = self.get_info()
- try_counter += 1
- if device_status.find("load ECU serials") == -1:
- break
- sleep(1)
+ device_status = self.get_info()
if not ((device_status.find(ecu_id[0]) != -1) and (device_status.find(ecu_id[1]) != -1)):
return False
@@ -377,7 +395,7 @@ class IpSecondaryTests(OESelftestTestCase):
return not_reg_start == -1 or (device_status.find(ecu_id[1], not_reg_start) == -1)
def get_info(self):
- stdout, stderr, retcode = self.send_command('aktualizr-info')
+ stdout, stderr, retcode = self.send_command('aktualizr-info --wait-until-provisioned', timeout=620)
self._test_ctx.assertEqual(retcode, 0, 'Unable to run aktualizr-info: {}'.format(stderr))
return stdout
@@ -473,4 +491,40 @@ class ResourceControlTests(OESelftestTestCase):
stdout, stderr, retcode = self.qemu_command('systemctl --no-pager show --property=ExecMainStatus aktualizr')
self.assertIn(b'ExecMainStatus=0', stdout, 'Aktualizr did not restart')
+
+class NonSystemdTests(OESelftestTestCase):
+ def setUpLocal(self):
+ layer = "meta-updater-qemux86-64"
+ result = runCmd('bitbake-layers show-layers')
+ if re.search(layer, result.output) is None:
+ self.meta_qemu = metadir() + layer
+ runCmd('bitbake-layers add-layer "%s"' % self.meta_qemu)
+ else:
+ self.meta_qemu = None
+ self.append_config('MACHINE = "qemux86-64"')
+ self.append_config('SOTA_CLIENT_PROV = " aktualizr-shared-prov "')
+ self.append_config('IMAGE_FSTYPES_remove = "ostreepush garagesign garagecheck"')
+ self.append_config('DISTRO = "poky-sota"')
+ self.append_config('IMAGE_INSTALL_remove += " aktualizr-resource-control"')
+ self.qemu, self.s = qemu_launch(machine='qemux86-64')
+
+ def tearDownLocal(self):
+ qemu_terminate(self.s)
+ if self.meta_qemu:
+ runCmd('bitbake-layers remove-layer "%s"' % self.meta_qemu, ignore_status=True)
+
+ def qemu_command(self, command):
+ return qemu_send_command(self.qemu.ssh_port, command)
+
+ def test_provisioning(self):
+ print('Checking if systemd is not installed...')
+ stdout, stderr, retcode = self.qemu_command('systemctl')
+ self.assertTrue(retcode != 0, 'systemd is installed while it is not supposed to: ' + str(stdout))
+
+ stdout, stderr, retcode = self.qemu_command('aktualizr --run-mode once')
+ self.assertEqual(retcode, 0, 'Failed to run aktualizr: ' + str(stdout) + str(stderr))
+
+ machine = get_bb_var('MACHINE', 'core-image-minimal')
+ verifyProvisioned(self, machine)
+
# vim:set ts=4 sw=4 sts=4 expandtab:
diff --git a/external/meta-updater/lib/oeqa/selftest/cases/updater_raspberrypi.py b/external/meta-updater/lib/oeqa/selftest/cases/updater_raspberrypi.py
index 26d5c4c6..25c5f12e 100644
--- a/external/meta-updater/lib/oeqa/selftest/cases/updater_raspberrypi.py
+++ b/external/meta-updater/lib/oeqa/selftest/cases/updater_raspberrypi.py
@@ -35,26 +35,10 @@ class RpiTests(OESelftestTestCase):
else:
self.meta_upd_rpi = None
- # This is trickier that I would've thought. The fundamental problem is
- # that the qemu layer changes the u-boot file extension to .rom, but
- # raspberrypi still expects .bin. To prevent this, the qemu layer must
- # be temporarily removed if it is present. It has to be removed by name
- # without the complete path, but to add it back when we are done, we
- # need the full path.
- p = re.compile(r'meta-updater-qemux86-64\s*(\S*meta-updater-qemux86-64)\s')
- m = p.search(result.output)
- if m and m.lastindex > 0:
- self.meta_qemu = m.group(1)
- runCmd('bitbake-layers remove-layer meta-updater-qemux86-64')
- else:
- self.meta_qemu = None
-
self.append_config('MACHINE = "raspberrypi3"')
self.append_config('SOTA_CLIENT_PROV = " aktualizr-shared-prov "')
def tearDownLocal(self):
- if self.meta_qemu:
- runCmd('bitbake-layers add-layer "%s"' % self.meta_qemu, ignore_status=True)
if self.meta_upd_rpi:
runCmd('bitbake-layers remove-layer "%s"' % self.meta_upd_rpi, ignore_status=True)
if self.meta_rpi: