-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...i/acctz/RecordHistoryTruncation/README.md → ...tests/record_history_truncation/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
feature/security/gnsi/acctz/tests/record_history_truncation/metadata.textproto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: {} |
51 changes: 51 additions & 0 deletions
51
...ure/security/gnsi/acctz/tests/record_history_truncation/record_history_truncation_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 devices 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") | ||
} | ||
} |