mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2026-05-09 18:25:36 +02:00
MariaDB 11.8/12.1: tests, downgrade note, doc
- test/upgrader_mariadb_version_test.sh: upgrader arg parsing and repo URL - test/test_upgrade_mariadb_version.py: mariadb_version file read, downgrade - test/run_mariadb_tests.sh: run all MariaDB version tests - cyberpanel_upgrade.sh: prompt mentions re-run for downgrade (11.8/12.1) - to-do/MARIADB-11.8-LTS-UPGRADE.md: 11.8/12.1 choice, downgrade, test commands
This commit is contained in:
@@ -1671,9 +1671,9 @@ if [[ "$*" != *"--branch "* ]] && [[ "$*" != *"-b "* ]] ; then
|
||||
Pre_Upgrade_Branch_Input
|
||||
fi
|
||||
|
||||
# Prompt for MariaDB version if not set via --mariadb-version (default 11.8)
|
||||
# Prompt for MariaDB version if not set via --mariadb-version (default 11.8). Downgrade supported (e.g. re-run with --mariadb-version 11.8).
|
||||
if [[ "$*" != *"--mariadb-version "* ]]; then
|
||||
echo -e "\nMariaDB version: use \e[31m11.8\e[39m LTS (default) or \e[31m12.1\e[39m."
|
||||
echo -e "\nMariaDB version: \e[31m11.8\e[39m LTS (default) or \e[31m12.1\e[39m. You can switch later by re-running with --mariadb-version 11.8 or 12.1."
|
||||
echo -e "Press Enter for 11.8 LTS, or type \e[31m12.1\e[39m and Enter for 12.1 (5 sec timeout): "
|
||||
read -r -t 5 Tmp_MariaDB_Ver || true
|
||||
if [[ "$Tmp_MariaDB_Ver" = "12.1" ]]; then
|
||||
|
||||
14
test/run_mariadb_tests.sh
Executable file
14
test/run_mariadb_tests.sh
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
# Run all MariaDB version tests (upgrader + upgrade.py logic).
|
||||
# From repo root: ./test/run_mariadb_tests.sh
|
||||
set -e
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||
cd "$REPO_ROOT"
|
||||
echo "=== Upgrader MariaDB version tests ==="
|
||||
./test/upgrader_mariadb_version_test.sh
|
||||
echo ""
|
||||
echo "=== Upgrade.py mariadb_version read tests ==="
|
||||
python3 test/test_upgrade_mariadb_version.py
|
||||
echo ""
|
||||
echo "=== All MariaDB version tests passed (11.8, 12.1, downgrade). ==="
|
||||
112
test/test_upgrade_mariadb_version.py
Normal file
112
test/test_upgrade_mariadb_version.py
Normal file
@@ -0,0 +1,112 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Unit tests for plogical/upgrade.py MariaDB version read from /etc/cyberpanel/mariadb_version.
|
||||
Tests that 11.8 and 12.1 are both accepted and that downgrade (12.1 -> 11.8) is supported.
|
||||
Run from repo root: python3 test/test_upgrade_mariadb_version.py
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
# Logic extracted from Upgrade.fix_almalinux9_mariadb() - read mariadb_version file
|
||||
def read_mariadb_version_from_file(filepath):
|
||||
mariadb_ver = "11.8"
|
||||
try:
|
||||
if os.path.isfile(filepath):
|
||||
with open(filepath, "r") as f:
|
||||
raw = f.read().strip()
|
||||
if raw in ("11.8", "12.1"):
|
||||
mariadb_ver = raw
|
||||
except Exception:
|
||||
pass
|
||||
return mariadb_ver
|
||||
|
||||
|
||||
def test_default_no_file():
|
||||
with tempfile.TemporaryDirectory() as d:
|
||||
path = os.path.join(d, "nonexistent")
|
||||
assert read_mariadb_version_from_file(path) == "11.8"
|
||||
print("OK: default when file missing = 11.8")
|
||||
|
||||
|
||||
def test_11_8():
|
||||
with tempfile.NamedTemporaryFile(mode="w", delete=False, suffix=".tmp") as f:
|
||||
f.write("11.8")
|
||||
path = f.name
|
||||
try:
|
||||
assert read_mariadb_version_from_file(path) == "11.8"
|
||||
print("OK: file 11.8 -> 11.8")
|
||||
finally:
|
||||
os.unlink(path)
|
||||
|
||||
|
||||
def test_12_1():
|
||||
with tempfile.NamedTemporaryFile(mode="w", delete=False, suffix=".tmp") as f:
|
||||
f.write("12.1")
|
||||
path = f.name
|
||||
try:
|
||||
assert read_mariadb_version_from_file(path) == "12.1"
|
||||
print("OK: file 12.1 -> 12.1")
|
||||
finally:
|
||||
os.unlink(path)
|
||||
|
||||
|
||||
def test_downgrade_simulation():
|
||||
# Simulate writing 12.1 then 11.8 (downgrade) - both must work
|
||||
with tempfile.NamedTemporaryFile(mode="w", delete=False, suffix=".tmp") as f:
|
||||
f.write("12.1")
|
||||
path = f.name
|
||||
try:
|
||||
assert read_mariadb_version_from_file(path) == "12.1"
|
||||
print("OK: downgrade step 1 - 12.1")
|
||||
finally:
|
||||
pass
|
||||
with open(path, "w") as f:
|
||||
f.write("11.8")
|
||||
try:
|
||||
assert read_mariadb_version_from_file(path) == "11.8"
|
||||
print("OK: downgrade step 2 - 11.8 (downgrade supported)")
|
||||
finally:
|
||||
os.unlink(path)
|
||||
|
||||
|
||||
def test_invalid_falls_back():
|
||||
with tempfile.NamedTemporaryFile(mode="w", delete=False, suffix=".tmp") as f:
|
||||
f.write("10.11")
|
||||
path = f.name
|
||||
try:
|
||||
assert read_mariadb_version_from_file(path) == "11.8"
|
||||
print("OK: invalid 10.11 -> 11.8")
|
||||
finally:
|
||||
os.unlink(path)
|
||||
with tempfile.NamedTemporaryFile(mode="w", delete=False, suffix=".tmp") as f:
|
||||
f.write("13")
|
||||
path = f.name
|
||||
try:
|
||||
assert read_mariadb_version_from_file(path) == "11.8"
|
||||
print("OK: invalid 13 -> 11.8")
|
||||
finally:
|
||||
os.unlink(path)
|
||||
|
||||
|
||||
def test_repo_command_format():
|
||||
mariadb_ver = "12.1"
|
||||
command = "curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | bash -s -- --mariadb-server-version='%s'" % mariadb_ver
|
||||
assert "12.1" in command
|
||||
assert "--mariadb-server-version='12.1'" in command
|
||||
print("OK: repo command includes version 12.1")
|
||||
mariadb_ver = "11.8"
|
||||
command = "curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | bash -s -- --mariadb-server-version='%s'" % mariadb_ver
|
||||
assert "--mariadb-server-version='11.8'" in command
|
||||
print("OK: repo command includes version 11.8")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_default_no_file()
|
||||
test_11_8()
|
||||
test_12_1()
|
||||
test_downgrade_simulation()
|
||||
test_invalid_falls_back()
|
||||
test_repo_command_format()
|
||||
print("\nAll upgrade.py MariaDB version tests passed.")
|
||||
sys.exit(0)
|
||||
105
test/upgrader_mariadb_version_test.sh
Executable file
105
test/upgrader_mariadb_version_test.sh
Executable file
@@ -0,0 +1,105 @@
|
||||
#!/bin/bash
|
||||
# Test script for cyberpanel_upgrade.sh MariaDB version handling (11.8, 12.1, downgrade).
|
||||
# Run from repo root: ./test/upgrader_mariadb_version_test.sh
|
||||
# Does not require root or a real CyberPanel install.
|
||||
|
||||
set -e
|
||||
FAILED=0
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||
UPGRADE_SCRIPT="$REPO_ROOT/cyberpanel_upgrade.sh"
|
||||
|
||||
# Default (same as cyberpanel_upgrade.sh)
|
||||
MARIADB_VER="11.8"
|
||||
|
||||
# Parse --mariadb-version from "$@" (same logic as Check_Argument in cyberpanel_upgrade.sh)
|
||||
parse_mariadb_version() {
|
||||
if [[ "$*" = *"--mariadb-version "* ]]; then
|
||||
MARIADB_VER=$(echo "$*" | sed -n 's/.*--mariadb-version \([^ ]*\).*/\1/p' | head -1)
|
||||
MARIADB_VER="${MARIADB_VER:-11.8}"
|
||||
fi
|
||||
if [[ "$MARIADB_VER" != "11.8" ]] && [[ "$MARIADB_VER" != "12.1" ]]; then
|
||||
MARIADB_VER="11.8"
|
||||
fi
|
||||
}
|
||||
|
||||
assert_equals() {
|
||||
local expected="$1"
|
||||
local actual="$2"
|
||||
local name="${3:-value}"
|
||||
if [[ "$actual" != "$expected" ]]; then
|
||||
echo "FAIL: $name expected '\''$expected'\'' got '\''$actual'\''"
|
||||
FAILED=1
|
||||
else
|
||||
echo "OK: $name = $actual"
|
||||
fi
|
||||
}
|
||||
|
||||
echo "=== 1. Default (no --mariadb-version) ==="
|
||||
MARIADB_VER="11.8"
|
||||
parse_mariadb_version ""
|
||||
assert_equals "11.8" "$MARIADB_VER" "default"
|
||||
|
||||
echo ""
|
||||
echo "=== 2. Explicit 11.8 ==="
|
||||
MARIADB_VER="11.8"
|
||||
parse_mariadb_version "--mariadb-version 11.8"
|
||||
assert_equals "11.8" "$MARIADB_VER" "--mariadb-version 11.8"
|
||||
|
||||
echo ""
|
||||
echo "=== 3. Explicit 12.1 ==="
|
||||
MARIADB_VER="11.8"
|
||||
parse_mariadb_version "--mariadb-version 12.1"
|
||||
assert_equals "12.1" "$MARIADB_VER" "--mariadb-version 12.1"
|
||||
|
||||
echo ""
|
||||
echo "=== 4. Downgrade: 12.1 then 11.8 (both must be accepted) ==="
|
||||
MARIADB_VER="11.8"
|
||||
parse_mariadb_version "--mariadb-version 12.1"
|
||||
assert_equals "12.1" "$MARIADB_VER" "first 12.1"
|
||||
parse_mariadb_version "--mariadb-version 11.8"
|
||||
assert_equals "11.8" "$MARIADB_VER" "then 11.8 (downgrade)"
|
||||
|
||||
echo ""
|
||||
echo "=== 5. Invalid value falls back to 11.8 ==="
|
||||
MARIADB_VER="11.8"
|
||||
parse_mariadb_version "--mariadb-version 10.11"
|
||||
assert_equals "11.8" "$MARIADB_VER" "invalid 10.11 -> 11.8"
|
||||
parse_mariadb_version "--mariadb-version 13"
|
||||
assert_equals "11.8" "$MARIADB_VER" "invalid 13 -> 11.8"
|
||||
|
||||
echo ""
|
||||
echo "=== 6. With -b and --mariadb-version ==="
|
||||
MARIADB_VER="11.8"
|
||||
parse_mariadb_version "-b v2.5.5-dev --mariadb-version 12.1"
|
||||
assert_equals "12.1" "$MARIADB_VER" "-b v2.5.5-dev --mariadb-version 12.1"
|
||||
|
||||
echo ""
|
||||
echo "=== 7. MariaDB.repo baseurl uses MARIADB_VER ==="
|
||||
MARIADB_VER="12.1"
|
||||
MARIADB_REPO="rhel9-amd64"
|
||||
baseurl="https://mirror.mariadb.org/yum/$MARIADB_VER/$MARIADB_REPO"
|
||||
assert_equals "https://mirror.mariadb.org/yum/12.1/rhel9-amd64" "$baseurl" "baseurl 12.1"
|
||||
MARIADB_VER="11.8"
|
||||
baseurl="https://mirror.mariadb.org/yum/$MARIADB_VER/$MARIADB_REPO"
|
||||
assert_equals "https://mirror.mariadb.org/yum/11.8/rhel9-amd64" "$baseurl" "baseurl 11.8"
|
||||
|
||||
echo ""
|
||||
echo "=== 8. Script contains required logic ==="
|
||||
if [[ ! -f "$UPGRADE_SCRIPT" ]]; then
|
||||
echo "FAIL: $UPGRADE_SCRIPT not found"
|
||||
FAILED=1
|
||||
else
|
||||
echo "OK: upgrade script exists"
|
||||
grep -q 'MARIADB_VER="11.8"' "$UPGRADE_SCRIPT" && echo "OK: default MARIADB_VER" || { echo "FAIL: default MARIADB_VER"; FAILED=1; }
|
||||
grep -q '/etc/cyberpanel/mariadb_version' "$UPGRADE_SCRIPT" && echo "OK: mariadb_version file" || { echo "FAIL: mariadb_version file"; FAILED=1; }
|
||||
fi
|
||||
|
||||
echo ""
|
||||
if [[ $FAILED -eq 0 ]]; then
|
||||
echo "All upgrader MariaDB version tests passed."
|
||||
exit 0
|
||||
else
|
||||
echo "Some tests failed."
|
||||
exit 1
|
||||
fi
|
||||
@@ -1,20 +1,34 @@
|
||||
# MariaDB 11.8 LTS (Long Term Service)
|
||||
# MariaDB 11.8 LTS and 12.1
|
||||
|
||||
## Summary
|
||||
|
||||
CyberPanel install and upgrade now target **MariaDB 11.8 LTS** instead of 10.11 or 12.1.
|
||||
CyberPanel install and upgrade support **MariaDB 11.8 LTS** (default) or **12.1**. User can choose at install/upgrade time; **downgrade is supported** (e.g. 12.1 → 11.8 by re-running upgrader with `--mariadb-version 11.8`).
|
||||
|
||||
- **New installs:** Use `mariadb_repo_setup --mariadb-server-version=11.8` and install from official MariaDB 11.8 repo.
|
||||
- **Upgrades:** Same; AlmaLinux 9 fix sets up 11.8 repo and installs MariaDB 11.8.
|
||||
- **cyberpanel_upgrade.sh:** Writes `/etc/yum.repos.d/MariaDB.repo` with `baseurl = https://mirror.mariadb.org/yum/11.8/$MARIADB_REPO`.
|
||||
- **UI (Database upgrade):** `databases/databaseManager.py` offers versions 10.6, 10.11, **11.8** for manual upgrade.
|
||||
- **mysqlUtilities.UpgradeMariaDB:** Still accepts version argument; repo baseurl uses `versionToInstall` (e.g. 11.8).
|
||||
- **New installs:** `--mariadb-version 11.8|12.1` (default 11.8); `install.py` and `venvsetup.sh` pass it through.
|
||||
- **Upgrades:** `cyberpanel_upgrade.sh --mariadb-version 11.8|12.1` or interactive prompt; writes `/etc/cyberpanel/mariadb_version` for `upgrade.py`.
|
||||
- **Downgrade:** Run upgrader again with the desired version (e.g. `--mariadb-version 11.8` to switch from 12.1 to 11.8). Repo and packages will target the chosen version.
|
||||
- **cyberpanel_upgrade.sh:** Uses `MARIADB_VER` (default 11.8) in `MariaDB.repo` baseurl and writes `/etc/cyberpanel/mariadb_version`.
|
||||
- **plogical/upgrade.py:** `fix_almalinux9_mariadb()` reads `/etc/cyberpanel/mariadb_version` (default 11.8) and runs `mariadb_repo_setup` with that version.
|
||||
- **UI (Database upgrade):** `databases/databaseManager.py` offers 10.6, 10.11, **11.8** for manual upgrade.
|
||||
- **mysqlUtilities.UpgradeMariaDB:** Repo baseurl uses `versionToInstall` (e.g. 11.8).
|
||||
|
||||
## Testing
|
||||
|
||||
From repo root:
|
||||
|
||||
- Shell (upgrader argument parsing and repo URL logic):
|
||||
`./test/upgrader_mariadb_version_test.sh`
|
||||
- Python (mariadb_version file read and downgrade):
|
||||
`python3 test/test_upgrade_mariadb_version.py`
|
||||
|
||||
Both 11.8 and 12.1 paths are tested; downgrade (12.1 → 11.8) is explicitly verified.
|
||||
|
||||
## References
|
||||
|
||||
- `cyberpanel_upgrade.sh`: MariaDB.repo 11.8
|
||||
- `plogical/upgrade.py`: mariadb_repo_setup 11.8, fix_almalinux9_comprehensive()
|
||||
- `install/install.py`: mariadb_repo_setup 11.8, _attemptMariaDBUpgrade(), installMySQL(), disableMariaDB12RepositoryIfNeeded()
|
||||
- `cyberpanel_upgrade.sh`: MARIADB_VER, --mariadb-version, /etc/cyberpanel/mariadb_version
|
||||
- `plogical/upgrade.py`: fix_almalinux9_mariadb() reads mariadb_version file
|
||||
- `install/install.py`: --mariadb-version, preFlightsChecks.mariadb_version
|
||||
- `install/venvsetup.sh`: MARIADB_VER prompt, --mariadb-version to install.py
|
||||
- `install/universal_os_fixes.py`: setup_mariadb_repository() 11.8
|
||||
- `databases/databaseManager.py`: mysqlversions 10.6, 10.11, 11.8
|
||||
- `plogical/mysqlUtilities.py`: UpgradeMariaDB() baseurl for RHEL
|
||||
|
||||
Reference in New Issue
Block a user