Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accountz-4.1 #3392

Merged
merged 4 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion feature/security/gnsi/acctz/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Create a library of device configuration to be used for all of the gNSI.acctz.v1
- [ACCTZ-1.1 Record Subscribe Full](RecordSubscribeFull)
- [ACCTZ-2.1 Record Subscribe Partial](RecordSubscribePartial)
- [ACCTZ-3.1 Record Subscribe Non-gRPC](RecordSubscribeNongrpc)
- [ACCTZ-4.1 Record History Truncation](RecordHistoryTruncation/)
- [ACCTZ-4.1 Record History Truncation](tests/record_history_truncation)
- [ACCTZ-4.2 Record Payload Truncation](RecordPayloadTruncation/)
- [ACCTZ-5.1 Record Subscribe Idle Timeout](RecordSubscribeIdleTimeout/)
- [ACCTZ-6.1 Record Subscribe Idle Timeout DoA](RecordSubscribeIdleTimeoutDoA/)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ACCTZ-4.1 - gNSI.acctz.v1 (Accounting) Test Record History Truncation
# ACCTZ-4.1: Record History Truncation

## Summary
Test Record Response Truncation boolean is set
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# proto-file: github.com/openconfig/featureprofiles/proto/metadata.proto
# proto-message: Metadata

uuid: "3ac6b788-687a-41c7-9324-0afb8d789e15"
plan_id: "ACCTZ-4.1"
description: "Record History Truncation"
testbed: TESTBED_DUT
platform_exceptions: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package record_history_truncation_test

import (
"context"
"testing"
"time"

"github.com/openconfig/featureprofiles/internal/fptest"
"github.com/openconfig/gnsi/acctz"
"github.com/openconfig/ondatra"
"github.com/openconfig/ondatra/gnmi"
"google.golang.org/protobuf/types/known/timestamppb"
)

func TestMain(m *testing.M) {
fptest.RunTests(m)
}

func TestAccountzRecordHistoryTruncation(t *testing.T) {
dut := ondatra.DUT(t, "dut")

systemState := gnmi.Get(t, dut, gnmi.OC().System().State())

bootTime := systemState.GetBootTime()

// try to get records from 1 day prior to device's boot time
recordStartTime := time.Unix(0, int64(bootTime)).Add(-24 * time.Hour)

acctzClient := dut.RawAPIs().GNSI(t).Acctz()

acctzSubClient, err := acctzClient.RecordSubscribe(context.Background())
if err != nil {
t.Fatalf("failed getting accountz record subscribe client, error: %s", err)
}

err = acctzSubClient.Send(&acctz.RecordRequest{
Timestamp: timestamppb.New(recordStartTime),
})
if err != nil {
t.Fatalf("failed sending record request, error: %s", err)
}

record, err := acctzSubClient.Recv()
if err != nil {
t.Fatalf("failed receiving from accountz record subscribe client, error: %s", err)
}

if record.GetHistoryIstruncated() != true {
t.Fatal("history is not truncated but should be")
}
}
Loading