Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
85 changes: 0 additions & 85 deletions compliance/compliance.go
Original file line number Diff line number Diff line change
Expand Up @@ -565,20 +565,6 @@ var (
Reference: "TE-3.1.1",
ShortName: "Error: Invalid prefix for the IPv4Entry",
},
}, {
In: Test{
Fn: IPv4EntryMissingNextHopGroup,
Reference: "TE-3.1.2",
ShortName: "Error: Missing NextHopGroup for the IPv4Entry",
RequiresDisallowedForwardReferences: true,
},
}, {
In: Test{
Fn: IPv4EntryEmptyNextHopGroup,
Reference: "TE-3.1.3",
ShortName: "Error: Empty NextHopGroup for the IPv4Entry",
RequiresDisallowedForwardReferences: true,
},
}}
)

Expand Down Expand Up @@ -2075,74 +2061,3 @@ func IPv4EntryInvalidPrefix(c *fluent.GRIBIClient, t testing.TB, _ ...TestOpt) {
AsResult(),
chk.IgnoreOperationID())
}

// IPv4EntryMissingNextHopGroup - Missing NextHopGroup for the IPv4Entry 203.0.113.1/32.
func IPv4EntryMissingNextHopGroup(c *fluent.GRIBIClient, t testing.TB, _ ...TestOpt) {
defer flushServer(c, t)

ops := []func(){
func() {
c.Modify().AddEntry(t, fluent.NextHopEntry().WithNetworkInstance(defaultNetworkInstanceName).WithIndex(1).WithIPAddress("192.0.2.3"))
// NB: NHG 11 has not been defined
c.Modify().AddEntry(t, fluent.IPv4Entry().WithPrefix("203.0.113.1/32").WithNetworkInstance(defaultNetworkInstanceName).WithNextHopGroup(11))
},
}

res := DoModifyOps(c, t, ops, fluent.InstalledInFIB, false)

chk.HasResult(t, res,
fluent.OperationResult().
WithNextHopOperation(1).
WithOperationType(constants.Add).
WithProgrammingResult(fluent.InstalledInFIB).
AsResult(),
chk.IgnoreOperationID())

chk.HasResult(t, res,
fluent.OperationResult().
WithIPv4Operation("203.0.113.1/32").
WithOperationType(constants.Add).
WithProgrammingResult(fluent.ProgrammingFailed).
AsResult(),
chk.IgnoreOperationID())
}

// IPv4EntryEmptyNextHopGroup - Empty NextHopGroup for the IPv4Entry 203.0.113.1/32.
func IPv4EntryEmptyNextHopGroup(c *fluent.GRIBIClient, t testing.TB, _ ...TestOpt) {
defer flushServer(c, t)

ops := []func(){
func() {
c.Modify().AddEntry(t, fluent.NextHopEntry().WithNetworkInstance(defaultNetworkInstanceName).WithIndex(1).WithIPAddress("192.0.2.3"))
// // NB: NHG is specified to not include any NHs
c.Modify().AddEntry(t, fluent.NextHopGroupEntry().WithNetworkInstance(defaultNetworkInstanceName).WithID(11))
c.Modify().AddEntry(t, fluent.IPv4Entry().WithPrefix("203.0.113.1/32").WithNetworkInstance(defaultNetworkInstanceName).WithNextHopGroup(11))
},
}

res := DoModifyOps(c, t, ops, fluent.InstalledInFIB, false)

chk.HasResult(t, res,
fluent.OperationResult().
WithNextHopOperation(1).
WithOperationType(constants.Add).
WithProgrammingResult(fluent.InstalledInFIB).
AsResult(),
chk.IgnoreOperationID())

chk.HasResult(t, res,
fluent.OperationResult().
WithNextHopGroupOperation(11).
WithOperationType(constants.Add).
WithProgrammingResult(fluent.ProgrammingFailed).
AsResult(),
chk.IgnoreOperationID())

chk.HasResult(t, res,
fluent.OperationResult().
WithIPv4Operation("203.0.113.1/32").
WithOperationType(constants.Add).
WithProgrammingResult(fluent.ProgrammingFailed).
AsResult(),
chk.IgnoreOperationID())
}
7 changes: 6 additions & 1 deletion compliance/compliance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ import (
)

func TestCompliance(t *testing.T) {
for _, tt := range TestSuite {
runTests(t, TestSuite)
runTests(t, FibAckComplianceTestSuite)
}

func runTests(t *testing.T, ts []*TestSpec) {
for _, tt := range ts {
t.Run(tt.In.ShortName, func(t *testing.T) {
cfg := &ocrt.Device{}
cfg.GetOrCreateNetworkInstance(server.DefaultNetworkInstanceName).Type = ocrt.NetworkInstanceTypes_NETWORK_INSTANCE_TYPE_DEFAULT_INSTANCE
Expand Down
116 changes: 116 additions & 0 deletions compliance/fiback_compliance.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
// Copyright 2025 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 compliance encapsulates a set of compliance tests for gRIBI. It is a test only
// library. All tests are of the form func(c *fluent.GRIBIClient, t testing.TB) where the
// client is the one that should be used for the test. The testing.TB object is used to report
// errors.
package compliance

import (
"testing"

"github.com/openconfig/gribigo/chk"
"github.com/openconfig/gribigo/constants"
"github.com/openconfig/gribigo/fluent"
)

var (
FibAckComplianceTestSuite = []*TestSpec{{

Check failure on line 30 in compliance/fiback_compliance.go

View workflow job for this annotation

GitHub Actions / go / Static Analysis

exported var FibAckComplianceTestSuite should have comment or be unexported
In: Test{
Fn: IPv4EntryMissingNextHopGroup,
Reference: "TE-3.1.2",
ShortName: "Error: Missing NextHopGroup for the IPv4Entry",
RequiresDisallowedForwardReferences: true,
},
}, {
In: Test{
Fn: IPv4EntryEmptyNextHopGroup,
Reference: "TE-3.1.3",
ShortName: "Error: Empty NextHopGroup for the IPv4Entry",
RequiresDisallowedForwardReferences: true,
},
}}
)

// IPv4EntryMissingNextHopGroup - Missing NextHopGroup for the IPv4Entry 203.0.113.1/32.
func IPv4EntryMissingNextHopGroup(c *fluent.GRIBIClient, t testing.TB, _ ...TestOpt) {
defer flushServer(c, t)

ops := []func(){
func() {
c.Modify().AddEntry(t, fluent.NextHopEntry().WithNetworkInstance(defaultNetworkInstanceName).WithIndex(1).WithIPAddress("192.0.2.3"))
// NB: NHG 11 has not been defined
c.Modify().AddEntry(t, fluent.IPv4Entry().WithPrefix("203.0.113.1/32").WithNetworkInstance(defaultNetworkInstanceName).WithNextHopGroup(11))
},
}

res := DoModifyOps(c, t, ops, fluent.InstalledInFIB, false)

chk.HasResult(t, res,
fluent.OperationResult().
WithNextHopOperation(1).
WithOperationType(constants.Add).
WithProgrammingResult(fluent.InstalledInFIB).
AsResult(),
chk.IgnoreOperationID())

chk.HasResult(t, res,
fluent.OperationResult().
WithIPv4Operation("203.0.113.1/32").
WithOperationType(constants.Add).
WithProgrammingResult(fluent.ProgrammingFailed).
AsResult(),
chk.IgnoreOperationID())
}

// IPv4EntryEmptyNextHopGroup - Empty NextHopGroup for the IPv4Entry 203.0.113.1/32.
func IPv4EntryEmptyNextHopGroup(c *fluent.GRIBIClient, t testing.TB, _ ...TestOpt) {
defer flushServer(c, t)

ops := []func(){
func() {
c.Modify().AddEntry(t, fluent.NextHopEntry().WithNetworkInstance(defaultNetworkInstanceName).WithIndex(1).WithIPAddress("192.0.2.3"))
// // NB: NHG is specified to not include any NHs
c.Modify().AddEntry(t, fluent.NextHopGroupEntry().WithNetworkInstance(defaultNetworkInstanceName).WithID(11))
c.Modify().AddEntry(t, fluent.IPv4Entry().WithPrefix("203.0.113.1/32").WithNetworkInstance(defaultNetworkInstanceName).WithNextHopGroup(11))
},
}

res := DoModifyOps(c, t, ops, fluent.InstalledInFIB, false)

chk.HasResult(t, res,
fluent.OperationResult().
WithNextHopOperation(1).
WithOperationType(constants.Add).
WithProgrammingResult(fluent.InstalledInFIB).
AsResult(),
chk.IgnoreOperationID())

chk.HasResult(t, res,
fluent.OperationResult().
WithNextHopGroupOperation(11).
WithOperationType(constants.Add).
WithProgrammingResult(fluent.ProgrammingFailed).
AsResult(),
chk.IgnoreOperationID())

chk.HasResult(t, res,
fluent.OperationResult().
WithIPv4Operation("203.0.113.1/32").
WithOperationType(constants.Add).
WithProgrammingResult(fluent.ProgrammingFailed).
AsResult(),
chk.IgnoreOperationID())
}
Loading