1
0
mirror of https://github.com/home-assistant/supervisor.git synced 2026-04-17 23:33:35 +01:00

Support armv7 and allow support of multible arch types per CPU (#892)

* Support armv7 and first abstraction

* Change layout

* Add more type hints

* Fix imports

* Update

* move forward

* add tests

* fix type

* fix lint & tests

* fix tests

* Fix unittests

* Fix create folder

* cleanup

* Fix import order

* cleanup loop parameter

* cleanup init function

* Allow changeable image name

* fix setup

* Fix load of arch

* Fix lint

* Add typing

* fix init

* fix hassos cli problem & stick on supervisor arch

* address comments

* cleanup

* Fix image selfheal

* Add comment

* update uvloop

* remove uvloop

* fix tagging

* Fix install name

* Fix validate build config

* Abstract image_name from system cache
This commit is contained in:
Pascal Vizeli
2019-01-31 18:47:44 +01:00
committed by GitHub
parent 118a2e1951
commit 35aae69f23
33 changed files with 1019 additions and 457 deletions

View File

@@ -40,10 +40,12 @@ def test_invalid_repository():
with pytest.raises(vol.Invalid):
vd.SCHEMA_ADDON_CONFIG(config)
config['image'] = "registry.gitlab.com/company/add-ons/test-example/text-example:no-tag-allow"
config[
'image'] = "registry.gitlab.com/company/add-ons/test-example/text-example:no-tag-allow"
with pytest.raises(vol.Invalid):
vd.SCHEMA_ADDON_CONFIG(config)
def test_valid_repository():
"""Validate basic config with different valid repositories"""
config = load_json_fixture("basic-addon-config.json")
@@ -59,4 +61,11 @@ def test_valid_map():
config = load_json_fixture("basic-addon-config.json")
config['map'] = ['backup:rw', 'ssl:ro', 'config']
valid_config = vd.SCHEMA_ADDON_CONFIG(config)
vd.SCHEMA_ADDON_CONFIG(config)
def test_valid_basic_build():
"""Validate basic build config."""
config = load_json_fixture("basic-build-config.json")
vd.SCHEMA_BUILD_CONFIG(config)

42
tests/conftest.py Normal file
View File

@@ -0,0 +1,42 @@
"""Common test functions."""
from unittest.mock import patch, PropertyMock, MagicMock
import pytest
from hassio.bootstrap import initialize_coresys
# pylint: disable=redefined-outer-name
@pytest.fixture
def docker():
"""Mock Docker API."""
with patch('hassio.coresys.DockerAPI') as mock:
yield mock
@pytest.fixture
async def coresys(loop, docker):
"""Create a CoreSys Mock."""
with patch('hassio.bootstrap.initialize_system_data'):
coresys_obj = await initialize_coresys()
yield coresys_obj
@pytest.fixture
def sys_machine():
"""Mock sys_machine."""
with patch(
'hassio.coresys.CoreSys.machine',
new_callable=PropertyMock) as mock:
yield mock
@pytest.fixture
def sys_supervisor():
with patch(
'hassio.coresys.CoreSys.supervisor',
new_callable=PropertyMock) as mock:
mock.return_value = MagicMock()
yield MagicMock

11
tests/fixtures/basic-build-config.json vendored Normal file
View File

@@ -0,0 +1,11 @@
{
"build_from": {
"armhf": "mycustom/base-image:latest",
"aarch64": "mycustom/base-image",
"amd64": "homeassistant/amd64-base-ubuntu:18.04"
},
"squash": false,
"args": {
"my_build_arg": "xy"
}
}

149
tests/test_arch.py Normal file
View File

@@ -0,0 +1,149 @@
"""Test arch object."""
async def test_machine_not_exits(coresys, sys_machine, sys_supervisor):
"""Test arch for raspberrypi."""
sys_machine.return_value = None
sys_supervisor.arch = "amd64"
await coresys.arch.load()
assert coresys.arch.default == "amd64"
assert coresys.arch.supported == ["amd64"]
async def test_machine_not_exits_in_db(coresys, sys_machine, sys_supervisor):
"""Test arch for raspberrypi."""
sys_machine.return_value = "jedi-master-knight"
sys_supervisor.arch = "amd64"
await coresys.arch.load()
assert coresys.arch.default == "amd64"
assert coresys.arch.supported == ["amd64"]
async def test_supervisor_arch(coresys, sys_machine, sys_supervisor):
"""Test arch for raspberrypi."""
sys_machine.return_value = None
sys_supervisor.arch = "amd64"
assert coresys.arch.supervisor == "amd64"
await coresys.arch.load()
assert coresys.arch.supervisor == "amd64"
async def test_raspberrypi_arch(coresys, sys_machine):
"""Test arch for raspberrypi."""
sys_machine.return_value = "raspberrypi"
await coresys.arch.load()
assert coresys.arch.default == "armhf"
assert coresys.arch.supported == ["armhf"]
async def test_raspberrypi2_arch(coresys, sys_machine):
"""Test arch for raspberrypi2."""
sys_machine.return_value = "raspberrypi2"
await coresys.arch.load()
assert coresys.arch.default == "armhf"
assert coresys.arch.supported == ["armhf"]
async def test_raspberrypi3_arch(coresys, sys_machine):
"""Test arch for raspberrypi3."""
sys_machine.return_value = "raspberrypi3"
await coresys.arch.load()
assert coresys.arch.default == "armhf"
assert coresys.arch.supported == ["armhf"]
async def test_raspberrypi3_64_arch(coresys, sys_machine):
"""Test arch for raspberrypi3_64."""
sys_machine.return_value = "raspberrypi3-64"
await coresys.arch.load()
assert coresys.arch.default == "aarch64"
assert coresys.arch.supported == ["aarch64", "armhf"]
async def test_tinker_arch(coresys, sys_machine):
"""Test arch for tinker."""
sys_machine.return_value = "tinker"
await coresys.arch.load()
assert coresys.arch.default == "armhf"
assert coresys.arch.supported == ["armhf"]
async def test_odroid_c2_arch(coresys, sys_machine):
"""Test arch for odroid-c2."""
sys_machine.return_value = "odroid-c2"
await coresys.arch.load()
assert coresys.arch.default == "aarch64"
assert coresys.arch.supported == ["aarch64"]
async def test_odroid_xu_arch(coresys, sys_machine):
"""Test arch for odroid-xu."""
sys_machine.return_value = "odroid-xu"
await coresys.arch.load()
assert coresys.arch.default == "armhf"
assert coresys.arch.supported == ["armhf"]
async def test_orangepi_prime_arch(coresys, sys_machine):
"""Test arch for orangepi_prime."""
sys_machine.return_value = "orangepi-prime"
await coresys.arch.load()
assert coresys.arch.default == "aarch64"
assert coresys.arch.supported == ["aarch64"]
async def test_intel_nuc_arch(coresys, sys_machine):
"""Test arch for intel-nuc."""
sys_machine.return_value = "intel-nuc"
await coresys.arch.load()
assert coresys.arch.default == "amd64"
assert coresys.arch.supported == ["amd64", "i386"]
async def test_qemux86_arch(coresys, sys_machine):
"""Test arch for qemux86."""
sys_machine.return_value = "qemux86"
await coresys.arch.load()
assert coresys.arch.default == "i386"
assert coresys.arch.supported == ["i386"]
async def test_qemux86_64_arch(coresys, sys_machine):
"""Test arch for qemux86-64."""
sys_machine.return_value = "qemux86-64"
await coresys.arch.load()
assert coresys.arch.default == "amd64"
assert coresys.arch.supported == ["amd64", "i386"]
async def test_qemuarm_arch(coresys, sys_machine):
"""Test arch for qemuarm."""
sys_machine.return_value = "qemuarm"
await coresys.arch.load()
assert coresys.arch.default == "armhf"
assert coresys.arch.supported == ["armhf"]
async def test_qemuarm_64_arch(coresys, sys_machine):
"""Test arch for qemuarm-64."""
sys_machine.return_value = "qemuarm-64"
await coresys.arch.load()
assert coresys.arch.default == "aarch64"
assert coresys.arch.supported == ["aarch64"]