Verified Commit 06d5ea25 authored by Karel Koci's avatar Karel Koci 🤘
Browse files

tests/sentinel: add basic tests for sentinel services

This only installs Sentinel components and checks if appropriate
services started.
parent 3c7282dd
......@@ -201,6 +201,26 @@ def fixture_basic_isp(lxd, board, client_board, wan):
client_board.run("uci commit network")
@pytest.fixture(name="updater_branch", scope="module")
def fixture_updater_branch(request, client_board):
"""Setup target branch to updater.
This is required as not in all branches is the target updater branch the build branch.
"""
if request.config.target_branch == "hbk":
# HBK needs special tweak as these medkits do not contain test key but repository is signed with it.
client_board.run("opkg update")
# TODO: We do not install package using opkg because of this open bug:
# https://gitlab.nic.cz/turris/updater/updater/-/issues/311
client_board.run("opkg download cznic-repo-keys-test")
client_board.run("pkgtransaction -a cznic-repo-keys-test_*.ipk || true")
# TODO: Install of cznic-repo-keys-test reports error as cert-backup does not work in systems running from RAM
client_board.run("rm -f cznic-repo-keys-test_*.ipk")
client_board.run(
f"uci set updater.turris.branch='{request.config.target_branch}' && uci commit updater.turris.branch")
yield request.config.target_branch
client_board.run("uci del updater.turris.branch && uci commit updater.turris.branch")
########################################################################################################################
# Reports enrichment ###################################################################################################
......
import pytest
@pytest.fixture(scope="module", autouse=True)
def fixture_sentinel(request, basic_isp, updater_branch, client_board):
"""Set that we agree with Sentinel EULA.
"""
client_board.run("uci add_list pkglists.pkglists.pkglist=datacollect && uci commit pkglists.pkglists")
request.addfinalizer(lambda: client_board.run(
"uci del_list pkglists.pkglists.pkglist=datacollect && uci commit pkglists.pkglists"))
client_board.run("pkgupdate --batch || true", timeout=120) # TODO updater fails because of schnapps hooks fail
client_board.run("uci set sentinel.main.agreed_with_eula_version=1 && uci commit sentinel.main")
request.addfinalizer(lambda: client_board.run(
"uci delete sentinel.main.agreed_with_eula_version && uci commit sentinel.main && sentinel-reload"))
client_board.run("sentinel-reload")
"""These tests just check that Sentinel components are running after installation.
"""
import pytest
from nsfarm.toolbox import service_is_running
sentinel_services = [
"sentinel-dynfw-client",
"sentinel-proxy",
"sentinel-minipot",
# TODO add sentinel-fwlogs replacing sentinel-nikola once deployed
]
@pytest.mark.parametrize("service", sentinel_services)
def test_service_running(client_board, service):
"""Check if expected processes we need for Sentinel are running and thus all should be correctly configured.
"""
assert service_is_running(service, client_board)
@pytest.mark.parametrize("service", sentinel_services)
def test_service_enabled(client_board, service):
"""Check if expected processes we need for Sentinel are running and thus all should be correctly configured.
"""
client_board.run(f"/etc/init.d/{service} enabled")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment