Skip to content

add ntp test - #19

Draft
Yoda-Yothada wants to merge 1 commit into
mainfrom
yoda_ntp_test
Draft

add ntp test#19
Yoda-Yothada wants to merge 1 commit into
mainfrom
yoda_ntp_test

Conversation

@Yoda-Yothada

Copy link
Copy Markdown

add test_ntp.py and format with black

@Yoda-Yothada

Copy link
Copy Markdown
Author

NTP_SOURCES variable updated to match stackhpc/stackhpc-kayobe-config

MAX_OFFSET_SECONDS = 0.5 # 500 ms limit


def test_ntp_configuration_and_sync():

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the moment, everything here is in one test function. Could you refactor it a bit so each test is a different function? See the docker tests for an example of what that looks like.

You could divide it into four functions:

  1. Prechecks to ensure that NTP_SOURCES is set and formatted correctly
  2. Check that chrony is running, and that something is syncing properly
  3. Check that the sources match what are expected
  4. Check time offset

assert ntp_sources, "NTP_SOURCES contains no valid source entries."

# 2. Basic service check via timedatectl
timedate_res = subprocess.run(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The existing tests (like Docker and SELinux) use the host fixture from pytest-testinfra to run commands (host.check_output(...)) could we switch to that here for consistency?

@Yoda-Yothada
Yoda-Yothada marked this pull request as draft August 26, 2026 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants