Install MySQL from official archive
This commit is contained in:
@@ -11,9 +11,13 @@ from deploy_tool.installer import (
|
||||
MAVEN_ARCHIVE_NAME,
|
||||
MYSQL_VERSION,
|
||||
MYSQL_ROOT_PASSWORD,
|
||||
MYSQL_INSTALLER_SHA256,
|
||||
MYSQL_INSTALLER_URL,
|
||||
build_mysql_installer_command,
|
||||
configure_mysql_weak_password_policy,
|
||||
TOMCAT_VERSION,
|
||||
install_maven,
|
||||
install_mysql,
|
||||
install_tomcat,
|
||||
build_install_command,
|
||||
explain_install_failure,
|
||||
@@ -104,18 +108,45 @@ class InstallerTests(unittest.TestCase):
|
||||
self.assertIn("--accept-package-agreements", command)
|
||||
self.assertIn("--disable-interactivity", command)
|
||||
|
||||
def test_builds_unattended_mysql_winget_install_command(self):
|
||||
command = build_install_command("MySQL")
|
||||
def test_builds_unattended_mysql_msi_install_command(self):
|
||||
command = build_mysql_installer_command(Path("mysql-installer.msi"))
|
||||
|
||||
self.assertEqual(command[0:5], ["winget", "install", "--exact", "--id", "Oracle.MySQL"])
|
||||
self.assertEqual(command[command.index("--version") + 1], MYSQL_VERSION)
|
||||
self.assertEqual(command[0:3], ["msiexec.exe", "/i", "mysql-installer.msi"])
|
||||
self.assertEqual(MYSQL_VERSION, "8.0.43")
|
||||
override = command[command.index("--override") + 1]
|
||||
self.assertIn("root_passwd=123456", override)
|
||||
self.assertIn("open_win_firewall=false", override)
|
||||
self.assertIn("--accept-source-agreements", command)
|
||||
self.assertIn("--accept-package-agreements", command)
|
||||
self.assertIn("--disable-interactivity", command)
|
||||
self.assertIn("root_passwd=123456", command[-1])
|
||||
self.assertIn("open_win_firewall=false", command[-1])
|
||||
self.assertEqual(MYSQL_INSTALLER_SHA256, "F60502EB1EE10A9C1D0A26706A627D224DFAE466D82EF3EB9D76A8A718DB9D80")
|
||||
self.assertIn("downloads.mysql.com/archives/", MYSQL_INSTALLER_URL)
|
||||
|
||||
def test_mysql_is_not_installed_from_stale_winget_manifest(self):
|
||||
with self.assertRaises(ValueError):
|
||||
build_install_command("MySQL")
|
||||
|
||||
def test_installs_mysql_from_verified_official_archive(self):
|
||||
installer_bytes = b"verified-mysql-installer"
|
||||
checksum = hashlib.sha256(installer_bytes).hexdigest()
|
||||
commands = []
|
||||
|
||||
def opener(_url, timeout):
|
||||
return io.BytesIO(installer_bytes)
|
||||
|
||||
def elevated_runner(command):
|
||||
commands.append(command)
|
||||
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)
|
||||
|
||||
self.assertEqual(executable, Path("mysql.exe"))
|
||||
self.assertEqual(commands[0][0], "msiexec.exe")
|
||||
self.assertTrue(any("校验通过" in message for message in messages))
|
||||
configure.assert_called_once()
|
||||
|
||||
def test_persists_six_character_mysql_password_policy(self):
|
||||
query_result = CompletedProcess(
|
||||
|
||||
Reference in New Issue
Block a user