Verified Commit 5909ade1 authored by Karel Koci's avatar Karel Koci 🤘
Browse files

nsfarm/toolbox: add check for running service

The idea of having one module called toolbox is simply to share common
short but still little bit complicated functions in multiple tests.

This also implements first test using this function. It checks if all
services we expect to run after router start are actually running.
parent 71785f37
"""This contains implementations of common actions that are commonly performed on router in tests.
"""
import json
from .cli import Shell
def service_is_running(service: str, shell: Shell):
"""Verifies if there is at least one process running and registered as part of requested service.
"""
shell.run(f"ubus -S call service list \"{{'name': '{service}'}}\"")
result = json.loads(shell.output)
instances = result.get(service, {}).get("instances", {})
return bool(instances)
......@@ -2,6 +2,7 @@
general errors such as disabled core services.
"""
import pytest
from nsfarm.toolbox import service_is_running
def test_syslog_ng(client_board):
......@@ -29,6 +30,29 @@ def test_processes(client_board, process):
client_board.run(f"pgrep -x '{process}' || pgrep -x \"$(which '{process}')\"")
@pytest.mark.parametrize("service", [
"cron",
"dnsmasq",
"kresd",
"foris-controller",
"foris-ws",
"fosquitto",
"haveged",
"lighttpd",
"network",
"odhcpd",
"rpcd",
"sshd",
"syslog-ng",
"sysntpd",
"umdns",
])
def test_services(client_board, service):
"""Check that various essential processes are running.
"""
assert service_is_running(service, client_board)
def test_lighttpd(client_board):
"""Test that there is access to router interface.
"""
......
Supports Markdown
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