summaryrefslogtreecommitdiffstats
path: root/lib/oeqa
diff options
context:
space:
mode:
Diffstat (limited to 'lib/oeqa')
-rw-r--r--lib/oeqa/selftest/cases/updater.py73
1 files changed, 59 insertions, 14 deletions
diff --git a/lib/oeqa/selftest/cases/updater.py b/lib/oeqa/selftest/cases/updater.py
index 0253a84..e620491 100644
--- a/lib/oeqa/selftest/cases/updater.py
+++ b/lib/oeqa/selftest/cases/updater.py
@@ -115,8 +115,8 @@ class AktualizrToolsTests(OESelftestTestCase):
115 bb_vars = get_bb_vars(['SOTA_PACKED_CREDENTIALS', 'T'], 'aktualizr-native') 115 bb_vars = get_bb_vars(['SOTA_PACKED_CREDENTIALS', 'T'], 'aktualizr-native')
116 creds = bb_vars['SOTA_PACKED_CREDENTIALS'] 116 creds = bb_vars['SOTA_PACKED_CREDENTIALS']
117 temp_dir = bb_vars['T'] 117 temp_dir = bb_vars['T']
118 bb_vars_prov = get_bb_vars(['STAGING_DIR_NATIVE', 'libdir'], 'aktualizr-implicit-prov') 118 bb_vars_prov = get_bb_vars(['STAGING_DIR_HOST', 'libdir'], 'aktualizr-implicit-prov')
119 config = bb_vars_prov['STAGING_DIR_NATIVE'] + bb_vars_prov['libdir'] + '/sota/sota_implicit_prov.toml' 119 config = bb_vars_prov['STAGING_DIR_HOST'] + bb_vars_prov['libdir'] + '/sota/sota_implicit_prov.toml'
120 120
121 akt_native_run(self, 'aktualizr_cert_provider -c {creds} -r -l {temp} -g {config}' 121 akt_native_run(self, 'aktualizr_cert_provider -c {creds} -r -l {temp} -g {config}'
122 .format(creds=creds, temp=temp_dir, config=config)) 122 .format(creds=creds, temp=temp_dir, config=config))
@@ -141,7 +141,7 @@ class AutoProvTests(OESelftestTestCase):
141 if re.search(layer, result.output) is None: 141 if re.search(layer, result.output) is None:
142 # Assume the directory layout for finding other layers. We could also 142 # Assume the directory layout for finding other layers. We could also
143 # make assumptions by using 'show-layers', but either way, if the 143 # make assumptions by using 'show-layers', but either way, if the
144 # layers we need aren't where we expect them, we are out of like. 144 # layers we need aren't where we expect them, we are out of luck.
145 path = os.path.abspath(os.path.dirname(__file__)) 145 path = os.path.abspath(os.path.dirname(__file__))
146 metadir = path + "/../../../../../" 146 metadir = path + "/../../../../../"
147 self.meta_qemu = metadir + layer 147 self.meta_qemu = metadir + layer
@@ -193,6 +193,49 @@ class AutoProvTests(OESelftestTestCase):
193 'Legacy secondary initialization failed: ' + stderr.decode() + stdout.decode()) 193 'Legacy secondary initialization failed: ' + stderr.decode() + stdout.decode())
194 194
195 195
196class ManualControlTests(OESelftestTestCase):
197
198 def setUpLocal(self):
199 layer = "meta-updater-qemux86-64"
200 result = runCmd('bitbake-layers show-layers')
201 if re.search(layer, result.output) is None:
202 # Assume the directory layout for finding other layers. We could also
203 # make assumptions by using 'show-layers', but either way, if the
204 # layers we need aren't where we expect them, we are out of like.
205 path = os.path.abspath(os.path.dirname(__file__))
206 metadir = path + "/../../../../../"
207 self.meta_qemu = metadir + layer
208 runCmd('bitbake-layers add-layer "%s"' % self.meta_qemu)
209 else:
210 self.meta_qemu = None
211 self.append_config('MACHINE = "qemux86-64"')
212 self.append_config('SOTA_CLIENT_PROV = " aktualizr-auto-prov "')
213 self.append_config('SYSTEMD_AUTO_ENABLE_aktualizr = "disable"')
214 self.qemu, self.s = qemu_launch(machine='qemux86-64')
215
216 def tearDownLocal(self):
217 qemu_terminate(self.s)
218 if self.meta_qemu:
219 runCmd('bitbake-layers remove-layer "%s"' % self.meta_qemu, ignore_status=True)
220
221 def qemu_command(self, command):
222 return qemu_send_command(self.qemu.ssh_port, command)
223
224 def test_manual_running_mode_once(self):
225 """
226 Disable the systemd service then run aktualizr manually
227 """
228 sleep(20)
229 stdout, stderr, retcode = self.qemu_command('aktualizr-info')
230 self.assertIn(b'Fetched metadata: no', stdout,
231 'Aktualizr should not have run yet' + stderr.decode() + stdout.decode())
232
233 stdout, stderr, retcode = self.qemu_command('aktualizr --running-mode=once')
234
235 stdout, stderr, retcode = self.qemu_command('aktualizr-info')
236 self.assertIn(b'Fetched metadata: yes', stdout,
237 'Aktualizr should have run' + stderr.decode() + stdout.decode())
238
196class RpiTests(OESelftestTestCase): 239class RpiTests(OESelftestTestCase):
197 240
198 def setUpLocal(self): 241 def setUpLocal(self):
@@ -204,7 +247,7 @@ class RpiTests(OESelftestTestCase):
204 result = runCmd('bitbake-layers show-layers') 247 result = runCmd('bitbake-layers show-layers')
205 # Assume the directory layout for finding other layers. We could also 248 # Assume the directory layout for finding other layers. We could also
206 # make assumptions by using 'show-layers', but either way, if the 249 # make assumptions by using 'show-layers', but either way, if the
207 # layers we need aren't where we expect them, we are out of like. 250 # layers we need aren't where we expect them, we are out of luck.
208 path = os.path.abspath(os.path.dirname(__file__)) 251 path = os.path.abspath(os.path.dirname(__file__))
209 metadir = path + "/../../../../../" 252 metadir = path + "/../../../../../"
210 if re.search(layer_python, result.output) is None: 253 if re.search(layer_python, result.output) is None:
@@ -277,7 +320,7 @@ class GrubTests(OESelftestTestCase):
277 result = runCmd('bitbake-layers show-layers') 320 result = runCmd('bitbake-layers show-layers')
278 # Assume the directory layout for finding other layers. We could also 321 # Assume the directory layout for finding other layers. We could also
279 # make assumptions by using 'show-layers', but either way, if the 322 # make assumptions by using 'show-layers', but either way, if the
280 # layers we need aren't where we expect them, we are out of like. 323 # layers we need aren't where we expect them, we are out of luck.
281 path = os.path.abspath(os.path.dirname(__file__)) 324 path = os.path.abspath(os.path.dirname(__file__))
282 metadir = path + "/../../../../../" 325 metadir = path + "/../../../../../"
283 if re.search(layer_intel, result.output) is None: 326 if re.search(layer_intel, result.output) is None:
@@ -339,7 +382,7 @@ class ImplProvTests(OESelftestTestCase):
339 if re.search(layer, result.output) is None: 382 if re.search(layer, result.output) is None:
340 # Assume the directory layout for finding other layers. We could also 383 # Assume the directory layout for finding other layers. We could also
341 # make assumptions by using 'show-layers', but either way, if the 384 # make assumptions by using 'show-layers', but either way, if the
342 # layers we need aren't where we expect them, we are out of like. 385 # layers we need aren't where we expect them, we are out of luck.
343 path = os.path.abspath(os.path.dirname(__file__)) 386 path = os.path.abspath(os.path.dirname(__file__))
344 metadir = path + "/../../../../../" 387 metadir = path + "/../../../../../"
345 self.meta_qemu = metadir + layer 388 self.meta_qemu = metadir + layer
@@ -348,6 +391,7 @@ class ImplProvTests(OESelftestTestCase):
348 self.meta_qemu = None 391 self.meta_qemu = None
349 self.append_config('MACHINE = "qemux86-64"') 392 self.append_config('MACHINE = "qemux86-64"')
350 self.append_config('SOTA_CLIENT_PROV = " aktualizr-implicit-prov "') 393 self.append_config('SOTA_CLIENT_PROV = " aktualizr-implicit-prov "')
394 runCmd('bitbake -c cleanall aktualizr aktualizr-implicit-prov')
351 self.qemu, self.s = qemu_launch(machine='qemux86-64') 395 self.qemu, self.s = qemu_launch(machine='qemux86-64')
352 396
353 def tearDownLocal(self): 397 def tearDownLocal(self):
@@ -392,8 +436,8 @@ class ImplProvTests(OESelftestTestCase):
392 # Run cert_provider. 436 # Run cert_provider.
393 bb_vars = get_bb_vars(['SOTA_PACKED_CREDENTIALS'], 'aktualizr-native') 437 bb_vars = get_bb_vars(['SOTA_PACKED_CREDENTIALS'], 'aktualizr-native')
394 creds = bb_vars['SOTA_PACKED_CREDENTIALS'] 438 creds = bb_vars['SOTA_PACKED_CREDENTIALS']
395 bb_vars_prov = get_bb_vars(['STAGING_DIR_NATIVE', 'libdir'], 'aktualizr-implicit-prov') 439 bb_vars_prov = get_bb_vars(['STAGING_DIR_HOST', 'libdir'], 'aktualizr-implicit-prov')
396 config = bb_vars_prov['STAGING_DIR_NATIVE'] + bb_vars_prov['libdir'] + '/sota/sota_implicit_prov.toml' 440 config = bb_vars_prov['STAGING_DIR_HOST'] + bb_vars_prov['libdir'] + '/sota/sota_implicit_prov.toml'
397 441
398 akt_native_run(self, 'aktualizr_cert_provider -c {creds} -t root@localhost -p {port} -s -g {config}' 442 akt_native_run(self, 'aktualizr_cert_provider -c {creds} -t root@localhost -p {port} -s -g {config}'
399 .format(creds=creds, port=self.qemu.ssh_port, config=config)) 443 .format(creds=creds, port=self.qemu.ssh_port, config=config))
@@ -409,7 +453,7 @@ class HsmTests(OESelftestTestCase):
409 if re.search(layer, result.output) is None: 453 if re.search(layer, result.output) is None:
410 # Assume the directory layout for finding other layers. We could also 454 # Assume the directory layout for finding other layers. We could also
411 # make assumptions by using 'show-layers', but either way, if the 455 # make assumptions by using 'show-layers', but either way, if the
412 # layers we need aren't where we expect them, we are out of like. 456 # layers we need aren't where we expect them, we are out of luck.
413 path = os.path.abspath(os.path.dirname(__file__)) 457 path = os.path.abspath(os.path.dirname(__file__))
414 metadir = path + "/../../../../../" 458 metadir = path + "/../../../../../"
415 self.meta_qemu = metadir + layer 459 self.meta_qemu = metadir + layer
@@ -419,6 +463,7 @@ class HsmTests(OESelftestTestCase):
419 self.append_config('MACHINE = "qemux86-64"') 463 self.append_config('MACHINE = "qemux86-64"')
420 self.append_config('SOTA_CLIENT_PROV = "aktualizr-hsm-prov"') 464 self.append_config('SOTA_CLIENT_PROV = "aktualizr-hsm-prov"')
421 self.append_config('SOTA_CLIENT_FEATURES = "hsm"') 465 self.append_config('SOTA_CLIENT_FEATURES = "hsm"')
466 runCmd('bitbake -c cleanall aktualizr aktualizr-hsm-prov')
422 self.qemu, self.s = qemu_launch(machine='qemux86-64') 467 self.qemu, self.s = qemu_launch(machine='qemux86-64')
423 468
424 def tearDownLocal(self): 469 def tearDownLocal(self):
@@ -473,8 +518,8 @@ class HsmTests(OESelftestTestCase):
473 # Run cert_provider. 518 # Run cert_provider.
474 bb_vars = get_bb_vars(['SOTA_PACKED_CREDENTIALS'], 'aktualizr-native') 519 bb_vars = get_bb_vars(['SOTA_PACKED_CREDENTIALS'], 'aktualizr-native')
475 creds = bb_vars['SOTA_PACKED_CREDENTIALS'] 520 creds = bb_vars['SOTA_PACKED_CREDENTIALS']
476 bb_vars_prov = get_bb_vars(['STAGING_DIR_NATIVE', 'libdir'], 'aktualizr-hsm-prov') 521 bb_vars_prov = get_bb_vars(['STAGING_DIR_HOST', 'libdir'], 'aktualizr-hsm-prov')
477 config = bb_vars_prov['STAGING_DIR_NATIVE'] + bb_vars_prov['libdir'] + '/sota/sota_hsm_prov.toml' 522 config = bb_vars_prov['STAGING_DIR_HOST'] + bb_vars_prov['libdir'] + '/sota/sota_hsm_prov.toml'
478 523
479 akt_native_run(self, 'aktualizr_cert_provider -c {creds} -t root@localhost -p {port} -r -s -g {config}' 524 akt_native_run(self, 'aktualizr_cert_provider -c {creds} -t root@localhost -p {port} -r -s -g {config}'
480 .format(creds=creds, port=self.qemu.ssh_port, config=config)) 525 .format(creds=creds, port=self.qemu.ssh_port, config=config))
@@ -527,7 +572,7 @@ class SecondaryTests(OESelftestTestCase):
527 if re.search(layer, result.output) is None: 572 if re.search(layer, result.output) is None:
528 # Assume the directory layout for finding other layers. We could also 573 # Assume the directory layout for finding other layers. We could also
529 # make assumptions by using 'show-layers', but either way, if the 574 # make assumptions by using 'show-layers', but either way, if the
530 # layers we need aren't where we expect them, we are out of like. 575 # layers we need aren't where we expect them, we are out of luck.
531 path = os.path.abspath(os.path.dirname(__file__)) 576 path = os.path.abspath(os.path.dirname(__file__))
532 metadir = path + "/../../../../../" 577 metadir = path + "/../../../../../"
533 self.meta_qemu = metadir + layer 578 self.meta_qemu = metadir + layer
@@ -554,7 +599,7 @@ class SecondaryTests(OESelftestTestCase):
554 599
555 def test_secondary_listening(self): 600 def test_secondary_listening(self):
556 print('Checking aktualizr-secondary service is listening') 601 print('Checking aktualizr-secondary service is listening')
557 stdout, stderr, retcode = self.qemu_command('echo test | nc localhost 9030') 602 stdout, stderr, retcode = self.qemu_command('aktualizr-check-discovery')
558 self.assertEqual(retcode, 0, "Unable to connect to secondary") 603 self.assertEqual(retcode, 0, "Unable to connect to secondary")
559 604
560 605
@@ -572,7 +617,7 @@ class PrimaryTests(OESelftestTestCase):
572 if re.search(layer, result.output) is None: 617 if re.search(layer, result.output) is None:
573 # Assume the directory layout for finding other layers. We could also 618 # Assume the directory layout for finding other layers. We could also
574 # make assumptions by using 'show-layers', but either way, if the 619 # make assumptions by using 'show-layers', but either way, if the
575 # layers we need aren't where we expect them, we are out of like. 620 # layers we need aren't where we expect them, we are out of luck.
576 path = os.path.abspath(os.path.dirname(__file__)) 621 path = os.path.abspath(os.path.dirname(__file__))
577 metadir = path + "/../../../../../" 622 metadir = path + "/../../../../../"
578 self.meta_qemu = metadir + layer 623 self.meta_qemu = metadir + layer