summaryrefslogtreecommitdiff
path: root/smoketest/scripts/cli
diff options
context:
space:
mode:
authorl0crian1 <ryan.claridge13@gmail.com>2025-10-31 18:12:46 -0400
committerl0crian1 <ryan.claridge13@gmail.com>2025-10-31 18:12:46 -0400
commit559dd60a3bdb5866eb81c332d594a8b91529c4a4 (patch)
treece7bb452c162b1737a019eabbc6c6d3c4c8664a6 /smoketest/scripts/cli
parent07936657062ce1fe1b9185b17e9230f20e96e365 (diff)
downloadvyos-1x-559dd60a3bdb5866eb81c332d594a8b91529c4a4.tar.gz
vyos-1x-559dd60a3bdb5866eb81c332d594a8b91529c4a4.zip
wlb: T7977: Fix weight calculation for multiple interfaces
- Fixed issue in T7977 - Added smoketest for 3 or more interfaces in rule - Added wait_for function to utils/misc.py
Diffstat (limited to 'smoketest/scripts/cli')
-rwxr-xr-xsmoketest/scripts/cli/test_load-balancing_wan.py76
1 files changed, 76 insertions, 0 deletions
diff --git a/smoketest/scripts/cli/test_load-balancing_wan.py b/smoketest/scripts/cli/test_load-balancing_wan.py
index 8dc0c2622..255203e91 100755
--- a/smoketest/scripts/cli/test_load-balancing_wan.py
+++ b/smoketest/scripts/cli/test_load-balancing_wan.py
@@ -21,8 +21,10 @@ import time
from base_vyostest_shim import VyOSUnitTestSHIM
from vyos.utils.file import chmod_755
from vyos.utils.file import write_file
+from vyos.utils.misc import wait_for
from vyos.utils.process import call
from vyos.utils.process import cmd
+from vyos.utils.process import rc_cmd
base_path = ['load-balancing']
@@ -428,6 +430,80 @@ echo "$ifname - $state" > {hook_output_path}
self.verify_nftables_chain(nftables_search, 'ip vyos_wanloadbalance', 'wlb_mangle_prerouting')
+ def test_3_or_more_interfaces_in_rule(self):
+ lan_iface = 'eth1'
+
+ # Interfaces for equal weight test
+ self.cli_set(['interfaces', 'ethernet', 'eth0', 'vif', '101', 'address', '203.0.113.2/30'])
+ self.cli_set(['interfaces', 'ethernet', 'eth0', 'vif', '102', 'address', '203.0.113.6/30'])
+ self.cli_set(['interfaces', 'ethernet', 'eth0', 'vif', '103', 'address', '203.0.113.10/30'])
+
+ # Interfaces for unequal weight test
+ self.cli_set(['interfaces', 'ethernet', 'eth0', 'vif', '201', 'address', '203.0.113.14/30'])
+ self.cli_set(['interfaces', 'ethernet', 'eth0', 'vif', '202', 'address', '203.0.113.18/30'])
+ self.cli_set(['interfaces', 'ethernet', 'eth0', 'vif', '203', 'address', '203.0.113.22/30'])
+
+ self.cli_set(['interfaces', 'ethernet', lan_iface, 'vif', '100', 'address', '198.51.100.2/30'])
+ self.cli_set(['interfaces', 'ethernet', lan_iface, 'vif', '200', 'address', '198.51.100.6/30'])
+
+ # Health checks for equal weight test
+ self.cli_set(base_path + ['wan', 'interface-health', 'eth0.101', 'nexthop', '203.0.113.2'])
+ self.cli_set(base_path + ['wan', 'interface-health', 'eth0.101', 'success-count', '1'])
+ self.cli_set(base_path + ['wan', 'interface-health', 'eth0.101', 'failure-count', '1'])
+ self.cli_set(base_path + ['wan', 'interface-health', 'eth0.102', 'nexthop', '203.0.113.6'])
+ self.cli_set(base_path + ['wan', 'interface-health', 'eth0.102', 'success-count', '1'])
+ self.cli_set(base_path + ['wan', 'interface-health', 'eth0.102', 'failure-count', '1'])
+ self.cli_set(base_path + ['wan', 'interface-health', 'eth0.103', 'nexthop', '203.0.113.10'])
+ self.cli_set(base_path + ['wan', 'interface-health', 'eth0.103', 'success-count', '1'])
+ self.cli_set(base_path + ['wan', 'interface-health', 'eth0.103', 'failure-count', '1'])
+ self.cli_set(base_path + ['wan', 'rule', '10', 'inbound-interface', f'{lan_iface}.100'])
+ self.cli_set(base_path + ['wan', 'rule', '10', 'interface', 'eth0.101'])
+ self.cli_set(base_path + ['wan', 'rule', '10', 'interface', 'eth0.102'])
+ self.cli_set(base_path + ['wan', 'rule', '10', 'interface', 'eth0.103'])
+
+ # Health checks for unequal weight test
+ self.cli_set(base_path + ['wan', 'interface-health', 'eth0.201', 'nexthop', '203.0.113.14'])
+ self.cli_set(base_path + ['wan', 'interface-health', 'eth0.201', 'success-count', '1'])
+ self.cli_set(base_path + ['wan', 'interface-health', 'eth0.201', 'failure-count', '1'])
+ self.cli_set(base_path + ['wan', 'interface-health', 'eth0.202', 'nexthop', '203.0.113.18'])
+ self.cli_set(base_path + ['wan', 'interface-health', 'eth0.202', 'success-count', '1'])
+ self.cli_set(base_path + ['wan', 'interface-health', 'eth0.202', 'failure-count', '1'])
+ self.cli_set(base_path + ['wan', 'interface-health', 'eth0.203', 'nexthop', '203.0.113.22'])
+ self.cli_set(base_path + ['wan', 'interface-health', 'eth0.203', 'success-count', '1'])
+ self.cli_set(base_path + ['wan', 'interface-health', 'eth0.203', 'failure-count', '1'])
+ self.cli_set(base_path + ['wan', 'rule', '20', 'inbound-interface', f'{lan_iface}.200'])
+ self.cli_set(base_path + ['wan', 'rule', '20', 'interface', 'eth0.201'])
+ self.cli_set(base_path + ['wan', 'rule', '20', 'interface', 'eth0.202', 'weight', '2'])
+ self.cli_set(base_path + ['wan', 'rule', '20', 'interface', 'eth0.203', 'weight', '3'])
+
+ # commit changes
+ self.cli_commit()
+
+ def check_wlb_status():
+ rc, wlb_status = rc_cmd('nft list chain ip vyos_wanloadbalance wlb_mangle_prerouting')
+ if rc != 0:
+ return False
+
+ # get all lines containing 'jump'
+ lines = [l for l in wlb_status.splitlines() if 'jump' in l]
+
+ # check total count of 'jump' across all matching lines
+ total_jumps = sum(l.count('jump') for l in lines)
+
+ return total_jumps == 6
+
+ wait_for(check_wlb_status)
+
+ nftables_search = [
+ ['jump wlb_mangle_isp_eth0.101'],
+ ['jump wlb_mangle_isp_eth0.102'],
+ ['jump wlb_mangle_isp_eth0.103'],
+ ['jump wlb_mangle_isp_eth0.201'],
+ ['jump wlb_mangle_isp_eth0.202'],
+ ['jump wlb_mangle_isp_eth0.203'],
+ ]
+
+ self.verify_nftables_chain(nftables_search, 'ip vyos_wanloadbalance', 'wlb_mangle_prerouting')
if __name__ == '__main__':
unittest.main(verbosity=2, failfast=VyOSUnitTestSHIM.TestCase.debug_on())