1
0
mirror of https://github.com/home-assistant/supervisor.git synced 2026-04-02 08:12:47 +01:00
Files
supervisor/tests/resolution/check/test_check_deprecated_arch_addon.py
Stefan Agner 0ef71d1dd1 Drop unsupported architectures and machines, create issue for affected apps (#6607)
* Drop unsupported architectures and machines from Supervisor

Since #5620 Supervisor no longer updates the version information on
unsupported architectures and machines. This means users can no longer
update to newer version of Supervisor since that PR got released.
Furthermore since #6347 we also no longer build for these
architectures. With this, any code related to these architectures
becomes dead code and should be removed.

This commit removes all refrences to the deprecated architectures and
machines from Supervisor.

This affects the following architectures:
- armhf
- armv7
- i386

And the following machines:
- odroid-xu
- qemuarm
- qemux86
- raspberrypi
- raspberrypi2
- raspberrypi3
- raspberrypi4
- tinker

* Create issue if an app using a deprecated architecture is installed

This adds a check to the resolution system to detect if an app is
installed that uses a deprecated architecture. If so, it will show a
warning to the user and recommend them to uninstall the app.

* Formally deprecate machine add-on configs as well

Not only deprecate add-on configs for unsupported architectures, but
also for unsupported machines.

* For installed add-ons architecture must always exist

Fail hard in case of missing architecture, as this is a required field
for installed add-ons. This will prevent the Supervisor from running
with an unsupported configuration and causing further issues down the
line.
2026-03-04 10:59:14 +01:00

165 lines
5.5 KiB
Python

"""Test check for add-ons with deprecated architectures."""
from unittest.mock import patch
from supervisor.addons.addon import Addon
from supervisor.const import AddonStage, CoreState
from supervisor.coresys import CoreSys
from supervisor.resolution.checks.deprecated_arch_addon import CheckDeprecatedArchAddon
from supervisor.resolution.const import ContextType, IssueType, SuggestionType
async def test_base(coresys: CoreSys):
"""Test check basics."""
deprecated_arch_addon = CheckDeprecatedArchAddon(coresys)
assert deprecated_arch_addon.slug == "deprecated_arch_addon"
assert deprecated_arch_addon.enabled
async def test_check(coresys: CoreSys, install_addon_ssh: Addon):
"""Test check for installed add-ons with deprecated architectures."""
deprecated_arch_addon = CheckDeprecatedArchAddon(coresys)
await coresys.core.set_state(CoreState.SETUP)
await deprecated_arch_addon()
assert len(coresys.resolution.issues) == 0
install_addon_ssh.data["arch"] = ["armv7"]
await deprecated_arch_addon()
assert len(coresys.resolution.issues) == 1
assert coresys.resolution.issues[0].type is IssueType.DEPRECATED_ARCH_ADDON
assert coresys.resolution.issues[0].context is ContextType.ADDON
assert coresys.resolution.issues[0].reference == install_addon_ssh.slug
assert len(coresys.resolution.suggestions) == 1
assert coresys.resolution.suggestions[0].type is SuggestionType.EXECUTE_REMOVE
async def test_check_ignores_mixed_supported_arch(
coresys: CoreSys, install_addon_ssh: Addon
):
"""Test check does not create issue when a supported arch is still present."""
deprecated_arch_addon = CheckDeprecatedArchAddon(coresys)
await coresys.core.set_state(CoreState.SETUP)
install_addon_ssh.data["arch"] = ["armv7", "amd64"]
await deprecated_arch_addon()
assert len(coresys.resolution.issues) == 0
async def test_check_deprecated_machine(coresys: CoreSys, install_addon_ssh: Addon):
"""Test check for installed add-ons using deprecated machine entries."""
deprecated_arch_addon = CheckDeprecatedArchAddon(coresys)
await coresys.core.set_state(CoreState.SETUP)
install_addon_ssh.data["machine"] = ["raspberrypi3"]
await deprecated_arch_addon()
assert len(coresys.resolution.issues) == 1
assert coresys.resolution.issues[0].type is IssueType.DEPRECATED_ARCH_ADDON
assert coresys.resolution.suggestions[0].type is SuggestionType.EXECUTE_REMOVE
async def test_check_ignores_mixed_supported_machine(
coresys: CoreSys, install_addon_ssh: Addon
):
"""Test check does not create issue when current machine is still supported."""
deprecated_arch_addon = CheckDeprecatedArchAddon(coresys)
await coresys.core.set_state(CoreState.SETUP)
install_addon_ssh.data["machine"] = ["raspberrypi3", install_addon_ssh.sys_machine]
await deprecated_arch_addon()
assert len(coresys.resolution.issues) == 0
async def test_check_ignores_stage_deprecated(
coresys: CoreSys, install_addon_ssh: Addon
):
"""Test check does not create arch repair issue for already deprecated add-ons."""
deprecated_arch_addon = CheckDeprecatedArchAddon(coresys)
await coresys.core.set_state(CoreState.SETUP)
install_addon_ssh.data["stage"] = AddonStage.DEPRECATED
install_addon_ssh.data["arch"] = ["armv7"]
await deprecated_arch_addon()
assert len(coresys.resolution.issues) == 0
async def test_approve(coresys: CoreSys, install_addon_ssh: Addon):
"""Test approve existing deprecated arch addon issues."""
deprecated_arch_addon = CheckDeprecatedArchAddon(coresys)
await coresys.core.set_state(CoreState.SETUP)
assert (
await deprecated_arch_addon.approve_check(reference=install_addon_ssh.slug)
is False
)
install_addon_ssh.data["arch"] = ["armv7"]
assert (
await deprecated_arch_addon.approve_check(reference=install_addon_ssh.slug)
is True
)
install_addon_ssh.data["arch"] = ["armv7", "amd64"]
assert (
await deprecated_arch_addon.approve_check(reference=install_addon_ssh.slug)
is False
)
install_addon_ssh.data["arch"] = ["amd64"]
install_addon_ssh.data["machine"] = ["raspberrypi3"]
assert (
await deprecated_arch_addon.approve_check(reference=install_addon_ssh.slug)
is True
)
install_addon_ssh.data["machine"] = ["raspberrypi3", install_addon_ssh.sys_machine]
assert (
await deprecated_arch_addon.approve_check(reference=install_addon_ssh.slug)
is False
)
install_addon_ssh.data["stage"] = AddonStage.DEPRECATED
assert (
await deprecated_arch_addon.approve_check(reference=install_addon_ssh.slug)
is False
)
async def test_did_run(coresys: CoreSys):
"""Test that the check ran as expected."""
deprecated_arch_addon = CheckDeprecatedArchAddon(coresys)
should_run = deprecated_arch_addon.states
should_not_run = [state for state in CoreState if state not in should_run]
assert should_run == [CoreState.SETUP, CoreState.RUNNING]
assert len(should_not_run) != 0
with patch.object(
CheckDeprecatedArchAddon, "run_check", return_value=None
) as check:
for state in should_run:
await coresys.core.set_state(state)
await deprecated_arch_addon()
check.assert_called_once()
check.reset_mock()
for state in should_not_run:
await coresys.core.set_state(state)
await deprecated_arch_addon()
check.assert_not_called()
check.reset_mock()