test: Verify Central backend uses configured port, not default

The reconciliation test for Central domain now verifies the HAProxy
backend uses port 15055 (the configured port) and NOT port 5055
(the default). This catches the bug where Reconcile() was called
before SetPort().

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-09 20:59:42 +00:00
parent 995d2cd7da
commit 112f7c7f55

View File

@@ -1,6 +1,7 @@
package v1
import (
"fmt"
"strings"
"testing"
@@ -271,12 +272,14 @@ func TestReconciliation_CentralDomainInHAProxy(t *testing.T) {
}
}
// Central domain goes first (as reconcileNetworking does)
// Central domain goes first (as reconcileNetworking does).
// Uses port 15055 — must match the running port, NOT default 5055.
centralDomain := "central.payne.io"
centralPort := 15055
httpRoutes = append([]haproxy.HTTPRoute{{
Name: "wild-central",
Domain: centralDomain,
Backend: "127.0.0.1:5055",
Backend: fmt.Sprintf("127.0.0.1:%d", centralPort),
}}, httpRoutes...)
cfg := api.haproxy.GenerateWithOpts(nil, nil, haproxy.GenerateOpts{
@@ -291,6 +294,14 @@ func TestReconciliation_CentralDomainInHAProxy(t *testing.T) {
t.Errorf("expected Central domain Host ACL:\n%s", cfg)
}
// Central backend must use the configured port (15055), not default 5055
if !strings.Contains(cfg, "server s0 127.0.0.1:15055") {
t.Errorf("Central backend must use port 15055, not 5055:\n%s", cfg)
}
if strings.Contains(cfg, "server s0 127.0.0.1:5055") {
t.Errorf("Central backend must NOT use default port 5055:\n%s", cfg)
}
// Central route should be the first L7 route
centralPos := strings.Index(cfg, "is_l7_wild_central")
appPos := strings.Index(cfg, "is_l7_my_app_payne_io")