Skip to content

Commit fc7083d

Browse files
authored
Merge pull request #1525 from kernelkit/remove-put-config-dict
test: Remove function put_config_dict and convert tests to use put_config_dicts
2 parents 46fb3a0 + 8e5d496 commit fc7083d

62 files changed

Lines changed: 961 additions & 970 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

test/case/containers/basic/test.py

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,29 +30,33 @@ def _verify(server, silent=False):
3030
test.skip()
3131

3232
with test.step("Set hostname to 'container-host'"):
33-
target.put_config_dict("ietf-system", {
34-
"system": {
35-
"hostname": "container-host"
33+
target.put_config_dicts({
34+
"ietf-system": {
35+
"system": {
36+
"hostname": "container-host"
37+
}
3638
}
3739
})
3840

3941
with test.step("Create container 'web' from bundled OCI image"):
40-
target.put_config_dict("infix-containers", {
41-
"containers": {
42-
"container": [
43-
{
44-
"name": f"{NAME}",
45-
"image": f"oci-archive:{infamy.Container.HTTPD_IMAGE}",
46-
"command": "/usr/sbin/httpd -f -v -p 91",
47-
"network": {
48-
"host": True
49-
},
50-
"resource-limit": {
51-
"memory": 512, # 512 KiB
52-
"cpu": 500 # 50% of one CPU (0.5 cores)
42+
target.put_config_dicts({
43+
"infix-containers": {
44+
"containers": {
45+
"container": [
46+
{
47+
"name": f"{NAME}",
48+
"image": f"oci-archive:{infamy.Container.HTTPD_IMAGE}",
49+
"command": "/usr/sbin/httpd -f -v -p 91",
50+
"network": {
51+
"host": True
52+
},
53+
"resource-limit": {
54+
"memory": 512, # 512 KiB
55+
"cpu": 500 # 50% of one CPU (0.5 cores)
56+
}
5357
}
54-
}
55-
]
58+
]
59+
}
5660
}
5761
})
5862

test/case/containers/enabled/test.py

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,16 @@
1717

1818
def set_container_enabled(target, name, enabled):
1919
"""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-
]
20+
target.put_config_dicts({
21+
"infix-containers": {
22+
"containers": {
23+
"container": [
24+
{
25+
"name": name,
26+
"enabled": enabled
27+
}
28+
]
29+
}
2830
}
2931
})
3032

@@ -39,27 +41,22 @@ def set_container_enabled(target, name, enabled):
3941
if not target.has_model("infix-containers"):
4042
test.skip()
4143

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-
4944
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
45+
target.put_config_dicts({
46+
"infix-containers": {
47+
"containers": {
48+
"container": [
49+
{
50+
"name": f"{NAME}",
51+
"enabled": True,
52+
"image": f"oci-archive:{infamy.Container.HTTPD_IMAGE}",
53+
"command": "/usr/sbin/httpd -f -v -p 91",
54+
"network": {
55+
"host": True
56+
}
6057
}
61-
}
62-
]
58+
]
59+
}
6360
}
6461
})
6562

test/case/containers/environment/test.py

Lines changed: 48 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,19 @@
3737

3838
with test.step("Configure data interface with static IPv4"):
3939
_, ifname = env.ltop.xlate("target", "data")
40-
target.put_config_dict("ietf-interfaces", {
41-
"interfaces": {
42-
"interface": [{
43-
"name": f"{ifname}",
44-
"ipv4": {
45-
"address": [{
46-
"ip": f"{DUTIP}",
47-
"prefix-length": 24
48-
}]
49-
}
50-
}]
40+
target.put_config_dicts({
41+
"ietf-interfaces": {
42+
"interfaces": {
43+
"interface": [{
44+
"name": f"{ifname}",
45+
"ipv4": {
46+
"address": [{
47+
"ip": f"{DUTIP}",
48+
"prefix-length": 24
49+
}]
50+
}
51+
}]
52+
}
5153
}
5254
})
5355

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

65-
target.put_config_dict("infix-containers", {
66-
"containers": {
67-
"container": [
68-
{
69-
"name": f"{NAME}",
70-
"image": f"oci-archive:{infamy.Container.HTTPD_IMAGE}",
71-
"command": "/usr/sbin/httpd -f -v -p 8080",
72-
"env": ENV_VARS,
73-
"network": {
74-
"host": True
75-
},
76-
"mount": [
77-
{
78-
"name": "env.cgi",
79-
"content": to_binary('\n'.join(cgi) + '\n'),
80-
"target": "/var/www/cgi-bin/env.cgi",
81-
"mode": "0755"
82-
}
83-
],
84-
"volume": [{
85-
"name": "www",
86-
"target": "/var/www"
87-
}]
88-
}
89-
]
67+
target.put_config_dicts({
68+
"infix-containers": {
69+
"containers": {
70+
"container": [
71+
{
72+
"name": f"{NAME}",
73+
"image": f"oci-archive:{infamy.Container.HTTPD_IMAGE}",
74+
"command": "/usr/sbin/httpd -f -v -p 8080",
75+
"env": ENV_VARS,
76+
"network": {
77+
"host": True
78+
},
79+
"mount": [
80+
{
81+
"name": "env.cgi",
82+
"content": to_binary('\n'.join(cgi) + '\n'),
83+
"target": "/var/www/cgi-bin/env.cgi",
84+
"mode": "0755"
85+
}
86+
],
87+
"volume": [{
88+
"name": "www",
89+
"target": "/var/www"
90+
}]
91+
}
92+
]
93+
}
9094
}
9195
})
9296

@@ -115,12 +119,14 @@
115119
{"key": "PATH_WITH_SPACES", "value": "/path with spaces/test"}
116120
]
117121

118-
target.put_config_dict("infix-containers", {
119-
"containers": {
120-
"container": [{
121-
"name": f"{NAME}",
122-
"env": UPDATED_ENV_VARS,
123-
}]
122+
target.put_config_dicts({
123+
"infix-containers": {
124+
"containers": {
125+
"container": [{
126+
"name": f"{NAME}",
127+
"env": UPDATED_ENV_VARS,
128+
}]
129+
}
124130
}
125131
})
126132

0 commit comments

Comments
 (0)