Keep cron host out of golang release

This commit is contained in:
zhx 2026-05-21 11:51:09 +08:00
parent 3c6d935836
commit 342e3b96ac
2 changed files with 11 additions and 17 deletions

View File

@ -183,14 +183,7 @@
"group": "cron", "group": "cron",
"instanceId": "ins-nt6bsay0", "instanceId": "ins-nt6bsay0",
"region": "ap-singapore", "region": "ap-singapore",
"services": [ "services": []
{
"name": "golang",
"kind": "golang",
"port": 2900,
"path": "/health"
}
]
} }
] ]
} }

View File

@ -3,22 +3,23 @@ from __future__ import annotations
import unittest import unittest
from unittest.mock import patch from unittest.mock import patch
from core.config import HARBOR_PROJECT, HARBOR_REGISTRY from core.config import HARBOR_PROJECT, HARBOR_REGISTRY, load_hosts
from monitors.yumi.service_release import build_update_targets_payload, deploy_updated_services_payload from monitors.yumi.service_release import build_update_targets_payload, deploy_updated_services_payload
from monitors.yumi.service_ops import service_records_by_name from monitors.yumi.service_ops import service_records_by_name
class ServiceReleaseTargetsTests(unittest.TestCase): class ServiceReleaseTargetsTests(unittest.TestCase):
def test_runtime_topology_includes_singapore_cron_golang(self) -> None: def test_runtime_topology_keeps_singapore_cron_out_of_golang_release(self) -> None:
hosts = load_hosts()
cron_hosts = [host for host in hosts if host["host"] == "cron-sg-1"]
records = service_records_by_name().get("golang") or [] records = service_records_by_name().get("golang") or []
cron_records = [record for record in records if record["host"] == "cron-sg-1"]
self.assertEqual(len(cron_records), 1) self.assertEqual(len(cron_hosts), 1)
self.assertEqual(cron_records[0]["ip"], "10.3.1.14") self.assertEqual(cron_hosts[0]["ip"], "10.3.1.14")
self.assertEqual(cron_records[0]["instanceId"], "ins-nt6bsay0") self.assertEqual(cron_hosts[0]["instanceId"], "ins-nt6bsay0")
self.assertEqual(cron_records[0]["kind"], "golang") self.assertEqual(cron_hosts[0]["group"], "cron")
self.assertEqual(cron_records[0]["port"], 2900) self.assertEqual(cron_hosts[0]["services"], [])
self.assertEqual(cron_records[0]["path"], "/health") self.assertFalse(any(record["host"] == "cron-sg-1" for record in records))
@patch("monitors.yumi.service_release.gateway_clb_configuration_error", return_value="gateway CLB protection requires .env") @patch("monitors.yumi.service_release.gateway_clb_configuration_error", return_value="gateway CLB protection requires .env")
@patch("monitors.yumi.service_release.frontend_release_enabled", return_value=False) @patch("monitors.yumi.service_release.frontend_release_enabled", return_value=False)