mirror of
https://github.com/kernelkit/infix.git
synced 2026-07-22 01:13:00 +02:00
test/case/infix_containers: new test, verify enable/disable
Regression test for issue #1123 Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
@@ -14,6 +14,8 @@ Verifies Infix Docker container support:
|
||||
|
||||
include::container_basic/Readme.adoc[]
|
||||
|
||||
include::container_enabled/Readme.adoc[]
|
||||
|
||||
include::container_bridge/Readme.adoc[]
|
||||
|
||||
include::container_phys/Readme.adoc[]
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
container_enabled.adoc
|
||||
@@ -0,0 +1,37 @@
|
||||
=== Container enabled/disabled
|
||||
==== Description
|
||||
Verify that a container can be enabled and disabled via configuration.
|
||||
Tests the 'enabled' leaf functionality by:
|
||||
|
||||
1. Creating an enabled container and verifying it starts
|
||||
2. Disabling the container and verifying it stops
|
||||
3. Re-enabling the container and verifying it starts again
|
||||
|
||||
Uses operational datastore to verify container running status.
|
||||
|
||||
==== Topology
|
||||
ifdef::topdoc[]
|
||||
image::{topdoc}../../test/case/infix_containers/container_enabled/topology.svg[Container enabled/disabled topology]
|
||||
endif::topdoc[]
|
||||
ifndef::topdoc[]
|
||||
ifdef::testgroup[]
|
||||
image::container_enabled/topology.svg[Container enabled/disabled topology]
|
||||
endif::testgroup[]
|
||||
ifndef::testgroup[]
|
||||
image::topology.svg[Container enabled/disabled topology]
|
||||
endif::testgroup[]
|
||||
endif::topdoc[]
|
||||
==== Test sequence
|
||||
. Set up topology and attach to target DUT
|
||||
. Set hostname to 'container-host'
|
||||
. Create enabled container from bundled OCI image
|
||||
. Verify container has started
|
||||
. Let container settle
|
||||
. Disable container
|
||||
. Verify container has stopped
|
||||
. Re-enable container
|
||||
. Verify container has started again
|
||||
|
||||
|
||||
<<<
|
||||
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Container enabled/disabled
|
||||
|
||||
Verify that a container can be enabled and disabled via configuration.
|
||||
Tests the 'enabled' leaf functionality by:
|
||||
|
||||
1. Creating an enabled container and verifying it starts
|
||||
2. Disabling the container and verifying it stops
|
||||
3. Re-enabling the container and verifying it starts again
|
||||
|
||||
Uses operational datastore to verify container running status.
|
||||
"""
|
||||
import infamy
|
||||
from infamy.util import until
|
||||
|
||||
|
||||
def set_container_enabled(target, name, enabled):
|
||||
"""Helper function to set container enabled state and verify the change"""
|
||||
target.put_config_dict("infix-containers", {
|
||||
"containers": {
|
||||
"container": [
|
||||
{
|
||||
"name": name,
|
||||
"enabled": enabled
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
with infamy.Test() as test:
|
||||
NAME = "web-enabled"
|
||||
|
||||
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("Set hostname to 'container-host'"):
|
||||
target.put_config_dict("ietf-system", {
|
||||
"system": {
|
||||
"hostname": "container-host"
|
||||
}
|
||||
})
|
||||
|
||||
with test.step("Create enabled container from bundled OCI image"):
|
||||
target.put_config_dict("infix-containers", {
|
||||
"containers": {
|
||||
"container": [
|
||||
{
|
||||
"name": f"{NAME}",
|
||||
"enabled": True,
|
||||
"image": f"oci-archive:{infamy.Container.HTTPD_IMAGE}",
|
||||
"command": "/usr/sbin/httpd -f -v -p 91",
|
||||
"network": {
|
||||
"host": True
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
with test.step("Verify container has started"):
|
||||
c = infamy.Container(target)
|
||||
until(lambda: c.running(NAME), attempts=60)
|
||||
|
||||
with test.step("Disable container"):
|
||||
set_container_enabled(target, NAME, False)
|
||||
|
||||
with test.step("Verify container has stopped"):
|
||||
until(lambda: not c.running(NAME), attempts=60)
|
||||
|
||||
with test.step("Re-enable container"):
|
||||
set_container_enabled(target, NAME, True)
|
||||
|
||||
with test.step("Verify container has started again"):
|
||||
until(lambda: c.running(NAME), attempts=60)
|
||||
|
||||
test.succeed()
|
||||
@@ -0,0 +1,23 @@
|
||||
graph "1x1" {
|
||||
layout="neato";
|
||||
overlap="false";
|
||||
esep="+80";
|
||||
|
||||
node [shape=record, fontname="DejaVu Sans Mono, Book"];
|
||||
edge [color="cornflowerblue", penwidth="2", fontname="DejaVu Serif, Book"];
|
||||
|
||||
host [
|
||||
label="host | { <mgmt> mgmt }",
|
||||
pos="0,12!",
|
||||
requires="controller",
|
||||
];
|
||||
|
||||
target [
|
||||
label="{ <mgmt> mgmt } | target",
|
||||
pos="10,12!",
|
||||
|
||||
requires="infix",
|
||||
];
|
||||
|
||||
host:mgmt -- target:mgmt [requires="mgmt", color="lightgray"]
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?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: 1x1 Pages: 1 -->
|
||||
<svg width="424pt" height="45pt"
|
||||
viewBox="0.00 0.00 424.03 45.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 41)">
|
||||
<title>1x1</title>
|
||||
<polygon fill="white" stroke="transparent" points="-4,4 -4,-41 420.03,-41 420.03,4 -4,4"/>
|
||||
<!-- host -->
|
||||
<g id="node1" class="node">
|
||||
<title>host</title>
|
||||
<polygon fill="none" stroke="black" points="0,-0.5 0,-36.5 100,-36.5 100,-0.5 0,-0.5"/>
|
||||
<text text-anchor="middle" x="25" y="-14.8" font-family="DejaVu Sans Mono, Book" font-size="14.00">host</text>
|
||||
<polyline fill="none" stroke="black" points="50,-0.5 50,-36.5 "/>
|
||||
<text text-anchor="middle" x="75" y="-14.8" font-family="DejaVu Sans Mono, Book" font-size="14.00">mgmt</text>
|
||||
</g>
|
||||
<!-- target -->
|
||||
<g id="node2" class="node">
|
||||
<title>target</title>
|
||||
<polygon fill="none" stroke="black" points="300.03,-0.5 300.03,-36.5 416.03,-36.5 416.03,-0.5 300.03,-0.5"/>
|
||||
<text text-anchor="middle" x="325.03" y="-14.8" font-family="DejaVu Sans Mono, Book" font-size="14.00">mgmt</text>
|
||||
<polyline fill="none" stroke="black" points="350.03,-0.5 350.03,-36.5 "/>
|
||||
<text text-anchor="middle" x="383.03" y="-14.8" font-family="DejaVu Sans Mono, Book" font-size="14.00">target</text>
|
||||
</g>
|
||||
<!-- host--target -->
|
||||
<g id="edge1" class="edge">
|
||||
<title>host:mgmt--target:mgmt</title>
|
||||
<path fill="none" stroke="lightgray" stroke-width="2" d="M100,-18.5C100,-18.5 300.03,-18.5 300.03,-18.5"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.6 KiB |
@@ -3,6 +3,9 @@
|
||||
- name: container_basic
|
||||
case: container_basic/test.py
|
||||
|
||||
- name: container_enabled
|
||||
case: container_enabled/test.py
|
||||
|
||||
- name: container_bridge
|
||||
case: container_bridge/test.py
|
||||
|
||||
@@ -20,4 +23,3 @@
|
||||
|
||||
- name: container_host_commands
|
||||
case: container_host_commands/test.py
|
||||
|
||||
|
||||
Reference in New Issue
Block a user