mirror of
https://github.com/kernelkit/infix.git
synced 2026-08-02 22:03:01 +02:00
test/case: split bridge-basic test in three
A basic test should be just that, very basic test of a feature. So we split out the more advanced ones, building up to the dual-bridge. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
committed by
Tobias Waldekranz
parent
16be0e9db5
commit
c832a906fd
@@ -1,2 +1,4 @@
|
||||
---
|
||||
- case: bridge_basic.py
|
||||
- case: bridge_veth.py
|
||||
- case: dual_bridge.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:
|
||||
|
||||
Executable
+82
@@ -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()
|
||||
Executable
+90
@@ -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()
|
||||
Reference in New Issue
Block a user