sssd_test_framework.utils.chrony
Chrony Utilities
Classes
|
Interface for manipulating system time via chrony. |
- class sssd_test_framework.utils.chrony.ChronyUtils(*args, **kwargs)
Bases:
MultihostUtility[MultihostHost]Interface for manipulating system time via chrony.
time_skew()takes seconds (signed): forward if non-negative, backward if negative (e.g.86400for one day forward,-3600for one hour back). It is a context manager: skew applies for thewithbody, then the clock is restored. If chronyd cannot enter manual mode, the current test is skipped viapytest.skip(). Ifsettimefails after that,RuntimeErroris raised.Example usage@pytest.mark.topology(KnownTopology.LDAP) def test_clock_skew(client: Client, provider: GenericProvider, kdc: KDC): # ... setup ... if not client.chrony.is_available(): pytest.skip("chronyc not available") with client.chrony.time_skew(24 * 60 * 60): # +1 day auth_ok = client.auth.ssh.password("user", "Secret123") assert not auth_ok, "Auth should fail due to clock skew!"
- Parameters:
host (MultihostHost) – Multihost host.
- is_available() bool
Check if
chronycis available on the host.- Returns:
True if chronyc is found, False otherwise.
- Return type:
bool
- time_skew(seconds: int) Generator[None, None, None]
Context manager that skews the system clock and restores it afterward.
Restarts
chronyd, enables manual mode, applies the offset viachronyc settime, then yields for thewithbody. On exit (normal or exception), the saved time is restored and NTP is re-synced.- Parameters:
seconds (int) – Signed offset in seconds (forward if non-negative, backward if negative; e.g.
86400for one day forward,-3600for one hour back).- Yields:
None— run assertions or steps while the clock is skewed.
If
chronydrestart orchronyc manual onfails, the current test is skipped viapytest.skip().- Raises:
RuntimeError – If the
settimebatch fails once manual mode is on.