test: new test, verify volume content is not lost

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2025-02-24 22:31:18 +01:00
parent 91f0094048
commit d68dacdc80
7 changed files with 151 additions and 0 deletions
+3
View File
@@ -7,6 +7,7 @@ Verifies Infix Docker container support:
- Common setup with a docker0 bridge, automatic VETH pairs to container(s)
- Connecting a container with a VETH pair to a standard Linux bridge
- Assigning a physical Ethernet interface to a container
- Upgrading a container with a volume, verifying volume data is intact
- Basic firewall container running in host network mode and full privileges
<<<
@@ -19,4 +20,6 @@ include::container_phys/Readme.adoc[]
include::container_veth/Readme.adoc[]
include::container_volume/Readme.adoc[]
include::container_firewall_basic/Readme.adoc[]
@@ -0,0 +1 @@
container_volume.adoc
@@ -0,0 +1,30 @@
=== Container Volume Persistence
==== Description
Verify that a container created from a local OCI archive, with a volume
for persistent content, can be upgraded at runtime, without losing the
content in the volume on restart.
==== Topology
ifdef::topdoc[]
image::{topdoc}../../test/case/infix_containers/container_volume/topology.svg[Container Volume Persistence topology]
endif::topdoc[]
ifndef::topdoc[]
ifdef::testgroup[]
image::container_volume/topology.svg[Container Volume Persistence topology]
endif::testgroup[]
ifndef::testgroup[]
image::topology.svg[Container Volume Persistence topology]
endif::testgroup[]
endif::topdoc[]
==== Test sequence
. Set up topology and attach to target DUT
. Create container with volume from bundled OCI image
. Verify container has started
. Modify container volume content
. Verify container volume content
. Upgrade container
. Verify container volume content survived upgrade
<<<
+71
View File
@@ -0,0 +1,71 @@
#!/usr/bin/env python3
"""Container Volume Persistence
Verify that a container created from a local OCI archive, with a volume
for persistent content, can be upgraded at runtime, without losing the
content in the volume on restart.
"""
import infamy
from infamy.util import until
with infamy.Test() as test:
NAME = "web-volume"
PORT = 8080
MESG = "HEJ"
with test.step("Set up topology and attach to target DUT"):
env = infamy.Env()
target = env.attach("target", "mgmt")
tgtssh = env.attach("target", "mgmt", "ssh")
addr = target.get_mgmt_ip()
url = infamy.Furl(f"http://[{addr}]:{PORT}/index.html")
if not target.has_model("infix-containers"):
test.skip()
with test.step("Create container with volume from bundled OCI image"):
target.put_config_dict("infix-containers", {
"containers": {
"container": [
{
"name": f"{NAME}",
"image": f"oci-archive:{infamy.Container.HTTPD_IMAGE}",
"command": f"/usr/sbin/httpd -f -v -p {PORT}",
"network": {
"host": True
},
"volume": [{
"name": "www",
"target": "/var/www"
}]
}
]
}
})
with test.step("Verify container has started"):
c = infamy.Container(target)
until(lambda: c.running(NAME), attempts=10)
with test.step("Modify container volume content"):
cmd = f"sudo container shell {NAME} 'echo {MESG} >/var/www/index.html'"
tgtssh.runsh(cmd)
with test.step("Verify container volume content"):
until(lambda: url.check(MESG), attempts=10)
with test.step("Upgrade container"):
out = tgtssh.runsh(f"sudo container upgrade {NAME}")
if ">> Done." not in out.stdout:
msg = f"Failed upgrading container {NAME}:\n" \
f"STDOUT:\n{out.stdout}\n" \
f"STDERR:\n{out.stderr}"
test.fail(msg)
# else:
# print(f"Container {NAME} upgraded: {out.stdout}")
with test.step("Verify container volume content survived upgrade"):
until(lambda: url.check(MESG), attempts=10)
test.succeed()
@@ -0,0 +1 @@
../../../infamy/topologies/1x2.dot
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Title: 1x2 Pages: 1 -->
<svg width="424pt" height="55pt"
viewBox="0.00 0.00 424.03 55.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 51)">
<title>1x2</title>
<polygon fill="white" stroke="transparent" points="-4,4 -4,-51 420.03,-51 420.03,4 -4,4"/>
<!-- host -->
<g id="node1" class="node">
<title>host</title>
<polygon fill="none" stroke="black" points="0,-0.5 0,-46.5 100,-46.5 100,-0.5 0,-0.5"/>
<text text-anchor="middle" x="25" y="-19.8" font-family="DejaVu Sans Mono, Book" font-size="14.00">host</text>
<polyline fill="none" stroke="black" points="50,-0.5 50,-46.5 "/>
<text text-anchor="middle" x="75" y="-31.3" font-family="DejaVu Sans Mono, Book" font-size="14.00">mgmt</text>
<polyline fill="none" stroke="black" points="50,-23.5 100,-23.5 "/>
<text text-anchor="middle" x="75" y="-8.3" font-family="DejaVu Sans Mono, Book" font-size="14.00">data</text>
</g>
<!-- target -->
<g id="node2" class="node">
<title>target</title>
<polygon fill="none" stroke="black" points="300.03,-0.5 300.03,-46.5 416.03,-46.5 416.03,-0.5 300.03,-0.5"/>
<text text-anchor="middle" x="325.03" y="-31.3" font-family="DejaVu Sans Mono, Book" font-size="14.00">mgmt</text>
<polyline fill="none" stroke="black" points="300.03,-23.5 350.03,-23.5 "/>
<text text-anchor="middle" x="325.03" y="-8.3" font-family="DejaVu Sans Mono, Book" font-size="14.00">data</text>
<polyline fill="none" stroke="black" points="350.03,-0.5 350.03,-46.5 "/>
<text text-anchor="middle" x="383.03" y="-19.8" font-family="DejaVu Sans Mono, Book" font-size="14.00">target</text>
</g>
<!-- host&#45;&#45;target -->
<g id="edge1" class="edge">
<title>host:mgmt&#45;&#45;target:mgmt</title>
<path fill="none" stroke="lightgrey" stroke-width="2" d="M100,-35.5C100,-35.5 300.03,-35.5 300.03,-35.5"/>
</g>
<!-- host&#45;&#45;target -->
<g id="edge2" class="edge">
<title>host:data&#45;&#45;target:data</title>
<path fill="none" stroke="black" stroke-width="2" d="M100,-11.5C100,-11.5 300.03,-11.5 300.03,-11.5"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.2 KiB

@@ -12,6 +12,9 @@
- name: container_veth
case: container_veth/test.py
- name: container_volume
case: container_volume/test.py
- name: container_firewall_basic
case: container_firewall_basic/test.py