Skip to content

Commit d685fb0

Browse files
ShadowCurseJackThomson2
authored andcommitted
fix(tests): switch to Info log level
Instead of fluding the console with debug logs from vsock and other places for all VMs, only do this for api tests. Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
1 parent 6cc3575 commit d685fb0

File tree

2 files changed

+71
-40
lines changed

2 files changed

+71
-40
lines changed

tests/framework/microvm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ def spawn(
637637
self,
638638
log_file="fc.log",
639639
serial_out_path="serial.log",
640-
log_level="Debug",
640+
log_level="Info",
641641
log_show_level=False,
642642
log_show_origin=False,
643643
metrics_path="fc.ndjson",

tests/integration_tests/functional/test_api.py

Lines changed: 70 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ def test_api_happy_start(uvm_plain):
3434
Test that a regular microvm API config and boot sequence works.
3535
"""
3636
test_microvm = uvm_plain
37-
test_microvm.spawn()
37+
test_microvm.time_api_requests = True
38+
test_microvm.spawn(log_level="Debug")
3839

3940
# Set up the microVM with 2 vCPUs, 256 MiB of RAM and
4041
# a root file system with the rw permission.
@@ -54,7 +55,8 @@ def test_drive_io_engine(uvm_plain, io_engine):
5455
support the given type and that FC returns an error otherwise.
5556
"""
5657
test_microvm = uvm_plain
57-
test_microvm.spawn()
58+
test_microvm.time_api_requests = True
59+
test_microvm.spawn(log_level="Debug")
5860

5961
test_microvm.basic_config(add_root_device=False)
6062
test_microvm.add_net_iface()
@@ -82,7 +84,8 @@ def test_api_put_update_pre_boot(uvm_plain, io_engine):
8284
Tests updates on drives, boot source and machine config.
8385
"""
8486
test_microvm = uvm_plain
85-
test_microvm.spawn()
87+
test_microvm.time_api_requests = True
88+
test_microvm.spawn(log_level="Debug")
8689

8790
# Set up the microVM with 2 vCPUs, 256 MiB of RAM and
8891
# a root file system with the rw permission.
@@ -177,7 +180,8 @@ def test_net_api_put_update_pre_boot(uvm_plain):
177180
Test PUT updates on network configurations before the microvm boots.
178181
"""
179182
test_microvm = uvm_plain
180-
test_microvm.spawn()
183+
test_microvm.time_api_requests = True
184+
test_microvm.spawn(log_level="Debug")
181185

182186
tap1name = test_microvm.id[:8] + "tap1"
183187
tap1 = net_tools.Tap(tap1name, test_microvm.netns)
@@ -227,7 +231,8 @@ def test_api_mmds_config(uvm_plain):
227231
Tests updates on MMDS config before and after attaching a network device.
228232
"""
229233
test_microvm = uvm_plain
230-
test_microvm.spawn()
234+
test_microvm.time_api_requests = True
235+
test_microvm.spawn(log_level="Debug")
231236

232237
# Set up the microVM with 2 vCPUs, 256 MiB of RAM and
233238
# a root file system with the rw permission.
@@ -303,7 +308,8 @@ def test_api_machine_config(uvm_plain):
303308
Test /machine_config PUT/PATCH scenarios that unit tests can't cover.
304309
"""
305310
test_microvm = uvm_plain
306-
test_microvm.spawn()
311+
test_microvm.time_api_requests = True
312+
test_microvm.spawn(log_level="Debug")
307313

308314
# Test invalid vcpu count < 0.
309315
with pytest.raises(RuntimeError):
@@ -417,7 +423,8 @@ def test_negative_machine_config_api(uvm_plain):
417423
response header should have "Deprecation: true".
418424
"""
419425
test_microvm = uvm_plain
420-
test_microvm.spawn()
426+
test_microvm.time_api_requests = True
427+
test_microvm.spawn(log_level="Debug")
421428

422429
# Use `cpu_template` field in PUT /machine-config
423430
response = test_microvm.api.machine_config.put(
@@ -444,7 +451,8 @@ def test_api_cpu_config(uvm_plain, custom_cpu_template):
444451
Test /cpu-config PUT scenarios.
445452
"""
446453
test_microvm = uvm_plain
447-
test_microvm.spawn()
454+
test_microvm.time_api_requests = True
455+
test_microvm.spawn(log_level="Debug")
448456

449457
with pytest.raises(RuntimeError):
450458
test_microvm.api.cpu_config.put(foo=False)
@@ -457,7 +465,8 @@ def test_api_put_update_post_boot(uvm_plain, io_engine):
457465
Test that PUT updates are rejected after the microvm boots.
458466
"""
459467
test_microvm = uvm_plain
460-
test_microvm.spawn()
468+
test_microvm.time_api_requests = True
469+
test_microvm.spawn(log_level="Debug")
461470

462471
# Set up the microVM with 2 vCPUs, 256 MiB of RAM and
463472
# a root file system with the rw permission.
@@ -517,7 +526,8 @@ def test_rate_limiters_api_config(uvm_plain, io_engine):
517526
Test the IO rate limiter API config.
518527
"""
519528
test_microvm = uvm_plain
520-
test_microvm.spawn()
529+
test_microvm.time_api_requests = True
530+
test_microvm.spawn(log_level="Debug")
521531

522532
# Test the DRIVE rate limiting API.
523533

@@ -625,7 +635,8 @@ def test_api_patch_pre_boot(uvm_plain, io_engine):
625635
Test that PATCH updates are not allowed before the microvm boots.
626636
"""
627637
test_microvm = uvm_plain
628-
test_microvm.spawn()
638+
test_microvm.time_api_requests = True
639+
test_microvm.spawn(log_level="Debug")
629640

630641
# Sets up the microVM with 2 vCPUs, 256 MiB of RAM, 1 network interface
631642
# and a root file system with the rw permission.
@@ -675,7 +686,8 @@ def test_negative_api_patch_post_boot(uvm_plain, io_engine):
675686
Test PATCH updates that are not allowed after the microvm boots.
676687
"""
677688
test_microvm = uvm_plain
678-
test_microvm.spawn()
689+
test_microvm.time_api_requests = True
690+
test_microvm.spawn(log_level="Debug")
679691

680692
# Sets up the microVM with 2 vCPUs, 256 MiB of RAM, 1 network iface and
681693
# a root file system with the rw permission.
@@ -717,7 +729,8 @@ def test_drive_patch(uvm_plain, io_engine):
717729
Extensively test drive PATCH scenarios before and after boot.
718730
"""
719731
test_microvm = uvm_plain
720-
test_microvm.spawn()
732+
test_microvm.time_api_requests = True
733+
test_microvm.spawn(log_level="Debug")
721734

722735
# Sets up the microVM with 2 vCPUs, 256 MiB of RAM and
723736
# a root file system with the rw permission.
@@ -756,7 +769,8 @@ def test_send_ctrl_alt_del(uvm_plain_any):
756769
# This relies on the i8042 device and AT Keyboard support being present in
757770
# the guest kernel.
758771
test_microvm = uvm_plain_any
759-
test_microvm.spawn()
772+
test_microvm.time_api_requests = True
773+
test_microvm.spawn(log_level="Debug")
760774

761775
test_microvm.basic_config()
762776
test_microvm.add_net_iface()
@@ -904,7 +918,8 @@ def test_api_version(uvm_plain):
904918
Test the permanent VM version endpoint.
905919
"""
906920
test_microvm = uvm_plain
907-
test_microvm.spawn()
921+
test_microvm.time_api_requests = True
922+
test_microvm.spawn(log_level="Debug")
908923
test_microvm.basic_config()
909924

910925
# Getting the VM version should be available pre-boot.
@@ -965,7 +980,8 @@ def test_api_entropy(uvm_plain):
965980
Test entropy related API commands.
966981
"""
967982
test_microvm = uvm_plain
968-
test_microvm.spawn()
983+
test_microvm.time_api_requests = True
984+
test_microvm.spawn(log_level="Debug")
969985
test_microvm.basic_config()
970986

971987
# Create a new entropy device should be OK.
@@ -986,7 +1002,8 @@ def test_api_memory_hotplug(uvm_plain_6_1):
9861002
Test hotplug related API commands.
9871003
"""
9881004
test_microvm = uvm_plain_6_1
989-
test_microvm.spawn()
1005+
test_microvm.time_api_requests = True
1006+
test_microvm.spawn(log_level="Debug")
9901007
test_microvm.basic_config()
9911008
test_microvm.add_net_iface()
9921009

@@ -1024,11 +1041,15 @@ def test_api_memory_hotplug(uvm_plain_6_1):
10241041
assert status["requested_size_mib"] == 512
10251042

10261043

1027-
def test_api_balloon(uvm_nano):
1044+
def test_api_balloon(uvm_plain):
10281045
"""
10291046
Test balloon related API commands.
10301047
"""
1031-
test_microvm = uvm_nano
1048+
test_microvm = uvm_plain
1049+
test_microvm.time_api_requests = True
1050+
test_microvm.spawn(log_level="Debug")
1051+
test_microvm.basic_config(vcpu_count=2, mem_size_mib=256)
1052+
test_microvm.add_net_iface()
10321053

10331054
# Updating an inexistent balloon device should give an error.
10341055
with pytest.raises(RuntimeError):
@@ -1093,7 +1114,8 @@ def test_pmem_api(uvm_plain_any, rootfs):
10931114
"""
10941115

10951116
vm = uvm_plain_any
1096-
vm.spawn()
1117+
vm.time_api_requests = True
1118+
vm.spawn(log_level="Debug")
10971119
vm.basic_config(add_root_device=False)
10981120

10991121
invalid_pmem_path_on_host = os.path.join(vm.fsfiles, "invalid_scratch")
@@ -1148,11 +1170,17 @@ def test_pmem_api(uvm_plain_any, rootfs):
11481170
vm.api.pmem.put(id="pmem")
11491171

11501172

1151-
def test_get_full_config_after_restoring_snapshot(microvm_factory, uvm_nano):
1173+
def test_get_full_config_after_restoring_snapshot(microvm_factory, uvm_plain):
11521174
"""
11531175
Test the configuration of a microVM after restoring from a snapshot.
11541176
"""
1155-
net_iface = uvm_nano.add_net_iface()
1177+
1178+
test_microvm = uvm_plain
1179+
test_microvm.time_api_requests = True
1180+
test_microvm.spawn(log_level="Debug")
1181+
test_microvm.basic_config(vcpu_count=2, mem_size_mib=256)
1182+
1183+
net_iface = test_microvm.add_net_iface()
11561184
cpu_vendor = utils_cpuid.get_cpu_vendor()
11571185

11581186
setup_cfg = {}
@@ -1171,7 +1199,7 @@ def test_get_full_config_after_restoring_snapshot(microvm_factory, uvm_nano):
11711199
if len(SUPPORTED_CPU_TEMPLATES) != 0:
11721200
setup_cfg["machine-config"]["cpu_template"] = SUPPORTED_CPU_TEMPLATES[0]
11731201

1174-
uvm_nano.api.machine_config.patch(**setup_cfg["machine-config"])
1202+
test_microvm.api.machine_config.patch(**setup_cfg["machine-config"])
11751203

11761204
setup_cfg["cpu-config"] = None
11771205

@@ -1182,30 +1210,30 @@ def test_get_full_config_after_restoring_snapshot(microvm_factory, uvm_nano):
11821210
"is_root_device": True,
11831211
"cache_type": "Unsafe",
11841212
"is_read_only": True,
1185-
"path_on_host": f"/{uvm_nano.rootfs_file.name}",
1213+
"path_on_host": f"/{test_microvm.rootfs_file.name}",
11861214
"rate_limiter": None,
11871215
"io_engine": "Sync",
11881216
"socket": None,
11891217
}
11901218
]
11911219

1192-
uvm_nano.api.pmem.put(
1220+
test_microvm.api.pmem.put(
11931221
id="pmem",
1194-
path_on_host="/" + uvm_nano.rootfs_file.name,
1222+
path_on_host="/" + test_microvm.rootfs_file.name,
11951223
root_device=False,
11961224
read_only=False,
11971225
)
11981226
setup_cfg["pmem"] = [
11991227
{
12001228
"id": "pmem",
1201-
"path_on_host": "/" + uvm_nano.rootfs_file.name,
1229+
"path_on_host": "/" + test_microvm.rootfs_file.name,
12021230
"root_device": False,
12031231
"read_only": False,
12041232
}
12051233
]
12061234

12071235
# Add a memory balloon device.
1208-
uvm_nano.api.balloon.put(amount_mib=1, deflate_on_oom=True)
1236+
test_microvm.api.balloon.put(amount_mib=1, deflate_on_oom=True)
12091237
setup_cfg["balloon"] = {
12101238
"amount_mib": 1,
12111239
"deflate_on_oom": True,
@@ -1215,15 +1243,15 @@ def test_get_full_config_after_restoring_snapshot(microvm_factory, uvm_nano):
12151243
}
12161244

12171245
# Add a vsock device.
1218-
uvm_nano.api.vsock.put(guest_cid=15, uds_path="vsock.sock")
1246+
test_microvm.api.vsock.put(guest_cid=15, uds_path="vsock.sock")
12191247
setup_cfg["vsock"] = {"guest_cid": 15, "uds_path": "vsock.sock"}
12201248

12211249
setup_cfg["memory-hotplug"] = {
12221250
"total_size_mib": 1024,
12231251
"block_size_mib": 128,
12241252
"slot_size_mib": 1024,
12251253
}
1226-
uvm_nano.api.memory_hotplug.put(**setup_cfg["memory-hotplug"])
1254+
test_microvm.api.memory_hotplug.put(**setup_cfg["memory-hotplug"])
12271255

12281256
setup_cfg["logger"] = None
12291257
setup_cfg["metrics"] = None
@@ -1232,18 +1260,18 @@ def test_get_full_config_after_restoring_snapshot(microvm_factory, uvm_nano):
12321260
"network_interfaces": [net_iface.dev_name],
12331261
}
12341262

1235-
uvm_nano.api.mmds_config.put(**setup_cfg["mmds-config"])
1263+
test_microvm.api.mmds_config.put(**setup_cfg["mmds-config"])
12361264

12371265
# Start the microvm.
1238-
uvm_nano.start()
1266+
test_microvm.start()
12391267

12401268
# Add a tx rate limiter to the net device.
12411269
tx_rl = {
12421270
"bandwidth": {"size": 1000000, "refill_time": 100, "one_time_burst": None},
12431271
"ops": None,
12441272
}
12451273

1246-
response = uvm_nano.api.network.patch(
1274+
response = test_microvm.api.network.patch(
12471275
iface_id=net_iface.dev_name, tx_rate_limiter=tx_rl
12481276
)
12491277
setup_cfg["network-interfaces"] = [
@@ -1256,17 +1284,17 @@ def test_get_full_config_after_restoring_snapshot(microvm_factory, uvm_nano):
12561284
}
12571285
]
12581286

1259-
snapshot = uvm_nano.snapshot_full()
1287+
snapshot = test_microvm.snapshot_full()
12601288
uvm2 = microvm_factory.build_from_snapshot(snapshot)
12611289
expected_cfg = setup_cfg.copy()
12621290

12631291
# We expect boot-source to be set with the following values
12641292
expected_cfg["boot-source"] = {
1265-
"kernel_image_path": uvm_nano.get_jailed_resource(uvm_nano.kernel_file),
1293+
"kernel_image_path": test_microvm.get_jailed_resource(test_microvm.kernel_file),
12661294
"initrd_path": None,
12671295
"boot_args": "reboot=k panic=1 nomodule swiotlb=noforce console=ttyS0",
12681296
}
1269-
if not uvm_nano.pci_enabled:
1297+
if not test_microvm.pci_enabled:
12701298
expected_cfg["boot-source"]["boot_args"] += " pci=off"
12711299

12721300
# no ipv4_address or imds_compat specified during PUT /mmds/config so we expect the default
@@ -1291,10 +1319,11 @@ def test_get_full_config(uvm_plain):
12911319
Test the reported configuration of a microVM configured with all resources.
12921320
"""
12931321
test_microvm = uvm_plain
1322+
test_microvm.time_api_requests = True
12941323

12951324
expected_cfg = {}
12961325

1297-
test_microvm.spawn()
1326+
test_microvm.spawn(log_level="Debug")
12981327
# Basic config also implies a root block device.
12991328
test_microvm.basic_config(boot_args="", rootfs_io_engine="Sync")
13001329
expected_cfg["machine-config"] = {
@@ -1428,10 +1457,11 @@ def test_map_private_seccomp_regression(uvm_plain):
14281457
killed by the seccomp filter before this PR.
14291458
"""
14301459
test_microvm = uvm_plain
1460+
test_microvm.time_api_requests = True
14311461
test_microvm.jailer.extra_args.update(
14321462
{"http-api-max-payload-size": str(1024 * 1024 * 2)}
14331463
)
1434-
test_microvm.spawn()
1464+
test_microvm.spawn(log_level="Debug")
14351465
test_microvm.time_api_request = False
14361466

14371467
response = test_microvm.api.mmds.get()
@@ -1447,7 +1477,8 @@ def test_negative_snapshot_load_api(microvm_factory):
14471477
Test snapshot load API.
14481478
"""
14491479
vm = microvm_factory.build()
1450-
vm.spawn()
1480+
vm.time_api_requests = True
1481+
vm.spawn(log_level="Debug")
14511482

14521483
# Specifying both `mem_backend` and 'mem_file_path` should fail.
14531484
err_msg = (

0 commit comments

Comments
 (0)