diff options
author | Laurent Bonnans <laurent.bonnans@here.com> | 2019-03-21 13:59:52 +0100 |
---|---|---|
committer | Patrick Vacek <patrickvacek@gmail.com> | 2019-04-29 09:55:05 +0200 |
commit | 2414cef43405698030db413821f76aef818219e0 (patch) | |
tree | 40ceed764e6a5db0d88b11e7b79fd97ad8eb1c91 /lib/oeqa | |
parent | aad4f89a9f46a49fe99472207bc5be73c26f833a (diff) | |
download | meta-updater-2414cef43405698030db413821f76aef818219e0.tar.gz |
Cleanup (not) provisioned checks in oe-selftest
Signed-off-by: Laurent Bonnans <laurent.bonnans@here.com>
Diffstat (limited to 'lib/oeqa')
-rw-r--r-- | lib/oeqa/selftest/cases/testutils.py | 28 | ||||
-rw-r--r-- | lib/oeqa/selftest/cases/updater_minnowboard.py | 13 | ||||
-rw-r--r-- | lib/oeqa/selftest/cases/updater_qemux86_64.py | 54 |
3 files changed, 33 insertions, 62 deletions
diff --git a/lib/oeqa/selftest/cases/testutils.py b/lib/oeqa/selftest/cases/testutils.py index d381d7d..90ba653 100644 --- a/lib/oeqa/selftest/cases/testutils.py +++ b/lib/oeqa/selftest/cases/testutils.py | |||
@@ -81,16 +81,42 @@ def akt_native_run(testInst, cmd, **kwargs): | |||
81 | testInst.assertEqual(result.status, 0, "Status not equal to 0. output: %s" % result.output) | 81 | testInst.assertEqual(result.status, 0, "Status not equal to 0. output: %s" % result.output) |
82 | 82 | ||
83 | 83 | ||
84 | def verifyNotProvisioned(testInst, machine): | ||
85 | print('Checking output of aktualizr-info:') | ||
86 | ran_ok = False | ||
87 | for delay in [5, 5, 5, 5, 10, 10, 10, 10]: | ||
88 | stdout, stderr, retcode = testInst.qemu_command('aktualizr-info') | ||
89 | if retcode == 0 and stderr == b'': | ||
90 | ran_ok = True | ||
91 | break | ||
92 | sleep(delay) | ||
93 | testInst.assertTrue(ran_ok, 'aktualizr-info failed: ' + stderr.decode() + stdout.decode()) | ||
94 | |||
95 | # Verify that device has NOT yet provisioned. | ||
96 | testInst.assertIn(b'Couldn\'t load device ID', stdout, | ||
97 | 'Device already provisioned!? ' + stderr.decode() + stdout.decode()) | ||
98 | testInst.assertIn(b'Couldn\'t load ECU serials', stdout, | ||
99 | 'Device already provisioned!? ' + stderr.decode() + stdout.decode()) | ||
100 | testInst.assertIn(b'Provisioned on server: no', stdout, | ||
101 | 'Device already provisioned!? ' + stderr.decode() + stdout.decode()) | ||
102 | testInst.assertIn(b'Fetched metadata: no', stdout, | ||
103 | 'Device already provisioned!? ' + stderr.decode() + stdout.decode()) | ||
104 | |||
105 | |||
84 | def verifyProvisioned(testInst, machine): | 106 | def verifyProvisioned(testInst, machine): |
85 | # Verify that device HAS provisioned. | 107 | # Verify that device HAS provisioned. |
108 | ran_ok = False | ||
86 | for delay in [5, 5, 5, 5, 10, 10, 10, 10]: | 109 | for delay in [5, 5, 5, 5, 10, 10, 10, 10]: |
87 | stdout, stderr, retcode = testInst.qemu_command('aktualizr-info') | 110 | stdout, stderr, retcode = testInst.qemu_command('aktualizr-info') |
88 | if retcode == 0 and stderr == b'' and stdout.decode().find('Fetched metadata: yes') >= 0: | 111 | if retcode == 0 and stderr == b'' and stdout.decode().find('Fetched metadata: yes') >= 0: |
112 | ran_ok = True | ||
89 | break | 113 | break |
90 | sleep(delay) | 114 | sleep(delay) |
115 | testInst.assertTrue(ran_ok, 'aktualizr-info failed: ' + stderr.decode() + stdout.decode()) | ||
116 | |||
91 | testInst.assertIn(b'Device ID: ', stdout, 'Provisioning failed: ' + stderr.decode() + stdout.decode()) | 117 | testInst.assertIn(b'Device ID: ', stdout, 'Provisioning failed: ' + stderr.decode() + stdout.decode()) |
92 | testInst.assertIn(b'Primary ecu hardware ID: ' + machine.encode(), stdout, | 118 | testInst.assertIn(b'Primary ecu hardware ID: ' + machine.encode(), stdout, |
93 | 'Provisioning failed: ' + stderr.decode() + stdout.decode()) | 119 | 'Provisioning failed: ' + stderr.decode() + stdout.decode()) |
94 | testInst.assertIn(b'Fetched metadata: yes', stdout, 'Provisioning failed: ' + stderr.decode() + stdout.decode()) | 120 | testInst.assertIn(b'Fetched metadata: yes', stdout, 'Provisioning failed: ' + stderr.decode() + stdout.decode()) |
95 | p = re.compile(r'Device ID: ([a-z0-9-]*)\n') | 121 | p = re.compile(r'Device ID: ([a-z0-9-]*)\n') |
96 | m = p.search(stdout.decode()) | 122 | m = p.search(stdout.decode()) |
diff --git a/lib/oeqa/selftest/cases/updater_minnowboard.py b/lib/oeqa/selftest/cases/updater_minnowboard.py index 97b2a86..f5df584 100644 --- a/lib/oeqa/selftest/cases/updater_minnowboard.py +++ b/lib/oeqa/selftest/cases/updater_minnowboard.py | |||
@@ -1,9 +1,8 @@ | |||
1 | import os | 1 | import os |
2 | import re | 2 | import re |
3 | from time import sleep | ||
4 | 3 | ||
5 | from oeqa.selftest.case import OESelftestTestCase | 4 | from oeqa.selftest.case import OESelftestTestCase |
6 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var | 5 | from oeqa.utils.commands import runCmd, get_bb_var |
7 | from testutils import qemu_launch, qemu_send_command, qemu_terminate, verifyProvisioned | 6 | from testutils import qemu_launch, qemu_send_command, qemu_terminate, verifyProvisioned |
8 | 7 | ||
9 | 8 | ||
@@ -55,16 +54,6 @@ class MinnowTests(OESelftestTestCase): | |||
55 | self.assertEqual(value, machine, | 54 | self.assertEqual(value, machine, |
56 | 'MACHINE does not match hostname: ' + machine + ', ' + value + | 55 | 'MACHINE does not match hostname: ' + machine + ', ' + value + |
57 | '\nIs TianoCore ovmf installed on your host machine?') | 56 | '\nIs TianoCore ovmf installed on your host machine?') |
58 | print(value) | ||
59 | print('Checking output of aktualizr-info:') | ||
60 | ran_ok = False | ||
61 | for delay in [1, 2, 5, 10, 15]: | ||
62 | stdout, stderr, retcode = self.qemu_command('aktualizr-info') | ||
63 | if retcode == 0 and stderr == b'': | ||
64 | ran_ok = True | ||
65 | break | ||
66 | sleep(delay) | ||
67 | self.assertTrue(ran_ok, 'aktualizr-info failed: ' + stderr.decode() + stdout.decode()) | ||
68 | 57 | ||
69 | verifyProvisioned(self, machine) | 58 | verifyProvisioned(self, machine) |
70 | 59 | ||
diff --git a/lib/oeqa/selftest/cases/updater_qemux86_64.py b/lib/oeqa/selftest/cases/updater_qemux86_64.py index 0fac159..bef6cdc 100644 --- a/lib/oeqa/selftest/cases/updater_qemux86_64.py +++ b/lib/oeqa/selftest/cases/updater_qemux86_64.py | |||
@@ -8,7 +8,7 @@ from time import sleep | |||
8 | from oeqa.selftest.case import OESelftestTestCase | 8 | from oeqa.selftest.case import OESelftestTestCase |
9 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars | 9 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars |
10 | from testutils import qemu_launch, qemu_send_command, qemu_terminate, \ | 10 | from testutils import qemu_launch, qemu_send_command, qemu_terminate, \ |
11 | akt_native_run, verifyProvisioned | 11 | akt_native_run, verifyNotProvisioned, verifyProvisioned |
12 | 12 | ||
13 | 13 | ||
14 | class GeneralTests(OESelftestTestCase): | 14 | class GeneralTests(OESelftestTestCase): |
@@ -106,16 +106,6 @@ class AutoProvTests(OESelftestTestCase): | |||
106 | value = stdout.decode()[:-1] | 106 | value = stdout.decode()[:-1] |
107 | self.assertEqual(value, machine, | 107 | self.assertEqual(value, machine, |
108 | 'MACHINE does not match hostname: ' + machine + ', ' + value) | 108 | 'MACHINE does not match hostname: ' + machine + ', ' + value) |
109 | print(value) | ||
110 | print('Checking output of aktualizr-info:') | ||
111 | ran_ok = False | ||
112 | for delay in [1, 2, 5, 10, 15]: | ||
113 | stdout, stderr, retcode = self.qemu_command('aktualizr-info') | ||
114 | if retcode == 0 and stderr == b'': | ||
115 | ran_ok = True | ||
116 | break | ||
117 | sleep(delay) | ||
118 | self.assertTrue(ran_ok, 'aktualizr-info failed: ' + stderr.decode() + stdout.decode()) | ||
119 | 109 | ||
120 | verifyProvisioned(self, machine) | 110 | verifyProvisioned(self, machine) |
121 | 111 | ||
@@ -204,25 +194,8 @@ class ImplProvTests(OESelftestTestCase): | |||
204 | value = stdout.decode()[:-1] | 194 | value = stdout.decode()[:-1] |
205 | self.assertEqual(value, machine, | 195 | self.assertEqual(value, machine, |
206 | 'MACHINE does not match hostname: ' + machine + ', ' + value) | 196 | 'MACHINE does not match hostname: ' + machine + ', ' + value) |
207 | print(value) | 197 | |
208 | print('Checking output of aktualizr-info:') | 198 | verifyNotProvisioned(self, machine) |
209 | ran_ok = False | ||
210 | for delay in [1, 2, 5, 10, 15]: | ||
211 | stdout, stderr, retcode = self.qemu_command('aktualizr-info') | ||
212 | if retcode == 0 and stderr == b'': | ||
213 | ran_ok = True | ||
214 | break | ||
215 | sleep(delay) | ||
216 | self.assertTrue(ran_ok, 'aktualizr-info failed: ' + stderr.decode() + stdout.decode()) | ||
217 | # Verify that device has NOT yet provisioned. | ||
218 | self.assertIn(b'Couldn\'t load device ID', stdout, | ||
219 | 'Device already provisioned!? ' + stderr.decode() + stdout.decode()) | ||
220 | self.assertIn(b'Couldn\'t load ECU serials', stdout, | ||
221 | 'Device already provisioned!? ' + stderr.decode() + stdout.decode()) | ||
222 | self.assertIn(b'Provisioned on server: no', stdout, | ||
223 | 'Device already provisioned!? ' + stderr.decode() + stdout.decode()) | ||
224 | self.assertIn(b'Fetched metadata: no', stdout, | ||
225 | 'Device already provisioned!? ' + stderr.decode() + stdout.decode()) | ||
226 | 199 | ||
227 | # Run aktualizr-cert-provider. | 200 | # Run aktualizr-cert-provider. |
228 | bb_vars = get_bb_vars(['SOTA_PACKED_CREDENTIALS'], 'aktualizr-native') | 201 | bb_vars = get_bb_vars(['SOTA_PACKED_CREDENTIALS'], 'aktualizr-native') |
@@ -279,25 +252,8 @@ class HsmTests(OESelftestTestCase): | |||
279 | value = stdout.decode()[:-1] | 252 | value = stdout.decode()[:-1] |
280 | self.assertEqual(value, machine, | 253 | self.assertEqual(value, machine, |
281 | 'MACHINE does not match hostname: ' + machine + ', ' + value) | 254 | 'MACHINE does not match hostname: ' + machine + ', ' + value) |
282 | print(value) | 255 | |
283 | print('Checking output of aktualizr-info:') | 256 | verifyNotProvisioned(self, machine) |
284 | ran_ok = False | ||
285 | for delay in [1, 2, 5, 10, 15]: | ||
286 | stdout, stderr, retcode = self.qemu_command('aktualizr-info') | ||
287 | if retcode == 0 and stderr == b'': | ||
288 | ran_ok = True | ||
289 | break | ||
290 | sleep(delay) | ||
291 | self.assertTrue(ran_ok, 'aktualizr-info failed: ' + stderr.decode() + stdout.decode()) | ||
292 | # Verify that device has NOT yet provisioned. | ||
293 | self.assertIn(b'Couldn\'t load device ID', stdout, | ||
294 | 'Device already provisioned!? ' + stderr.decode() + stdout.decode()) | ||
295 | self.assertIn(b'Couldn\'t load ECU serials', stdout, | ||
296 | 'Device already provisioned!? ' + stderr.decode() + stdout.decode()) | ||
297 | self.assertIn(b'Provisioned on server: no', stdout, | ||
298 | 'Device already provisioned!? ' + stderr.decode() + stdout.decode()) | ||
299 | self.assertIn(b'Fetched metadata: no', stdout, | ||
300 | 'Device already provisioned!? ' + stderr.decode() + stdout.decode()) | ||
301 | 257 | ||
302 | # Verify that HSM is not yet initialized. | 258 | # Verify that HSM is not yet initialized. |
303 | pkcs11_command = 'pkcs11-tool --module=/usr/lib/softhsm/libsofthsm2.so -O' | 259 | pkcs11_command = 'pkcs11-tool --module=/usr/lib/softhsm/libsofthsm2.so -O' |