From 73a4759e0671b66c1d404ca8f8115b4142dfe43a Mon Sep 17 00:00:00 2001 From: Octavian Petre Date: Fri, 14 Jul 2023 18:51:31 +0000 Subject: [PATCH 1/3] verifying state not config of the lldp neighbours --- .../core_lldp_tlv_population_test.go | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/feature/lldp/otg_tests/core_lldp_tlv_population_test/core_lldp_tlv_population_test.go b/feature/lldp/otg_tests/core_lldp_tlv_population_test/core_lldp_tlv_population_test.go index cf719418b65..1bd1e6ced34 100644 --- a/feature/lldp/otg_tests/core_lldp_tlv_population_test/core_lldp_tlv_population_test.go +++ b/feature/lldp/otg_tests/core_lldp_tlv_population_test/core_lldp_tlv_population_test.go @@ -33,6 +33,12 @@ import ( "github.com/openconfig/ygnmi/ygnmi" ) +type stateParams struct { + systemName string + chassisId string + chassisIdType oc.E_Lldp_ChassisIdType +} + type lldpTestParameters struct { systemName string macAddress string @@ -41,8 +47,6 @@ type lldpTestParameters struct { type lldpNeighbors struct { systemName string - portId string - portIdType otgtelemetry.E_LldpNeighbor_PortIdType chassisId string chassisIdType otgtelemetry.E_LldpNeighbor_ChassisIdType } @@ -78,7 +82,7 @@ func TestLLDPEnabled(t *testing.T) { t.Log("Configure DUT.") dut, dutConf := configureDUT(t, "dut", lldpEnabled) dutPort := dut.Port(t, portName) - verifyNodeConfig(t, dut, dutPort, dutConf, lldpEnabled) + stateValues := verifyNodeConfig(t, dut, dutPort, dutConf, lldpEnabled) // ATE Configuration. t.Log("Configure ATE.") @@ -92,17 +96,13 @@ func TestLLDPEnabled(t *testing.T) { systemName: lldpSrc.systemName, chassisId: lldpSrc.macAddress, chassisIdType: otgtelemetry.LldpNeighbor_ChassisIdType_MAC_ADDRESS, - portId: ate.Port(t, portName).Name(), - portIdType: otgtelemetry.LldpNeighbor_PortIdType_INTERFACE_NAME, } verifyDUTTelemetry(t, dut, dutPort, dutConf, dutPeerState) expOtgLLDPNeighbor := lldpNeighbors{ - systemName: dutConf.GetSystemName(), - portId: dutPort.Name(), - portIdType: otgtelemetry.LldpNeighbor_PortIdType_INTERFACE_NAME, - chassisId: strings.ToUpper(dutConf.GetChassisId()), - chassisIdType: otgtelemetry.E_LldpNeighbor_ChassisIdType(dutConf.GetChassisIdType()), + systemName: stateValues.systemName, + chassisId: strings.ToUpper(stateValues.chassisId), + chassisIdType: otgtelemetry.E_LldpNeighbor_ChassisIdType(stateValues.chassisIdType), } checkOTGLLDPNeighbor(t, otg, otgConfig, expOtgLLDPNeighbor) @@ -171,7 +171,7 @@ func configureATE(t *testing.T, otg *otg.OTG) gosnappi.Config { } // verifyNodeConfig verifies the config by comparing against the telemetry state object. -func verifyNodeConfig(t *testing.T, node gnmi.DeviceOrOpts, port *ondatra.Port, conf *oc.Lldp, lldpEnabled bool) { +func verifyNodeConfig(t *testing.T, node gnmi.DeviceOrOpts, port *ondatra.Port, conf *oc.Lldp, lldpEnabled bool) stateParams { statePath := gnmi.OC().Lldp() state := gnmi.Get(t, node, statePath.State()) fptest.LogQuery(t, "Node LLDP", statePath.State(), state) @@ -201,6 +201,7 @@ func verifyNodeConfig(t *testing.T, node gnmi.DeviceOrOpts, port *ondatra.Port, if lldpEnabled && got != want { t.Errorf("LLDP interfaces/interface/state/name = %s, want %s", got, want) } + return stateParams{state.GetSystemName(), state.GetChassisId(), state.GetChassisIdType()} } // checkLLDPMetricsOTG verifies OTG side lldp Metrics values based on DUT side lldp is enabled or not @@ -216,7 +217,8 @@ func checkLLDPMetricsOTG(t *testing.T, otg *otg.OTG, c gosnappi.Config, lldpEnab } framesIn, _ := gnmi.Watch(t, otg, gnmi.OTG().LldpInterface(lldp.Name()).Counters().FrameIn().State(), time.Minute, func(v *ygnmi.Value[uint64]) bool { time.Sleep(1 * time.Second) - return v.IsPresent() + rxFrames, ok := v.Val() + return ok && rxFrames > 0 }).Await(t) otgutils.LogLLDPMetrics(t, otg, c) if lldpEnabled { @@ -281,17 +283,14 @@ func verifyDUTTelemetry(t *testing.T, dut *ondatra.DUTDevice, nodePort *ondatra. wantNbrState := &oc.Lldp_Interface_Neighbor{ ChassisId: &dutPeerState.chassisId, ChassisIdType: oc.E_Lldp_ChassisIdType(dutPeerState.chassisIdType), - PortId: &dutPeerState.portId, - PortIdType: oc.E_Lldp_PortIdType(dutPeerState.portIdType), SystemName: &dutPeerState.systemName, } confirm.State(t, wantNbrState, gotNbrState) } func (expLldpNeighbor *lldpNeighbors) Equal(neighbour *otgtelemetry.LldpInterface_LldpNeighborDatabase_LldpNeighbor) bool { + return neighbour.GetChassisId() == expLldpNeighbor.chassisId && neighbour.GetChassisIdType() == expLldpNeighbor.chassisIdType && - neighbour.GetPortId() == expLldpNeighbor.portId && - neighbour.GetPortIdType() == expLldpNeighbor.portIdType && neighbour.GetSystemName() == expLldpNeighbor.systemName } From f791da9f52653fd29a34071018145d750e451f66 Mon Sep 17 00:00:00 2001 From: Octavian Petre Date: Tue, 25 Jul 2023 21:17:43 +0000 Subject: [PATCH 2/3] Added portId and portIdType verification --- .../core_lldp_tlv_population_test.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/feature/lldp/otg_tests/core_lldp_tlv_population_test/core_lldp_tlv_population_test.go b/feature/lldp/otg_tests/core_lldp_tlv_population_test/core_lldp_tlv_population_test.go index 1bd1e6ced34..bf4bd64533c 100644 --- a/feature/lldp/otg_tests/core_lldp_tlv_population_test/core_lldp_tlv_population_test.go +++ b/feature/lldp/otg_tests/core_lldp_tlv_population_test/core_lldp_tlv_population_test.go @@ -45,6 +45,14 @@ type lldpTestParameters struct { otgName string } +type otgLLDPNeighbors struct { + systemName string + chassisId string + chassisIdType otgtelemetry.E_LldpNeighbor_ChassisIdType + portId string + portIdType otgtelemetry.E_LldpNeighbor_PortIdType +} + type lldpNeighbors struct { systemName string chassisId string @@ -92,10 +100,12 @@ func TestLLDPEnabled(t *testing.T) { checkLLDPMetricsOTG(t, otg, otgConfig, lldpEnabled) - dutPeerState := lldpNeighbors{ + dutPeerState := otgLLDPNeighbors{ systemName: lldpSrc.systemName, chassisId: lldpSrc.macAddress, chassisIdType: otgtelemetry.LldpNeighbor_ChassisIdType_MAC_ADDRESS, + portId: ate.Port(t, portName).Name(), + portIdType: otgtelemetry.LldpNeighbor_PortIdType_INTERFACE_NAME, } verifyDUTTelemetry(t, dut, dutPort, dutConf, dutPeerState) @@ -255,7 +265,7 @@ func checkOTGLLDPNeighbor(t *testing.T, otg *otg.OTG, c gosnappi.Config, expLldp } // verifyDUTTelemetry verifies the telemetry values from the node such as port LLDP neighbor info. -func verifyDUTTelemetry(t *testing.T, dut *ondatra.DUTDevice, nodePort *ondatra.Port, conf *oc.Lldp, dutPeerState lldpNeighbors) { +func verifyDUTTelemetry(t *testing.T, dut *ondatra.DUTDevice, nodePort *ondatra.Port, conf *oc.Lldp, dutPeerState otgLLDPNeighbors) { verifyNodeConfig(t, dut, nodePort, conf, true) interfacePath := gnmi.OC().Lldp().Interface(nodePort.Name()) @@ -284,6 +294,8 @@ func verifyDUTTelemetry(t *testing.T, dut *ondatra.DUTDevice, nodePort *ondatra. ChassisId: &dutPeerState.chassisId, ChassisIdType: oc.E_Lldp_ChassisIdType(dutPeerState.chassisIdType), SystemName: &dutPeerState.systemName, + PortId: &dutPeerState.portId, + PortIdType: oc.E_Lldp_PortIdType(dutPeerState.portIdType), } confirm.State(t, wantNbrState, gotNbrState) } From bd8ce37dd6022d9abcd9ed285923651f6e5ef296 Mon Sep 17 00:00:00 2001 From: Octavian Petre Date: Tue, 12 Sep 2023 17:44:47 +0000 Subject: [PATCH 3/3] created lldpNeighbors struct --- .../core_lldp_tlv_population_test.go | 26 ++++++------------- 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/feature/lldp/otg_tests/core_lldp_tlv_population_test/core_lldp_tlv_population_test.go b/feature/lldp/otg_tests/core_lldp_tlv_population_test/core_lldp_tlv_population_test.go index cfdeddfd41b..4d72f5dd34d 100644 --- a/feature/lldp/otg_tests/core_lldp_tlv_population_test/core_lldp_tlv_population_test.go +++ b/feature/lldp/otg_tests/core_lldp_tlv_population_test/core_lldp_tlv_population_test.go @@ -48,7 +48,7 @@ type lldpTestParameters struct { otgName string } -type otgLLDPNeighbors struct { +type lldpNeighbors struct { systemName string chassisId string chassisIdType otgtelemetry.E_LldpNeighbor_ChassisIdType @@ -56,12 +56,6 @@ type otgLLDPNeighbors struct { portIdType otgtelemetry.E_LldpNeighbor_PortIdType } -type lldpNeighbors struct { - systemName string - chassisId string - chassisIdType otgtelemetry.E_LldpNeighbor_ChassisIdType -} - const ( portName = "port1" lldpEnabled = true @@ -104,7 +98,7 @@ func TestLLDPEnabled(t *testing.T) { checkLLDPMetricsOTG(t, otg, otgConfig, lldpEnabled) - dutPeerState := otgLLDPNeighbors{ + dutPeerState := lldpNeighbors{ systemName: lldpSrc.systemName, chassisId: lldpSrc.macAddress, chassisIdType: otgtelemetry.LldpNeighbor_ChassisIdType_MAC_ADDRESS, @@ -117,6 +111,8 @@ func TestLLDPEnabled(t *testing.T) { systemName: stateValues.systemName, chassisId: strings.ToUpper(stateValues.chassisId), chassisIdType: otgtelemetry.E_LldpNeighbor_ChassisIdType(stateValues.chassisIdType), + portId: dut.Port(t, portName).Name(), + portIdType: otgtelemetry.LldpNeighbor_PortIdType_INTERFACE_NAME, } checkOTGLLDPNeighbor(t, otg, otgConfig, expOtgLLDPNeighbor) @@ -194,19 +190,13 @@ func verifyNodeConfig(t *testing.T, node gnmi.DeviceOrOpts, port *ondatra.Port, if lldpEnabled != state.GetEnabled() { t.Errorf("LLDP enabled got: %t, want: %t.", state.GetEnabled(), lldpEnabled) } - if state.GetChassisId() != "" { - t.Logf("LLDP ChassisId got: %s", state.GetChassisId()) - } else { + if state.GetChassisId() == "" { t.Errorf("LLDP chassisID is not proper, got %s", state.GetChassisId()) } - if state.GetChassisIdType() != 0 { - t.Logf("LLDP ChassisIdType got: %s", state.GetChassisIdType()) - } else { + if state.GetChassisIdType() == 0 { t.Errorf("LLDP chassisIdType is not proper, got %s", state.GetChassisIdType()) } - if state.GetSystemName() != "" { - t.Logf("LLDP SystemName got: %s", state.GetSystemName()) - } else { + if state.GetSystemName() == "" { t.Errorf("LLDP SystemName is not proper, got %s", state.GetSystemName()) } @@ -270,7 +260,7 @@ func checkOTGLLDPNeighbor(t *testing.T, otg *otg.OTG, c gosnappi.Config, expLldp } // verifyDUTTelemetry verifies the telemetry values from the node such as port LLDP neighbor info. -func verifyDUTTelemetry(t *testing.T, dut *ondatra.DUTDevice, nodePort *ondatra.Port, conf *oc.Lldp, dutPeerState otgLLDPNeighbors) { +func verifyDUTTelemetry(t *testing.T, dut *ondatra.DUTDevice, nodePort *ondatra.Port, conf *oc.Lldp, dutPeerState lldpNeighbors) { verifyNodeConfig(t, dut, nodePort, conf, true) interfacePath := gnmi.OC().Lldp().Interface(nodePort.Name())