diff --git a/test/case/infix_interfaces/all.yaml b/test/case/infix_interfaces/all.yaml index 3477e297..10f592a8 100644 --- a/test/case/infix_interfaces/all.yaml +++ b/test/case/infix_interfaces/all.yaml @@ -1,2 +1,4 @@ --- - case: bridge_basic.py +- case: bridge_veth.py +- case: dual_bridge.py diff --git a/test/case/infix_interfaces/bridge_basic.py b/test/case/infix_interfaces/bridge_basic.py index d7023d5c..24b066e6 100755 --- a/test/case/infix_interfaces/bridge_basic.py +++ b/test/case/infix_interfaces/bridge_basic.py @@ -1,8 +1,8 @@ #!/usr/bin/env python3 # -# PING --> br0 br1 10.0.0.2 -# / \ / -# PC ---- e0 veth +# PING --> br0 10.0.0.2 +# / +# PC ---- e0 # import infamy @@ -22,11 +22,6 @@ with infamy.Test() as test: "name": "br0", "type": "iana-if-type:bridge", "enabled": True, - }, - { - "name": "br1", - "type": "iana-if-type:bridge", - "enabled": True, "ipv4": { "address": [ { @@ -36,28 +31,6 @@ with infamy.Test() as test: ] } }, - { - "name": "veth0a", - "type": "infix-if-type:veth", - "enabled": True, - "infix-interfaces:veth": { - "peer": "veth0b" - }, - "infix-interfaces:bridge-port": { - "bridge": "br0" - } - }, - { - "name": "veth0b", - "type": "infix-if-type:veth", - "enabled": True, - "infix-interfaces:veth": { - "peer": "veth0a" - }, - "infix-interfaces:bridge-port": { - "bridge": "br1" - } - }, { "name": tport, "type": "iana-if-type:ethernetCsmacd", @@ -70,7 +43,7 @@ with infamy.Test() as test: } }) - with test.step("Ping furthest bridge 10.0.0.2 from host:data with IP 10.0.0.1"): + with test.step("Ping bridge 10.0.0.2 from host:data with IP 10.0.0.1"): _, hport = env.ltop.xlate("host", "data") with infamy.IsolatedMacVlan(hport) as ns: diff --git a/test/case/infix_interfaces/bridge_veth.py b/test/case/infix_interfaces/bridge_veth.py new file mode 100755 index 00000000..70dc9181 --- /dev/null +++ b/test/case/infix_interfaces/bridge_veth.py @@ -0,0 +1,82 @@ +#!/usr/bin/env python3 +# +# PING --> br0 +# / \ +# PC ---- e0 veth 10.0.0.2 +# + +import infamy + +with infamy.Test() as test: + with test.step("Initialize"): + env = infamy.Env(infamy.std_topology("1x2")) + target = env.attach("target", "mgmt") + + with test.step("Configure two bridges linked with a veth pair furthest bridge has IP 10.0.0.2"): + _, tport = env.ltop.xlate("target", "data") + + target.put_config_dict("ietf-interfaces", { + "interfaces": { + "interface": [ + { + "name": "br0", + "type": "iana-if-type:bridge", + "enabled": True, + }, + { + "name": tport, + "type": "iana-if-type:ethernetCsmacd", + "enabled": True, + "infix-interfaces:bridge-port": { + "bridge": "br0" + } + }, + { + "name": "veth0a", + "type": "infix-if-type:veth", + "enabled": True, + "infix-interfaces:veth": { + "peer": "veth0b" + }, + "infix-interfaces:bridge-port": { + "bridge": "br0" + } + }, + { + "name": "veth0b", + "type": "infix-if-type:veth", + "enabled": True, + "infix-interfaces:veth": { + "peer": "veth0a" + }, + "ipv4": { + "address": [ + { + "ip": "10.0.0.2", + "prefix-length": 24, + } + ] + } + }, + ] + } + }) + + with test.step("Ping other end of bridged veth pair on 10.0.0.2 from host:data with IP 10.0.0.1"): + _, hport = env.ltop.xlate("host", "data") + + with infamy.IsolatedMacVlan(hport) as ns: + pingtest = ns.runsh(""" + set -ex + + ip link set iface up + ip addr add 10.0.0.1/24 dev iface + + ping -c1 -w10 10.0.0.2 || exit 1 + """) + + if pingtest.returncode: + print(pingtest.stdout) + test.fail() + + test.succeed() diff --git a/test/case/infix_interfaces/dual_bridge.py b/test/case/infix_interfaces/dual_bridge.py new file mode 100755 index 00000000..05d11ce8 --- /dev/null +++ b/test/case/infix_interfaces/dual_bridge.py @@ -0,0 +1,90 @@ +#!/usr/bin/env python3 +# +# PING --> br0 br1 10.0.0.2 +# / \ / +# PC ---- e0 veth +# + +import infamy + +with infamy.Test() as test: + with test.step("Initialize"): + env = infamy.Env(infamy.std_topology("1x2")) + target = env.attach("target", "mgmt") + + with test.step("Configure two bridges linked with a veth pair furthest bridge has IP 10.0.0.2"): + _, tport = env.ltop.xlate("target", "data") + + target.put_config_dict("ietf-interfaces", { + "interfaces": { + "interface": [ + { + "name": "br0", + "type": "iana-if-type:bridge", + "enabled": True, + }, + { + "name": "br1", + "type": "iana-if-type:bridge", + "enabled": True, + "ipv4": { + "address": [ + { + "ip": "10.0.0.2", + "prefix-length": 24, + } + ] + } + }, + { + "name": "veth0a", + "type": "infix-if-type:veth", + "enabled": True, + "infix-interfaces:veth": { + "peer": "veth0b" + }, + "infix-interfaces:bridge-port": { + "bridge": "br0" + } + }, + { + "name": "veth0b", + "type": "infix-if-type:veth", + "enabled": True, + "infix-interfaces:veth": { + "peer": "veth0a" + }, + "infix-interfaces:bridge-port": { + "bridge": "br1" + } + }, + { + "name": tport, + "type": "iana-if-type:ethernetCsmacd", + "enabled": True, + "infix-interfaces:bridge-port": { + "bridge": "br0" + } + }, + ] + } + }) + + with test.step("Ping furthest bridge 10.0.0.2 from host:data with IP 10.0.0.1"): + _, hport = env.ltop.xlate("host", "data") + + with infamy.IsolatedMacVlan(hport) as ns: + pingtest = ns.runsh(""" + set -ex + + ip link set iface up + ip addr add 10.0.0.1/24 dev iface + + ping -c1 -w10 10.0.0.2 || exit 1 + """) + + if pingtest.returncode: + print(pingtest.stdout) + test.fail() + + test.succeed()