Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 22 additions & 18 deletions test/case/containers/basic/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,33 @@ def _verify(server, silent=False):
test.skip()

with test.step("Set hostname to 'container-host'"):
target.put_config_dict("ietf-system", {
"system": {
"hostname": "container-host"
target.put_config_dicts({
"ietf-system": {
"system": {
"hostname": "container-host"
}
}
})

with test.step("Create container 'web' from bundled OCI image"):
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": {
"host": True
},
"resource-limit": {
"memory": 512, # 512 KiB
"cpu": 500 # 50% of one CPU (0.5 cores)
target.put_config_dicts({
"infix-containers": {
"containers": {
"container": [
{
"name": f"{NAME}",
"image": f"oci-archive:{infamy.Container.HTTPD_IMAGE}",
"command": "/usr/sbin/httpd -f -v -p 91",
"network": {
"host": True
},
"resource-limit": {
"memory": 512, # 512 KiB
"cpu": 500 # 50% of one CPU (0.5 cores)
}
}
}
]
]
}
}
})

Expand Down
51 changes: 24 additions & 27 deletions test/case/containers/enabled/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@

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
}
]
target.put_config_dicts({
"infix-containers": {
"containers": {
"container": [
{
"name": name,
"enabled": enabled
}
]
}
}
})

Expand All @@ -39,27 +41,22 @@ def set_container_enabled(target, name, enabled):
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
target.put_config_dicts({
"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
}
}
}
]
]
}
}
})

Expand Down
90 changes: 48 additions & 42 deletions test/case/containers/environment/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,19 @@

with test.step("Configure data interface with static IPv4"):
_, 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
}]
}
}]
target.put_config_dicts({
"ietf-interfaces": {
"interfaces": {
"interface": [{
"name": f"{ifname}",
"ipv4": {
"address": [{
"ip": f"{DUTIP}",
"prefix-length": 24
}]
}
}]
}
}
})

Expand All @@ -62,31 +64,33 @@
for var in ENV_VARS:
cgi.append(f'echo "{var["key"]}=${var["key"]}"')

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 8080",
"env": ENV_VARS,
"network": {
"host": True
},
"mount": [
{
"name": "env.cgi",
"content": to_binary('\n'.join(cgi) + '\n'),
"target": "/var/www/cgi-bin/env.cgi",
"mode": "0755"
}
],
"volume": [{
"name": "www",
"target": "/var/www"
}]
}
]
target.put_config_dicts({
"infix-containers": {
"containers": {
"container": [
{
"name": f"{NAME}",
"image": f"oci-archive:{infamy.Container.HTTPD_IMAGE}",
"command": "/usr/sbin/httpd -f -v -p 8080",
"env": ENV_VARS,
"network": {
"host": True
},
"mount": [
{
"name": "env.cgi",
"content": to_binary('\n'.join(cgi) + '\n'),
"target": "/var/www/cgi-bin/env.cgi",
"mode": "0755"
}
],
"volume": [{
"name": "www",
"target": "/var/www"
}]
}
]
}
}
})

Expand Down Expand Up @@ -115,12 +119,14 @@
{"key": "PATH_WITH_SPACES", "value": "/path with spaces/test"}
]

target.put_config_dict("infix-containers", {
"containers": {
"container": [{
"name": f"{NAME}",
"env": UPDATED_ENV_VARS,
}]
target.put_config_dicts({
"infix-containers": {
"containers": {
"container": [{
"name": f"{NAME}",
"env": UPDATED_ENV_VARS,
}]
}
}
})

Expand Down
Loading
Loading