Skip to content

Commit

Permalink
test: verify modifying a running container takes
Browse files Browse the repository at this point in the history
Add new test step that adds a content mount to /var/www/index.html to
verify that changes to a running container are activated.

This test pass was previously part of the container bridge test, but
was moved here to allow that test to focus on bridge specific checks.

Issue #930

Signed-off-by: Joachim Wiberg <[email protected]>
  • Loading branch information
troglobit committed Feb 23, 2025
1 parent 472488a commit 1359195
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 30 deletions.
7 changes: 4 additions & 3 deletions test/case/infix_containers/container_phys/container_phys.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ endif::testgroup[]
endif::topdoc[]
==== Test sequence
. Set up topology and attach to target DUT
. Create container 'web-phys' from bundled OCI image
. Verify container 'web-phys' has started
. Create httpd container from bundled OCI image
. Verify container has started
. Verify host:data can ping 10.0.0.2
. Verify container 'web-phys' is reachable on http://10.0.0.2:91
. Verify container is reachable on http://10.0.0.2:91
. Verify modifying a running container takes


<<<
Expand Down
71 changes: 44 additions & 27 deletions test/case/infix_containers/container_phys/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
"""
import base64
import infamy
from infamy.util import until
from infamy.util import until, to_binary

with infamy.Test() as test:
NAME = "web-phys"
DUTIP = "10.0.0.2"
OURIP = "10.0.0.1"
MESG = "Kilroy was here"
BODY = f"<html><body><p>{MESG}</p></body></html>"
URL = f"http://{DUTIP}:91/index.html"

with test.step("Set up topology and attach to target DUT"):
Expand All @@ -26,43 +28,39 @@
if not target.has_model("infix-containers"):
test.skip()

with test.step("Create container 'web-phys' from bundled OCI image"):
with test.step("Create httpd container from bundled OCI image"):
_, ifname = env.ltop.xlate("target", "data")

target.put_config_dict("ietf-interfaces", {
"interfaces": {
"interface": [
{
"name": f"{ifname}",
"ipv4": {
"address": [{
"ip": f"{DUTIP}",
"prefix-length": 24
}]
},
"container-network": {}
}
]
"interface": [{
"name": f"{ifname}",
"ipv4": {
"address": [{
"ip": f"{DUTIP}",
"prefix-length": 24
}]
},
"container-network": {}
}]
}
})
target.put_config_dict("infix-containers", {
"containers": {
"container": [
{
"name": f"{NAME}",
"image": f"oci-archive:{infamy.Container.HTTPD_IMAGE}",
"command": "/usr/sbin/httpd -f -v -p 91",
"network": {
"interface": [
{ "name": f"{ifname}" }
]
}
"container": [{
"name": f"{NAME}",
"image": f"oci-archive:{infamy.Container.HTTPD_IMAGE}",
"command": "/usr/sbin/httpd -f -v -p 91",
"network": {
"interface": [
{"name": f"{ifname}"}
]
}
]
}]
}
})

with test.step("Verify container 'web-phys' has started"):
with test.step("Verify container has started"):
c = infamy.Container(target)
until(lambda: c.running(NAME), attempts=10)

Expand All @@ -74,7 +72,26 @@
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"):
with test.step("Verify container is reachable on http://10.0.0.2:91"):
until(lambda: url.nscheck(ns, "It works"), attempts=10)

with test.step("Verify modifying a running container takes"):
# Regression test for issue #930
data = to_binary(BODY)

target.put_config_dict("infix-containers", {
"containers": {
"container": [{
"name": f"{NAME}",
"mount": [{
"name": "index.html",
"content": f"{data}",
"target": "/var/www/index.html"
}]
}]
}
})

until(lambda: url.nscheck(ns, MESG), attempts=10)

test.succeed()

0 comments on commit 1359195

Please sign in to comment.