mirror of
https://github.com/dredx/prole.git
synced 2026-09-24 19:34:31 +00:00
- add tools/manage-node.sh for k3s node add/remove automation with inventory reconciliation - include kubectl drain flag compatibility and --ssh-host targeting for uninstall workflows - persist installer cfg/env values and update deploy/database/cfg UI handling - refresh related inventory/network artifacts and expand installer/database test coverage Co-authored-by: Junie <junie@jetbrains.com>
129 lines
3.5 KiB
Python
129 lines
3.5 KiB
Python
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
import knoe.ui.screens.deploy as deploy_mod
|
|
from knoe.ui.screens.deploy import DeployScreenMixin
|
|
|
|
|
|
class _Var:
|
|
def __init__(self, value):
|
|
self._value = value
|
|
|
|
def get(self):
|
|
return self._value
|
|
|
|
|
|
class _PropsApp(DeployScreenMixin):
|
|
def __init__(self):
|
|
self.kerberos_enabled = _Var(True)
|
|
self.kerberos_realm = _Var("PROLE.ORG")
|
|
self.kerberos_user = _Var("administrator")
|
|
self.kerberos_kdc = _Var("10.0.0.3")
|
|
|
|
|
|
def test_generate_prole_properties_dev_writes_local_endpoints(tmp_path, monkeypatch):
|
|
(tmp_path / "prole-tools-app").mkdir(parents=True)
|
|
monkeypatch.chdir(tmp_path)
|
|
|
|
app = _PropsApp()
|
|
app.generate_prole_properties("Dev")
|
|
|
|
content = (tmp_path / "prole-tools-app" / "prole.properties").read_text()
|
|
assert "pf.enabled=true" in content
|
|
assert "svc.1.host=localhost" in content
|
|
assert "svc.7.port=9402" in content
|
|
|
|
|
|
def test_generate_prole_properties_service_and_prod_skip_service_endpoints(
|
|
tmp_path, monkeypatch
|
|
):
|
|
(tmp_path / "prole-tools-app").mkdir(parents=True)
|
|
monkeypatch.chdir(tmp_path)
|
|
|
|
app = _PropsApp()
|
|
for env in ("Service", "Prod"):
|
|
app.generate_prole_properties(env)
|
|
content = (tmp_path / "prole-tools-app" / "prole.properties").read_text()
|
|
assert "pf.enabled=false" in content
|
|
assert "svc.1.host=" not in content
|
|
assert "Service/Prod endpoint mappings are intentionally not persisted here." in content
|
|
|
|
|
|
class _LabelChild:
|
|
def __init__(self):
|
|
self.text = ""
|
|
|
|
def configure(self, **kwargs):
|
|
self.text = kwargs.get("text", self.text)
|
|
|
|
|
|
class _LabelMaster:
|
|
def __init__(self):
|
|
self._children = [object(), _LabelChild()]
|
|
|
|
def winfo_children(self):
|
|
return self._children
|
|
|
|
|
|
class _Label:
|
|
def __init__(self):
|
|
self.master = _LabelMaster()
|
|
|
|
|
|
class _RunDeploymentApp(DeployScreenMixin):
|
|
def __init__(self, selected_env: str):
|
|
self.deploy_environment = _Var(selected_env)
|
|
self.generated_env = ""
|
|
self.deploy_widgets = {
|
|
"Ensure target cluster": {
|
|
"step": {"name": "Ensure target cluster"},
|
|
"label": _Label(),
|
|
}
|
|
}
|
|
|
|
def generate_prole_properties(self, env: str):
|
|
self.generated_env = env
|
|
|
|
def update_deploy_step_status(self, *_args, **_kwargs):
|
|
return None
|
|
|
|
def build_prole_app(self):
|
|
return None
|
|
|
|
def check_docker_running(self):
|
|
return True
|
|
|
|
def ensure_registry_available(self, _env):
|
|
return "registry.local"
|
|
|
|
def create_or_select_cluster(self, _env):
|
|
return None
|
|
|
|
def build_docker_image(self):
|
|
return None
|
|
|
|
def tag_docker_image(self):
|
|
return None
|
|
|
|
def push_docker_image(self):
|
|
return None
|
|
|
|
def import_k3d_image(self, cluster_name=""):
|
|
return None
|
|
|
|
def install_launchagent_port_forwards(self) -> bool:
|
|
return True
|
|
|
|
|
|
def test_run_deployment_normalizes_environment_before_generation(monkeypatch):
|
|
app = _RunDeploymentApp("service")
|
|
monkeypatch.setattr(deploy_mod.messagebox, "showinfo", lambda *_a, **_k: None)
|
|
monkeypatch.setattr(deploy_mod.messagebox, "showerror", lambda *_a, **_k: None)
|
|
|
|
app.run_deployment()
|
|
|
|
assert app.generated_env == "Service"
|
|
ensure_label = app.deploy_widgets["Ensure target cluster"]["label"].master.winfo_children()[1]
|
|
assert "Ensure target cluster (Service)" == ensure_label.text
|