From d4a316d08c785afb8f75fa6dd9503c38ee0065c5 Mon Sep 17 00:00:00 2001 From: Azhar Date: Wed, 17 Aug 2022 08:57:58 +0000 Subject: [PATCH 1/2] tx only test added --- .../otg_tests/tx_only_test/tx_only_test.go | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 feature/tx_only/otg_tests/tx_only_test/tx_only_test.go diff --git a/feature/tx_only/otg_tests/tx_only_test/tx_only_test.go b/feature/tx_only/otg_tests/tx_only_test/tx_only_test.go new file mode 100644 index 00000000000..e5e35252240 --- /dev/null +++ b/feature/tx_only/otg_tests/tx_only_test/tx_only_test.go @@ -0,0 +1,72 @@ +package tx_only_test + +import ( + "testing" + "time" + + "github.com/open-traffic-generator/snappi/gosnappi" + "github.com/openconfig/featureprofiles/internal/fptest" + "github.com/openconfig/ondatra" + otg "github.com/openconfig/ondatra/otg" + otgtelemetry "github.com/openconfig/ondatra/telemetry/otg" +) + +func TestMain(m *testing.M) { + fptest.RunTests(m) +} +func configureOTGTxOnly(t *testing.T, otg *otg.OTG) gosnappi.Config { + config := otg.NewConfig(t) + port1 := config.Ports().Add().SetName("port1") + flow := config.Flows().Add().SetName("f1") + flow.Metrics().SetEnable(true) + flow.TxRx().SetChoice("port").Port().SetTxName(port1.Name()) + flow.Duration().FixedPackets().SetPackets(100) + flow.Rate().SetPps(50) + eth := flow.Packet().Add().Ethernet() + eth.Dst().SetValue("00:AB:BC:AB:BC:AB") + eth.Src().SetValue("00:CD:DC:CD:DC:CD") + + otg.PushConfig(t, config) + return config +} + +func verifyTraffic(t *testing.T, ate *ondatra.ATEDevice, c gosnappi.Config, expectedPacket uint64) { + otg := ate.OTG() + for _, p := range c.Ports().Items() { + _, ok := otg.Telemetry().Port(p.Name()).Counters().OutFrames().Watch(t, time.Minute, func(val *otgtelemetry.QualifiedUint64) bool { + return val.IsPresent() && val.Val(t) == expectedPacket + }).Await(t) + if !ok { + t.Logf("Expected Tx Packets :%v, Actual: %v", expectedPacket, otg.Telemetry().Port(p.Name()).Counters().OutFrames().Get(t)) + t.Fatal("Expected Packet Mismatch!!!") + } + } + for _, f := range c.Flows().Items() { + _, ok := otg.Telemetry().Flow(f.Name()).Counters().OutPkts().Watch(t, time.Minute, func(val *otgtelemetry.QualifiedUint64) bool { + return val.IsPresent() && val.Val(t) == expectedPacket + }).Await(t) + if !ok { + t.Logf("Expected Tx Packets :%v, Actual: %v", expectedPacket, otg.Telemetry().Flow(f.Name()).Counters().OutPkts().Get(t)) + t.Fatal("Expected Packet Mismatch!!!") + } + } + t.Logf("Port and Flow Metrics is Ok!!!") +} + +func TestOTGTxOnly(t *testing.T) { + ate := ondatra.ATE(t, "ate") + otg := ate.OTG() + otgConfig := configureOTGTxOnly(t, otg) + + t.Logf("Setting config") + otg.PushConfig(t, otgConfig) + + t.Logf("Starting traffic") + otg.StartTraffic(t) + + t.Logf("Verify traffic") + verifyTraffic(t, ate, otgConfig, 100) + + t.Logf("Stop traffic") + otg.StopTraffic(t) +} From d53e4a1fcb93e46a31836a75f42c0fa10ab4cda6 Mon Sep 17 00:00:00 2001 From: Azhar Date: Thu, 18 Aug 2022 10:36:35 +0000 Subject: [PATCH 2/2] test location modified --- .../otg_tests/one_arm/one_arm_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) rename feature/tx_only/otg_tests/tx_only_test/tx_only_test.go => topologies/otg_tests/one_arm/one_arm_test.go (92%) diff --git a/feature/tx_only/otg_tests/tx_only_test/tx_only_test.go b/topologies/otg_tests/one_arm/one_arm_test.go similarity index 92% rename from feature/tx_only/otg_tests/tx_only_test/tx_only_test.go rename to topologies/otg_tests/one_arm/one_arm_test.go index e5e35252240..5c937141faa 100644 --- a/feature/tx_only/otg_tests/tx_only_test/tx_only_test.go +++ b/topologies/otg_tests/one_arm/one_arm_test.go @@ -1,4 +1,4 @@ -package tx_only_test +package one_arm_test import ( "testing" @@ -14,7 +14,7 @@ import ( func TestMain(m *testing.M) { fptest.RunTests(m) } -func configureOTGTxOnly(t *testing.T, otg *otg.OTG) gosnappi.Config { +func configureOTGOneArm(t *testing.T, otg *otg.OTG) gosnappi.Config { config := otg.NewConfig(t) port1 := config.Ports().Add().SetName("port1") flow := config.Flows().Add().SetName("f1") @@ -53,10 +53,10 @@ func verifyTraffic(t *testing.T, ate *ondatra.ATEDevice, c gosnappi.Config, expe t.Logf("Port and Flow Metrics is Ok!!!") } -func TestOTGTxOnly(t *testing.T) { +func TestOTGOneArm(t *testing.T) { ate := ondatra.ATE(t, "ate") otg := ate.OTG() - otgConfig := configureOTGTxOnly(t, otg) + otgConfig := configureOTGOneArm(t, otg) t.Logf("Setting config") otg.PushConfig(t, otgConfig)