summaryrefslogtreecommitdiff
path: root/tests/topotests/tc_basic/test_tc_basic.py
diff options
context:
space:
mode:
authorDonald Sharp <donaldsharp72@gmail.com>2024-04-29 09:14:52 -0400
committerGitHub <noreply@github.com>2024-04-29 09:14:52 -0400
commitf3720c477ea86b91ed30d03ebb48405fb0258c9a (patch)
tree0e7f08816a59575e9618137cdf7a58f7844d71cd /tests/topotests/tc_basic/test_tc_basic.py
parent2187b8271460f279feea3d92f6aad6bfd3b5ff74 (diff)
parent422e0dd25665617ca2530eaeee82071bc47c4ee8 (diff)
Merge pull request #15865 from opensourcerouting/fix/drop_duplicate_pytestmark
tests: A bit of housekeeping for topotests
Diffstat (limited to 'tests/topotests/tc_basic/test_tc_basic.py')
-rwxr-xr-xtests/topotests/tc_basic/test_tc_basic.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/tests/topotests/tc_basic/test_tc_basic.py b/tests/topotests/tc_basic/test_tc_basic.py
index f64e83c3cb..822d2016a8 100755
--- a/tests/topotests/tc_basic/test_tc_basic.py
+++ b/tests/topotests/tc_basic/test_tc_basic.py
@@ -22,9 +22,8 @@ sys.path.append(os.path.join(CWD, "../lib/"))
from lib.topogen import Topogen, TopoRouter
from lib.topolog import logger
-pytestmark = [
- pytest.mark.sharpd
-]
+pytestmark = [pytest.mark.sharpd]
+
def build_topo(tgen):
"Build function"
@@ -42,6 +41,7 @@ def build_topo(tgen):
switch = tgen.add_switch("s2")
switch.add_link(r2)
+
# New form of setup/teardown using pytest fixture
@pytest.fixture(scope="module")
def tgen(request):
@@ -79,22 +79,28 @@ def skip_on_failure(tgen):
if tgen.routers_have_failure():
pytest.skip("skipped because of previous test failure")
+
def fetch_iproute2_tc_info(r, interface):
qdisc = r.cmd("tc qdisc show dev %s" % interface)
tclass = r.cmd("tc class show dev %s" % interface)
tfilter = r.cmd("tc filter show dev %s" % interface)
return qdisc, tclass, tfilter
+
# ===================
# The tests functions
# ===================
+
def test_tc_basic(tgen):
"Test installing one pair of filter & class by sharpd"
r1 = tgen.gears["r1"]
intf = "r1-eth0"
- r1.vtysh_cmd("sharp tc dev %s source 192.168.100.0/24 destination 192.168.101.0/24 ip-protocol tcp src-port 8000 dst-port 8001 rate 20mbit" % intf)
+ r1.vtysh_cmd(
+ "sharp tc dev %s source 192.168.100.0/24 destination 192.168.101.0/24 ip-protocol tcp src-port 8000 dst-port 8001 rate 20mbit"
+ % intf
+ )
time.sleep(3)
@@ -115,6 +121,7 @@ def test_tc_basic(tgen):
assert "dst_port 8001" in tfilter
assert "src_port 8000" in tfilter
+
if __name__ == "__main__":
args = ["-s"] + sys.argv[1:]
- sys.exit(pytest.main(args)) \ No newline at end of file
+ sys.exit(pytest.main(args))