Skip to content

Commit 7f829cf

Browse files
committed
test/case/infix_containers: new test, verify enable/disable
Regression test for issue #1123 Signed-off-by: Joachim Wiberg <[email protected]>
1 parent 86df54c commit 7f829cf

File tree

7 files changed

+181
-1
lines changed

7 files changed

+181
-1
lines changed

test/case/infix_containers/Readme.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Verifies Infix Docker container support:
1414

1515
include::container_basic/Readme.adoc[]
1616

17+
include::container_enabled/Readme.adoc[]
18+
1719
include::container_bridge/Readme.adoc[]
1820

1921
include::container_phys/Readme.adoc[]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
container_enabled.adoc
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
=== Container enabled/disabled
2+
==== Description
3+
Verify that a container can be enabled and disabled via configuration.
4+
Tests the 'enabled' leaf functionality by:
5+
6+
1. Creating an enabled container and verifying it starts
7+
2. Disabling the container and verifying it stops
8+
3. Re-enabling the container and verifying it starts again
9+
10+
Uses operational datastore to verify container running status.
11+
12+
==== Topology
13+
ifdef::topdoc[]
14+
image::{topdoc}../../test/case/infix_containers/container_enabled/topology.svg[Container enabled/disabled topology]
15+
endif::topdoc[]
16+
ifndef::topdoc[]
17+
ifdef::testgroup[]
18+
image::container_enabled/topology.svg[Container enabled/disabled topology]
19+
endif::testgroup[]
20+
ifndef::testgroup[]
21+
image::topology.svg[Container enabled/disabled topology]
22+
endif::testgroup[]
23+
endif::topdoc[]
24+
==== Test sequence
25+
. Set up topology and attach to target DUT
26+
. Set hostname to 'container-host'
27+
. Create enabled container from bundled OCI image
28+
. Verify container has started
29+
. Let container settle
30+
. Disable container
31+
. Verify container has stopped
32+
. Re-enable container
33+
. Verify container has started again
34+
35+
36+
<<<
37+
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Container enabled/disabled
4+
5+
Verify that a container can be enabled and disabled via configuration.
6+
Tests the 'enabled' leaf functionality by:
7+
8+
1. Creating an enabled container and verifying it starts
9+
2. Disabling the container and verifying it stops
10+
3. Re-enabling the container and verifying it starts again
11+
12+
Uses operational datastore to verify container running status.
13+
"""
14+
import infamy
15+
from infamy.util import until
16+
17+
18+
def set_container_enabled(target, name, enabled):
19+
"""Helper function to set container enabled state and verify the change"""
20+
target.put_config_dict("infix-containers", {
21+
"containers": {
22+
"container": [
23+
{
24+
"name": name,
25+
"enabled": enabled
26+
}
27+
]
28+
}
29+
})
30+
31+
32+
with infamy.Test() as test:
33+
NAME = "web-enabled"
34+
35+
with test.step("Set up topology and attach to target DUT"):
36+
env = infamy.Env()
37+
target = env.attach("target", "mgmt")
38+
39+
if not target.has_model("infix-containers"):
40+
test.skip()
41+
42+
with test.step("Set hostname to 'container-host'"):
43+
target.put_config_dict("ietf-system", {
44+
"system": {
45+
"hostname": "container-host"
46+
}
47+
})
48+
49+
with test.step("Create enabled container from bundled OCI image"):
50+
target.put_config_dict("infix-containers", {
51+
"containers": {
52+
"container": [
53+
{
54+
"name": f"{NAME}",
55+
"enabled": True,
56+
"image": f"oci-archive:{infamy.Container.HTTPD_IMAGE}",
57+
"command": "/usr/sbin/httpd -f -v -p 91",
58+
"network": {
59+
"host": True
60+
}
61+
}
62+
]
63+
}
64+
})
65+
66+
with test.step("Verify container has started"):
67+
c = infamy.Container(target)
68+
until(lambda: c.running(NAME), attempts=60)
69+
70+
with test.step("Disable container"):
71+
set_container_enabled(target, NAME, False)
72+
73+
with test.step("Verify container has stopped"):
74+
until(lambda: not c.running(NAME), attempts=60)
75+
76+
with test.step("Re-enable container"):
77+
set_container_enabled(target, NAME, True)
78+
79+
with test.step("Verify container has started again"):
80+
until(lambda: c.running(NAME), attempts=60)
81+
82+
test.succeed()
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
graph "1x1" {
2+
layout="neato";
3+
overlap="false";
4+
esep="+80";
5+
6+
node [shape=record, fontname="DejaVu Sans Mono, Book"];
7+
edge [color="cornflowerblue", penwidth="2", fontname="DejaVu Serif, Book"];
8+
9+
host [
10+
label="host | { <mgmt> mgmt }",
11+
pos="0,12!",
12+
requires="controller",
13+
];
14+
15+
target [
16+
label="{ <mgmt> mgmt } | target",
17+
pos="10,12!",
18+
19+
requires="infix",
20+
];
21+
22+
host:mgmt -- target:mgmt [requires="mgmt", color="lightgray"]
23+
}
Lines changed: 33 additions & 0 deletions
Loading

test/case/infix_containers/infix_containers.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
- name: container_basic
44
case: container_basic/test.py
55

6+
- name: container_enabled
7+
case: container_enabled/test.py
8+
69
- name: container_bridge
710
case: container_bridge/test.py
811

@@ -20,4 +23,3 @@
2023

2124
- name: container_host_commands
2225
case: container_host_commands/test.py
23-

0 commit comments

Comments
 (0)