Skip to content

Commit

Permalink
Accountz-4.1 (openconfig#3392)
Browse files Browse the repository at this point in the history
* Accountz-4.1

"This code is a Contribution to the OpenConfig Feature Profiles project ("Work") made under the Google Software Grant and Corporate Contributor License Agreement ("CLA") and governed by the Apache License 2.0. No other rights or licenses in or to any of Nokia's intellectual property are granted for any other purpose. This code is provided on an "as is" basis without any warranties of any kind."

* Fix comments

"This code is a Contribution to the OpenConfig Feature Profiles project ("Work") made under the Google Software Grant and Corporate Contributor License Agreement ("CLA") and governed by the Apache License 2.0. No other rights or licenses in or to any of Nokia's intellectual property are granted for any other purpose. This code is provided on an "as is" basis without any warranties of any kind."
  • Loading branch information
dipchauh authored and ANISH-GOTTAPU committed Nov 28, 2024
1 parent 593dfff commit 7c25812
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 2 deletions.
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](tests/record_subscribe_full)
- [ACCTZ-2.1 Record Subscribe Partial](tests/record_subscribe_partial)
- [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](tests/record_payload_truncation)
- [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,65 @@
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

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.")
}
}

0 comments on commit 7c25812

Please sign in to comment.