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

RT-1.53 : prefix_set_test.go #3631

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,12 @@ platform_exceptions: {
deviations: {
skip_prefix_set_mode: true
}
}
}
platform_exceptions: {
platform: {
vendor: JUNIPER
}
deviations: {
bgp_prefixset_req_routepol_ref: true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/openconfig/ondatra"
"github.com/openconfig/ondatra/gnmi"
"github.com/openconfig/ondatra/gnmi/oc"
"github.com/openconfig/ygot/ygot"
)

const (
Expand All @@ -39,6 +40,19 @@ func TestMain(m *testing.M) {
fptest.RunTests(m)
}

func configurePrefSetPolicy(t *testing.T, dut *ondatra.DUTDevice, prefSet string) {
d := &oc.Root{}
rp := d.GetOrCreateRoutingPolicy()
pdef := rp.GetOrCreatePolicyDefinition("pol1")
stmt, err := pdef.AppendNewStatement("pol1")
if err != nil {
t.Fatalf("AppendNewStatement(%s) failed: %v", "pol1", err)
}
stmt.GetOrCreateActions().PolicyResult = oc.RoutingPolicy_PolicyResultType_ACCEPT_ROUTE
stmt.GetOrCreateConditions().GetOrCreateMatchPrefixSet().PrefixSet = ygot.String(prefSet)
gnmi.Update(t, dut, gnmi.OC().RoutingPolicy().Config(), rp)
}

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

Expand All @@ -55,6 +69,11 @@ func TestPrefixSet(t *testing.T) {
v4PrefixSet.GetOrCreatePrefix(pfx2, mskLen)

gnmi.Replace(t, dut, gnmi.OC().RoutingPolicy().DefinedSets().PrefixSet(prefixSetA).Config(), v4PrefixSet)

if deviations.BgpPrefixsetReqRoutepolRef(dut) {
configurePrefSetPolicy(t, dut, prefixSetA)
}

prefixSet := gnmi.Get[*oc.RoutingPolicy_DefinedSets_PrefixSet](t, dut, gnmi.OC().RoutingPolicy().DefinedSets().PrefixSet(prefixSetA).State())
if len(prefixSet.Prefix) != 2 {
t.Errorf("Prefix set has %v prefixes, want 2", len(prefixSet.Prefix))
Expand Down Expand Up @@ -128,6 +147,11 @@ func TestPrefixSetWithOCAgentRestart(t *testing.T) {
v4PrefixSet.GetOrCreatePrefix("173.42.128.0/20", mskLen)
v4PrefixSet.GetOrCreatePrefix("173.43.128.0/20", mskLen)
gnmi.Replace(t, dut, gnmi.OC().RoutingPolicy().DefinedSets().PrefixSet(tag3IPv4).Config(), v4PrefixSet)

if deviations.BgpPrefixsetReqRoutepolRef(dut) {
configurePrefSetPolicy(t, dut, tag3IPv4)
}

prefixSet := gnmi.Get[*oc.RoutingPolicy_DefinedSets_PrefixSet](t, dut, gnmi.OC().RoutingPolicy().DefinedSets().PrefixSet(tag3IPv4).State())
if got, want := len(prefixSet.Prefix), 10; got != want {
t.Errorf("Prefix set has %v prefixes, want %v", got, want)
Expand Down
5 changes: 5 additions & 0 deletions internal/deviations/deviations.go
Original file line number Diff line number Diff line change
Expand Up @@ -1292,3 +1292,8 @@
}
return "DEFAULT"
}

// Devices needs route policy reference to stream prefix set info.

Check failure on line 1296 in internal/deviations/deviations.go

View workflow job for this annotation

GitHub Actions / Static Analysis

comment on exported function BgpPrefixsetReqRoutepolRef should be of the form "BgpPrefixsetReqRoutepolRef ..."
func BgpPrefixsetReqRoutepolRef(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetBgpPrefixsetReqRoutepolRef()
}
3 changes: 3 additions & 0 deletions internal/gnoi/gnoi.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ var (
},
ondatra.JUNIPER: {
GRIBI: "rpd",
OCAGENT: "mgd-api",
P4RT: "p4-switch",
ROUTING: "rpd",
},
Expand Down Expand Up @@ -103,6 +104,8 @@ func KillProcess(t *testing.T, dut *ondatra.DUTDevice, daemon Daemon, signal spb
}
gnoiClient.System().KillProcess(context.Background(), killProcessRequest)

time.Sleep(120 * time.Second)

if waitForRestart {
gnmi.WatchAll(
t,
Expand Down
3 changes: 3 additions & 0 deletions proto/metadata.proto
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,9 @@ message Metadata {
// Cisco: b/388983709
// default bgp instance name is used to set bgp instance name value other than DEFAULT
string default_bgp_instance_name = 246;
// Juniper: b/383145521
// Device needs route policy reference to stream prefix set info.
bool bgp_prefixset_req_routepol_ref = 247;

// Reserved field numbers and identifiers.
reserved 84, 9, 28, 20, 90, 97, 55, 89, 19, 36, 35, 40, 173;
Expand Down
113 changes: 66 additions & 47 deletions proto/metadata_go_proto/metadata.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading