From 152fdcd54edfeed0bd07dbb55dab515d164b48a4 Mon Sep 17 00:00:00 2001 From: jasdeep-hundal Date: Wed, 24 Apr 2024 01:29:23 +0000 Subject: [PATCH] Remove next set of converted ATE tests All removed tests have had OTG versions merged/validated > 1 month ago. --- .../ate_tests/bgp_2byte_4byte_asn/README.md | 29 - .../bgp_2byte_4byte_asn_test.go | 253 --------- .../bgp_2byte_4byte_asn/metadata.textproto | 29 - .../bgp_2byte_4byte_asn_policy_test/README.md | 34 -- .../bgp_2byte_4byte_asn_policy_test.go | 499 ------------------ .../metadata.textproto | 38 -- .../ate_tests/bgp_remove_private_as/README.md | 41 -- .../bgp_remove_private_as_test.go | 394 -------------- .../bgp_remove_private_as/metadata.textproto | 24 - .../README.md | 55 -- ...configuration_convergence_time_bgp_test.go | 367 ------------- ...onfiguration_convergence_time_isis_test.go | 150 ------ .../metadata.textproto | 43 -- 13 files changed, 1956 deletions(-) delete mode 100644 feature/experimental/bgp/ate_tests/bgp_2byte_4byte_asn/README.md delete mode 100644 feature/experimental/bgp/ate_tests/bgp_2byte_4byte_asn/bgp_2byte_4byte_asn_test.go delete mode 100644 feature/experimental/bgp/ate_tests/bgp_2byte_4byte_asn/metadata.textproto delete mode 100644 feature/experimental/bgp/ate_tests/bgp_2byte_4byte_asn_policy_test/README.md delete mode 100644 feature/experimental/bgp/ate_tests/bgp_2byte_4byte_asn_policy_test/bgp_2byte_4byte_asn_policy_test.go delete mode 100644 feature/experimental/bgp/ate_tests/bgp_2byte_4byte_asn_policy_test/metadata.textproto delete mode 100644 feature/experimental/bgp/ate_tests/bgp_remove_private_as/README.md delete mode 100644 feature/experimental/bgp/ate_tests/bgp_remove_private_as/bgp_remove_private_as_test.go delete mode 100644 feature/experimental/bgp/ate_tests/bgp_remove_private_as/metadata.textproto delete mode 100644 feature/experimental/system/gnmi/benchmarking/ate_tests/drained_configuration_convergence_time/README.md delete mode 100644 feature/experimental/system/gnmi/benchmarking/ate_tests/drained_configuration_convergence_time/drained_configuration_convergence_time_bgp_test.go delete mode 100644 feature/experimental/system/gnmi/benchmarking/ate_tests/drained_configuration_convergence_time/drained_configuration_convergence_time_isis_test.go delete mode 100644 feature/experimental/system/gnmi/benchmarking/ate_tests/drained_configuration_convergence_time/metadata.textproto diff --git a/feature/experimental/bgp/ate_tests/bgp_2byte_4byte_asn/README.md b/feature/experimental/bgp/ate_tests/bgp_2byte_4byte_asn/README.md deleted file mode 100644 index 724e759f578..00000000000 --- a/feature/experimental/bgp/ate_tests/bgp_2byte_4byte_asn/README.md +++ /dev/null @@ -1,29 +0,0 @@ -# RT-1.19: BGP 2-Byte and 4-Byte ASN support - -## Summary - -BGP 2-Byte and 4-Byte ASN support - -## Procedure - -* Establish BGP sessions as follows and verify all the sessions are established - * ATE (2-byte) - DUT (4-byte) - eBGP IPv4 with ASN < 65535 on DUT side - * ATE (2-byte) - DUT (4-byte) - eBGP IPv6 with ASN < 65535 on DUT side - * ATE (4-byte) - DUT (4-byte) - eBGP IPv4 - * ATE (4-byte) - DUT (4-byte) - eBGP IPv6 - * ATE (2-byte) - DUT (4-byte) - iBGP IPv4 with ASN < 65535 on DUT side - * ATE (4-byte) - DUT (4-byte) - iBGP IPv6 with ASN < 65535 on DUT side - * ATE (4-byte) - DUT (4-byte) - iBGP IPv4 - * ATE (4-byte) - DUT (4-byte) - iBGP IPv6 - -## Config Parameter Coverage - -* /global/config/as -* /neighbors/neighbor/config/peer-as -* /neighbors/neighbor/config/local-as - -## Telemetry Parameter Coverage - -* /global/config/as -* /neighbors/neighbor/config/peer-as -* /neighbors/neighbor/config/local-as diff --git a/feature/experimental/bgp/ate_tests/bgp_2byte_4byte_asn/bgp_2byte_4byte_asn_test.go b/feature/experimental/bgp/ate_tests/bgp_2byte_4byte_asn/bgp_2byte_4byte_asn_test.go deleted file mode 100644 index af656255725..00000000000 --- a/feature/experimental/bgp/ate_tests/bgp_2byte_4byte_asn/bgp_2byte_4byte_asn_test.go +++ /dev/null @@ -1,253 +0,0 @@ -// Copyright 2023 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 bgp_2byte_4byte_asn_test - -import ( - "testing" - "time" - - "github.com/openconfig/featureprofiles/internal/attrs" - "github.com/openconfig/featureprofiles/internal/deviations" - "github.com/openconfig/ondatra/gnmi/oc" - "github.com/openconfig/ygot/ygot" - - "github.com/openconfig/featureprofiles/internal/fptest" - "github.com/openconfig/ondatra" - "github.com/openconfig/ondatra/gnmi" -) - -const ( - connInternal = "INTERNAL" - connExternal = "EXTERNAL" -) - -var ( - dutSrc = attrs.Attributes{ - Desc: "DUT to ATE source", - IPv4: "192.0.2.1", - IPv6: "2001:db8::192:0:2:1", - IPv4Len: 30, - IPv6Len: 126, - } - ateSrc = attrs.Attributes{ - Name: "ateSrc", - IPv4: "192.0.2.2", - IPv6: "2001:db8::192:0:2:2", - IPv4Len: 30, - IPv6Len: 126, - } -) - -type bgpNbr struct { - globalAS, localAS, peerAS uint32 - peerIP string - isV4 bool -} - -func TestMain(m *testing.M) { - fptest.RunTests(m) -} - -func TestBgpSession(t *testing.T) { - t.Log("Configure DUT interface") - dut := ondatra.DUT(t, "dut") - dc := gnmi.OC() - i1 := dutSrc.NewOCInterface(dut.Port(t, "port1").Name(), dut) - gnmi.Replace(t, dut, dc.Interface(i1.GetName()).Config(), i1) - if deviations.ExplicitInterfaceInDefaultVRF(dut) { - fptest.AssignToNetworkInstance(t, dut, i1.GetName(), deviations.DefaultNetworkInstance(dut), 0) - } - - t.Log("Configure Network Instance") - dutConfNIPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)) - gnmi.Replace(t, dut, dutConfNIPath.Type().Config(), oc.NetworkInstanceTypes_NETWORK_INSTANCE_TYPE_DEFAULT_INSTANCE) - - dutConfPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP") - statePath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP").Bgp() - - cases := []struct { - name string - nbr *bgpNbr - dutConf *oc.NetworkInstance_Protocol - ateConf *ondatra.ATETopology - }{ - { - name: "Establish eBGP connection between ATE (2-byte) - DUT (4-byte < 65535) for ipv4 peers", - nbr: &bgpNbr{globalAS: 300, localAS: 100, peerIP: ateSrc.IPv4, peerAS: 200, isV4: true}, - dutConf: createBgpNeighbor(&bgpNbr{globalAS: 300, localAS: 100, peerIP: ateSrc.IPv4, peerAS: 200, isV4: true}, dut), - ateConf: configureATE(t, &bgpNbr{globalAS: 300, localAS: 200, peerIP: dutSrc.IPv4, peerAS: 100, isV4: true}, connExternal), - }, { - name: "Establish eBGP connection between ATE (2-byte) - DUT (4-byte < 65535) for ipv6 peers", - nbr: &bgpNbr{globalAS: 300, localAS: 100, peerIP: ateSrc.IPv6, peerAS: 200, isV4: false}, - dutConf: createBgpNeighbor(&bgpNbr{globalAS: 300, localAS: 100, peerIP: ateSrc.IPv6, peerAS: 200, isV4: false}, dut), - ateConf: configureATE(t, &bgpNbr{globalAS: 300, localAS: 200, peerIP: dutSrc.IPv6, peerAS: 100, isV4: false}, connExternal), - }, { - name: "Establish eBGP connection between ATE (4-byte) - DUT (4-byte) for ipv4 peers", - nbr: &bgpNbr{globalAS: 300, localAS: 70000, peerIP: ateSrc.IPv4, peerAS: 80000, isV4: true}, - dutConf: createBgpNeighbor(&bgpNbr{globalAS: 300, localAS: 70000, peerIP: ateSrc.IPv4, peerAS: 80000, isV4: true}, dut), - ateConf: configureATE(t, &bgpNbr{globalAS: 300, localAS: 80000, peerIP: dutSrc.IPv4, peerAS: 70000, isV4: true}, connExternal), - }, { - name: "Establish eBGP connection between ATE (4-byte) - DUT (4-byte) for ipv6 peers", - nbr: &bgpNbr{globalAS: 300, localAS: 70000, peerIP: ateSrc.IPv6, peerAS: 80000, isV4: true}, - dutConf: createBgpNeighbor(&bgpNbr{globalAS: 300, localAS: 70000, peerIP: ateSrc.IPv6, peerAS: 80000, isV4: false}, dut), - ateConf: configureATE(t, &bgpNbr{globalAS: 300, localAS: 80000, peerIP: dutSrc.IPv6, peerAS: 70000, isV4: false}, connExternal), - }, { - name: "Establish iBGP connection between ATE (2-byte) - DUT (4-byte < 65535) for ipv4 peers", - nbr: &bgpNbr{globalAS: 300, localAS: 200, peerIP: ateSrc.IPv4, peerAS: 200, isV4: true}, - dutConf: createBgpNeighbor(&bgpNbr{globalAS: 300, localAS: 200, peerIP: ateSrc.IPv4, peerAS: 200, isV4: true}, dut), - ateConf: configureATE(t, &bgpNbr{globalAS: 300, localAS: 200, peerIP: dutSrc.IPv4, peerAS: 200, isV4: true}, connInternal), - }, { - name: "Establish iBGP connection between ATE (4-byte) - DUT (4-byte < 65535) for ipv6 peers", - nbr: &bgpNbr{globalAS: 300, localAS: 200, peerIP: ateSrc.IPv6, peerAS: 200, isV4: false}, - dutConf: createBgpNeighbor(&bgpNbr{globalAS: 300, localAS: 200, peerIP: ateSrc.IPv6, peerAS: 200, isV4: false}, dut), - ateConf: configureATE(t, &bgpNbr{globalAS: 300, localAS: 200, peerIP: dutSrc.IPv6, peerAS: 200, isV4: false}, connInternal), - }, { - name: "Establish iBGP connection between ATE (4-byte) - DUT (4-byte) for ipv4 peers", - nbr: &bgpNbr{globalAS: 300, localAS: 80000, peerIP: ateSrc.IPv4, peerAS: 80000, isV4: true}, - dutConf: createBgpNeighbor(&bgpNbr{globalAS: 300, localAS: 80000, peerIP: ateSrc.IPv4, peerAS: 80000, isV4: true}, dut), - ateConf: configureATE(t, &bgpNbr{globalAS: 300, localAS: 80000, peerIP: dutSrc.IPv4, peerAS: 80000, isV4: true}, connInternal), - }, { - name: "Establish iBGP connection between ATE (4-byte) - DUT (4-byte) for ipv6 peers", - nbr: &bgpNbr{globalAS: 300, localAS: 80000, peerIP: ateSrc.IPv6, peerAS: 80000, isV4: false}, - dutConf: createBgpNeighbor(&bgpNbr{globalAS: 300, localAS: 80000, peerIP: ateSrc.IPv6, peerAS: 80000, isV4: false}, dut), - ateConf: configureATE(t, &bgpNbr{globalAS: 300, localAS: 80000, peerIP: dutSrc.IPv6, peerAS: 80000, isV4: false}, connInternal), - }, - } - - for _, tc := range cases { - t.Run(tc.name, func(t *testing.T) { - t.Log("Clear BGP Configs on DUT") - bgpClearConfig(t, dut) - - t.Log("Configure BGP on DUT") - gnmi.Replace(t, dut, dutConfPath.Config(), tc.dutConf) - - fptest.LogQuery(t, "DUT BGP Config ", dutConfPath.Config(), gnmi.Get(t, dut, dutConfPath.Config())) - t.Log("Configure BGP on ATE") - tc.ateConf.Push(t) - tc.ateConf.StartProtocols(t) - - t.Log("Verify BGP session state : ESTABLISHED") - nbrPath := statePath.Neighbor(tc.nbr.peerIP) - gnmi.Await(t, dut, nbrPath.SessionState().State(), time.Second*60, oc.Bgp_Neighbor_SessionState_ESTABLISHED) - - t.Log("Verify BGP AS numbers") - verifyPeer(t, tc.nbr, dut) - - t.Log("Clear BGP Configs on ATE") - tc.ateConf.StopProtocols(t) - }) - } -} - -// bgpClearConfig removes all BGP configuration from the DUT. -func bgpClearConfig(t *testing.T, dut *ondatra.DUTDevice) { - t.Helper() - resetBatch := &gnmi.SetBatch{} - gnmi.BatchDelete(resetBatch, gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP").Config()) - - if deviations.NetworkInstanceTableDeletionRequired(dut) { - tablePath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).TableAny() - for _, table := range gnmi.LookupAll(t, dut, tablePath.Config()) { - if val, ok := table.Val(); ok { - if val.GetProtocol() == oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP { - gnmi.BatchDelete(resetBatch, gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).Table(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, val.GetAddressFamily()).Config()) - } - } - } - } - resetBatch.Set(t, dut) -} - -func verifyPeer(t *testing.T, nbr *bgpNbr, dut *ondatra.DUTDevice) { - t.Helper() - statePath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP").Bgp() - nbrPath := statePath.Neighbor(nbr.peerIP) - glblPath := statePath.Global() - - // Check BGP peerAS from telemetry. - peerAS := gnmi.Get(t, dut, nbrPath.State()).GetPeerAs() - if peerAS != nbr.peerAS { - t.Errorf("BGP peerAs: got %v, want %v", peerAS, nbr.peerAS) - } - - // Check BGP localAS from telemetry. - localAS := gnmi.Get(t, dut, nbrPath.State()).GetLocalAs() - if localAS != nbr.localAS { - t.Errorf("BGP localAS: got %v, want %v", localAS, nbr.localAS) - } - - // Check BGP globalAS from telemetry. - globalAS := gnmi.Get(t, dut, glblPath.State()).GetAs() - if globalAS != nbr.globalAS { - t.Errorf("BGP globalAS: got %v, want %v", globalAS, nbr.globalAS) - } -} - -func configureATE(t *testing.T, ateParams *bgpNbr, connectionType string) *ondatra.ATETopology { - t.Helper() - t.Log("Configure ATE interface") - ate := ondatra.ATE(t, "ate") - port1 := ate.Port(t, "port1") - topo := ate.Topology().New() - - iDut1 := topo.AddInterface(ateSrc.Name).WithPort(port1) - iDut1.IPv4().WithAddress(ateSrc.IPv4CIDR()).WithDefaultGateway(dutSrc.IPv4) - iDut1.IPv6().WithAddress(ateSrc.IPv6CIDR()).WithDefaultGateway(dutSrc.IPv6) - - bgpDut1 := iDut1.BGP() - - peer := bgpDut1.AddPeer().WithPeerAddress(ateParams.peerIP).WithLocalASN(ateParams.localAS) - if connectionType == connInternal { - peer.WithTypeInternal() - } else { - peer.WithTypeExternal() - } - return topo -} - -func createBgpNeighbor(nbr *bgpNbr, dut *ondatra.DUTDevice) *oc.NetworkInstance_Protocol { - d := &oc.Root{} - ni1 := d.GetOrCreateNetworkInstance(deviations.DefaultNetworkInstance(dut)) - niProto := ni1.GetOrCreateProtocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP") - bgp := niProto.GetOrCreateBgp() - - global := bgp.GetOrCreateGlobal() - global.As = ygot.Uint32(nbr.globalAS) - global.RouterId = ygot.String(dutSrc.IPv4) - global.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).Enabled = ygot.Bool(true) - - pg := bgp.GetOrCreatePeerGroup("ATE") - pg.PeerAs = ygot.Uint32(nbr.peerAS) - pg.PeerGroupName = ygot.String("ATE") - - neighbor := bgp.GetOrCreateNeighbor(nbr.peerIP) - neighbor.PeerAs = ygot.Uint32(nbr.peerAS) - neighbor.Enabled = ygot.Bool(true) - neighbor.PeerGroup = ygot.String("ATE") - neighbor.LocalAs = ygot.Uint32(nbr.localAS) - neighbor.GetOrCreateTimers().RestartTime = ygot.Uint16(75) - - if nbr.isV4 { - afisafi := neighbor.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST) - afisafi.Enabled = ygot.Bool(true) - neighbor.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST).Enabled = ygot.Bool(false) - } else { - afisafi6 := neighbor.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST) - afisafi6.Enabled = ygot.Bool(true) - neighbor.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).Enabled = ygot.Bool(false) - } - return niProto -} diff --git a/feature/experimental/bgp/ate_tests/bgp_2byte_4byte_asn/metadata.textproto b/feature/experimental/bgp/ate_tests/bgp_2byte_4byte_asn/metadata.textproto deleted file mode 100644 index 18a90886ebd..00000000000 --- a/feature/experimental/bgp/ate_tests/bgp_2byte_4byte_asn/metadata.textproto +++ /dev/null @@ -1,29 +0,0 @@ -# proto-file: github.com/openconfig/featureprofiles/proto/metadata.proto -# proto-message: Metadata - -uuid: "b960ced4-2f59-49bf-b078-e53f169fac06" -plan_id: "RT-1.19" -description: "BGP 2-Byte and 4-Byte ASN support" -testbed: TESTBED_DUT_ATE_2LINKS -platform_exceptions: { - platform: { - vendor: ARISTA - } - deviations: { - route_policy_under_afi_unsupported: true - omit_l2_mtu: true - network_instance_table_deletion_required: true - interface_enabled: true - default_network_instance: "default" - } -} -platform_exceptions: { - platform: { - vendor: NOKIA - } - deviations: { - interface_enabled: true - explicit_interface_in_default_vrf: true - } -} -tags: TAGS_AGGREGATION diff --git a/feature/experimental/bgp/ate_tests/bgp_2byte_4byte_asn_policy_test/README.md b/feature/experimental/bgp/ate_tests/bgp_2byte_4byte_asn_policy_test/README.md deleted file mode 100644 index 51d125b5eb9..00000000000 --- a/feature/experimental/bgp/ate_tests/bgp_2byte_4byte_asn_policy_test/README.md +++ /dev/null @@ -1,34 +0,0 @@ -# RT-1.24: BGP 2-Byte and 4-Byte ASN support with policy - -## Summary - -BGP 2-Byte and 4-Byte ASN support with policy - -## Procedure - -* Establish BGP sessions as follows and verify all the sessions are established: - * ATE (2-byte) - DUT (4-byte) - eBGP IPv4 with ASN < 65535 on DUT side - * ATE (2-byte) - DUT (4-byte) - eBGP IPv6 with ASN < 65535 on DUT side - * ATE (4-byte) - DUT (4-byte) - eBGP IPv4 - * ATE (4-byte) - DUT (4-byte) - eBGP IPv6 - * ATE (2-byte) - DUT (4-byte) - iBGP IPv4 with ASN < 65535 on DUT side - * ATE (4-byte) - DUT (4-byte) - iBGP IPv6 with ASN < 65535 on DUT side - * ATE (4-byte) - DUT (4-byte) - iBGP IPv4 - * ATE (4-byte) - DUT (4-byte) - iBGP IPv6 - -* Configure below policies and verify prefix count: - * Policy to reject prefix with prefix filter - * Policy to reject prefix with community filter - * Policy to reject prefix with regex filter to match as-path - -## Config Parameter Coverage - -* /global/config/as -* /neighbors/neighbor/config/peer-as -* /neighbors/neighbor/config/local-as - -## Telemetry Parameter Coverage - -* /global/config/as -* /neighbors/neighbor/config/peer-as -* /neighbors/neighbor/config/local-as diff --git a/feature/experimental/bgp/ate_tests/bgp_2byte_4byte_asn_policy_test/bgp_2byte_4byte_asn_policy_test.go b/feature/experimental/bgp/ate_tests/bgp_2byte_4byte_asn_policy_test/bgp_2byte_4byte_asn_policy_test.go deleted file mode 100644 index 7ea95500983..00000000000 --- a/feature/experimental/bgp/ate_tests/bgp_2byte_4byte_asn_policy_test/bgp_2byte_4byte_asn_policy_test.go +++ /dev/null @@ -1,499 +0,0 @@ -// Copyright 2023 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 bgp_2byte_4byte_asn_with_policy_test - -import ( - "context" - "fmt" - "testing" - "time" - - "github.com/openconfig/featureprofiles/internal/attrs" - "github.com/openconfig/featureprofiles/internal/deviations" - "github.com/openconfig/featureprofiles/internal/fptest" - gpb "github.com/openconfig/gnmi/proto/gnmi" - "github.com/openconfig/ondatra" - "github.com/openconfig/ondatra/gnmi" - "github.com/openconfig/ondatra/gnmi/oc" - "github.com/openconfig/ygot/ygot" -) - -const ( - connInternal = "INTERNAL" - connExternal = "EXTERNAL" - rejectPrefix = "REJECT-PREFIX" - communitySet = "COMM-SET" - rejectCommunity = "REJECT-COMMUNITY" - rejectAspath = "REJECT-AS-PATH" - aclStatement1 = "10" - aclStatement2 = "20" - aclStatement3 = "50" - aclStatement4 = "60" - prefixSubnetRangeV4 = "30..32" - prefixSubnetRangeV6 = "126..128" - globalAsNumber = 999 -) - -var prefixV4 = []string{"198.51.100.0/30", "198.51.100.4/30", "198.51.100.8/30"} -var prefixV6 = []string{"2001:DB8:1::0/126", "2001:DB8:1::4/126", "2001:DB8:1::8/126"} -var community = []string{"200:1"} - -var ( - dutSrc = attrs.Attributes{ - Desc: "DUT to ATE source", - IPv4: "192.0.2.1", - IPv6: "2001:db8::192:0:2:1", - IPv4Len: 30, - IPv6Len: 126, - } - ateSrc = attrs.Attributes{ - Name: "ateSrc", - IPv4: "192.0.2.2", - IPv6: "2001:db8::192:0:2:2", - IPv4Len: 30, - IPv6Len: 126, - } -) - -type bgpNbr struct { - localAS, peerAS uint32 - peerIP string - isV4 bool -} - -func TestMain(m *testing.M) { - fptest.RunTests(m) -} -func TestBgpSession(t *testing.T) { - t.Log("Configure DUT interface") - dut := ondatra.DUT(t, "dut") - dc := gnmi.OC() - i1 := dutSrc.NewOCInterface(dut.Port(t, "port1").Name(), dut) - gnmi.Replace(t, dut, dc.Interface(i1.GetName()).Config(), i1) - - t.Log("Configure Network Instance") - dutConfNIPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)) - gnmi.Replace(t, dut, dutConfNIPath.Type().Config(), oc.NetworkInstanceTypes_NETWORK_INSTANCE_TYPE_DEFAULT_INSTANCE) - - dutConfPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP") - statePath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP").Bgp() - - cases := []struct { - name string - nbr *bgpNbr - dutConf *oc.NetworkInstance_Protocol - ateConf *ondatra.ATETopology - }{ - { - name: "Establish eBGP connection between ATE (2-byte) - DUT (4-byte < 65535) for ipv4 peers", - nbr: &bgpNbr{localAS: 100, peerIP: ateSrc.IPv4, peerAS: 200, isV4: true}, - dutConf: createBgpNeighbor(&bgpNbr{localAS: 100, peerIP: ateSrc.IPv4, peerAS: 200, isV4: true}, dut), - ateConf: configureATE(t, &bgpNbr{localAS: 200, peerIP: dutSrc.IPv4, peerAS: 100, isV4: true}, connExternal, prefixV4), - }, { - name: "Establish eBGP connection between ATE (2-byte) - DUT (4-byte < 65535) for ipv6 peers", - nbr: &bgpNbr{localAS: 100, peerIP: ateSrc.IPv6, peerAS: 200, isV4: false}, - dutConf: createBgpNeighbor(&bgpNbr{localAS: 100, peerIP: ateSrc.IPv6, peerAS: 200, isV4: false}, dut), - ateConf: configureATE(t, &bgpNbr{localAS: 200, peerIP: dutSrc.IPv6, peerAS: 100, isV4: false}, connExternal, prefixV6), - }, { - name: "Establish eBGP connection between ATE (4-byte) - DUT (4-byte) for ipv4 peers", - nbr: &bgpNbr{localAS: 70000, peerIP: ateSrc.IPv4, peerAS: 80000, isV4: true}, - dutConf: createBgpNeighbor(&bgpNbr{localAS: 70000, peerIP: ateSrc.IPv4, peerAS: 80000, isV4: true}, dut), - ateConf: configureATE(t, &bgpNbr{localAS: 80000, peerIP: dutSrc.IPv4, peerAS: 70000, isV4: true}, connExternal, prefixV4), - }, { - name: "Establish eBGP connection between ATE (4-byte) - DUT (4-byte) for ipv6 peers", - nbr: &bgpNbr{localAS: 70000, peerIP: ateSrc.IPv6, peerAS: 80000, isV4: false}, - dutConf: createBgpNeighbor(&bgpNbr{localAS: 70000, peerIP: ateSrc.IPv6, peerAS: 80000, isV4: false}, dut), - ateConf: configureATE(t, &bgpNbr{localAS: 80000, peerIP: dutSrc.IPv6, peerAS: 70000, isV4: false}, connExternal, prefixV6), - }, { - name: "Establish iBGP connection between ATE (2-byte) - DUT (4-byte < 65535) for ipv4 peers", - nbr: &bgpNbr{localAS: 200, peerIP: ateSrc.IPv4, peerAS: 200, isV4: true}, - dutConf: createBgpNeighbor(&bgpNbr{localAS: 200, peerIP: ateSrc.IPv4, peerAS: 200, isV4: true}, dut), - ateConf: configureATE(t, &bgpNbr{localAS: 200, peerIP: dutSrc.IPv4, peerAS: 200, isV4: true}, connInternal, prefixV4), - }, { - name: "Establish iBGP connection between ATE (4-byte) - DUT (4-byte < 65535) for ipv6 peers", - nbr: &bgpNbr{localAS: 200, peerIP: ateSrc.IPv6, peerAS: 200, isV4: false}, - dutConf: createBgpNeighbor(&bgpNbr{localAS: 200, peerIP: ateSrc.IPv6, peerAS: 200, isV4: false}, dut), - ateConf: configureATE(t, &bgpNbr{localAS: 200, peerIP: dutSrc.IPv6, peerAS: 200, isV4: false}, connInternal, prefixV6), - }, { - name: "Establish iBGP connection between ATE (4-byte) - DUT (4-byte) for ipv4 peers", - nbr: &bgpNbr{localAS: 80000, peerIP: ateSrc.IPv4, peerAS: 80000, isV4: true}, - dutConf: createBgpNeighbor(&bgpNbr{localAS: 80000, peerIP: ateSrc.IPv4, peerAS: 80000, isV4: true}, dut), - ateConf: configureATE(t, &bgpNbr{localAS: 80000, peerIP: dutSrc.IPv4, peerAS: 80000, isV4: true}, connInternal, prefixV4), - }, { - name: "Establish iBGP connection between ATE (4-byte) - DUT (4-byte) for ipv6 peers", - nbr: &bgpNbr{localAS: 80000, peerIP: ateSrc.IPv6, peerAS: 80000, isV4: false}, - dutConf: createBgpNeighbor(&bgpNbr{localAS: 80000, peerIP: ateSrc.IPv6, peerAS: 80000, isV4: false}, dut), - ateConf: configureATE(t, &bgpNbr{localAS: 80000, peerIP: dutSrc.IPv6, peerAS: 80000, isV4: false}, connInternal, prefixV6), - }, - } - - for _, tc := range cases { - t.Run(tc.name, func(t *testing.T) { - t.Log("Clear BGP Configs on DUT") - bgpClearConfig(t, dut) - - configureRegexPolicy(t, dut) - - d := &oc.Root{} - rpl := configureBGPPolicy(t, d, tc.nbr.isV4) - gnmi.Replace(t, dut, gnmi.OC().RoutingPolicy().Config(), rpl) - - t.Log("Configure BGP on DUT") - gnmi.Replace(t, dut, dutConfPath.Config(), tc.dutConf) - - fptest.LogQuery(t, "DUT BGP Config ", dutConfPath.Config(), gnmi.Get(t, dut, dutConfPath.Config())) - t.Log("Configure BGP on ATE") - tc.ateConf.Push(t) - tc.ateConf.StartProtocols(t) - - t.Log("Verify BGP session state : ESTABLISHED") - nbrPath := statePath.Neighbor(tc.nbr.peerIP) - gnmi.Await(t, dut, nbrPath.SessionState().State(), time.Second*60, oc.Bgp_Neighbor_SessionState_ESTABLISHED) - - t.Log("Verify BGP AS numbers and prefix count") - verifyPeer(t, tc.nbr, dut) - - t.Log("Apply BGP policy for rejecting prefix") - pol := applyBgpPolicy(rejectPrefix, dut, tc.nbr.isV4) - gnmi.Update(t, dut, dutConfPath.Config(), pol) - verifyPrefixesTelemetry(t, dut, 2, tc.nbr.isV4) - deleteBgpPolicy(t, dut, tc.nbr.isV4) - verifyPrefixesTelemetry(t, dut, 3, tc.nbr.isV4) - - t.Log("Apply BGP policy for rejecting prefix with community filter") - pol = applyBgpPolicy(rejectCommunity, dut, tc.nbr.isV4) - gnmi.Update(t, dut, dutConfPath.Config(), pol) - verifyPrefixesTelemetry(t, dut, 2, tc.nbr.isV4) - deleteBgpPolicy(t, dut, tc.nbr.isV4) - verifyPrefixesTelemetry(t, dut, 3, tc.nbr.isV4) - - t.Log("Apply BGP policy for rejecting prefix with as-path regex filter") - pol = applyBgpPolicy(rejectAspath, dut, tc.nbr.isV4) - gnmi.Update(t, dut, dutConfPath.Config(), pol) - verifyPrefixesTelemetry(t, dut, 2, tc.nbr.isV4) - - t.Log("Clear BGP Configs on ATE") - tc.ateConf.StopProtocols(t) - }) - } -} - -// Build config with Origin set to cli and Ascii encoded config. -func buildCliConfigRequest(config string) (*gpb.SetRequest, error) { - gpbSetRequest := &gpb.SetRequest{ - Update: []*gpb.Update{{ - Path: &gpb.Path{ - Origin: "cli", - Elem: []*gpb.PathElem{}, - }, - Val: &gpb.TypedValue{ - Value: &gpb.TypedValue_AsciiVal{ - AsciiVal: config, - }, - }, - }}, - } - return gpbSetRequest, nil -} - -// juniperCLI returns Juniper CLI config statement. -func juniperCLI() string { - return fmt.Sprintf(` - policy-options { - policy-statement %s { - term term1 { - from as-path match-as-path; - then reject; - } - term term2 { - then accept; - } - } - as-path match-as-path ".* 4400 3300"; - }`, rejectAspath) -} - -// configureRegexPolicy is used to configure vendor specific config statement. -func configureRegexPolicy(t *testing.T, dut *ondatra.DUTDevice) { - t.Helper() - var config string - gnmiClient := dut.RawAPIs().GNMI(t) - - switch dut.Vendor() { - case ondatra.JUNIPER: - config = juniperCLI() - t.Logf("Push the CLI config:%s", dut.Vendor()) - } - - gpbSetRequest, err := buildCliConfigRequest(config) - if err != nil { - t.Fatalf("Cannot build a gNMI SetRequest: %v", err) - } - - if _, err = gnmiClient.Set(context.Background(), gpbSetRequest); err != nil { - t.Fatalf("gnmiClient.Set() with unexpected error: %v", err) - } -} - -// configureBGPPolicy configures a BGP routing policy to accept or reject routes based on prefix match conditions -// Additonally, it also configures policy to match prefix based on community and regex for as path -func configureBGPPolicy(t *testing.T, d *oc.Root, isV4 bool) *oc.RoutingPolicy { - t.Helper() - rp := d.GetOrCreateRoutingPolicy() - pset := rp.GetOrCreateDefinedSets().GetOrCreatePrefixSet(rejectPrefix) - - if isV4 { - pset.GetOrCreatePrefix(prefixV4[2], prefixSubnetRangeV4) - } else { - pset.GetOrCreatePrefix(prefixV6[2], prefixSubnetRangeV6) - } - pdef := rp.GetOrCreatePolicyDefinition(rejectPrefix) - - stmt10, err := pdef.AppendNewStatement(aclStatement1) - if err != nil { - t.Errorf("Error while creating new statement %v", err) - } - stmt10.GetOrCreateActions().PolicyResult = oc.RoutingPolicy_PolicyResultType_REJECT_ROUTE - stmt10.GetOrCreateConditions().GetOrCreateMatchPrefixSet().PrefixSet = ygot.String(rejectPrefix) - - stmt20, err := pdef.AppendNewStatement(aclStatement2) - if err != nil { - t.Errorf("Error while creating new statement %v", err) - } - stmt20.GetOrCreateActions().PolicyResult = oc.RoutingPolicy_PolicyResultType_ACCEPT_ROUTE - - commSet := rp.GetOrCreateDefinedSets().GetOrCreateBgpDefinedSets().GetOrCreateCommunitySet(communitySet) - commSet.CommunitySetName = ygot.String(communitySet) - var communityMembers []oc.RoutingPolicy_DefinedSets_BgpDefinedSets_CommunitySet_CommunityMember_Union - for _, member := range community { - communityMember, _ := commSet.To_RoutingPolicy_DefinedSets_BgpDefinedSets_CommunitySet_CommunityMember_Union(member) - communityMembers = append(communityMembers, communityMember) - } - commSet.SetCommunityMember(communityMembers) - pdefComm := rp.GetOrCreatePolicyDefinition(rejectCommunity) - - stmt50, err := pdefComm.AppendNewStatement(aclStatement3) - if err != nil { - t.Errorf("Error while creating new statement %v", err) - } - stmt50.GetOrCreateActions().PolicyResult = oc.RoutingPolicy_PolicyResultType_REJECT_ROUTE - stmt50.GetOrCreateConditions().GetOrCreateBgpConditions().CommunitySet = ygot.String(communitySet) - - stmt60, err := pdefComm.AppendNewStatement(aclStatement4) - if err != nil { - t.Errorf("Error while creating new statement %v", err) - } - stmt60.GetOrCreateActions().PolicyResult = oc.RoutingPolicy_PolicyResultType_ACCEPT_ROUTE - - return rp -} - -func verifyPrefixesTelemetry(t *testing.T, dut *ondatra.DUTDevice, wantInstalled uint32, isV4 bool) { - t.Helper() - t.Logf("Verify BGP prefix count") - if isV4 { - verifyPrefixesTelemetryV4(t, dut, wantInstalled) - } else { - verifyPrefixesTelemetryV6(t, dut, wantInstalled) - } -} - -// verifyPrefixesTelemetry confirms that the dut shows the correct numbers of installed, sent and -// received IPv4 prefixes -func verifyPrefixesTelemetryV4(t *testing.T, dut *ondatra.DUTDevice, wantInstalled uint32) { - t.Helper() - statePath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP").Bgp() - prefixesv4 := statePath.Neighbor(ateSrc.IPv4).AfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).Prefixes() - - if gotInstalled := gnmi.Get(t, dut, prefixesv4.Installed().State()); gotInstalled != wantInstalled { - t.Errorf("Installed prefixes mismatch: got %v, want %v", gotInstalled, wantInstalled) - } -} - -// verifyPrefixesTelemetryV6 confirms that the dut shows the correct numbers of installed, sent and -// received IPv6 prefixes -func verifyPrefixesTelemetryV6(t *testing.T, dut *ondatra.DUTDevice, wantInstalledv6 uint32) { - statePath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP").Bgp() - prefixesv6 := statePath.Neighbor(ateSrc.IPv6).AfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST).Prefixes() - - if gotInstalledv6 := gnmi.Get(t, dut, prefixesv6.Installed().State()); gotInstalledv6 != wantInstalledv6 { - t.Errorf("IPV6 Installed prefixes mismatch: got %v, want %v", gotInstalledv6, wantInstalledv6) - } -} - -// bgpClearConfig removes all BGP configuration from the DUT. -func bgpClearConfig(t *testing.T, dut *ondatra.DUTDevice) { - resetBatch := &gnmi.SetBatch{} - gnmi.BatchDelete(resetBatch, gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP").Config()) - - if deviations.NetworkInstanceTableDeletionRequired(dut) { - tablePath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).TableAny() - for _, table := range gnmi.LookupAll(t, dut, tablePath.Config()) { - if val, ok := table.Val(); ok { - if val.GetProtocol() == oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP { - gnmi.BatchDelete(resetBatch, gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).Table(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, val.GetAddressFamily()).Config()) - } - } - } - } - resetBatch.Set(t, dut) -} - -func verifyPeer(t *testing.T, nbr *bgpNbr, dut *ondatra.DUTDevice) { - statePath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP").Bgp() - nbrPath := statePath.Neighbor(nbr.peerIP) - glblPath := statePath.Global() - - // Check BGP peerAS from telemetry. - peerAS := gnmi.Get(t, dut, nbrPath.State()).GetPeerAs() - if peerAS != nbr.peerAS { - t.Errorf("BGP peerAs: got %v, want %v", peerAS, nbr.peerAS) - } - - // Check BGP localAS from telemetry. - localAS := gnmi.Get(t, dut, nbrPath.State()).GetLocalAs() - if localAS != nbr.localAS { - t.Errorf("BGP localAS: got %v, want %v", localAS, nbr.localAS) - } - - // Check BGP globalAS from telemetry. - globalAS := gnmi.Get(t, dut, glblPath.State()).GetAs() - if globalAS != globalAsNumber { - t.Errorf("BGP globalAS: got %v, want %v", globalAS, nbr.localAS) - } - - verifyPrefixesTelemetry(t, dut, 3, nbr.isV4) -} - -func configureATE(t *testing.T, ateParams *bgpNbr, connectionType string, prefixes []string) *ondatra.ATETopology { - t.Helper() - t.Log("Configure ATE interface") - ate := ondatra.ATE(t, "ate") - port1 := ate.Port(t, "port1") - topo := ate.Topology().New() - - iDut1 := topo.AddInterface(ateSrc.Name).WithPort(port1) - iDut1.IPv4().WithAddress(ateSrc.IPv4CIDR()).WithDefaultGateway(dutSrc.IPv4) - iDut1.IPv6().WithAddress(ateSrc.IPv6CIDR()).WithDefaultGateway(dutSrc.IPv6) - - bgpDut1 := iDut1.BGP() - peer := bgpDut1.AddPeer().WithPeerAddress(ateParams.peerIP).WithLocalASN(ateParams.localAS) - - if connectionType == connInternal { - peer.WithTypeInternal() - } else { - peer.WithTypeExternal() - } - - network1 := iDut1.AddNetwork("bgpNeti1") - network2 := iDut1.AddNetwork("bgpNeti2") - network3 := iDut1.AddNetwork("bgpNeti3") - - if ateParams.isV4 { - network1.IPv4().WithAddress(prefixes[0]).WithCount(1) - network1.BGP().WithNextHopAddress(ateSrc.IPv4).AddASPathSegment(55000, 4400, 3300) - - network2.IPv4().WithAddress(prefixes[1]).WithCount(1) - network2.BGP().WithNextHopAddress(ateSrc.IPv4).AddASPathSegment(55000, 7700) - network2.BGP().Communities().WithPrivateCommunities("200:1") - - network3.IPv4().WithAddress(prefixes[2]).WithCount(1) - network3.BGP().WithNextHopAddress(ateSrc.IPv4) - } else { - network1.IPv6().WithAddress(prefixes[0]).WithCount(1) - network1.BGP().WithNextHopAddress(ateSrc.IPv6).AddASPathSegment(55000, 4400, 3300) - - network2.IPv6().WithAddress(prefixes[1]).WithCount(1) - network2.BGP().WithNextHopAddress(ateSrc.IPv6).AddASPathSegment(55000, 7700) - network2.BGP().Communities().WithPrivateCommunities("200:1") - - network3.IPv6().WithAddress(prefixes[2]).WithCount(1) - network3.BGP().WithNextHopAddress(ateSrc.IPv6) - } - return topo -} - -func applyBgpPolicy(policyName string, dut *ondatra.DUTDevice, isV4 bool) *oc.NetworkInstance_Protocol { - d := &oc.Root{} - ni1 := d.GetOrCreateNetworkInstance(deviations.DefaultNetworkInstance(dut)) - niProto := ni1.GetOrCreateProtocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP") - bgp := niProto.GetOrCreateBgp() - - pg := bgp.GetOrCreatePeerGroup("ATE") - pg.PeerGroupName = ygot.String("ATE") - - if deviations.RoutePolicyUnderAFIUnsupported(dut) { - //policy under peer group - pg.GetOrCreateApplyPolicy().ImportPolicy = []string{policyName} - return niProto - } - - aftType := oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST - if isV4 { - aftType = oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST - } - - afisafi := pg.GetOrCreateAfiSafi(aftType) - afisafi.Enabled = ygot.Bool(true) - rpl := afisafi.GetOrCreateApplyPolicy() - rpl.SetImportPolicy([]string{policyName}) - - return niProto -} - -func deleteBgpPolicy(t *testing.T, dut *ondatra.DUTDevice, isV4 bool) { - t.Helper() - t.Logf("Delete BGP policy on DUT") - aftType := oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST - if isV4 { - aftType = oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST - } - - policyConfPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP").Bgp().PeerGroup("ATE").AfiSafi(aftType).ApplyPolicy().Config() - gnmi.Delete(t, dut, policyConfPath) -} - -func createBgpNeighbor(nbr *bgpNbr, dut *ondatra.DUTDevice) *oc.NetworkInstance_Protocol { - d := &oc.Root{} - ni1 := d.GetOrCreateNetworkInstance(deviations.DefaultNetworkInstance(dut)) - niProto := ni1.GetOrCreateProtocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP") - bgp := niProto.GetOrCreateBgp() - - global := bgp.GetOrCreateGlobal() - global.As = ygot.Uint32(globalAsNumber) - global.RouterId = ygot.String(dutSrc.IPv4) - - pg := bgp.GetOrCreatePeerGroup("ATE") - pg.PeerAs = ygot.Uint32(nbr.peerAS) - pg.PeerGroupName = ygot.String("ATE") - - neighbor := bgp.GetOrCreateNeighbor(nbr.peerIP) - neighbor.PeerAs = ygot.Uint32(nbr.peerAS) - neighbor.LocalAs = ygot.Uint32(nbr.localAS) - neighbor.Enabled = ygot.Bool(true) - neighbor.PeerGroup = ygot.String("ATE") - neighbor.GetOrCreateTimers().RestartTime = ygot.Uint16(75) - - if nbr.isV4 { - afisafi := neighbor.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST) - afisafi.Enabled = ygot.Bool(true) - neighbor.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST).Enabled = ygot.Bool(false) - } else { - afisafi6 := neighbor.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST) - afisafi6.Enabled = ygot.Bool(true) - neighbor.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).Enabled = ygot.Bool(false) - } - return niProto -} diff --git a/feature/experimental/bgp/ate_tests/bgp_2byte_4byte_asn_policy_test/metadata.textproto b/feature/experimental/bgp/ate_tests/bgp_2byte_4byte_asn_policy_test/metadata.textproto deleted file mode 100644 index bc335a7ac99..00000000000 --- a/feature/experimental/bgp/ate_tests/bgp_2byte_4byte_asn_policy_test/metadata.textproto +++ /dev/null @@ -1,38 +0,0 @@ -# proto-file: github.com/openconfig/featureprofiles/proto/metadata.proto -# proto-message: Metadata - -uuid: "a993eb24-40f8-4b86-bc6b-02c19f6a0d53" -plan_id: "RT-1.24" -description: "BGP 2-Byte and 4-Byte ASN support with policy" -testbed: TESTBED_DUT_ATE_2LINKS -platform_exceptions: { - platform: { - vendor: CISCO - } - deviations: { - ipv4_missing_enabled: true - } -} -platform_exceptions: { - platform: { - vendor: NOKIA - } - deviations: { - use_vendor_native_acl_config: true - explicit_port_speed: true - explicit_interface_in_default_vrf: true - interface_enabled: true - } -} -platform_exceptions: { - platform: { - vendor: ARISTA - } - deviations: { - route_policy_under_afi_unsupported: true - omit_l2_mtu: true - interface_enabled: true - default_network_instance: "default" - } -} -tags: TAGS_AGGREGATION diff --git a/feature/experimental/bgp/ate_tests/bgp_remove_private_as/README.md b/feature/experimental/bgp/ate_tests/bgp_remove_private_as/README.md deleted file mode 100644 index 3cf8f73d886..00000000000 --- a/feature/experimental/bgp/ate_tests/bgp_remove_private_as/README.md +++ /dev/null @@ -1,41 +0,0 @@ -# RT-1.11: BGP remove private ASĀ  - -## Summary - -BGP remove private AS - -## Procedure - -* Establish BGP sessions as follows between ATE and DUT. - * ATE emulates two eBGP neighbors peering with the DUT using public AS numbers. - * DUT Port1 (AS 500) ---eBGP--- ATE Port1 (AS 100) - * DUT Port2 (AS 500) ---eBGP--- ATE Port2 (AS 200) - * Inject routes with AS_PATH modified to have private AS number 65501 from eBGP neighbor #1 - (ATE Port1). - * Validate received routes on ATE Port2 should have AS Path "500 100 65501". - * Configure "remove private AS" with type PRIVATE_AS_REMOVE_ALL on DUT. - * Validate that private AS numbers are stripped before advertisement to the eBGP peer ATE Port2. - * AS path for received routes on ATE Port2 should be "500 100". - * TODO: different patterns of private AS should be tested. - * AS Path SEQ - 65501, 65507, 65554 - * AS Path SEQ - 65501, 600 - * AS Path SEQ - 800, 65501, 600 - ## TODO : https://github.com/openconfig/featureprofiles/issues/1659 - ## SET mode is not working in ATE. - * AS Path SET - 800, 65505, 600 - -## Config Parameter coverage - -* /network-instances/network-instance/protocols/protocol/bgp/peer-groups/peer-group/config/remove-private-as - -## Telemetry Parameter coverage - -* /network-instances/network-instance/protocols/protocol/bgp/rib/attr-sets/attr-set/as4-path/as4-segment/state - -## Protocol/RPC Parameter coverage - -N/A - -## Minimum DUT platform requirement - -N/A \ No newline at end of file diff --git a/feature/experimental/bgp/ate_tests/bgp_remove_private_as/bgp_remove_private_as_test.go b/feature/experimental/bgp/ate_tests/bgp_remove_private_as/bgp_remove_private_as_test.go deleted file mode 100644 index 0d785ad59c7..00000000000 --- a/feature/experimental/bgp/ate_tests/bgp_remove_private_as/bgp_remove_private_as_test.go +++ /dev/null @@ -1,394 +0,0 @@ -// Copyright 2023 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 bgp_remove_private_as_test - -import ( - "testing" - "time" - - "github.com/google/go-cmp/cmp" - "github.com/openconfig/featureprofiles/internal/attrs" - "github.com/openconfig/featureprofiles/internal/deviations" - "github.com/openconfig/featureprofiles/internal/fptest" - "github.com/openconfig/ondatra" - "github.com/openconfig/ondatra/gnmi" - "github.com/openconfig/ondatra/gnmi/oc" - "github.com/openconfig/ygnmi/ygnmi" - "github.com/openconfig/ygot/ygot" -) - -func TestMain(m *testing.M) { - fptest.RunTests(m) -} - -// The testbed consists of ate:port1 -> dut:port1 and -// dut:port2 -> ate:port2. The first pair is called the "source" -// pair, and the second the "destination" pair. -// -// Source: ate:port1 -> dut:port1 subnet 192.0.2.0/30 -// Destination: dut:port2 -> ate:port2 subnet 192.0.2.4/30 -// -// Note that the first (.0, .3) and last (.4, .7) IPv4 addresses are -// reserved from the subnet for broadcast, so a /30 leaves exactly 2 -// usable addresses. This does not apply to IPv6 which allows /127 -// for point to point links, but we use /126 so the numbering is -// consistent with IPv4. - -const ( - trafficDuration = 1 * time.Minute - ipv4SrcTraffic = "192.0.2.2" - advertisedRoutesv4CIDR = "203.0.113.1/32" - peerGrpName1 = "BGP-PEER-GROUP1" - peerGrpName2 = "BGP-PEER-GROUP2" - policyName = "ALLOW" - routeCount = 254 - dutAS = 500 - ateAS1 = 100 - ateAS2 = 200 - plenIPv4 = 30 - plenIPv6 = 126 - removeASPath = true -) - -var ( - dutSrc = attrs.Attributes{ - Desc: "DUT to ATE source", - IPv4: "192.0.2.1", - IPv6: "2001:db8::192:0:2:1", - IPv4Len: plenIPv4, - IPv6Len: plenIPv6, - } - ateSrc = attrs.Attributes{ - Name: "ateSrc", - IPv4: "192.0.2.2", - IPv6: "2001:db8::192:0:2:2", - IPv4Len: plenIPv4, - IPv6Len: plenIPv6, - } - dutDst = attrs.Attributes{ - Desc: "DUT to ATE destination", - IPv4: "192.0.2.5", - IPv6: "2001:db8::192:0:2:5", - IPv4Len: plenIPv4, - IPv6Len: plenIPv6, - } - ateDst = attrs.Attributes{ - Name: "atedst", - IPv4: "192.0.2.6", - IPv6: "2001:db8::192:0:2:6", - IPv4Len: plenIPv4, - IPv6Len: plenIPv6, - } -) - -// configureDUT configures all the interfaces on the DUT. -func configureDUT(t *testing.T, dut *ondatra.DUTDevice) { - dc := gnmi.OC() - i1 := dutSrc.NewOCInterface(dut.Port(t, "port1").Name(), dut) - gnmi.Replace(t, dut, dc.Interface(i1.GetName()).Config(), i1) - - i2 := dutDst.NewOCInterface(dut.Port(t, "port2").Name(), dut) - gnmi.Replace(t, dut, dc.Interface(i2.GetName()).Config(), i2) -} - -// verifyPortsUp asserts that each port on the device is operating. -func verifyPortsUp(t *testing.T, dev *ondatra.Device) { - t.Helper() - for _, p := range dev.Ports() { - status := gnmi.Get(t, dev, gnmi.OC().Interface(p.Name()).OperStatus().State()) - if want := oc.Interface_OperStatus_UP; status != want { - t.Errorf("%s Status: got %v, want %v", p, status, want) - } - } -} - -// bgpCreateNbr creates a BGP object with neighbors pointing to ateSrc and ateDst. -func bgpCreateNbr(localAs, peerAs uint32, dut *ondatra.DUTDevice) *oc.NetworkInstance_Protocol { - nbr1v4 := &bgpNeighbor{as: ateAS1, neighborip: ateSrc.IPv4, isV4: true, peerGrp: peerGrpName1} - nbr2v4 := &bgpNeighbor{as: ateAS2, neighborip: ateDst.IPv4, isV4: true, peerGrp: peerGrpName2} - nbrs := []*bgpNeighbor{nbr1v4, nbr2v4} - - d := &oc.Root{} - ni1 := d.GetOrCreateNetworkInstance(deviations.DefaultNetworkInstance(dut)) - niProto := ni1.GetOrCreateProtocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP") - bgp := niProto.GetOrCreateBgp() - global := bgp.GetOrCreateGlobal() - global.RouterId = ygot.String(dutDst.IPv4) - global.As = ygot.Uint32(localAs) - global.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).Enabled = ygot.Bool(true) - global.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST).Enabled = ygot.Bool(true) - - // Note: we have to define the peer group even if we aren't setting any policy because it's - // invalid OC for the neighbor to be part of a peer group that doesn't exist. - pg1 := bgp.GetOrCreatePeerGroup(peerGrpName1) - pg1.PeerAs = ygot.Uint32(ateAS1) - pg1.PeerGroupName = ygot.String(peerGrpName1) - - pg2 := bgp.GetOrCreatePeerGroup(peerGrpName2) - pg2.PeerAs = ygot.Uint32(ateAS2) - pg2.PeerGroupName = ygot.String(peerGrpName2) - - if deviations.RoutePolicyUnderAFIUnsupported(dut) { - rpl := pg1.GetOrCreateApplyPolicy() - rpl.ImportPolicy = []string{policyName} - rpl.ExportPolicy = []string{policyName} - - rp2 := pg2.GetOrCreateApplyPolicy() - rp2.ImportPolicy = []string{policyName} - rp2.ExportPolicy = []string{policyName} - } else { - pgaf := pg1.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST) - pgaf.Enabled = ygot.Bool(true) - rpl := pgaf.GetOrCreateApplyPolicy() - rpl.ImportPolicy = []string{policyName} - rpl.ExportPolicy = []string{policyName} - - pgaf2 := pg2.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST) - pgaf2.Enabled = ygot.Bool(true) - rp2 := pgaf2.GetOrCreateApplyPolicy() - rp2.ImportPolicy = []string{policyName} - rp2.ExportPolicy = []string{policyName} - } - - for _, nbr := range nbrs { - nv4 := bgp.GetOrCreateNeighbor(nbr.neighborip) - nv4.PeerGroup = ygot.String(nbr.peerGrp) - nv4.PeerAs = ygot.Uint32(nbr.as) - nv4.Enabled = ygot.Bool(true) - af4 := nv4.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST) - af4.Enabled = ygot.Bool(true) - af6 := nv4.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST) - af6.Enabled = ygot.Bool(false) - } - return niProto -} - -// verifyBGPTelemetry checks that the dut has an established BGP session with reasonable settings. -func verifyBGPTelemetry(t *testing.T, dut *ondatra.DUTDevice) { - var nbrIP = []string{ateSrc.IPv4, ateDst.IPv4} - t.Logf("Verifying BGP state.") - statePath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP").Bgp() - for _, nbr := range nbrIP { - var status *ygnmi.Value[oc.E_Bgp_Neighbor_SessionState] - nbrPath := statePath.Neighbor(nbr) - t.Logf("Waiting for BGP neighbor to establish...") - status, ok := gnmi.Watch(t, dut, nbrPath.SessionState().State(), time.Minute, func(val *ygnmi.Value[oc.E_Bgp_Neighbor_SessionState]) bool { - state, ok := val.Val() - return ok && state == oc.Bgp_Neighbor_SessionState_ESTABLISHED - }).Await(t) - if !ok { - fptest.LogQuery(t, "BGP reported state", nbrPath.State(), gnmi.Get(t, dut, nbrPath.State())) - t.Fatal("No BGP neighbor formed") - } - state, _ := status.Val() - t.Logf("BGP adjacency for %s: %s", nbr, state) - if want := oc.Bgp_Neighbor_SessionState_ESTABLISHED; state != want { - t.Errorf("BGP peer %s status got %v, want %d", nbr, status, want) - } - } -} - -// verifyPrefixesTelemetry confirms that the dut shows the correct numbers of installed, -// sent and received IPv4 prefixes. -func verifyPrefixesTelemetry(t *testing.T, dut *ondatra.DUTDevice, nbr string, wantInstalled, wantSent uint32) { - statePath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP").Bgp() - prefixesv4 := statePath.Neighbor(nbr).AfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).Prefixes() - if gotInstalled := gnmi.Get(t, dut, prefixesv4.Installed().State()); gotInstalled != wantInstalled { - t.Errorf("Installed prefixes mismatch: got %v, want %v", gotInstalled, wantInstalled) - } - if gotSent := gnmi.Get(t, dut, prefixesv4.Sent().State()); gotSent != wantSent { - t.Errorf("Sent prefixes mismatch: got %v, want %v", gotSent, wantSent) - } -} - -// configureATE configures the interfaces and BGP protocols on an ATE, including -// advertising some(faked) networks over BGP. -func configureATE(t *testing.T, ate *ondatra.ATEDevice, asSeg []uint32, asSEQMode bool) *ondatra.ATETopology { - port1 := ate.Port(t, "port1") - topo := ate.Topology().New() - iDut1 := topo.AddInterface(ateSrc.Name).WithPort(port1) - iDut1.IPv4().WithAddress(ateSrc.IPv4CIDR()).WithDefaultGateway(dutSrc.IPv4) - - port2 := ate.Port(t, "port2") - iDut2 := topo.AddInterface(ateDst.Name).WithPort(port2) - iDut2.IPv4().WithAddress(ateDst.IPv4CIDR()).WithDefaultGateway(dutDst.IPv4) - - // Setup ATE BGP route v4 advertisement. - bgpDut1 := iDut1.BGP() - bgpDut1.AddPeer().WithPeerAddress(dutSrc.IPv4).WithLocalASN(ateAS1). - WithTypeExternal() - - bgpDut2 := iDut2.BGP() - bgpDut2.AddPeer().WithPeerAddress(dutDst.IPv4).WithLocalASN(ateAS2). - WithTypeExternal() - - bgpNeti1 := iDut1.AddNetwork("bgpNeti1") - bgpNeti1.IPv4().WithAddress(advertisedRoutesv4CIDR).WithCount(routeCount) - bgpNeti1.BGP().WithNextHopAddress(ateSrc.IPv4) - - if asSEQMode { - bgpNeti1.BGP().AddASPathSegment(asSeg...).WithTypeSEQ() - } else { - // TODO : SET mode is not working - // https://github.com/openconfig/featureprofiles/issues/1659 - bgpNeti1.BGP().AddASPathSegment(asSeg...).WithTypeSET() - } - - t.Logf("Pushing config to ATE and starting protocols...") - topo.Push(t) - topo.StartProtocols(t) - - return topo -} - -type bgpNeighbor struct { - as uint32 - neighborip string - isV4 bool - peerGrp string -} - -// verifyBGPAsPath is to Validate AS Path attribute using bgp rib telemetry on ATE. -func verifyBGPAsPath(t *testing.T, dut *ondatra.DUTDevice, ate *ondatra.ATEDevice, asSeg []uint32, removeASPath bool) { - at := gnmi.OC() - rib := at.NetworkInstance(ateDst.Name).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "0").Bgp().Rib() - prefixPath := rib.AfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).Ipv4Unicast(). - NeighborAny().AdjRibInPre().RouteAny().WithPathId(0).Prefix() - - gnmi.WatchAll(t, ate, prefixPath.State(), time.Minute, func(v *ygnmi.Value[string]) bool { - _, present := v.Val() - return present - }).Await(t) - - var wantASSeg = []uint32{dutAS, ateAS1} - - if removeASPath { - for _, as := range asSeg { - if as < 64512 { - wantASSeg = append(wantASSeg, as) - } - } - } else { - wantASSeg = append(wantASSeg, asSeg...) - } - - gotASSeg, ok := gnmi.WatchAll(t, ate, rib.AttrSetAny().AsSegmentMap().State(), 1*time.Minute, func(v *ygnmi.Value[map[uint32]*oc.NetworkInstance_Protocol_Bgp_Rib_AttrSet_AsSegment]) bool { - val, present := v.Val() - if present { - for _, as := range val { - if cmp.Equal(as.Member, wantASSeg) { - return true - } - } - } - return false - }).Await(t) - if !ok { - t.Errorf("Obtained AS path on ATE is not as expected, gotASSeg %v, wantASSeg %v", gotASSeg, wantASSeg) - } -} - -// configreRoutePolicy adds route-policy config -func configureRoutePolicy(t *testing.T, dut *ondatra.DUTDevice, name string, pr oc.E_RoutingPolicy_PolicyResultType) { - d := &oc.Root{} - rp := d.GetOrCreateRoutingPolicy() - pd := rp.GetOrCreatePolicyDefinition(name) - st, err := pd.AppendNewStatement("id-1") - if err != nil { - t.Fatal(err) - } - stc := st.GetOrCreateConditions() - stc.InstallProtocolEq = oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP - st.GetOrCreateActions().PolicyResult = pr - gnmi.Replace(t, dut, gnmi.OC().RoutingPolicy().Config(), rp) -} - -// TestRemovePrivateAS is to Validate that private AS numbers are stripped -// before advertisement to the eBGP neighbor. -func TestRemovePrivateAS(t *testing.T) { - t.Logf("Start DUT config load.") - dut := ondatra.DUT(t, "dut") - - t.Run("Configure DUT interfaces", func(t *testing.T) { - t.Logf("Start DUT interface Config.") - configureDUT(t, dut) - }) - - t.Run("Configure DEFAULT network instance.", func(t *testing.T) { - t.Log("Configure Network Instance type to DEFAULT.") - dutConfNIPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)) - gnmi.Replace(t, dut, dutConfNIPath.Type().Config(), oc.NetworkInstanceTypes_NETWORK_INSTANCE_TYPE_DEFAULT_INSTANCE) - }) - - dutConfPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP") - t.Run("Configure BGP Neighbors.", func(t *testing.T) { - t.Logf("Start DUT BGP Config.") - gnmi.Delete(t, dut, dutConfPath.Config()) - configureRoutePolicy(t, dut, policyName, oc.RoutingPolicy_PolicyResultType_ACCEPT_ROUTE) - dutConf := bgpCreateNbr(dutAS, ateAS1, dut) - gnmi.Replace(t, dut, dutConfPath.Config(), dutConf) - fptest.LogQuery(t, "DUT BGP Config", dutConfPath.Config(), gnmi.Get(t, dut, dutConfPath.Config())) - }) - - cases := []struct { - desc string - asSeg []uint32 - asSEQMode bool - }{{ - desc: "AS Path SEQ - 65501, 65507, 65534", - asSeg: []uint32{65501, 65507, 65534}, - asSEQMode: true, - }, { - desc: "AS Path SEQ - 65501, 600", - asSeg: []uint32{65501, 600}, - asSEQMode: true, - }, { - desc: "AS Path SEQ - 800, 65501, 600", - asSeg: []uint32{800, 65501, 600}, - asSEQMode: true, - }} - - for _, tc := range cases { - t.Run(tc.desc, func(t *testing.T) { - t.Logf("Start ATE Config.") - ate := ondatra.ATE(t, "ate") - topo := configureATE(t, ate, tc.asSeg, tc.asSEQMode) - - t.Log("Verifying port status.") - verifyPortsUp(t, dut.Device) - - t.Log("Check BGP parameters.") - verifyBGPTelemetry(t, dut) - - t.Log("Verify BGP prefix telemetry.") - verifyPrefixesTelemetry(t, dut, ateSrc.IPv4, routeCount, 0) - verifyPrefixesTelemetry(t, dut, ateDst.IPv4, 0, routeCount) - - t.Log("Verify AS Path list received at ate Port2 including private AS number.") - verifyBGPAsPath(t, dut, ate, tc.asSeg, !removeASPath) - - t.Log("Configure remove private AS on DUT.") - gnmi.Update(t, dut, dutConfPath.Bgp().PeerGroup(peerGrpName2).RemovePrivateAs().Config(), oc.Bgp_RemovePrivateAsOption_PRIVATE_AS_REMOVE_ALL) - - t.Log("Private AS numbers should be stripped off while advertising BGP routes into public AS.") - verifyBGPAsPath(t, dut, ate, tc.asSeg, removeASPath) - - topo.StopProtocols(t) - - t.Log("Remove remove-private-AS on DUT.") - gnmi.Delete(t, dut, dutConfPath.Bgp().PeerGroup(peerGrpName2).RemovePrivateAs().Config()) - }) - } -} diff --git a/feature/experimental/bgp/ate_tests/bgp_remove_private_as/metadata.textproto b/feature/experimental/bgp/ate_tests/bgp_remove_private_as/metadata.textproto deleted file mode 100644 index 4a298ab13bd..00000000000 --- a/feature/experimental/bgp/ate_tests/bgp_remove_private_as/metadata.textproto +++ /dev/null @@ -1,24 +0,0 @@ -# proto-file: github.com/openconfig/featureprofiles/proto/metadata.proto -# proto-message: Metadata - -uuid: "2b4372c2-8827-4624-837c-f44b1a54edf7" -plan_id: "RT-1.11" -description: "BGP remove private AS" -testbed: TESTBED_DUT_ATE_2LINKS -platform_exceptions: { - platform: { - vendor: ARISTA - } - deviations: { - interface_enabled: true - default_network_instance: "default" - } -} -platform_exceptions: { - platform: { - vendor: NOKIA - } - deviations: { - interface_enabled: true - } -} diff --git a/feature/experimental/system/gnmi/benchmarking/ate_tests/drained_configuration_convergence_time/README.md b/feature/experimental/system/gnmi/benchmarking/ate_tests/drained_configuration_convergence_time/README.md deleted file mode 100644 index 80b76298f1e..00000000000 --- a/feature/experimental/system/gnmi/benchmarking/ate_tests/drained_configuration_convergence_time/README.md +++ /dev/null @@ -1,55 +0,0 @@ -# gNMI-1.3: Benchmarking: Drained Configuration Convergence Time - -## Summary - -Measure performance of drained configuration being applied. - -## Procedure - -Configure DUT with maximum number of IS-IS adjacencies, and BGP -peers - with physical interfaces between ATE and DUT for IS-IS -peers. - -First port is used as ingress port to send routes from ATE to DUT. - -For each of the following configurations, generate complete device -configuration and measure time for the operation to complete (as -defined in the case): - * TODO: IS-IS overload: - * At t=0, send Set to DUT marking IS-IS overload bit. - * Measure time between t=0 and all IS-IS sessions on ATE to - report DUT as overloaded. - * IS-IS metric change: - * At t=0, send Set to DUT marking IS-IS metric as changed for - all IS-IS interfaces. - * Measure time between t=0 and all IS-IS sessions on ATE to - report changed metric. - * BGP AS_PATH prepend: - * At t=0, send Set to DUT changing BGP policy for each session - to prepend AS_PATH. - * Measure time between t=0 and all BGP received routes on ATE - to report change in as path. - * TODO: BGP MED manipulation. - * At t=0, send Set to DUT changing BGP policy for each session to - set MED to non-default value. - * Measure time between t=0 and all BGP received routes on ATE to - report changed metric. - -## Config Parameter coverage - - * BGP - * /routing-policy/policy-definitions/policy-definition/statements/statement/actions/bgp-actions/config/set-med - * /routing-policy/policy-definitions/policy-definition/statements/statement/actions/bgp-actions/set-as-path-prepend/config/repeat-n - * /routing-policy/policy-definitions/policy-definition/statements/statement/actions/bgp-actions/set-as-path-prepend/config/as-number - - * ISIS - * /network-instances/network-instance/protocols/protocol/isis/interfaces/interface/levels/level/afi-safi/af/state/metric - * /network-instances/network-instance/protocols/protocol/isis/global/lsp-bit/overload-bit/state/set-bit - -## Telemetry Parameter coverage - - * ISIS - * /interfaces/interfaces/levels/level/adjacencies/adjacency/state/adjacency-state - * BGP - * /afi-safis/afi-safi/state/prefixes/sent - * /network-instances/network-instance/protocols/protocol/bgp/neighbors/neighbor diff --git a/feature/experimental/system/gnmi/benchmarking/ate_tests/drained_configuration_convergence_time/drained_configuration_convergence_time_bgp_test.go b/feature/experimental/system/gnmi/benchmarking/ate_tests/drained_configuration_convergence_time/drained_configuration_convergence_time_bgp_test.go deleted file mode 100644 index 925e9149c55..00000000000 --- a/feature/experimental/system/gnmi/benchmarking/ate_tests/drained_configuration_convergence_time/drained_configuration_convergence_time_bgp_test.go +++ /dev/null @@ -1,367 +0,0 @@ -// Copyright 2023 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. - -// drained_configuration_convergence_time_test is used to verify bgp test scenarios -// as given in gnmi1.3 testcase. -package drained_configuration_convergence_time_test - -import ( - "net" - "testing" - "time" - - "github.com/google/go-cmp/cmp" - "github.com/openconfig/featureprofiles/feature/experimental/system/gnmi/benchmarking/internal/setup" - "github.com/openconfig/featureprofiles/internal/deviations" - "github.com/openconfig/featureprofiles/internal/fptest" - "github.com/openconfig/ondatra" - "github.com/openconfig/ondatra/gnmi" - "github.com/openconfig/ondatra/gnmi/oc" - "github.com/openconfig/ygnmi/ygnmi" - "github.com/openconfig/ygot/ygot" -) - -func TestMain(m *testing.M) { - fptest.RunTests(m) -} - -const ( - asPathRepeatValue = 3 - aclStatement2 = "20" - aclStatement3 = "30" - setASpathPrependPolicy = "SET-ASPATH-PREPEND" - setMEDPolicy = "SET-MED" - setALLOWPolicy = "ALLOW" - bgpMED = 25 -) - -// setAllow is used to configure ALLOW routing policy on DUT. -func setAllow(t *testing.T, dut *ondatra.DUTDevice, d *oc.Root) { - - // Configure Allow Policy on DUT. - rp := d.GetOrCreateRoutingPolicy() - pd := rp.GetOrCreatePolicyDefinition(setALLOWPolicy) - st, err := pd.AppendNewStatement("id-1") - if err != nil { - t.Fatal(err) - } - st.GetOrCreateActions().PolicyResult = oc.RoutingPolicy_PolicyResultType_ACCEPT_ROUTE - - gnmi.Replace(t, dut, gnmi.OC().RoutingPolicy().Config(), rp) -} - -// setMED is used to configure routing policy to set BGP MED on DUT. -func setMED(t *testing.T, dut *ondatra.DUTDevice, d *oc.Root) { - - // Configure SetMED on DUT. - rp := d.GetOrCreateRoutingPolicy() - pdef5 := rp.GetOrCreatePolicyDefinition(setMEDPolicy) - stmt, err := pdef5.AppendNewStatement(aclStatement3) - if err != nil { - t.Fatal(err) - } - actions5 := stmt.GetOrCreateActions() - setMedBGP := actions5.GetOrCreateBgpActions() - setMedBGP.SetMed = oc.UnionUint32(bgpMED) - actions5.PolicyResult = oc.RoutingPolicy_PolicyResultType_ACCEPT_ROUTE - if deviations.BGPSetMedRequiresEqualOspfSetMetric(dut) { - actions5.GetOrCreateOspfActions().GetOrCreateSetMetric().SetMetric(bgpMED) - } - - gnmi.Replace(t, dut, gnmi.OC().RoutingPolicy().Config(), rp) -} - -// setASPath is used to configure route policy set-as-path prepend on DUT. -func setASPath(t *testing.T, dut *ondatra.DUTDevice, d *oc.Root) { - - // Configure SetASPATH routing policy on DUT. - rp := d.GetOrCreateRoutingPolicy() - pdef5 := rp.GetOrCreatePolicyDefinition(setASpathPrependPolicy) - stmt, err := pdef5.AppendNewStatement(aclStatement2) - if err != nil { - t.Fatal(err) - } - actions5 := stmt.GetOrCreateActions() - actions5.PolicyResult = oc.RoutingPolicy_PolicyResultType_ACCEPT_ROUTE - aspend := actions5.GetOrCreateBgpActions().GetOrCreateSetAsPathPrepend() - aspend.Asn = ygot.Uint32(setup.DUTAs) - aspend.RepeatN = ygot.Uint8(asPathRepeatValue) - - gnmi.Replace(t, dut, gnmi.OC().RoutingPolicy().Config(), rp) - - netInstance := d.GetOrCreateNetworkInstance(deviations.DefaultNetworkInstance(dut)) - bgp := netInstance.GetOrCreateProtocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP").GetOrCreateBgp() - pg := bgp.GetOrCreatePeerGroup(setup.PeerGrpName) - rpl := pg.GetOrCreateApplyPolicy() - rpl.SetImportPolicy([]string{setALLOWPolicy}) - - gnmi.Update(t, dut, gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP").Bgp().PeerGroup(setup.PeerGrpName).Config(), pg) - -} - -func setPolicyPeerGroup(t *testing.T, dut *ondatra.DUTDevice, d *oc.Root, policy []string) { - - // Set BGP Import policy - netInstance := d.GetOrCreateNetworkInstance(deviations.DefaultNetworkInstance(dut)) - bgp := netInstance.GetOrCreateProtocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP").GetOrCreateBgp() - pg := bgp.GetOrCreatePeerGroup(setup.PeerGrpName) - pg.PeerAs = ygot.Uint32(setup.ATEAs) - pg.PeerGroupName = ygot.String(setup.PeerGrpName) - afipg := pg.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST) - afipg.Enabled = ygot.Bool(true) - if deviations.RoutePolicyUnderAFIUnsupported(dut) { - pgpolicy := pg.GetOrCreateApplyPolicy() - pgpolicy.ImportPolicy = policy - gnmi.Replace(t, dut, gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP").Bgp().PeerGroup(setup.PeerGrpName).Config(), pg) - - } else { - pgpolicy := afipg.GetOrCreateApplyPolicy() - pgpolicy.ImportPolicy = policy - gnmi.Replace(t, dut, gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP").Bgp().PeerGroup(setup.PeerGrpName).Config(), pg) - - } -} - -// isConverged function is used to check if ATE has received all the prefixes. -func isConverged(t *testing.T, dut *ondatra.DUTDevice, ate *ondatra.ATEDevice, ap *ondatra.Port) { - - // Add 10 second timer for BGP update to propagate - time.Sleep(10 * time.Second) - // Check if all prefixes are learned at ATE. - statePath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)). - Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP").Bgp() -prefixLoop: - for repeat := 4; repeat > 0; repeat-- { - prefixesv4 := statePath.Neighbor(setup.ATEIPList[ap.ID()].String()). - AfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).Prefixes() - gotSent := gnmi.Get(t, dut, prefixesv4.Sent().State()) - switch { - case gotSent == setup.RouteCount: - t.Logf("Prefixes sent from ingress port are learnt at ATE dst port : %v are %v", setup.ATEIPList[ap.ID()].String(), setup.RouteCount) - break prefixLoop - case repeat > 0 && gotSent < setup.RouteCount: - t.Logf("All the prefixes are not learnt , wait for 5 secs before retry.. got %v, want %v", gotSent, setup.RouteCount) - time.Sleep(time.Second * 5) - case repeat == 0 && gotSent < setup.RouteCount: - t.Errorf("sent prefixes from DUT to neighbor %v is mismatch: got %v, want %v", setup.ATEIPList[ap.ID()].String(), gotSent, setup.RouteCount) - } - } - -} - -// verifyBGPAsPath is to Validate AS Path attribute using bgp rib telemetry on ATE. -func verifyBGPAsPath(t *testing.T, dut *ondatra.DUTDevice, ate *ondatra.ATEDevice) { - - // Start the timer. - start := time.Now() - if deviations.RoutePolicyUnderAFIUnsupported(dut) { - dutPolicyConfPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)). - Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP").Bgp(). - PeerGroup(setup.PeerGrpName).ApplyPolicy().ExportPolicy() - - gnmi.Replace(t, dut, dutPolicyConfPath.Config(), []string{setASpathPrependPolicy}) - } else { - dutPolicyConfPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)). - Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP").Bgp(). - PeerGroup(setup.PeerGrpName).AfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).ApplyPolicy().ExportPolicy() - gnmi.Replace(t, dut, dutPolicyConfPath.Config(), []string{setASpathPrependPolicy}) - } - t.Run("BGP-AS-PATH Verification", func(t *testing.T) { - at := gnmi.OC() - for _, ap := range ate.Ports() { - if ap.ID() == "port1" { - // port1 is ingress, skip verification on ingress port. - continue - } - - // Validate if all prefixes are received by ATE. - isConverged(t, dut, ate, ap) - - rib := at.NetworkInstance(ap.Name()).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "0").Bgp().Rib() - prefixPath := rib.AfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).Ipv4Unicast(). - NeighborAny().AdjRibInPre().RouteAny().WithPathId(0).Prefix() - - gnmi.WatchAll(t, ate, prefixPath.State(), time.Minute, func(v *ygnmi.Value[string]) bool { - _, present := v.Val() - return present - }).Await(t) - - singlepath := []uint32{setup.DUTAs, setup.DUTAs, setup.DUTAs, setup.DUTAs, setup.ATEAs2} - _, ok := gnmi.WatchAll(t, ate, rib.AttrSetAny().AsSegmentMap().State(), 5*time.Minute, func(v *ygnmi.Value[map[uint32]*oc.NetworkInstance_Protocol_Bgp_Rib_AttrSet_AsSegment]) bool { - val, present := v.Val() - if present { - for _, as := range val { - if cmp.Equal(as.Member, singlepath) { - return true - } - } - } - return false - }).Await(t) - if !ok { - t.Errorf("Obtained AS path on ATE is not as expected") - } - } - }) - - // End the timer and calculate time. - elapsed := time.Since(start) - t.Logf("Duration taken to apply as path prepend policy is %v", elapsed) -} - -// verifyBGPSetMED is to Validate MED attribute using bgp rib telemetry on ATE. -func verifyBGPSetMED(t *testing.T, dut *ondatra.DUTDevice, ate *ondatra.ATEDevice) { - - // Build wantSetMED to compare the diff. - var wantSetMED []uint32 - for i := 0; i < setup.RouteCount; i++ { - wantSetMED = append(wantSetMED, bgpMED) - } - - // Start the timer. - start := time.Now() - if deviations.RoutePolicyUnderAFIUnsupported(dut) { - dutPolicyConfPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)). - Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP").Bgp(). - PeerGroup(setup.PeerGrpName).ApplyPolicy().ExportPolicy() - gnmi.Replace(t, dut, dutPolicyConfPath.Config(), []string{setMEDPolicy}) - } else { - dutPolicyConfPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)). - Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP").Bgp(). - PeerGroup(setup.PeerGrpName).AfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).ApplyPolicy().ExportPolicy() - gnmi.Replace(t, dut, dutPolicyConfPath.Config(), []string{setMEDPolicy}) - } - - t.Run("BGP-MED-Verification", func(t *testing.T) { - at := gnmi.OC() - for _, ap := range ate.Ports() { - if ap.ID() == "port1" { - continue - } - - // Validate if all prefixes are received by ATE. - isConverged(t, dut, ate, ap) - rib := at.NetworkInstance(ap.Name()).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "0").Bgp().Rib() - routeP := rib.AfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).Ipv4Unicast(). - NeighborAny().AdjRibInPre().RouteAny().WithPathId(0) - routes := gnmi.GetAll(t, ate, routeP.State()) - attrs := gnmi.GetAll(t, ate, rib.AttrSetAny().State()) - mask := net.IPv4Mask(255, 255, 255, 0) - masked := net.ParseIP(setup.AdvertiseBGPRoutesv4).Mask(mask) - var gotSetMED []uint32 - var pref []string - for _, route := range routes { - ip, _, _ := net.ParseCIDR(route.GetPrefix()) - pref = append(pref, route.GetPrefix()) - if ip.Mask(mask).Equal(masked) { - idx := route.GetAttrIndex() - if idx >= uint64(len(attrs)) { - t.Errorf("Invalid attr-index %d for prefix: %s", idx, route.GetPrefix()) - continue - } - gotSetMED = append(gotSetMED, attrs[idx].GetMed()) - } - } - if diff := cmp.Diff(wantSetMED, gotSetMED); diff != "" { - t.Errorf("obtained MED on ATE is not as expected, got %v, want %v, Prefixes %v", gotSetMED, wantSetMED, pref) - } - } - }) - // End the timer and calculate time taken to apply setMED. - elapsed := time.Since(start) - t.Logf("Duration taken to apply setMed routing policy is %v", elapsed) -} - -// TestEstablish is to configure Interface, BGP and ISIS configurations on DUT -// using gnmi set request. It also verifies for bgp and isis adjacencies. -func TestEstablish(t *testing.T) { - - dut := ondatra.DUT(t, "dut") - dutConfigPath := gnmi.OC() - - t.Log("Configure Network Instance type to DEFAULT on DUT.") - fptest.ConfigureDefaultNetworkInstance(t, dut) - - t.Log("Build Benchmarking BGP and ISIS test configs.") - dutBenchmarkConfig := setup.BuildBenchmarkingConfig(t) - if !deviations.ExplicitInterfaceInDefaultVRF(dut) { - fptest.LogQuery(t, "Benchmarking configs to configure on DUT", dutConfigPath.Config(), dutBenchmarkConfig) - } - // Apply benchmarking configs on dut - gnmi.Update(t, dut, dutConfigPath.Config(), dutBenchmarkConfig) - - t.Log("Configure ATE with Interfaces, BGP, ISIS configs.") - ate := ondatra.ATE(t, "ate") - setup.ConfigureATE(t, ate) - - t.Log("Verify BGP Session state , should be in ESTABLISHED State.") - setup.VerifyBgpTelemetry(t, dut) - - t.Log("Verify ISIS adjacency state, should be UP.") - setup.VerifyISISTelemetry(t, dut) -} - -// TestBGPBenchmarking is test time taken to apply set as path prepend and set med routing -// policies on routes in bgp rib. Verification of routing policy is done on ATE using bgp -// rib table. -func TestBGPBenchmarking(t *testing.T) { - - d := &oc.Root{} - dut := ondatra.DUT(t, "dut") - ate := ondatra.ATE(t, "ate") - // Cleanup existing policy details. - if deviations.RoutePolicyUnderAFIUnsupported(dut) { - dutPolicyConfPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP").Bgp().PeerGroup(setup.PeerGrpName).ApplyPolicy() - gnmi.Delete(t, dut, dutPolicyConfPath.ExportPolicy().Config()) - gnmi.Delete(t, dut, dutPolicyConfPath.ImportPolicy().Config()) - } else { - dutPolicyConfPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP").Bgp().PeerGroup(setup.PeerGrpName).AfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).ApplyPolicy() - gnmi.Delete(t, dut, dutPolicyConfPath.ExportPolicy().Config()) - gnmi.Delete(t, dut, dutPolicyConfPath.ImportPolicy().Config()) - } - gnmi.Delete(t, dut, gnmi.OC().RoutingPolicy().Config()) - - t.Logf("Configure Allow policy.") - setAllow(t, dut, d) - - t.Logf("Configure MED routing policy.") - setMED(t, dut, d) - - t.Logf("Configure Allow Import routing policy in BGP.") - setPolicyPeerGroup(t, dut, d, []string{setALLOWPolicy}) - - t.Logf("Verify time taken to apply MED to all routes in bgp rib.") - verifyBGPSetMED(t, dut, ate) - - // Cleanup existing policy details. - if deviations.RoutePolicyUnderAFIUnsupported(dut) { - dutPolicyConfPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP").Bgp().PeerGroup(setup.PeerGrpName).ApplyPolicy() - gnmi.Delete(t, dut, dutPolicyConfPath.ExportPolicy().Config()) - gnmi.Delete(t, dut, dutPolicyConfPath.ImportPolicy().Config()) - } else { - dutPolicyConfPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP").Bgp().PeerGroup(setup.PeerGrpName).AfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).ApplyPolicy() - gnmi.Delete(t, dut, dutPolicyConfPath.ExportPolicy().Config()) - gnmi.Delete(t, dut, dutPolicyConfPath.ImportPolicy().Config()) - } - gnmi.Delete(t, dut, gnmi.OC().RoutingPolicy().Config()) - - t.Logf("Configure SET-AS-PATH routing policy.") - setASPath(t, dut, d) - - t.Logf("Configure Allow Import routing policy in BGP.") - setPolicyPeerGroup(t, dut, d, []string{setALLOWPolicy}) - - t.Logf("Verify time taken to apply SET-AS-PATH to all routes in bgp rib.") - verifyBGPAsPath(t, dut, ate) -} diff --git a/feature/experimental/system/gnmi/benchmarking/ate_tests/drained_configuration_convergence_time/drained_configuration_convergence_time_isis_test.go b/feature/experimental/system/gnmi/benchmarking/ate_tests/drained_configuration_convergence_time/drained_configuration_convergence_time_isis_test.go deleted file mode 100644 index e14f163c63f..00000000000 --- a/feature/experimental/system/gnmi/benchmarking/ate_tests/drained_configuration_convergence_time/drained_configuration_convergence_time_isis_test.go +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright 2023 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. - -// drained_configuration_convergence_time_test is used to verify isis test scenarios -// as given in gnmi 1.3 testcase -package drained_configuration_convergence_time_test - -import ( - "testing" - "time" - - "github.com/openconfig/featureprofiles/feature/experimental/system/gnmi/benchmarking/internal/setup" - "github.com/openconfig/featureprofiles/internal/deviations" - "github.com/openconfig/ondatra" - "github.com/openconfig/ondatra/gnmi" - "github.com/openconfig/ondatra/gnmi/oc" - "github.com/openconfig/ygnmi/ygnmi" -) - -// setISISOverloadBit is used to configure isis overload bit to true. -func setISISOverloadBit(t *testing.T, dut *ondatra.DUTDevice) { - - // ISIS Configs to set Overload Bit to true. - dutISISPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_ISIS, setup.ISISInstance).Isis() - lspBit := dutISISPath.Global().LspBit().OverloadBit() - gnmi.Replace(t, dut, lspBit.SetBit().Config(), true) -} - -// setISISMetric is used to configure metric on isis interfaces. -func setISISMetric(t *testing.T, dut *ondatra.DUTDevice) { - - dutISISPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_ISIS, setup.ISISInstance).Isis() - t.Logf("Configure ISIS metric to %v", setup.ISISMetric) - for _, dp := range dut.Ports() { - intfName := dp.Name() - if deviations.ExplicitInterfaceInDefaultVRF(dut) { - intfName = dp.Name() + ".0" - } - dutISISPathIntfAF := dutISISPath.Interface(intfName).Level(2).Af(oc.IsisTypes_AFI_TYPE_IPV4, oc.IsisTypes_SAFI_TYPE_UNICAST) - if deviations.ISISRequireSameL1MetricWithL2Metric(dut) { - b := &gnmi.SetBatch{} - gnmi.BatchReplace(b, dutISISPathIntfAF.Metric().Config(), setup.ISISMetric) - l1AF := dutISISPath.Interface(intfName).Level(1).Af(oc.IsisTypes_AFI_TYPE_IPV4, oc.IsisTypes_SAFI_TYPE_UNICAST) - gnmi.BatchReplace(b, l1AF.Metric().Config(), setup.ISISMetric) - b.Set(t, dut) - } else { - gnmi.Replace(t, dut, dutISISPathIntfAF.Metric().Config(), setup.ISISMetric) - } - } -} - -// verifyISISMetric is used to verify on ATE to see how much time it -// has taken to apply changes in metric -func verifyISISMetric(t *testing.T, dut *ondatra.DUTDevice, ate *ondatra.ATEDevice) { - - t.Run("ISIS Metric verification", func(t *testing.T) { - at := gnmi.OC() - for _, ap := range ate.Ports() { - if ap.ID() == "port1" { - // Port1 is ingress, skip verification on ingress port - continue - } - - const want = oc.Interface_OperStatus_UP - - if got := gnmi.Get(t, ate, at.Interface(ap.Name()).OperStatus().State()); got != want { - t.Errorf("%s oper-status got %v, want %v", ap, got, want) - } - is := at.NetworkInstance(ap.Name()).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_ISIS, "0").Isis() - lsps := is.LevelAny().LspAny() - - _, ok := gnmi.WatchAll(t, ate, lsps.Tlv(oc.IsisLsdbTypes_ISIS_TLV_TYPE_EXTENDED_IPV4_REACHABILITY).ExtendedIpv4Reachability().PrefixAny().Metric().State(), 5*time.Minute, func(v *ygnmi.Value[uint32]) bool { - val, present := v.Val() - return present && val == setup.ISISMetric - }).Await(t) - if !ok { - t.Errorf("Obtained Metric on ATE is not as expected") - } - } - }) -} - -// verifyISISOverloadBit is used to verify on ATE to see how much time it -// has taken to apply overload bit on isis adjacencies. -func verifyISISOverloadBit(t *testing.T, dut *ondatra.DUTDevice, ate *ondatra.ATEDevice) { - - t.Run("ISIS Overload bit verification", func(t *testing.T) { - at := gnmi.OC() - for _, ap := range ate.Ports() { - if ap.ID() == "port1" { - // port1 is ingress, skip verification on ingress port - continue - } - - const want = oc.Interface_OperStatus_UP - - if got := gnmi.Get(t, ate, at.Interface(ap.Name()).OperStatus().State()); got != want { - t.Errorf("%s oper-status got %v, want %v", ap, got, want) - } - // TODO: SetBit retrieval is not working in ATE. - // Ref: https://github.com/openconfig/featureprofiles/issues/1176 - // Below code will be uncommented once above issue is resolved. - - // is := at.NetworkInstance(ap.Name()).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_ISIS, "0").Isis() - // lsps := is.LevelAny().LspAny() - // gotIsisSetBit := gnmi.GetAll(t, ate, lsps.Tlv(oc.IsisLsdbTypes_ISIS_TLV_TYPE_EXTENDED_IPV4_REACHABILITY).ExtendedIpv4Reachability().PrefixAny().SBit().State()) - // if diff := cmp.Diff(setup.ISISSetBitList, gotIsisSetBit); diff != "" { - // t.Errorf("obtained setBit on ATE is not as expected, got %v, want %v", gotIsisSetBit, setup.ISISSetBitList) - // } - } - }) -} - -// TestISISBenchmarking is to test ISIS overload bit and metric change -// applied on all isis sessions. -func TestISISBenchmarking(t *testing.T) { - - dut := ondatra.DUT(t, "dut") - ate := ondatra.ATE(t, "ate") - t.Log("Start timer for ISIS overload bit verification test.") - start := time.Now() - t.Log("Configure ISIS overload bit on DUT.") - setISISOverloadBit(t, dut) - t.Log("Verify on ATE if ISIS overload bit is reflected on ATE.") - verifyISISOverloadBit(t, dut, ate) - t.Log("End the timer and calculate time taken to apply ISIS overload bit.") - elapsed := time.Since(start) - t.Logf("Duration taken to apply overload bit: %v", elapsed) - - t.Log("Start timer for ISIS Metric test.") - start = time.Now() - t.Log("Configure ISIS Metric on DUT.") - setISISMetric(t, dut) - t.Log("Verify on ATE if ISIS Metric changes are reflected.") - verifyISISMetric(t, dut, ate) - t.Log("End the timer and calculate time taken to apply ISIS Metric.") - elapsed = time.Since(start) - t.Logf("Duration taken to apply isis metric: %v", elapsed) -} diff --git a/feature/experimental/system/gnmi/benchmarking/ate_tests/drained_configuration_convergence_time/metadata.textproto b/feature/experimental/system/gnmi/benchmarking/ate_tests/drained_configuration_convergence_time/metadata.textproto deleted file mode 100644 index e6104d7837a..00000000000 --- a/feature/experimental/system/gnmi/benchmarking/ate_tests/drained_configuration_convergence_time/metadata.textproto +++ /dev/null @@ -1,43 +0,0 @@ -# proto-file: github.com/openconfig/featureprofiles/proto/metadata.proto -# proto-message: Metadata - -uuid: "44ec09b1-d985-4188-9f4a-ae542ad9d3a2" -plan_id: "gNMI-1.3" -description: "Benchmarking: Drained Configuration Convergence Time" -testbed: TESTBED_DUT_ATE_2LINKS -platform_exceptions: { - platform: { - vendor: NOKIA - } - deviations: { - isis_global_authentication_not_required: true - isis_explicit_level_authentication_config: true - missing_isis_interface_afi_safi_enable: true - explicit_port_speed: true - explicit_interface_in_default_vrf: true - interface_enabled: true - } -} -platform_exceptions: { - platform: { - vendor: JUNIPER - } - deviations: { - isis_level_enabled: true - } -} -platform_exceptions: { - platform: { - vendor: ARISTA - } - deviations: { - route_policy_under_afi_unsupported: true - interface_enabled: true - default_network_instance: "default" - missing_isis_interface_afi_safi_enable: true - isis_interface_afi_unsupported: true - isis_require_same_l1_metric_with_l2_metric: true - bgp_set_med_requires_equal_ospf_set_metric: true - isis_instance_enabled_required: true - } -}