diff --git a/subiquity/server/controllers/filesystem.py b/subiquity/server/controllers/filesystem.py index a9cc78bea..5ec441303 100644 --- a/subiquity/server/controllers/filesystem.py +++ b/subiquity/server/controllers/filesystem.py @@ -1657,5 +1657,4 @@ async def _pre_shutdown(self): ) else: await self.app.command_runner.run(["umount", "--recursive", "/target"]) - if len(self.model._all(type="zpool")) > 0: - await self.app.command_runner.run(["zpool", "export", "-a"]) + await self.app.command_runner.run(["zpool", "export", "-a"]) diff --git a/subiquity/server/controllers/tests/test_filesystem.py b/subiquity/server/controllers/tests/test_filesystem.py index 859f33a08..c15e3f242 100644 --- a/subiquity/server/controllers/tests/test_filesystem.py +++ b/subiquity/server/controllers/tests/test_filesystem.py @@ -361,9 +361,10 @@ async def test__pre_shutdown_install_started(self): [ mock.call(["mountpoint", "/target"]), mock.call(["umount", "--recursive", "/target"]), + mock.call(["zpool", "export", "-a"]), ] ) - self.assertEqual(len(mock_run.mock_calls), 2) + self.assertEqual(3, mock_run.call_count) async def test__pre_shutdown_install_not_started(self): async def fake_run(cmd, **kwargs): @@ -372,10 +373,15 @@ async def fake_run(cmd, **kwargs): self.fsc.reset_partition_only = False run = mock.patch.object(self.app.command_runner, "run", side_effect=fake_run) - _all = mock.patch.object(self.fsc.model, "_all") - with run as mock_run, _all: + with run as mock_run: await self.fsc._pre_shutdown() - mock_run.assert_called_once_with(["mountpoint", "/target"]) + mock_run.assert_has_calls( + [ + mock.call(["mountpoint", "/target"]), + mock.call(["zpool", "export", "-a"]), + ] + ) + self.assertEqual(2, mock_run.call_count) async def test_examine_systems(self): # In LP: #2037723 and other similar reports, the user selects the