mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-06 18:22:04 -04:00
[9.20] fix: test: Use UTC timezone when handling keys in kasp test library
When working with key timestamps, ensure we correctly set the UTC timezone in order for the tests to work consistently regardless of the local time setting. Closes #4999 Backport of MR !9673 Merge branch 'backport-4999-pytest-kasp-use-utc-timezone-9.20' into 'bind-9.20' See merge request isc-projects/bind9!9679
This commit is contained in:
commit
36cac5d27d
2 changed files with 6 additions and 4 deletions
|
|
@ -901,6 +901,7 @@ system:gcc:bookworm:amd64:
|
|||
<<: *system_test_gcov_job
|
||||
variables:
|
||||
CI_ENABLE_ALL_TESTS: 1
|
||||
TZ: Australia/Sydney
|
||||
needs:
|
||||
- job: unit:gcc:bookworm:amd64
|
||||
artifacts: true
|
||||
|
|
|
|||
|
|
@ -17,8 +17,7 @@ import subprocess
|
|||
import time
|
||||
from typing import Optional, Union
|
||||
|
||||
from datetime import datetime
|
||||
from datetime import timedelta
|
||||
from datetime import datetime, timedelta, timezone
|
||||
|
||||
import dns
|
||||
import isctest.log
|
||||
|
|
@ -54,7 +53,9 @@ class KeyTimingMetadata:
|
|||
def __init__(self, timestamp: str):
|
||||
if int(timestamp) <= 0:
|
||||
raise ValueError(f'invalid timing metadata value: "{timestamp}"')
|
||||
self.value = datetime.strptime(timestamp, self.FORMAT)
|
||||
self.value = datetime.strptime(timestamp, self.FORMAT).replace(
|
||||
tzinfo=timezone.utc
|
||||
)
|
||||
|
||||
def __repr__(self):
|
||||
return self.value.strftime(self.FORMAT)
|
||||
|
|
@ -95,7 +96,7 @@ class KeyTimingMetadata:
|
|||
@staticmethod
|
||||
def now() -> "KeyTimingMetadata":
|
||||
result = KeyTimingMetadata.__new__(KeyTimingMetadata)
|
||||
result.value = datetime.now()
|
||||
result.value = datetime.now(timezone.utc)
|
||||
return result
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue