From 45024dbca150fa08919d51a078660f45862f4eba Mon Sep 17 00:00:00 2001 From: pjacak Date: Wed, 29 Apr 2026 03:56:24 -0700 Subject: [PATCH] acctz: use helpers.GetRouterTime for RecordSubscribe timestamps The record_payload_truncation and record_subscribe_full tests use time.Now() from the test host as the RecordSubscribe request timestamp. Clock skew between the test host and DUT (~300-825ms observed) causes the acctz service to reject the timestamp as "in the future", resulting in deterministic test failures. Replace time.Now() with helpers.GetRouterTime() to source the timestamp from the DUT's own clock, matching the pattern already used in record_subscribe_non_grpc and record_subscribe_partial. --- .../record_payload_truncation_test.go | 9 ++++++--- .../record_subscribe_full/record_subscribe_full_test.go | 5 +++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/feature/gnsi/acctz/tests/record_payload_truncation/record_payload_truncation_test.go b/feature/gnsi/acctz/tests/record_payload_truncation/record_payload_truncation_test.go index 1736c034e18..6e762941a0a 100644 --- a/feature/gnsi/acctz/tests/record_payload_truncation/record_payload_truncation_test.go +++ b/feature/gnsi/acctz/tests/record_payload_truncation/record_payload_truncation_test.go @@ -78,11 +78,14 @@ func TestAccountzRecordPayloadTruncation(t *testing.T) { helpers.GnmiCLIConfig(t, dut, communitySetCLIConfig) } - startTime := time.Now() - + // Get the current time from the router via gNMI to avoid clock skew issues. + startTime := helpers.GetRouterTime(t, dut) acctzClient := dut.RawAPIs().GNSI(t).AcctzStream() acctzSubClient, err := acctzClient.RecordSubscribe(context.Background(), &acctzpb.RecordRequest{ - Timestamp: timestamppb.New(startTime), + Timestamp: ×tamppb.Timestamp{ + Seconds: startTime.Unix(), + Nanos: 0, + }, }) if err != nil { t.Fatalf("Failed to subscribe to acctz records: %v", err) diff --git a/feature/gnsi/acctz/tests/record_subscribe_full/record_subscribe_full_test.go b/feature/gnsi/acctz/tests/record_subscribe_full/record_subscribe_full_test.go index 7a2bdf8ba91..bc944053716 100644 --- a/feature/gnsi/acctz/tests/record_subscribe_full/record_subscribe_full_test.go +++ b/feature/gnsi/acctz/tests/record_subscribe_full/record_subscribe_full_test.go @@ -26,6 +26,7 @@ import ( "github.com/openconfig/featureprofiles/internal/deviations" "github.com/openconfig/featureprofiles/internal/fptest" + "github.com/openconfig/featureprofiles/internal/helpers" "github.com/openconfig/featureprofiles/internal/security/acctz" acctzpb "github.com/openconfig/gnsi/acctz" "github.com/openconfig/ondatra" @@ -53,8 +54,8 @@ func TestAccountzRecordSubscribeFull(t *testing.T) { } else { acctz.SetupUsers(t, dut, false) } - startTime := time.Now() - + // Get the current time from the router via gNMI to avoid clock skew issues. + startTime := helpers.GetRouterTime(t, dut) // Get gNSI record subscribe client. requestTimestamp := ×tamppb.Timestamp{ Seconds: startTime.Unix(),