Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion sdn_tests/pins_ondatra/infrastructure/testhelper/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ go_library(
"platform_info.go",
"port_management.go",
"results.go",
"ssh.go",
"ssh.go",
"//infrastructure/testhelper/platform_info:platform_info",
],
data = [
"//infrastructure/data",
Expand Down
28 changes: 14 additions & 14 deletions sdn_tests/pins_ondatra/infrastructure/testhelper/port_management.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,20 @@ var stringToEnumSpeedMap = map[string]oc.E_IfEthernet_ETHERNET_SPEED{
}

var enumToSpeedInfoMap = map[oc.E_IfEthernet_ETHERNET_SPEED]speedEnumInfo{
oc.IfEthernet_ETHERNET_SPEED_SPEED_10MB: speedEnumInfo{"10M", 10_000_000},
oc.IfEthernet_ETHERNET_SPEED_SPEED_100MB: speedEnumInfo{"100M", 100_000_000},
oc.IfEthernet_ETHERNET_SPEED_SPEED_1GB: speedEnumInfo{"1G", 1_000_000_000},
oc.IfEthernet_ETHERNET_SPEED_SPEED_2500MB: speedEnumInfo{"2500M", 2500_000_000},
oc.IfEthernet_ETHERNET_SPEED_SPEED_5GB: speedEnumInfo{"5G", 5_000_000_000},
oc.IfEthernet_ETHERNET_SPEED_SPEED_10GB: speedEnumInfo{"10G", 10_000_000_000},
oc.IfEthernet_ETHERNET_SPEED_SPEED_25GB: speedEnumInfo{"25G", 25_000_000_000},
oc.IfEthernet_ETHERNET_SPEED_SPEED_40GB: speedEnumInfo{"40G", 40_000_000_000},
oc.IfEthernet_ETHERNET_SPEED_SPEED_50GB: speedEnumInfo{"50G", 50_000_000_000},
oc.IfEthernet_ETHERNET_SPEED_SPEED_100GB: speedEnumInfo{"100G", 100_000_000_000},
oc.IfEthernet_ETHERNET_SPEED_SPEED_200GB: speedEnumInfo{"200G", 200_000_000_000},
oc.IfEthernet_ETHERNET_SPEED_SPEED_400GB: speedEnumInfo{"400G", 400_000_000_000},
oc.IfEthernet_ETHERNET_SPEED_SPEED_600GB: speedEnumInfo{"600G", 600_000_000_000},
oc.IfEthernet_ETHERNET_SPEED_SPEED_800GB: speedEnumInfo{"800G", 800_000_000_000},
oc.IfEthernet_ETHERNET_SPEED_SPEED_10MB: {"10M", 10_000_000},
oc.IfEthernet_ETHERNET_SPEED_SPEED_100MB: {"100M", 100_000_000},
oc.IfEthernet_ETHERNET_SPEED_SPEED_1GB: {"1G", 1_000_000_000},
oc.IfEthernet_ETHERNET_SPEED_SPEED_2500MB: {"2500M", 2500_000_000},
oc.IfEthernet_ETHERNET_SPEED_SPEED_5GB: {"5G", 5_000_000_000},
oc.IfEthernet_ETHERNET_SPEED_SPEED_10GB: {"10G", 10_000_000_000},
oc.IfEthernet_ETHERNET_SPEED_SPEED_25GB: {"25G", 25_000_000_000},
oc.IfEthernet_ETHERNET_SPEED_SPEED_40GB: {"40G", 40_000_000_000},
oc.IfEthernet_ETHERNET_SPEED_SPEED_50GB: {"50G", 50_000_000_000},
oc.IfEthernet_ETHERNET_SPEED_SPEED_100GB: {"100G", 100_000_000_000},
oc.IfEthernet_ETHERNET_SPEED_SPEED_200GB: {"200G", 200_000_000_000},
oc.IfEthernet_ETHERNET_SPEED_SPEED_400GB: {"400G", 400_000_000_000},
oc.IfEthernet_ETHERNET_SPEED_SPEED_600GB: {"600G", 600_000_000_000},
oc.IfEthernet_ETHERNET_SPEED_SPEED_800GB: {"800G", 800_000_000_000},
}

// Indices for slot, port and lane number in Ethernet<slot/port/lane> port naming format.
Expand Down
102 changes: 102 additions & 0 deletions sdn_tests/pins_ondatra/tests/ondatra_test.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
"""Generate Ondatra test definitions."""

load("@io_bazel_rules_go//go:def.bzl", "go_test")

def ondatra_test(
name,
srcs,
testbed = "",
run_timeout = "30m",
args = None,
deps = None,
data = None,
tags = None,
visibility = None):
"""Compiles and runs an Ondatra test written in Go.

Args:
name: Name; required
srcs: List of labels; required
testbed: Label of testbed file; required
run_timeout: Timeout on the test run, excluding the wait time for the
testbed to become available, specified as a duration string
(see http://godoc/pkg/time#ParseDuration); default is 30 minutes
args: List of args: optional
tags: List of arbitrary text tags; optional
deps: List of labels; optional
data: List of labels; optional
visibility: List of visibility labels; optional
"""
data = (data or []) + ["//ondatra/data"]
testbed = testbed or "ondatra/data/testbeds.textproto"
testbed_arg = "--testbed=%s" % testbed

args = (args or []) + [
testbed_arg,
"--run_time=%s" % run_timeout,
"--wait_time=0",
]
go_test(
name = name,
srcs = srcs,
deps = deps,
data = data,
args = args,
tags = (tags or []) + ["manual", "exclusive", "external"],
rundir = ".",
visibility = visibility,
size = "enormous", # Reservation is highly variable.
local = True, # Tests cannot run on Forge.
)

def ondatra_test_suite(
name,
srcs,
testbeds = {},
per_test_run_timeout = "30m",
args = None,
deps = None,
data = None,
tags = None,
visibility = None):
"""Defines a suite of Ondatra tests written in Go.

For every (testbed-name, testbed-file) entry in the provided testbeds map,
this rule creates an ondatra_test with the name "[name]_[testbed-name]" and
the testbed equal to testbed-file.

Args:
name: Name; required
srcs: List of labels; required
testbeds: Map of custom testbed name to testbed label; required
per_test_run_timeout: Timeout on each test run in the suite, excluding the
wait time for the testbed to become available, specified as a duration
string (see http://godoc/pkg/time#ParseDuration); default is 30 minutes
args: List of args: optional
deps: List of labels; optional
data: List of labels; optional
tags: List of arbitrary text tags; optional
visibility: List of visibility labels; optional
"""
if len(testbeds) == 0:
testbeds = {"dualnode" : "ondatra/data/testbeds.textproto"}

tests = []
for testbed_name, testbed_src in testbeds.items():
test_name = "%s_%s" % (name, testbed_name)
tests.append(test_name)
go_test_tags = (tags or []) + [testbed_name]
ondatra_test(
name = test_name,
srcs = srcs,
testbed = testbed_src,
run_timeout = per_test_run_timeout,
args = args,
deps = deps,
data = data,
tags = go_test_tags,
visibility = visibility,
)

# Unlike other tags, "manual" on a test_suite means the suite itself is manual.
native.test_suite(name = name, tests = tests, visibility = visibility, tags = ["manual"])