From de95f2241ff62f005342b45e369c0770c8bbe8d0 Mon Sep 17 00:00:00 2001 From: Egor Lazarchuk Date: Mon, 11 Dec 2023 22:14:57 +0000 Subject: [PATCH] refactor(errors): updated integration tests with new errors Updated integration tests with new errors Signed-off-by: Egor Lazarchuk --- tests/integration_tests/functional/test_api.py | 9 ++++----- tests/integration_tests/functional/test_logging.py | 4 +--- .../integration_tests/functional/test_snapshot_basic.py | 6 +++--- tests/integration_tests/functional/test_uffd.py | 4 ++-- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/tests/integration_tests/functional/test_api.py b/tests/integration_tests/functional/test_api.py index b4edc1e7223..1f398da1cd8 100644 --- a/tests/integration_tests/functional/test_api.py +++ b/tests/integration_tests/functional/test_api.py @@ -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. @@ -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() @@ -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) diff --git a/tests/integration_tests/functional/test_logging.py b/tests/integration_tests/functional/test_logging.py index d3520a51424..37d0f855c2d 100644 --- a/tests/integration_tests/functional/test_logging.py +++ b/tests/integration_tests/functional/test_logging.py @@ -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( diff --git a/tests/integration_tests/functional/test_snapshot_basic.py b/tests/integration_tests/functional/test_snapshot_basic.py index 80a7f675673..3e8553d51e1 100644 --- a/tests/integration_tests/functional/test_snapshot_basic.py +++ b/tests/integration_tests/functional/test_snapshot_basic.py @@ -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." ) @@ -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)" ) @@ -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): diff --git a/tests/integration_tests/functional/test_uffd.py b/tests/integration_tests/functional/test_uffd.py index 9531d68aab7..6e7e96552a8 100644 --- a/tests/integration_tests/functional/test_uffd.py +++ b/tests/integration_tests/functional/test_uffd.py @@ -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)" ) @@ -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)" )