sssd_test_framework.utils.chrony

Chrony Utilities

Classes

ChronyUtils(*args, **kwargs)

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. 86400 for one day forward, -3600 for one hour back). It is a context manager: skew applies for the with body, then the clock is restored. If chronyd cannot enter manual mode, the current test is skipped via pytest.skip(). If settime fails after that, RuntimeError is 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 chronyc is 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 via chronyc settime, then yields for the with body. 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. 86400 for one day forward, -3600 for one hour back).

Yields:

None — run assertions or steps while the clock is skewed.

If chronyd restart or chronyc manual on fails, the current test is skipped via pytest.skip().

Raises:

RuntimeError – If the settime batch fails once manual mode is on.