Verify Linux installer architecture selection and display available targets
This commit is contained in:
@@ -56,9 +56,11 @@ class EnrollmentRetry(unittest.TestCase):
|
||||
lifecycle.device_idle()
|
||||
self.assertEqual(output.getvalue().strip(), expected)
|
||||
|
||||
def bootstrap_tenant(self, tenant):
|
||||
def bootstrap_tenant(self, tenant, expected_platform=None):
|
||||
def answer(source, route, target):
|
||||
self.assertEqual(source, (self.base,'0' * 64))
|
||||
if expected_platform:
|
||||
self.assertEqual(route, '/agent/v1/bootstrap/current?platform=' + expected_platform)
|
||||
target.write_text(json.dumps({'tenant_id': tenant}))
|
||||
return self.stack.enter_context(patch.object(lifecycle,'remote',side_effect=answer))
|
||||
|
||||
@@ -80,6 +82,29 @@ class EnrollmentRetry(unittest.TestCase):
|
||||
self.save.assert_called_once()
|
||||
self.healthy.assert_called_once_with('1.0',0)
|
||||
|
||||
def test_arm64_install_retry_requests_arm64_release(self):
|
||||
self.bootstrap_tenant(self.tenant, 'aarch64-unknown-linux-gnu')
|
||||
with patch.object(lifecycle.platform, 'machine', return_value='aarch64'):
|
||||
lifecycle.install(self.base, self.token, enable_admin_scripts=True)
|
||||
self.save.assert_called_once()
|
||||
self.provision.assert_called_once_with(True)
|
||||
|
||||
def test_unsupported_architecture_stops_before_enrollment(self):
|
||||
with patch.object(lifecycle.platform, 'machine', return_value='armv7l'), \
|
||||
patch.object(lifecycle, 'enrollment_token') as token:
|
||||
with self.assertRaisesRegex(ValueError, 'Linux x86-64 or ARM64 required'):
|
||||
lifecycle.install(self.base, self.token)
|
||||
token.assert_not_called()
|
||||
self.enable.assert_not_called()
|
||||
|
||||
def test_x64_release_is_rejected_before_downloading_to_arm64(self):
|
||||
doc = {'manifest': {'release_id': self.tenant, 'platform': 'x86_64-unknown-linux-gnu'}}
|
||||
with patch.object(lifecycle.platform, 'machine', return_value='aarch64'), \
|
||||
patch.object(lifecycle, 'remote') as download:
|
||||
with self.assertRaisesRegex(ValueError, 'release architecture differs'):
|
||||
lifecycle.pair(lifecycle.ROOT, doc, (self.base, '0' * 64), lifecycle.ROOT / 'updater')
|
||||
download.assert_not_called()
|
||||
|
||||
def test_timer_starts_only_after_confirmed_first_connection(self):
|
||||
self.bootstrap_tenant(self.tenant)
|
||||
self.healthy.return_value = False
|
||||
|
||||
Reference in New Issue
Block a user