summaryrefslogtreecommitdiff
path: root/smoketest/scripts/cli
diff options
context:
space:
mode:
authorOleksandr Kuchmystyi <o.kuchmystyi@vyos.io>2025-10-21 15:51:31 +0300
committerOleksandr Kuchmystyi <o.kuchmystyi@vyos.io>2025-10-24 16:54:28 +0300
commitbba498d2cf6d897789641ca093c2d3b9daff8472 (patch)
tree3d1a14ee972bb6eb79a8c4d826dcd6ca656163d4 /smoketest/scripts/cli
parentfd8794f36b487ba2102cc50437056e93eb62f7f3 (diff)
downloadvyos-1x-bba498d2cf6d897789641ca093c2d3b9daff8472.tar.gz
vyos-1x-bba498d2cf6d897789641ca093c2d3b9daff8472.zip
haproxy: T7906: Probing of a port other than the one to which normal traffic is sent
Add support for specifying a custom health check port for HAProxy backend servers. This allows health probes to target a dedicated endpoint - such as port 8080 - separate from normal traffic ports (e.g., 80 or 443).
Diffstat (limited to 'smoketest/scripts/cli')
-rwxr-xr-xsmoketest/scripts/cli/test_load-balancing_haproxy.py60
1 files changed, 60 insertions, 0 deletions
diff --git a/smoketest/scripts/cli/test_load-balancing_haproxy.py b/smoketest/scripts/cli/test_load-balancing_haproxy.py
index 2b8672e1f..84e9f21fe 100755
--- a/smoketest/scripts/cli/test_load-balancing_haproxy.py
+++ b/smoketest/scripts/cli/test_load-balancing_haproxy.py
@@ -485,6 +485,66 @@ class TestLoadBalancingReverseProxy(VyOSUnitTestSHIM.TestCase):
config = read_file(HAPROXY_CONF)
self.assertIn(f'option smtpchk', config)
+ def test_reverse_proxy_tcp_health_checks_custom_port(self):
+ # Define variables
+ service = 'my-tcp-api'
+ mode = 'tcp'
+ front_port = '9000'
+ backend = 'bk-01'
+ balance = 'round-robin'
+ servers = [
+ ('srv01', '192.0.2.11', '9001', '9011'),
+ ('srv02', '192.0.2.12', '9002', None),
+ ('srv03', '192.0.2.13', '9003', '9013'),
+ ]
+
+ # Configure frontend
+ self.cli_set(base_path + ['service', service, 'backend', backend])
+ self.cli_set(base_path + ['service', service, 'mode', mode])
+ self.cli_set(base_path + ['service', service, 'port', front_port])
+
+ # Configure backend
+ self.cli_set(base_path + ['backend', backend, 'balance', balance])
+ self.cli_set(base_path + ['backend', backend, 'mode', mode])
+
+ # Configure backend servers
+ for name, addr, port, check_port in servers:
+ base_server_path = base_path + ['backend', backend, 'server', name]
+ self.cli_set(base_server_path + ['address', addr])
+ self.cli_set(base_server_path + ['port', port])
+
+ if check_port:
+ self.cli_set(base_server_path + ['check', 'port', check_port])
+ else:
+ self.cli_set(base_server_path + ['check'])
+
+ # Commit and read config
+ self.cli_commit()
+ config = read_file(HAPROXY_CONF)
+ config_lines = [line.strip() for line in config.splitlines()]
+
+ # Validate Frontend
+ self.assertIn(f'frontend {service}', config)
+ self.assertIn(f'bind [::]:{front_port} v4v6', config)
+ self.assertIn(f'mode {mode}', config)
+ self.assertIn(f'default_backend {backend}', config)
+
+ # Validate Backend
+ self.assertIn(f'backend {backend}', config)
+ self.assertIn('balance roundrobin', config)
+ self.assertIn(f'mode {mode}', config)
+
+ # Validate backend servers
+ for name, addr, port, check_port in servers:
+ with self.subTest(name=name):
+ expected_line = f'server {name} {addr}:{port}'
+ if check_port:
+ expected_line += f' check port {check_port}'
+ else:
+ expected_line += f' check'
+
+ self.assertIn(expected_line, config_lines)
+
def test_reverse_proxy_logging(self):
# Setup base
self.base_config()