Skip to content

Commit cc41cb3

Browse files
committed
Detach the loopback device at the end
Signed-off-by: Kazuyoshi Kato <[email protected]>
1 parent 7271309 commit cc41cb3

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

tests/integration_tests/functional/test_drives.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,17 @@ def test_rescan_dev(test_microvm_with_ssh, network_config):
9595
losetup_result = run(losetup, stdout=PIPE, check=True)
9696
loopback_device = losetup_result.stdout.decode('utf-8').rstrip()
9797

98-
response = test_microvm.drive.patch(
99-
drive_id='scratch',
100-
path_on_host=test_microvm.create_jailed_resource(loopback_device),
101-
)
102-
assert test_microvm.api_session.is_status_no_content(response.status_code)
98+
try:
99+
response = test_microvm.drive.patch(
100+
drive_id='scratch',
101+
path_on_host=test_microvm.create_jailed_resource(loopback_device),
102+
)
103+
assert test_microvm.api_session.is_status_no_content(response.status_code)
104+
105+
_check_scratch_size(ssh_connection, fs2.size())
106+
finally:
107+
run(['losetup', '-d', loopback_device], check=True)
103108

104-
_check_scratch_size(ssh_connection, fs2.size())
105109

106110

107111
def test_non_partuuid_boot(test_microvm_with_ssh, network_config):

0 commit comments

Comments
 (0)