Skip to content

Commit fc69c33

Browse files
roypatbchalios
authored andcommitted
test: Use Microvm.wait_for_up in tests that boot via config
Tests that boot a microvm via a config file do not use `.start()`, as `.spawn()` already start the bootup process. This is probably why these tests were overlooked when we did the `.wait_for_up()` refactor. Fix potential issues by adding the `wait_for_up()` calls here, to replace various homegrown waiting solutions. Some tests do not have network devices, and also don't really need to wait for the guest to have booted as they only validate firecracker API responses. Don't try to use wait_for_up in those (since we can't anyway). Signed-off-by: Patrick Roy <[email protected]>
1 parent 4f0909a commit fc69c33

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

tests/integration_tests/functional/test_cmd_line_start.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import platform
88
import re
99
import shutil
10-
import time
1110
from pathlib import Path
1211

1312
import pytest
@@ -164,7 +163,7 @@ def test_config_start_no_api_exit(uvm_plain, vm_config_file):
164163
test_microvm.jailer.extra_args.update({"no-api": None})
165164

166165
test_microvm.spawn() # Start Firecracker and MicroVM
167-
time.sleep(3) # Wait for startup
166+
test_microvm.wait_for_up()
168167
test_microvm.ssh.run("reboot") # Exit
169168

170169
test_microvm.mark_killed() # waits for process to terminate
@@ -266,7 +265,7 @@ def test_config_start_with_limit(uvm_plain, vm_config_file):
266265
response += '{ "error": "Request payload with size 260 is larger than '
267266
response += "the limit of 250 allowed by server.\n"
268267
response += 'All previous unanswered requests will be dropped." }'
269-
_, stdout, _stderr = utils.check_output(cmd)
268+
_, stdout, _ = utils.check_output(cmd)
270269
assert stdout.encode("utf-8") == response.encode("utf-8")
271270

272271

@@ -420,8 +419,7 @@ def test_config_start_and_mmds_with_api(uvm_plain, vm_config_file):
420419

421420
# Network namespace has already been created.
422421
test_microvm.spawn()
423-
424-
assert test_microvm.state == "Running"
422+
test_microvm.wait_for_up()
425423

426424
data_store = {
427425
"latest": {
@@ -480,6 +478,7 @@ def test_with_config_and_metadata_no_api(uvm_plain, vm_config_file, metadata_fil
480478
_configure_network_interface(test_microvm)
481479
test_microvm.jailer.extra_args.update({"no-api": None})
482480
test_microvm.spawn()
481+
test_microvm.wait_for_up()
483482

484483
# Get MMDS version and IPv4 address configured from the file.
485484
version, ipv4_address = _get_optional_fields_from_file(vm_config_file)

0 commit comments

Comments
 (0)