新增NAS一键打包部署脚本及Docker部署方案
This commit is contained in:
81
tests/deploy/test_deploy_to_nas.py
Normal file
81
tests/deploy/test_deploy_to_nas.py
Normal file
@@ -0,0 +1,81 @@
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[2]
|
||||
DEPLOY_PS1 = REPO_ROOT / "deploy" / "deploy.ps1"
|
||||
DEPLOY_BAT = REPO_ROOT / "deploy" / "deploy-to-nas.bat"
|
||||
DOCKER_COMPOSE = REPO_ROOT / "docker-compose.yml"
|
||||
|
||||
|
||||
def run_powershell(*args):
|
||||
return subprocess.run(
|
||||
[
|
||||
"powershell",
|
||||
"-NoProfile",
|
||||
"-ExecutionPolicy",
|
||||
"Bypass",
|
||||
"-File",
|
||||
str(DEPLOY_PS1),
|
||||
*args,
|
||||
],
|
||||
cwd=REPO_ROOT,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
|
||||
def run_bat(*args):
|
||||
return subprocess.run(
|
||||
[
|
||||
"cmd.exe",
|
||||
"/c",
|
||||
str(DEPLOY_BAT),
|
||||
*args,
|
||||
],
|
||||
cwd=REPO_ROOT,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
|
||||
def test_deploy_ps1_dry_run_prints_target():
|
||||
result = run_powershell("-DryRun")
|
||||
output = f"{result.stdout}\n{result.stderr}"
|
||||
|
||||
assert result.returncode == 0
|
||||
assert "DryRun" in output
|
||||
assert "116.62.17.81" in output
|
||||
assert "9444" in output
|
||||
assert "/volume1/webapp/ccdi" in output
|
||||
|
||||
|
||||
def test_bat_dry_run_uses_default_nas_target():
|
||||
result = run_bat("--dry-run")
|
||||
output = f"{result.stdout}\n{result.stderr}"
|
||||
|
||||
assert result.returncode == 0
|
||||
assert "DryRun" in output
|
||||
assert "116.62.17.81" in output
|
||||
assert "9444" in output
|
||||
assert "/volume1/webapp/ccdi" in output
|
||||
|
||||
|
||||
def test_bat_dry_run_accepts_override_arguments():
|
||||
result = run_bat("1.2.3.4", "9000", "demo", "demoPwd", "/demo/path", "--dry-run")
|
||||
output = f"{result.stdout}\n{result.stderr}"
|
||||
|
||||
assert result.returncode == 0
|
||||
assert "1.2.3.4" in output
|
||||
assert "9000" in output
|
||||
assert "demo" in output
|
||||
assert "/demo/path" in output
|
||||
|
||||
|
||||
def test_compose_exposes_lsfx_mock_port_via_backend_namespace():
|
||||
compose_text = DOCKER_COMPOSE.read_text(encoding="utf-8")
|
||||
|
||||
assert '${LSFX_MOCK_PORT:-62320}:8000' in compose_text
|
||||
assert 'network_mode: "service:backend"' in compose_text
|
||||
Reference in New Issue
Block a user