Skip to content

Commit

Permalink
refactor(errors): updated integration tests with new errors
Browse files Browse the repository at this point in the history
Updated integration tests with new errors

Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
  • Loading branch information
ShadowCurse committed Dec 12, 2023
1 parent 2b33b9b commit de95f22
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
9 changes: 4 additions & 5 deletions tests/integration_tests/functional/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ def test_drive_io_engine(test_microvm_with_api):
test_microvm.api.drive.put(io_engine="Async", **kwargs)
# The Async engine is not supported for older kernels.
test_microvm.check_log_message(
"Received Error. Status code: 400 Bad Request. Message: Unable"
" to create the virtio block device: FileEngine(UnsupportedEngine(Async))"
"Received Error. Status code: 400 Bad Request. Message: Drive config error: Unable to create the virtio block device: FileEngine(UnsupportedEngine(Async))"
)

# Now configure the default engine type and check that it works.
Expand Down Expand Up @@ -394,7 +393,7 @@ def test_api_machine_config(test_microvm_with_api):
test_microvm.api.machine_config.patch(mem_size_mib=bad_size)

fail_msg = re.escape(
"Invalid Memory Configuration: MemfdSetLen(Custom { kind: InvalidInput, error: TryFromIntError(()) })"
"Invalid Memory Configuration: Cannot resize memfd file: Custom { kind: InvalidInput, error: TryFromIntError(()) }"
)
with pytest.raises(RuntimeError, match=fail_msg):
test_microvm.start()
Expand Down Expand Up @@ -852,8 +851,8 @@ def _drive_patch(test_microvm):

# Updates to `path_on_host` with an invalid path are not allowed.
expected_msg = (
"Unable to patch the block device: BackingFile(Os { code: 2, "
f'kind: NotFound, message: "No such file or directory" }}, "{drive_path}")'
"Unable to patch the block device: Device manager error: BackingFile(Os { code: 2, "
f'kind: NotFound, message: "No such file or directory" }}, "{drive_path}") Please verify the request arguments.'
)
with pytest.raises(RuntimeError, match=re.escape(expected_msg)):
test_microvm.api.drive.patch(drive_id="scratch", path_on_host=drive_path)
Expand Down
4 changes: 1 addition & 3 deletions tests/integration_tests/functional/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,7 @@ def test_api_requests_logs(test_microvm_with_api):

# Check that the fault message return by the client is also logged in the
# FIFO.
fault_msg = (
"The kernel file cannot be opened: No such file or directory (os error 2)"
)
fault_msg = "Boot source error: The kernel file cannot be opened: No such file or directory (os error 2)"
with pytest.raises(RuntimeError, match=re.escape(fault_msg)):
microvm.api.boot.put(kernel_image_path="inexistent_path")
microvm.check_log_message(
Expand Down
6 changes: 3 additions & 3 deletions tests/integration_tests/functional/test_snapshot_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def test_load_snapshot_failure_handling(test_microvm_with_api):

# Load the snapshot
expected_msg = (
"Load microVM snapshot error: Failed to restore from snapshot: Failed to get snapshot "
"Load snapshot error: Failed to restore from snapshot: Failed to get snapshot "
"state from file: Failed to load snapshot state from file: Snapshot file is smaller "
"than CRC length."
)
Expand Down Expand Up @@ -327,7 +327,7 @@ def test_negative_snapshot_permissions(uvm_plain_rw, microvm_factory):
microvm.spawn()

expected_err = re.escape(
"Load microVM snapshot error: Failed to restore from snapshot: Failed to load guest "
"Load snapshot error: Failed to restore from snapshot: Failed to load guest "
"memory: Error creating guest memory from file: Failed to load guest memory: "
"Permission denied (os error 13)"
)
Expand All @@ -341,7 +341,7 @@ def test_negative_snapshot_permissions(uvm_plain_rw, microvm_factory):
microvm.spawn()

expected_err = re.escape(
"Load microVM snapshot error: Failed to restore from snapshot: Failed to get snapshot "
"Load snapshot error: Failed to restore from snapshot: Failed to get snapshot "
"state from file: Failed to open snapshot file: Permission denied (os error 13)"
)
with pytest.raises(RuntimeError, match=expected_err):
Expand Down
4 changes: 2 additions & 2 deletions tests/integration_tests/functional/test_uffd.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def test_bad_socket_path(uvm_plain, snapshot):
jailed_vmstate = vm.create_jailed_resource(snapshot.vmstate)

expected_msg = re.escape(
"Load microVM snapshot error: Failed to restore from snapshot: Failed to load guest "
"Load snapshot error: Failed to restore from snapshot: Failed to load guest "
"memory: Error creating guest memory from uffd: Failed to connect to UDS Unix stream: No "
"such file or directory (os error 2)"
)
Expand All @@ -89,7 +89,7 @@ def test_unbinded_socket(uvm_plain, snapshot):
jailed_sock_path = vm.create_jailed_resource(socket_path)

expected_msg = re.escape(
"Load microVM snapshot error: Failed to restore from snapshot: Failed to load guest "
"Load snapshot error: Failed to restore from snapshot: Failed to load guest "
"memory: Error creating guest memory from uffd: Failed to connect to UDS Unix stream: "
"Connection refused (os error 111)"
)
Expand Down

0 comments on commit de95f22

Please sign in to comment.