test: Update infix-container for test specification

This commit is contained in:
Mattias Walström
2024-10-04 11:22:58 +02:00
parent 5a28a5611a
commit 69ba9110fc
11 changed files with 95 additions and 36 deletions
@@ -20,6 +20,14 @@ endif::testgroup[]
endif::topdoc[]
==== Test sequence
. Set up topology and attach to target DUT
. Set hostname to 'container-host'
. Create container 'web' from bundled OCI image
. Verify container 'web' has started
. Verify container 'web' is reachable on http://container-host.local:91
. Stop container 'web'
. Verify container 'web' is stopped
. Restart container 'web'
. Verify container 'web' is reachable on http://container-host.local:91
<<<
@@ -20,6 +20,7 @@ from infamy.util import until
def _verify(server):
# Should really use mDNS here....
url = infamy.Furl(f"http://[{server}]:91/index.html")
return url.check("It works")
@@ -35,7 +36,14 @@ with infamy.Test() as test:
if not target.has_model("infix-containers"):
test.skip()
with test.step(f"Create {NAME} container from bundled OCI image"):
with test.step("Set hostname to 'container-host'"):
target.put_config_dict("ietf-system", {
"system": {
"hostname": "container-host"
}
})
with test.step("Create container 'web' from bundled OCI image"):
target.put_config_dict("infix-containers", {
"containers": {
"container": [
@@ -51,21 +59,24 @@ with infamy.Test() as test:
}
})
with test.step(f"Verify {NAME} container has started"):
with test.step("Verify container 'web' has started"):
c = infamy.Container(target)
until(lambda: c.running(NAME), attempts=10)
with test.step(f"Verify {NAME} container responds"):
with test.step("Verify container 'web' is reachable on http://container-host.local:91"):
until(lambda: _verify(addr), attempts=10)
with test.step(f"Verify {NAME} container can be stopped and restarted"):
with test.step("Stop container 'web'"):
c = infamy.Container(target)
c.action(NAME, "stop")
with test.step("Verify container 'web' is stopped"):
until(lambda: not c.running(NAME), attempts=10)
with test.step("Restart container 'web'"):
c.action(NAME, "restart")
with test.step(f"Verify {NAME} container still responds"):
with test.step("Verify container 'web' is reachable on http://container-host.local:91"):
# Wait for it to restart and respond, or fail
until(lambda: _verify(addr), attempts=10)
test.succeed()
@@ -4,6 +4,9 @@ Verify connectivity with a simple web server container from behind a
docker0 bridge. As an added twist, this test also verifies content
mounts, i.e., custom index.html from running-config.
This also verifies port forwarding from container internal port to a
port accessed from the host.
==== Topology
ifdef::topdoc[]
image::../../test/case/infix_containers/container_bridge/topology.png[Container with bridge network topology]
@@ -17,7 +20,11 @@ image::topology.png[Container with bridge network topology]
endif::testgroup[]
endif::topdoc[]
==== Test sequence
. Initialize
. Set up topology and attach to target DUT
. Create container 'web-docker0' from bundled OCI image
. Verify container 'web-docker0' has started
. Verify basic DUT connectivity, host:data can ping DUT 10.0.0.2
. Verify container 'web-docker0' is reachable on http://10.0.0.2:8080
<<<
@@ -10,6 +10,9 @@ Container with bridge network
Verify connectivity with a simple web server container from behind a
docker0 bridge. As an added twist, this test also verifies content
mounts, i.e., custom index.html from running-config.
This also verifies port forwarding from container internal port to a
port accessed from the host.
"""
import base64
import infamy
@@ -23,14 +26,14 @@ with infamy.Test() as test:
BODY = "<html><body><p>Kilroy was here</p></body></html>"
URL = f"http://{DUTIP}:8080/index.html"
with test.step("Initialize"):
with test.step("Set up topology and attach to target DUT"):
env = infamy.Env()
target = env.attach("target", "mgmt")
if not target.has_model("infix-containers"):
test.skip()
with test.step(f"Create {NAME} container from bundled OCI image"):
with test.step("Create container 'web-docker0' from bundled OCI image"):
_, ifname = env.ltop.xlate("target", "data")
enc = base64.b64encode(BODY.encode('utf-8'))
target.put_config_dict("ietf-interfaces", {
@@ -84,18 +87,18 @@ with infamy.Test() as test:
}
})
with test.step(f"Verify {NAME} container has started"):
with test.step("Verify container 'web-docker0' has started"):
c = infamy.Container(target)
until(lambda: c.running(NAME), attempts=10)
with test.step(f"Verify {NAME} container responds"):
_, hport = env.ltop.xlate("host", "data")
url = infamy.Furl(URL)
_, hport = env.ltop.xlate("host", "data")
url = infamy.Furl(URL)
with infamy.IsolatedMacVlan(hport) as ns:
ns.addip(OURIP)
with infamy.IsolatedMacVlan(hport) as ns:
ns.addip(OURIP)
with test.step("Verify basic DUT connectivity, host:data can ping DUT 10.0.0.2"):
ns.must_reach(DUTIP)
with test.step("Verify container 'web-docker0' is reachable on http://10.0.0.2:8080"):
until(lambda: url.nscheck(ns, "Kilroy was here"), attempts=10)
test.succeed()
Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

@@ -16,7 +16,11 @@ image::topology.png[Container with physical interface topology]
endif::testgroup[]
endif::topdoc[]
==== Test sequence
. Initialize
. Set up topology and attach to target DUT
. Create container 'web-phys' from bundled OCI image
. Verify container 'web-phys' has started
. Verify host:data can ping 10.0.0.2
. Verify container 'web-phys' is reachable on http://10.0.0.2:91
<<<
@@ -20,14 +20,14 @@ with infamy.Test() as test:
OURIP = "10.0.0.1"
URL = f"http://{DUTIP}:91/index.html"
with test.step("Initialize"):
with test.step("Set up topology and attach to target DUT"):
env = infamy.Env()
target = env.attach("target", "mgmt")
if not target.has_model("infix-containers"):
test.skip()
with test.step(f"Create {NAME} container from bundled OCI image"):
with test.step("Create container 'web-phys' from bundled OCI image"):
_, ifname = env.ltop.xlate("target", "data")
target.put_config_dict("ietf-interfaces", {
@@ -63,18 +63,19 @@ with infamy.Test() as test:
}
})
with test.step(f"Verify {NAME} container has started"):
with test.step("Verify container 'web-phys' has started"):
c = infamy.Container(target)
until(lambda: c.running(NAME), attempts=10)
with test.step(f"Verify {NAME} container responds"):
_, hport = env.ltop.xlate("host", "data")
url = infamy.Furl(URL)
_, hport = env.ltop.xlate("host", "data")
url = infamy.Furl(URL)
with infamy.IsolatedMacVlan(hport) as ns:
ns.addip(OURIP)
with infamy.IsolatedMacVlan(hport) as ns:
ns.addip(OURIP)
with test.step("Verify host:data can ping 10.0.0.2"):
ns.must_reach(DUTIP)
with test.step("Verify container 'web-phys' is reachable on http://10.0.0.2:91"):
until(lambda: url.nscheck(ns, "It works"), attempts=10)
test.succeed()
Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

@@ -3,6 +3,16 @@
Verify connectivity with a simple web server container from behind a
regular bridge, a VETH pair connects the container to the bridge.
....
.-------------. .---------------. .--------.
| | tgt |---------| mgmt | | | web- |
| host | data |---------| data | target | | server |
'-------------' '---------------' '--------'
| /
br0 /
`----- veth0 -----'
....
==== Topology
ifdef::topdoc[]
image::../../test/case/infix_containers/container_veth/topology.png[Container with VETH pair topology]
@@ -16,7 +26,11 @@ image::topology.png[Container with VETH pair topology]
endif::testgroup[]
endif::topdoc[]
==== Test sequence
. Initialize
. Set up topology and attach to target DUT
. Create 'web-br0-veth' container from bundled OCI image
. Verify container 'web-br0-veth' has started
. Verify basic DUT connectivity, host:data can ping DUT 10.0.0.2
. Verify container 'web-br0-veth' is reachable on http://10.0.0.2:91
<<<
@@ -3,11 +3,22 @@
# Verify connectivity with a simple web server container from behind a
# regular bridge, a VETH pair connects the container to the bridge.
#
"""
r"""
Container with VETH pair
Verify connectivity with a simple web server container from behind a
regular bridge, a VETH pair connects the container to the bridge.
....
.-------------. .---------------. .--------.
| | tgt |---------| mgmt | | | web- |
| host | data |---------| data | target | | server |
'-------------' '---------------' '--------'
| /
br0 /
`----- veth0 -----'
....
"""
import base64
import infamy
@@ -20,14 +31,14 @@ with infamy.Test() as test:
OURIP = "10.0.0.1"
URL = f"http://{DUTIP}:91/index.html"
with test.step("Initialize"):
with test.step("Set up topology and attach to target DUT"):
env = infamy.Env()
target = env.attach("target", "mgmt")
if not target.has_model("infix-containers"):
test.skip()
with test.step(f"Create {NAME} container from bundled OCI image"):
with test.step("Create 'web-br0-veth' container from bundled OCI image"):
_, ifname = env.ltop.xlate("target", "data")
target.put_config_dict("ietf-interfaces", {
"interfaces": {
@@ -86,18 +97,18 @@ with infamy.Test() as test:
}
})
with test.step(f"Verify {NAME} container has started"):
with test.step("Verify container 'web-br0-veth' has started"):
c = infamy.Container(target)
until(lambda: c.running(NAME), attempts=10)
with test.step(f"Verify {NAME} container responds"):
_, hport = env.ltop.xlate("host", "data")
url = infamy.Furl(URL)
_, hport = env.ltop.xlate("host", "data")
url = infamy.Furl(URL)
with infamy.IsolatedMacVlan(hport) as ns:
ns.addip(OURIP)
with infamy.IsolatedMacVlan(hport) as ns:
ns.addip(OURIP)
with test.step("Verify basic DUT connectivity, host:data can ping DUT 10.0.0.2"):
ns.must_reach(DUTIP)
with test.step("Verify container 'web-br0-veth' is reachable on http://10.0.0.2:91"):
until(lambda: url.nscheck(ns, "It works"), attempts=10)
test.succeed()
Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB