openconfig / ondatra

54 stars 37 forks source link

Feature request - need a way to retrieve ISIS Learned info in ATE #42

Closed Vibaswan closed 2 years ago

Vibaswan commented 2 years ago

Use-case: ISIS feature profile tests would be needing ISIS metrics which would in turn, would require to get some learned info of the ISIS LSPS

So currently I see there are ways we can fetch Isis metrics like the below snippet:

isis := at.NetworkInstance(ap.Name()).Protocol(telemetry.PolicyTypes_INSTALL_PROTOCOL_TYPE_ISIS, fmt.Sprintf("isis-%s", ap.Name())).Isis()
isis.LevelAny().LspAny().IsType().Get(t)
isis.LevelAny().LspAny().Flags().Get(t)
isis.LevelAny().LspAny().LspId().Get(t)

But they return empty results. So I guess we need to populate these with the result fetched from ATE .

I see a similar effort was done for BGP in the following files https://github.com/openconfig/ondatra/blob/main/internal/ixgnmi/ixgnmi.go https://github.com/openconfig/ondatra/blob/main/internal/ixgnmi/learnedinfo.go

Probably would be needing similar kind of support for ISIS as well.

Please let me know If I have missed something

greg-dennis commented 2 years ago

I still be investigating this feature request in my sprint that starts tomorrow. It may be quite a sizable feature request, so no promises about this being completed immediately. I'll report back when the investigation is done.

greg-dennis commented 2 years ago

I am evaluating this request this sprint and will have either completed this request or will have a timetable to announce by 10/25.

greg-dennis commented 2 years ago

@Vibaswan can you please provide an IxNetwork config and reference to the IxNetwork operation that retrieves the specific info you are interested in?

Vibaswan commented 2 years ago

Hi @greg-dennis , Given below is the test which would create ISIS in b2b and can retrieve the info using the api /topology/deviceGroup/ethernet/isisL3/operations/getlearnedinfo and then retrieving the table from learned info `/topology/2/deviceGroup/1/ethernet/1/isisL3/2/learnedInfo/1/table/1' the same way we have retrieved bgp learned info

Note: some parameters like off-load bit is not yet supported by ATE and we have raised feature request for the same in Ixnetwork, would let you know once its done.

ISIS-b2b Test:

package topology_test

import (
    "fmt"
    "sort"
    "testing"

    "github.com/openconfig/featureprofiles/internal/fptest"
    "github.com/openconfig/ondatra"
    "github.com/openconfig/ondatra/telemetry"
)

func TestMain(m *testing.M) {
    fptest.RunTests(m)
}

// plen is the IPv4 prefix length used for IPv4 assignments in this
// topology.
const plen = 30

// dutPortIP assigns IP addresses for DUT port i, where i is the index
// of the port slices returned by dut.Ports().
func dutPortIP(i int) string {
    if i == 0 {
        return fmt.Sprintf("100.1.0.11")
    } else {
        return fmt.Sprintf("100.1.0.1")
    }
}

// atePortCIDR assigns IP addresses with prefixlen for ATE port i, where
// i is the index of the port slices returned by ate.Ports().
func atePortCIDR(i int) string {
    if i == 0 {
        return fmt.Sprintf("100.1.0.1/24")
    } else {
        return fmt.Sprintf("100.1.0.11/24")
    }
}

func ipPrefix(i int) string {
    if i == 0 {
        return fmt.Sprintf("1.2.3.4/24")
    } else {
        return fmt.Sprintf("5.6.7.8/24")
    }
}

func getRouterId(i int) string {
    if i == 1 {
        return fmt.Sprintf("1.1.1.2")
    } else {
        return fmt.Sprintf("1.1.1.1")
    }
}

func configureIsisATE(t *testing.T, ate *ondatra.ATEDevice, atePorts []*ondatra.Port) {
    top := ate.Topology().New()

    for i, ap := range atePorts {
        t.Logf("ATE AddInterface: ports[%d] = %v", i, ap)
        in := top.AddInterface(ap.Name()).WithPort(ap)
        in.IPv4().WithAddress(atePortCIDR(i)).WithDefaultGateway(dutPortIP(i))
        if false {
            t.Logf("Disabling FEC on port %v", ap)
            in.Ethernet().FEC().WithEnabled(false)
        }
        in.ISIS().WithTERouterID(getRouterId(i)).WithLevelL1().WithNetworkTypeBroadcast()
        ng := in.AddNetwork(fmt.Sprintf("isis-%d", i+1))
        ng.IPv4().WithAddress(ipPrefix(i))
        ng.ISIS().WithActive(true).WithIPReachabilityMetric(20)
    }

    top.Push(t).StartProtocols(t)
}

func sortPorts(ports []*ondatra.Port) []*ondatra.Port {
    sort.Slice(ports, func(i, j int) bool {
        idi, idj := ports[i].ID(), ports[j].ID()
        li, lj := len(idi), len(idj)
        if li == lj {
            return idi < idj
        }
        return li < lj // "port2" < "port10"
    })
    return ports
}

func TestIsis(t *testing.T) {
    ate := ondatra.ATE(t, "ate")
    atePorts := sortPorts(ate.Ports())
    configureIsisATE(t, ate, atePorts)

    // Query Telemetry
    t.Run("Telemetry", func(t *testing.T) {
        const want = telemetry.Interface_OperStatus_UP

        at := ate.Telemetry()
        for _, ap := range atePorts {
            if got := at.Interface(ap.Name()).OperStatus().Get(t); got != want {
                t.Errorf("%s oper-status got %v, want %v", ap, got, want)
            }

            // currently we cant get these attributes and it returns empty objects or lists
            is := at.NetworkInstance(ap.Name()).Protocol(telemetry.PolicyTypes_INSTALL_PROTOCOL_TYPE_ISIS, fmt.Sprintf("isis-%s", ap.Name())).Isis()
            level := is.LevelAny().LspAny()
            fmt.Println(level)
            isType := is.LevelAny().LspAny().IsType().Get(t)
            fmt.Println(isType)
            flags := is.LevelAny().LspAny().Flags().Get(t)
            fmt.Println(flags)
            seq := is.LevelAny().LspAny().SequenceNumber().Get(t)
            fmt.Println(seq)
        }
    })
}
greg-dennis commented 2 years ago

Here is a sample table of information I received from the ISIS learned info:

name value
Learned Via L2
Learned From
Metric 30
IPv4 Prefix 72.16.1.0
Mask 30
Prefix Attribute Flags
IPv4 Source Router ID
IPv6 Source Router ID
SID/Label
Algorithm
FAPM Metric
System ID 11 11 11 11 11 11
Pseudo Node Index 0
LSP Index 0
Host Name xx07.sql17
Sequence Number 3
Age (in secs) 32

As you can see, several values were blank. Does this contain everything of interest?

greg-dennis commented 2 years ago

@Vibaswan, for this example, I am inferring that both the level number and is-type is 2, that the LSP ID is "1111.1111.1111.00-00", the sequence number is 3, and the flags are an empty list. Do you know how I trigger some flag attributes to be learned?

Vibaswan commented 2 years ago

Hi @greg-dennis , Currently we are on Holiday, will get back to you by the end of the week

Vibaswan commented 2 years ago

Hi @greg-dennis , In order to activate the flags we need to add some more configuration to the below line in the test script

in.ISIS().WithTERouterID(getRouterId(i)).WithLevelL1().WithNetworkTypeBroadcast()

so, after the addition it will look something like this

isis := in.ISIS().WithTERouterID(getRouterId(i)).WithLevelL1().WithNetworkTypeBroadcast()
isis.WithWideMetricEnabled(true)
isis.SegmentRouting().WithEnabled(true)
Vibaswan commented 2 years ago

Hi @greg-dennis,

The test script which I shared for you is just a sample to retrieve learned info from ISIS router. This requirement has come from @cprabha of Juniper and in future there might be other fields that may be needed by the WBB test cases. @cprabha would you please comment if the given table of contents (provided in the earlier comments by @greg-dennis ) would suffice your need (apart from overload bit, as this is not present in current IxNetwork ISIS router)

cprabha commented 2 years ago

@Vibaswan , @greg-dennis As Per gnmi1.3 testcase details we need verify overload bit and metric on ATE for ISIS sessions.

greg-dennis commented 2 years ago

The latest Ondatra commit now provides some basic support for gathering ISIS LSPs through gNMI. It provides the LSP ID, IS type/level, and sequence number. Please note that the network instance value for both ISIS and BGP must be the name of the interface created when using the Ondatra AddInterface function, and the id of the protocol is always "0". Please give it a try and I will let you know when flags is done.

cprabha commented 2 years ago

Thanks Greg, I will check and update you.

greg-dennis commented 2 years ago

I tried the suggestion configuration but couldn't get Ixia to render flags in the learned info. I'm tempted to mark this fixed and let either of you @Vibaswan or @cprabha augment the inference now that the structure for it is in place: https://github.com/openconfig/ondatra/blob/main/internal/ixgnmi/isislsdb.go#L106

Now that the basic structure is in place, do you think you could submit PRs for whatever additional information you want rendered in the telemetry?

cprabha commented 2 years ago

Hi Vibaswan,

Please could you help to verify this fix.

Thanks, Prabha

Juniper Business Use Only From: Greg Dennis @.> Sent: Wednesday, November 2, 2022 5:29 PM To: openconfig/ondatra @.> Cc: Prabha Chethan @.>; Mention @.> Subject: Re: [openconfig/ondatra] Feature request - need a way to retrieve ISIS Learned info in ATE (Issue #42)

[External Email. Be cautious of content]

I tried the suggestion configuration but couldn't get Ixia to render flags in the learned info. I'm tempted to mark this fixed and let either of you @Vibaswanhttps://urldefense.com/v3/__https:/github.com/Vibaswan__;!!NEt6yMaO-gk!E2YUGLuv6255RL_18SL45cXzVDYmuGxLSx0ZcRurA4fO54cZryD36ke1DqW7HFWJtLNsSRS-5pIqWzJSjPsA5S_v$ or @cprabhahttps://urldefense.com/v3/__https:/github.com/cprabha__;!!NEt6yMaO-gk!E2YUGLuv6255RL_18SL45cXzVDYmuGxLSx0ZcRurA4fO54cZryD36ke1DqW7HFWJtLNsSRS-5pIqWzJSjBq1jUKU$ augment the inference now that the structure for it is in place: https://github.com/openconfig/ondatra/blob/main/internal/ixgnmi/isislsdb.go#L106https://urldefense.com/v3/__https:/github.com/openconfig/ondatra/blob/main/internal/ixgnmi/isislsdb.go*L106__;Iw!!NEt6yMaO-gk!E2YUGLuv6255RL_18SL45cXzVDYmuGxLSx0ZcRurA4fO54cZryD36ke1DqW7HFWJtLNsSRS-5pIqWzJSjGSztUKH$

Now that the basic structure is in place, do you think you could submit PRs for whatever additional information you want rendered in the telemetry?

- Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https:/github.com/openconfig/ondatra/issues/42*issuecomment-1301519967__;Iw!!NEt6yMaO-gk!E2YUGLuv6255RL_18SL45cXzVDYmuGxLSx0ZcRurA4fO54cZryD36ke1DqW7HFWJtLNsSRS-5pIqWzJSjO-nPLbF$, or unsubscribehttps://urldefense.com/v3/__https:/github.com/notifications/unsubscribe-auth/AHCEB5UXUF4NTHKREC2IHKDWGMBNPANCNFSM6AAAAAAQZUPGTA__;!!NEt6yMaO-gk!E2YUGLuv6255RL_18SL45cXzVDYmuGxLSx0ZcRurA4fO54cZryD36ke1DqW7HFWJtLNsSRS-5pIqWzJSjGdII5ww$. You are receiving this because you were mentioned.Message ID: @.**@.>>

Vibaswan commented 2 years ago

yes I could fetch the sequence number and istype using the new ondatra release also could see the learned info is being triggered at IxNetwork side

greg-dennis commented 2 years ago

I am going to mark this fixed then. The code has been significantly refactored to make adding new gnmi from learned info fairly straightforward. Please submit PRs for any additional gnmi needed from learned info or reach out to me with any difficulties you have doing that.

cprabha commented 2 years ago

Thanks Greg, Vibaswan.