Skip to content

Commit

Permalink
use cluster admin user when checking upgradability, use default port (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
paulomach authored Sep 12, 2024
1 parent f4c8d83 commit 1b4d923
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/charms/mysql/v0/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def wait_until_mysql_connection(self) -> None:
# Increment this major API version when introducing breaking changes
LIBAPI = 0

LIBPATCH = 71
LIBPATCH = 72

UNIT_TEARDOWN_LOCKNAME = "unit-teardown"
UNIT_ADD_LOCKNAME = "unit-add"
Expand Down Expand Up @@ -2247,8 +2247,9 @@ def get_cluster_members_addresses(self) -> Optional[Iterable[str]]:

def verify_server_upgradable(self, instance: Optional[str] = None) -> None:
"""Wrapper for API check_for_server_upgrade."""
# use cluster admin user to enforce standard port usage
check_command = [
f"shell.connect('{self.instance_def(self.server_config_user, host=instance)}')",
f"shell.connect('{self.instance_def(self.cluster_admin_user, host=instance)}')",
"try:",
" util.check_for_server_upgrade(options={'outputFormat': 'JSON'})",
"except ValueError:", # ValueError is raised for same version check
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -1728,7 +1728,7 @@ def test_set_cluster_primary(self, _run_mysqlsh_script):
def test_verify_server_upgradable(self, _run_mysqlsh_script):
"""Test is_server_upgradable."""
commands = (
"shell.connect('serverconfig:serverconfigpassword@127.0.0.1:33062')",
"shell.connect('clusteradmin:clusteradminpassword@2.3.4.5:3306')",
"try:\n util.check_for_server_upgrade(options={'outputFormat': 'JSON'})",
"except ValueError:",
" if session.run_sql('select @@version').fetch_all()[0][0].split('-')[0] == shell.version.split()[1]:",
Expand All @@ -1752,7 +1752,7 @@ def test_verify_server_upgradable(self, _run_mysqlsh_script):
'"detectedProblems": [] }],'
'"manualChecks": []}'
)
self.mysql.verify_server_upgradable()
self.mysql.verify_server_upgradable("2.3.4.5")
_run_mysqlsh_script.assert_called_with("\n".join(commands))
_run_mysqlsh_script.return_value = (
'{"serverAddress": "10.1.148.145:33060",'
Expand Down

0 comments on commit 1b4d923

Please sign in to comment.