Show MySQL installation progress
This commit is contained in:
@@ -17,6 +17,7 @@ from deploy_tool.installer import (
|
||||
MYSQL_INSTALLER_URL,
|
||||
build_mysql_installer_command,
|
||||
configure_mysql_weak_password_policy,
|
||||
default_mysql_install_log_path,
|
||||
TOMCAT_VERSION,
|
||||
install_maven,
|
||||
install_mysql,
|
||||
@@ -111,9 +112,13 @@ class InstallerTests(unittest.TestCase):
|
||||
self.assertIn("--disable-interactivity", command)
|
||||
|
||||
def test_builds_unattended_mysql_msi_install_command(self):
|
||||
command = build_mysql_installer_command(Path("mysql-installer.msi"))
|
||||
command = build_mysql_installer_command(Path("mysql-installer.msi"), Path("mysql-install.log"))
|
||||
|
||||
self.assertEqual(command[0:3], ["msiexec.exe", "/i", "mysql-installer.msi"])
|
||||
self.assertIn("/passive", command)
|
||||
self.assertNotIn("/qn", command)
|
||||
self.assertIn("/L*V", command)
|
||||
self.assertIn("mysql-install.log", command)
|
||||
self.assertEqual(MYSQL_VERSION, "8.0.43")
|
||||
self.assertIn("root_passwd=123456", command[-1])
|
||||
self.assertIn("open_win_firewall=false", command[-1])
|
||||
@@ -137,19 +142,39 @@ class InstallerTests(unittest.TestCase):
|
||||
self.assertTrue(Path(command[2]).exists())
|
||||
return 0
|
||||
|
||||
with (
|
||||
patch("deploy_tool.installer.MYSQL_INSTALLER_SHA256", checksum),
|
||||
patch("deploy_tool.installer.wait_for_mysql_executable", return_value=Path("mysql.exe")),
|
||||
patch("deploy_tool.installer.configure_mysql_weak_password_policy") as configure,
|
||||
):
|
||||
messages = []
|
||||
executable = install_mysql(messages.append, opener=opener, elevated_runner=elevated_runner)
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
install_log = Path(tmp) / "logs" / "mysql-install.log"
|
||||
with (
|
||||
patch("deploy_tool.installer.MYSQL_INSTALLER_SHA256", checksum),
|
||||
patch("deploy_tool.installer.wait_for_mysql_executable", return_value=Path("mysql.exe")),
|
||||
patch("deploy_tool.installer.configure_mysql_weak_password_policy") as configure,
|
||||
):
|
||||
messages = []
|
||||
executable = install_mysql(
|
||||
messages.append,
|
||||
opener=opener,
|
||||
elevated_runner=elevated_runner,
|
||||
log_path=install_log,
|
||||
)
|
||||
|
||||
self.assertEqual(executable, Path("mysql.exe"))
|
||||
self.assertEqual(commands[0][0], "msiexec.exe")
|
||||
self.assertIn("/passive", commands[0])
|
||||
self.assertIn(str(install_log), commands[0])
|
||||
self.assertTrue(any("校验通过" in message for message in messages))
|
||||
self.assertTrue(any("进度窗口" in message for message in messages))
|
||||
self.assertTrue(any(str(install_log) in message for message in messages))
|
||||
configure.assert_called_once()
|
||||
|
||||
def test_uses_persistent_mysql_install_log_location(self):
|
||||
with patch.dict("os.environ", {"LOCALAPPDATA": r"C:\Users\tester\AppData\Local"}):
|
||||
log_path = default_mysql_install_log_path()
|
||||
|
||||
self.assertEqual(
|
||||
log_path,
|
||||
Path(r"C:\Users\tester\AppData\Local") / "AutoDeploy" / "logs" / "mysql-install.log",
|
||||
)
|
||||
|
||||
def test_windows_elevation_dependency_is_imported(self):
|
||||
self.assertIs(installer_module.ctypes, ctypes)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user