diff --git a/test/case/infix_containers/container_basic/Readme.adoc b/test/case/infix_containers/container_basic/Readme.adoc index 541e6658..f8d56c73 100644 --- a/test/case/infix_containers/container_basic/Readme.adoc +++ b/test/case/infix_containers/container_basic/Readme.adoc @@ -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 <<< diff --git a/test/case/infix_containers/container_basic/test.py b/test/case/infix_containers/container_basic/test.py index 0dab2cd3..d95059d7 100755 --- a/test/case/infix_containers/container_basic/test.py +++ b/test/case/infix_containers/container_basic/test.py @@ -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() diff --git a/test/case/infix_containers/container_bridge/Readme.adoc b/test/case/infix_containers/container_bridge/Readme.adoc index e269b6ab..d521040d 100644 --- a/test/case/infix_containers/container_bridge/Readme.adoc +++ b/test/case/infix_containers/container_bridge/Readme.adoc @@ -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 <<< diff --git a/test/case/infix_containers/container_bridge/test.py b/test/case/infix_containers/container_bridge/test.py index ac26c51d..ea4ebd37 100755 --- a/test/case/infix_containers/container_bridge/test.py +++ b/test/case/infix_containers/container_bridge/test.py @@ -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 = "

Kilroy was here

" 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() diff --git a/test/case/infix_containers/container_bridge/topology.png b/test/case/infix_containers/container_bridge/topology.png index c5eff8f6..8b93e191 100644 Binary files a/test/case/infix_containers/container_bridge/topology.png and b/test/case/infix_containers/container_bridge/topology.png differ diff --git a/test/case/infix_containers/container_phys/Readme.adoc b/test/case/infix_containers/container_phys/Readme.adoc index fff617ed..107dabee 100644 --- a/test/case/infix_containers/container_phys/Readme.adoc +++ b/test/case/infix_containers/container_phys/Readme.adoc @@ -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 <<< diff --git a/test/case/infix_containers/container_phys/test.py b/test/case/infix_containers/container_phys/test.py index d8c6d42a..63001e54 100755 --- a/test/case/infix_containers/container_phys/test.py +++ b/test/case/infix_containers/container_phys/test.py @@ -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() diff --git a/test/case/infix_containers/container_phys/topology.png b/test/case/infix_containers/container_phys/topology.png index c5eff8f6..8b93e191 100644 Binary files a/test/case/infix_containers/container_phys/topology.png and b/test/case/infix_containers/container_phys/topology.png differ diff --git a/test/case/infix_containers/container_veth/Readme.adoc b/test/case/infix_containers/container_veth/Readme.adoc index ba61cdbf..8fb69568 100644 --- a/test/case/infix_containers/container_veth/Readme.adoc +++ b/test/case/infix_containers/container_veth/Readme.adoc @@ -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 <<< diff --git a/test/case/infix_containers/container_veth/test.py b/test/case/infix_containers/container_veth/test.py index 323d6371..09600be8 100755 --- a/test/case/infix_containers/container_veth/test.py +++ b/test/case/infix_containers/container_veth/test.py @@ -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() diff --git a/test/case/infix_containers/container_veth/topology.png b/test/case/infix_containers/container_veth/topology.png index c5eff8f6..8b93e191 100644 Binary files a/test/case/infix_containers/container_veth/topology.png and b/test/case/infix_containers/container_veth/topology.png differ