Skip to content

Commit 360876e

Browse files
author
Alexandra Iordache
committed
Integration tests for all network update use cases
The network interfaces update test case only covered interface name update, which worked because a new tap device was created. See #354 Signed-off-by: Alexandra Iordache <[email protected]>
1 parent d69ff56 commit 360876e

File tree

2 files changed

+52
-3
lines changed

2 files changed

+52
-3
lines changed

tests/functional/test_api.py

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,16 +143,65 @@ def test_api_put_update_pre_boot(test_microvm_with_api):
143143
assert (response_json['mem_size_mib'] == str(microvm_config_json['mem_size_mib']))
144144
assert (response_json['cpu_template'] == str(microvm_config_json['cpu_template']))
145145

146+
second_if_name = 'second_tap'
147+
response = test_microvm.api_session.put(
148+
test_microvm.net_cfg_url + '/2',
149+
json={
150+
'iface_id': '2',
151+
'host_dev_name': test_microvm.slot.make_tap(name=second_if_name),
152+
'guest_mac': '07:00:00:00:00:01',
153+
'state': 'Attached'
154+
}
155+
)
156+
""" Adding new network interfaces is allowed. """
157+
assert(test_microvm.api_session.is_good_response(response.status_code))
158+
159+
response = test_microvm.api_session.put(
160+
test_microvm.net_cfg_url + '/2',
161+
json={
162+
'iface_id': '2',
163+
'host_dev_name': second_if_name,
164+
'guest_mac': '06:00:00:00:00:01',
165+
'state': 'Attached'
166+
}
167+
)
168+
""" Updates to a network interface with an unavailable MAC are not allowed. """
169+
assert(not test_microvm.api_session.is_good_response(response.status_code))
170+
171+
response = test_microvm.api_session.put(
172+
test_microvm.net_cfg_url + '/2',
173+
json={
174+
'iface_id': '2',
175+
'host_dev_name': second_if_name,
176+
'guest_mac': '08:00:00:00:00:01',
177+
'state': 'Attached'
178+
}
179+
)
180+
""" Updates to a network interface with an available MAC are allowed. """
181+
assert(test_microvm.api_session.is_good_response(response.status_code))
182+
146183
response = test_microvm.api_session.put(
147184
test_microvm.net_cfg_url + '/1',
148185
json={
149186
'iface_id': '1',
150-
'host_dev_name': test_microvm.slot.make_tap(name='newtap'),
187+
'host_dev_name': second_if_name,
188+
'guest_mac': '06:00:00:00:00:01',
189+
'state': 'Attached'
190+
}
191+
)
192+
""" Updates to a network interface with an unavailable name are not allowed. """
193+
assert(not test_microvm.api_session.is_good_response(response.status_code))
194+
195+
response = test_microvm.api_session.put(
196+
test_microvm.net_cfg_url + '/1',
197+
json={
198+
'iface_id': '1',
199+
'host_dev_name': test_microvm.slot.make_tap(),
151200
'guest_mac': '06:00:00:00:00:01',
152201
'state': 'Attached'
153202
}
154203
)
155-
""" Valid updates to the network `host_dev_name` are allowed. """
204+
""" Updates to a network interface with an available name are allowed. """
156205
assert(test_microvm.api_session.is_good_response(response.status_code))
157206

158207

tests/microvm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ def basic_config(
351351
)
352352
responses.append(response)
353353

354-
for net_iface_index in range(0, net_iface_count):
354+
for net_iface_index in range(1, net_iface_count + 1):
355355
response = self.api_session.put(
356356
self.net_cfg_url + '/' + str(net_iface_index),
357357
json={

0 commit comments

Comments
 (0)