Skip to content

Commit

Permalink
Merge pull request #711 from kernelkit/minor-test-formating
Browse files Browse the repository at this point in the history
test: minor code formating
  • Loading branch information
mattiaswal authored Oct 15, 2024
2 parents afc40ac + 614b7ef commit 0e276a9
Show file tree
Hide file tree
Showing 34 changed files with 280 additions and 186 deletions.
10 changes: 9 additions & 1 deletion test/case/ietf_interfaces/bridge_basic/Readme.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
==== Description
Test basic connectivity to a bridge

....
PING --> br0 (10.0.0.2)
/
PC -------- target:data
....

==== Topology
ifdef::topdoc[]
image::../../test/case/ietf_interfaces/bridge_basic/topology.png[Bridge basic topology]
Expand All @@ -15,7 +23,7 @@ image::topology.png[Bridge basic topology]
endif::testgroup[]
endif::topdoc[]
==== Test sequence
. Initialize
. Set up topology and attach to target DUT
. Configure single bridge with a single physical port, bridge @ IP 10.0.0.2
. Verify ping 10.0.0.2 is possible from host:data

Expand Down
18 changes: 11 additions & 7 deletions test/case/ietf_interfaces/bridge_basic/test.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
#!/usr/bin/env python3
#
# PING --> br0 10.0.0.2
# /
# PC ---- e0
#
"""
r"""
Bridge basic
Test basic connectivity to a bridge
....
PING --> br0 (10.0.0.2)
/
PC -------- target:data
....
"""
import infamy

with infamy.Test() as test:
with test.step("Initialize"):
with test.step("Set up topology and attach to target DUT"):
env = infamy.Env()
target = env.attach("target", "mgmt")

Expand Down
6 changes: 3 additions & 3 deletions test/case/ietf_interfaces/bridge_basic/topology.dot
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ graph "1x2" {
edge [color="cornflowerblue", penwidth="2"];

host [
label="host | { <tgt> tgt | <data> data }",
label="host | { <mgmt> mgmt | <data> data }",
pos="0,12!",
kind="controller",
];

target [
label="{ <mgmt> mgmt | <data> data } | target\n10.0.0.2/24 (br0)",
label="{ <mgmt> mgmt | <data> data } | target",
pos="10,12!",

kind="infix",
];

host:tgt -- target:mgmt [kind=mgmt]
host:mgmt -- target:mgmt [kind=mgmt, color=lightgrey]
host:data -- target:data [color=black, fontcolor=black, taillabel="10.0.0.1/24"]
}
Binary file modified test/case/ietf_interfaces/bridge_basic/topology.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 21 additions & 1 deletion test/case/ietf_interfaces/bridge_fwd_dual_dut/Readme.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@
==== Description
Ping through two bridges on two different DUTs.

....
,-------------------------------------, ,-------------------------------------,
| dut1:link | | dut2:link |
| br0 ----------|-------|--------- br0 |
| / | | / \ |
|dut1:mgmt dut1:data1 | | dut2:data1 dut2:data2 dut2:mgmt |
'-------------------------------------' '-------------------------------------'
| | | | |
| | | | |
,-----------------------------------------------------------------------------------------,
| host:mgmt1 host:data11 host:data21 host:data22 host:mgmt2 |
| [10.0.0.2] [10.0.0.3] [10.0.0.4] |
| (ns11) (ns20) (ns21) |
| |
| [ HOST ] |
'-----------------------------------------------------------------------------------------'
....

==== Topology
ifdef::topdoc[]
image::../../test/case/ietf_interfaces/bridge_fwd_dual_dut/topology.png[Bridge forwarding dual DUTs topology]
Expand All @@ -15,7 +35,7 @@ image::topology.png[Bridge forwarding dual DUTs topology]
endif::testgroup[]
endif::topdoc[]
==== Test sequence
. Initialize
. Set up topology and attach to target DUT
. Configure a bridge with triple physical port
. Verify ping 10.0.0.3 and 10.0.0.4 from host:data11

Expand Down
69 changes: 38 additions & 31 deletions test/case/ietf_interfaces/bridge_fwd_dual_dut/test.py
Original file line number Diff line number Diff line change
@@ -1,38 +1,45 @@
#!/usr/bin/env python3
# ,-------------------------------------, ,-------------------------------------,
# | dut1:data2 | | dut2:data2 |
# | br0 ----------|-------|--------- br0 |
# | / \ | | / \ |
# |dut1:mgmt dut1:data0 dut1:data1 | | dut2:data0 dut2:data1 dut2:mgmt |
# '-------------------------------------' '-------------------------------------'
# | | | | | |
# | | | | | |
# ,-----------------------------------------------------------------------------------------,
# | host:mgmt0 host:data10 host:data11 host:data20 host:data21 host:mgmt1 |
# | [10.0.0.2] [10.0.0.3] [10.0.0.4] |
# | (ns11) (ns20) (ns21) |
# | |
# | [ HOST ] |
# '-----------------------------------------------------------------------------------------'
"""
r"""
Bridge forwarding dual DUTs
Ping through two bridges on two different DUTs.
....
,-------------------------------------, ,-------------------------------------,
| dut1:link | | dut2:link |
| br0 ----------|-------|--------- br0 |
| / | | / \ |
|dut1:mgmt dut1:data1 | | dut2:data1 dut2:data2 dut2:mgmt |
'-------------------------------------' '-------------------------------------'
| | | | |
| | | | |
,-----------------------------------------------------------------------------------------,
| host:mgmt1 host:data11 host:data21 host:data22 host:mgmt2 |
| [10.0.0.2] [10.0.0.3] [10.0.0.4] |
| (ns11) (ns20) (ns21) |
| |
| [ HOST ] |
'-----------------------------------------------------------------------------------------'
....
"""

import infamy

with infamy.Test() as test:
with test.step("Initialize"):
with test.step("Set up topology and attach to target DUT"):
env = infamy.Env()
dut1 = env.attach("dut1", "mgmt")
dut2 = env.attach("dut2", "mgmt")

with test.step("Configure a bridge with triple physical port"):
_, tport11 = env.ltop.xlate("dut1", "data1")
_, tport12 = env.ltop.xlate("dut1", "data2")
_, tport20 = env.ltop.xlate("dut2", "data0")
_, tport1_link = env.ltop.xlate("dut1", "link")
_, tport21 = env.ltop.xlate("dut2", "data1")
_, tport22 = env.ltop.xlate("dut2", "data2")
_, tport2_link = env.ltop.xlate("dut2", "link")

dut1.put_config_dict("ietf-interfaces", {
"interfaces": {
Expand All @@ -47,7 +54,7 @@
{
"vid": 10,
"untagged": [ tport11 ],
"tagged": [ "br0", tport12 ]
"tagged": [ "br0", tport1_link ]
}
]
}
Expand All @@ -62,7 +69,7 @@
}
},
{
"name": tport12,
"name": tport1_link,
"enabled": True,
"infix-interfaces:bridge-port": {
"bridge": "br0",
Expand All @@ -84,31 +91,31 @@
"vlan": [
{
"vid": 10,
"untagged": [ tport20, tport21 ],
"tagged": [ "br0", tport22 ]
"untagged": [ tport21, tport22 ],
"tagged": [ "br0", tport2_link ]
}
]
}
}
},
{
"name": tport20,
"name": tport21,
"enabled": True,
"infix-interfaces:bridge-port": {
"pvid": 10,
"bridge": "br0"
}
},
{
"name": tport21,
"name": tport22,
"enabled": True,
"infix-interfaces:bridge-port": {
"pvid": 10,
"bridge": "br0"
}
},
{
"name": tport22,
"name": tport2_link,
"enabled": True,
"infix-interfaces:bridge-port": {
"bridge": "br0",
Expand All @@ -121,16 +128,16 @@
with test.step("Verify ping 10.0.0.3 and 10.0.0.4 from host:data11"):

_, hport11 = env.ltop.xlate("host", "data11")
_, hport20 = env.ltop.xlate("host", "data20")
_, hport21 = env.ltop.xlate("host", "data21")
_, hport22 = env.ltop.xlate("host", "data22")

with infamy.IsolatedMacVlan(hport11) as ns11, \
infamy.IsolatedMacVlan(hport20) as ns20, \
infamy.IsolatedMacVlan(hport21) as ns21:
infamy.IsolatedMacVlan(hport21) as ns21, \
infamy.IsolatedMacVlan(hport22) as ns22:

ns11.addip("10.0.0.2")
ns20.addip("10.0.0.3")
ns21.addip("10.0.0.4")
ns21.addip("10.0.0.3")
ns22.addip("10.0.0.4")

ns11.must_reach("10.0.0.3")
ns11.must_reach("10.0.0.4")
Expand Down
34 changes: 17 additions & 17 deletions test/case/ietf_interfaces/bridge_fwd_dual_dut/topology.dot
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,32 @@ graph "2x4" {
edge [color="cornflowerblue", penwidth="2"];

host [
label="host | { <mgmt1> mgmt1 | <data11> data11 | <> \n\n\n| <mgmt2> mgmt2 | <data20> data20 | <data21> data21 }",
pos="0,15!",
height=3,
label="host | { <mgmt1> mgmt1 | <data11> data11 | <> \n\n\n| <mgmt2> mgmt2 | <data21> data21 | <data22> data22 }",
pos="0,15!",
height=3,

kind="controller",
kind="controller",
];

dut1 [
label="{ <mgmt> mgmt | <data1> data1 } | { dut1 \n\n| <data2> data2 }",
pos="4,15.68!",
kind="infix",
label="{ <mgmt> mgmt | <data1> data1 } | { dut1 \n\n| <link> link }",
pos="4,15.68!",
kind="infix",
];

dut2 [
label="{ <mgmt> mgmt | <data0> data0 | <data1> data1 } | { <data2> data2 | \n dut2 }",
pos="4,14.43!",
height=1.2,
kind="infix",
label="{ <mgmt> mgmt | <data1> data1 | <data2> data2 } | { <link> link | \n dut2 }",
pos="4,14.43!",
height=1.2,
kind="infix",
];

host:mgmt1 -- dut1:mgmt [kind=mgmt]
host:mgmt1 -- dut1:mgmt [kind=mgmt, color=lightgrey]
host:data11 -- dut1:data1 [color=black, fontcolor=black, taillabel="10.0.0.2"]

host:mgmt2 -- dut2:mgmt [kind=mgmt]
host:data20 -- dut2:data0 [color=black, fontcolor=black, taillabel="10.0.0.3"]
host:data21 -- dut2:data1 [color=black, fontcolor=black, taillabel="10.0.0.4"]
host:mgmt2 -- dut2:mgmt [kind=mgmt, color=lightgrey]
host:data21 -- dut2:data1 [color=black, fontcolor=black, taillabel="10.0.0.3"]
host:data22 -- dut2:data2 [color=black, fontcolor=black, taillabel="10.0.0.4"]

dut1:data2 -- dut2:data2
}
dut1:link -- dut2:link [color=black]
}
Binary file modified test/case/ietf_interfaces/bridge_fwd_dual_dut/topology.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 21 additions & 1 deletion test/case/ietf_interfaces/bridge_fwd_sgl_dut/Readme.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@
==== Description
Tests forwarding through a DUT with two bridged interfaces on one DUT.

....
,------------------------------------------,
| |
| br0 |
| / \ |
| target:mgmt target:data1 target:data2 |
'------------------------------------------'
| | |
| | |
,------------------------------------------,
| host:mgmt host:data1 host:data2 |
| [10.0.0.1] [10.0.0.2] |
| (ns0) (ns1) |
| |
| [ HOST ] |
'------------------------------------------'
....

==== Topology
ifdef::topdoc[]
image::../../test/case/ietf_interfaces/bridge_fwd_sgl_dut/topology.png[Bridge forwarding single DUTs topology]
Expand All @@ -15,7 +35,7 @@ image::topology.png[Bridge forwarding single DUTs topology]
endif::testgroup[]
endif::topdoc[]
==== Test sequence
. Initialize
. Set up topology and attach to target DUT
. Configure a bridge with dual physical port
. Verify ping from host:data0 to 10.0.0.1

Expand Down
Loading

0 comments on commit 0e276a9

Please sign in to comment.