diff --git a/machines/src/mysql_vm_helpers.py b/machines/src/mysql_vm_helpers.py index 658b2bc35..3eb4fa4d1 100644 --- a/machines/src/mysql_vm_helpers.py +++ b/machines/src/mysql_vm_helpers.py @@ -339,7 +339,7 @@ def initialise_mysqld(self) -> None: try: self.reset_data_dir() - subprocess.run(bootstrap_command) # noqa: S603 + subprocess.run(bootstrap_command, check=True) # noqa: S603 except subprocess.CalledProcessError: logger.exception("Failed to initialise MySQL data directory") raise MySQLInitialiseMySQLDError from None diff --git a/machines/tests/unit/test_mysqlsh_helpers.py b/machines/tests/unit/test_mysqlsh_helpers.py index e2a7cedf2..a0e2a699b 100644 --- a/machines/tests/unit/test_mysqlsh_helpers.py +++ b/machines/tests/unit/test_mysqlsh_helpers.py @@ -481,12 +481,15 @@ def test_initialise_mysqld(self, _subprocess_run, _reset_data_dir): self.mysql.initialise_mysqld() _reset_data_dir.assert_called_once() - _subprocess_run.assert_called_once_with([ - "/usr/bin/sudo", - "/snap/bin/charmed-mysql.mysqld-initialize", - "--datadir", - "/var/snap/charmed-mysql/common/var/lib/mysql", - ]) + _subprocess_run.assert_called_once_with( + [ + "/usr/bin/sudo", + "/snap/bin/charmed-mysql.mysqld-initialize", + "--datadir", + "/var/snap/charmed-mysql/common/var/lib/mysql", + ], + check=True, + ) @patch("mysql_vm_helpers.MySQL.reset_data_dir") @patch("subprocess.run")