Skip to content

Commit efa5969

Browse files
committed
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.
1 parent dd7ecb0 commit efa5969

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

feature/gnsi/acctz/tests/record_payload_truncation/record_payload_truncation_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,14 @@ func TestAccountzRecordPayloadTruncation(t *testing.T) {
7878
helpers.GnmiCLIConfig(t, dut, communitySetCLIConfig)
7979
}
8080

81-
startTime := time.Now()
82-
81+
// Get the current time from the router via gNMI to avoid clock skew issues.
82+
startTime := helpers.GetRouterTime(t, dut)
8383
acctzClient := dut.RawAPIs().GNSI(t).AcctzStream()
8484
acctzSubClient, err := acctzClient.RecordSubscribe(context.Background(), &acctzpb.RecordRequest{
85-
Timestamp: timestamppb.New(startTime),
85+
Timestamp: &timestamppb.Timestamp{
86+
Seconds: startTime.Unix(),
87+
Nanos: 0,
88+
},
8689
})
8790
if err != nil {
8891
t.Fatalf("Failed to subscribe to acctz records: %v", err)

feature/gnsi/acctz/tests/record_subscribe_full/record_subscribe_full_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626

2727
"github.com/openconfig/featureprofiles/internal/deviations"
2828
"github.com/openconfig/featureprofiles/internal/fptest"
29+
"github.com/openconfig/featureprofiles/internal/helpers"
2930
"github.com/openconfig/featureprofiles/internal/security/acctz"
3031
acctzpb "github.com/openconfig/gnsi/acctz"
3132
"github.com/openconfig/ondatra"
@@ -53,8 +54,8 @@ func TestAccountzRecordSubscribeFull(t *testing.T) {
5354
} else {
5455
acctz.SetupUsers(t, dut, false)
5556
}
56-
startTime := time.Now()
57-
57+
// Get the current time from the router via gNMI to avoid clock skew issues.
58+
startTime := helpers.GetRouterTime(t, dut)
5859
// Get gNSI record subscribe client.
5960
requestTimestamp := &timestamppb.Timestamp{
6061
Seconds: startTime.Unix(),

0 commit comments

Comments
 (0)