Fix MySQL diagnostic script quoting
This commit is contained in:
@@ -22,7 +22,7 @@ from deploy_tool.installer import (
|
||||
NODE_DIST_BASE,
|
||||
build_mysql_installer_command,
|
||||
build_mysql_server_install_command,
|
||||
build_mysql_service_start_command,
|
||||
build_mysql_service_start_script,
|
||||
configure_mysql_weak_password_policy,
|
||||
default_mysql_install_log_path,
|
||||
default_mysql_server_install_log_path,
|
||||
@@ -31,6 +31,7 @@ from deploy_tool.installer import (
|
||||
find_mysql_error_log,
|
||||
mysql_service_failure_detail,
|
||||
query_mysql_service_state,
|
||||
run_mysql_service_start_diagnostic,
|
||||
run_elevated_command_with_log,
|
||||
TOMCAT_VERSION,
|
||||
install_maven,
|
||||
@@ -462,10 +463,7 @@ class InstallerTests(unittest.TestCase):
|
||||
self.assertTrue(any("已启动" in message for message in messages))
|
||||
|
||||
def test_builds_privileged_mysql_service_start_diagnostic(self):
|
||||
command = build_mysql_service_start_command()
|
||||
|
||||
self.assertEqual(command[0], "powershell.exe")
|
||||
script = command[-1]
|
||||
script = build_mysql_service_start_script()
|
||||
self.assertIn("Start-Service -Name $name", script)
|
||||
self.assertIn("Get-CimInstance Win32_Service", script)
|
||||
self.assertIn("my.ini", script)
|
||||
@@ -479,6 +477,28 @@ class InstallerTests(unittest.TestCase):
|
||||
Path(r"C:\Users\tester\AppData\Local") / "AutoDeploy" / "logs" / "mysql-service-start.log",
|
||||
)
|
||||
|
||||
def test_runs_mysql_service_diagnostic_from_script_file(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
log_path = Path(tmp) / "mysql-service-start.log"
|
||||
|
||||
def inspect_command(command, passed_log, show_window=True):
|
||||
self.assertEqual(command[0], "powershell.exe")
|
||||
self.assertEqual(command[-2], "-File")
|
||||
script_path = Path(command[-1])
|
||||
self.assertTrue(script_path.exists())
|
||||
self.assertIn("Name='\"+$name+\"'", script_path.read_text(encoding="utf-8-sig"))
|
||||
self.assertEqual(passed_log, log_path)
|
||||
self.assertFalse(show_window)
|
||||
return 1
|
||||
|
||||
with patch(
|
||||
"deploy_tool.installer.run_elevated_command_with_log",
|
||||
side_effect=inspect_command,
|
||||
):
|
||||
exit_code = run_mysql_service_start_diagnostic("MySQL80", log_path)
|
||||
|
||||
self.assertEqual(exit_code, 1)
|
||||
|
||||
def test_reports_mysql_error_log_when_service_stops_after_start(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
program_data = Path(tmp)
|
||||
|
||||
Reference in New Issue
Block a user