mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-12-25 04:46:25 +00:00
Add startup time and boot_timestamp (#3136)
* Add startup time * Add boot_timestamp * Fix type * patch and rename properties fixture
This commit is contained in:
27
tests/dbus/test_systemd.py
Normal file
27
tests/dbus/test_systemd.py
Normal file
@@ -0,0 +1,27 @@
|
||||
"""Test hostname dbus interface."""
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
from supervisor.coresys import CoreSys
|
||||
from supervisor.dbus.const import DBUS_NAME_SYSTEMD
|
||||
|
||||
from tests.common import load_json_fixture
|
||||
|
||||
|
||||
async def test_dbus_systemd_info(coresys: CoreSys):
|
||||
"""Test coresys dbus connection."""
|
||||
assert coresys.dbus.systemd.boot_timestamp is None
|
||||
assert coresys.dbus.systemd.startup_time is None
|
||||
|
||||
await coresys.dbus.systemd.connect()
|
||||
|
||||
async def mock_get_properties(dbus_obj, interface):
|
||||
return load_json_fixture(
|
||||
f"{DBUS_NAME_SYSTEMD.replace('.', '_')}_properties.json"
|
||||
)
|
||||
|
||||
with patch("supervisor.utils.gdbus.DBus.get_properties", new=mock_get_properties):
|
||||
await coresys.dbus.systemd.update()
|
||||
|
||||
assert coresys.dbus.systemd.boot_timestamp == 1632236713344227
|
||||
assert coresys.dbus.systemd.startup_time == 45.304696
|
||||
138
tests/fixtures/org_freedesktop_systemd1_properties.json
vendored
Normal file
138
tests/fixtures/org_freedesktop_systemd1_properties.json
vendored
Normal file
@@ -0,0 +1,138 @@
|
||||
{
|
||||
"Version": "245.4-4ubuntu3.11",
|
||||
"Features": "+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD +IDN2 -IDN +PCRE2 default-hierarchy=hybrid",
|
||||
"Virtualization": "",
|
||||
"Architecture": "x86-64",
|
||||
"Tainted": "",
|
||||
"FirmwareTimestamp": 0,
|
||||
"FirmwareTimestampMonotonic": 28723572,
|
||||
"LoaderTimestamp": 0,
|
||||
"LoaderTimestampMonotonic": 12402885,
|
||||
"KernelTimestamp": 1632236694969442,
|
||||
"KernelTimestampMonotonic": 0,
|
||||
"InitRDTimestamp": 0,
|
||||
"InitRDTimestampMonotonic": 0,
|
||||
"UserspaceTimestamp": 1632236699147681,
|
||||
"UserspaceTimestampMonotonic": 4178239,
|
||||
"FinishTimestamp": 1632236713344227,
|
||||
"FinishTimestampMonotonic": 18374785,
|
||||
"SecurityStartTimestamp": 1632236699156494,
|
||||
"SecurityStartTimestampMonotonic": 4187052,
|
||||
"SecurityFinishTimestamp": 1632236699156980,
|
||||
"SecurityFinishTimestampMonotonic": 4187538,
|
||||
"GeneratorsStartTimestamp": 1632236699281427,
|
||||
"GeneratorsStartTimestampMonotonic": 4311984,
|
||||
"GeneratorsFinishTimestamp": 1632236699334042,
|
||||
"GeneratorsFinishTimestampMonotonic": 4364600,
|
||||
"UnitsLoadStartTimestamp": 1632236699334044,
|
||||
"UnitsLoadStartTimestampMonotonic": 4364602,
|
||||
"UnitsLoadFinishTimestamp": 1632236699424558,
|
||||
"UnitsLoadFinishTimestampMonotonic": 4455116,
|
||||
"InitRDSecurityStartTimestamp": 0,
|
||||
"InitRDSecurityStartTimestampMonotonic": 0,
|
||||
"InitRDSecurityFinishTimestamp": 0,
|
||||
"InitRDSecurityFinishTimestampMonotonic": 0,
|
||||
"InitRDGeneratorsStartTimestamp": 0,
|
||||
"InitRDGeneratorsStartTimestampMonotonic": 0,
|
||||
"InitRDGeneratorsFinishTimestamp": 0,
|
||||
"InitRDGeneratorsFinishTimestampMonotonic": 0,
|
||||
"InitRDUnitsLoadStartTimestamp": 0,
|
||||
"InitRDUnitsLoadStartTimestampMonotonic": 0,
|
||||
"InitRDUnitsLoadFinishTimestamp": 0,
|
||||
"InitRDUnitsLoadFinishTimestampMonotonic": 0,
|
||||
"LogLevel": "info",
|
||||
"LogTarget": "journal-or-kmsg",
|
||||
"NNames": 564,
|
||||
"NFailedUnits": 0,
|
||||
"NJobs": 0,
|
||||
"NInstalledJobs": 1575,
|
||||
"NFailedJobs": 0,
|
||||
"Progress": 1.0,
|
||||
"Environment": [
|
||||
"LANG=en_US.UTF-8",
|
||||
"LC_ADDRESS=nb_NO.UTF-8",
|
||||
"LC_IDENTIFICATION=nb_NO.UTF-8",
|
||||
"LC_MEASUREMENT=nb_NO.UTF-8",
|
||||
"LC_MONETARY=nb_NO.UTF-8",
|
||||
"LC_NAME=nb_NO.UTF-8",
|
||||
"LC_NUMERIC=nb_NO.UTF-8",
|
||||
"LC_PAPER=nb_NO.UTF-8",
|
||||
"LC_TELEPHONE=nb_NO.UTF-8",
|
||||
"LC_TIME=nb_NO.UTF-8",
|
||||
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
|
||||
],
|
||||
"ConfirmSpawn": false,
|
||||
"ShowStatus": false,
|
||||
"UnitPath": [
|
||||
"/etc/systemd/system.control",
|
||||
"/run/systemd/system.control",
|
||||
"/run/systemd/transient",
|
||||
"/run/systemd/generator.early",
|
||||
"/etc/systemd/system",
|
||||
"/etc/systemd/system.attached",
|
||||
"/run/systemd/system",
|
||||
"/run/systemd/system.attached",
|
||||
"/run/systemd/generator",
|
||||
"/usr/local/lib/systemd/system",
|
||||
"/lib/systemd/system",
|
||||
"/usr/lib/systemd/system",
|
||||
"/run/systemd/generator.late"
|
||||
],
|
||||
"DefaultStandardOutput": "journal",
|
||||
"DefaultStandardError": "journal",
|
||||
"RuntimeWatchdogUSec": 0,
|
||||
"RebootWatchdogUSec": 600000000,
|
||||
"KExecWatchdogUSec": 0,
|
||||
"ServiceWatchdogs": true,
|
||||
"ControlGroup": "",
|
||||
"SystemState": "running",
|
||||
"ExitCode": [
|
||||
0
|
||||
],
|
||||
"DefaultTimerAccuracyUSec": 60000000,
|
||||
"DefaultTimeoutStartUSec": 90000000,
|
||||
"DefaultTimeoutStopUSec": 90000000,
|
||||
"DefaultTimeoutAbortUSec": 90000000,
|
||||
"DefaultRestartUSec": 100000,
|
||||
"DefaultStartLimitIntervalUSec": 10000000,
|
||||
"DefaultStartLimitBurst": 5,
|
||||
"DefaultCPUAccounting": false,
|
||||
"DefaultBlockIOAccounting": false,
|
||||
"DefaultMemoryAccounting": true,
|
||||
"DefaultTasksAccounting": true,
|
||||
"DefaultLimitCPU": 18446744073709551615,
|
||||
"DefaultLimitCPUSoft": 18446744073709551615,
|
||||
"DefaultLimitFSIZE": 18446744073709551615,
|
||||
"DefaultLimitFSIZESoft": 18446744073709551615,
|
||||
"DefaultLimitDATA": 18446744073709551615,
|
||||
"DefaultLimitDATASoft": 18446744073709551615,
|
||||
"DefaultLimitSTACK": 18446744073709551615,
|
||||
"DefaultLimitSTACKSoft": 8388608,
|
||||
"DefaultLimitCORE": 18446744073709551615,
|
||||
"DefaultLimitCORESoft": 0,
|
||||
"DefaultLimitRSS": 18446744073709551615,
|
||||
"DefaultLimitRSSSoft": 18446744073709551615,
|
||||
"DefaultLimitNOFILE": 524288,
|
||||
"DefaultLimitNOFILESoft": 1024,
|
||||
"DefaultLimitAS": 18446744073709551615,
|
||||
"DefaultLimitASSoft": 18446744073709551615,
|
||||
"DefaultLimitNPROC": 127764,
|
||||
"DefaultLimitNPROCSoft": 127764,
|
||||
"DefaultLimitMEMLOCK": 65536,
|
||||
"DefaultLimitMEMLOCKSoft": 65536,
|
||||
"DefaultLimitLOCKS": 18446744073709551615,
|
||||
"DefaultLimitLOCKSSoft": 18446744073709551615,
|
||||
"DefaultLimitSIGPENDING": 127764,
|
||||
"DefaultLimitSIGPENDINGSoft": 127764,
|
||||
"DefaultLimitMSGQUEUE": 819200,
|
||||
"DefaultLimitMSGQUEUESoft": 819200,
|
||||
"DefaultLimitNICE": 0,
|
||||
"DefaultLimitNICESoft": 0,
|
||||
"DefaultLimitRTPRIO": 0,
|
||||
"DefaultLimitRTPRIOSoft": 0,
|
||||
"DefaultLimitRTTIME": 18446744073709551615,
|
||||
"DefaultLimitRTTIMESoft": 18446744073709551615,
|
||||
"DefaultTasksMax": 38329,
|
||||
"TimerSlackNSec": 50000,
|
||||
"DefaultOOMPolicy": "stop"
|
||||
}
|
||||
Reference in New Issue
Block a user