summaryrefslogtreecommitdiff
path: root/smoketest/scripts/cli/test_load-balancing_haproxy.py
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2025-10-27 18:10:02 +0100
committerGitHub <noreply@github.com>2025-10-27 18:10:02 +0100
commitc4ead67fd111aa44314e604df1c4ec475fcedd45 (patch)
tree2c0c074d7493202bf4edc5289a574fb528bae1c5 /smoketest/scripts/cli/test_load-balancing_haproxy.py
parentd316d808669994c4528b67a651fe0559a4b3dc77 (diff)
parentbba498d2cf6d897789641ca093c2d3b9daff8472 (diff)
downloadvyos-1x-c4ead67fd111aa44314e604df1c4ec475fcedd45.tar.gz
vyos-1x-c4ead67fd111aa44314e604df1c4ec475fcedd45.zip
Merge pull request #4806 from alexandr-san4ez/T7906-current
haproxy: T7906: Probing of a port other than the one to which normal traffic is sent
Diffstat (limited to 'smoketest/scripts/cli/test_load-balancing_haproxy.py')
-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 8efa259f5..8223c6f60 100755
--- a/smoketest/scripts/cli/test_load-balancing_haproxy.py
+++ b/smoketest/scripts/cli/test_load-balancing_haproxy.py
@@ -488,6 +488,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()