summaryrefslogtreecommitdiff
path: root/smoketest
diff options
context:
space:
mode:
Diffstat (limited to 'smoketest')
-rw-r--r--smoketest/scripts/cli/base_accel_ppp_test.py18
-rwxr-xr-xsmoketest/scripts/cli/test_load-balancing_reverse-proxy.py53
-rwxr-xr-xsmoketest/scripts/cli/test_qos.py95
-rwxr-xr-xsmoketest/scripts/cli/test_service_dns_forwarding.py10
4 files changed, 176 insertions, 0 deletions
diff --git a/smoketest/scripts/cli/base_accel_ppp_test.py b/smoketest/scripts/cli/base_accel_ppp_test.py
index ab723e707..212dc58ab 100644
--- a/smoketest/scripts/cli/base_accel_ppp_test.py
+++ b/smoketest/scripts/cli/base_accel_ppp_test.py
@@ -628,3 +628,21 @@ delegate={delegate_2_prefix},{delegate_mask},name={pool_name}"""
self.assertEqual(conf['connlimit']['limit'], limits)
self.assertEqual(conf['connlimit']['burst'], burst)
self.assertEqual(conf['connlimit']['timeout'], timeout)
+
+ def test_accel_log_level(self):
+ self.basic_config()
+ self.cli_commit()
+
+ # check default value
+ conf = ConfigParser(allow_no_value=True)
+ conf.read(self._config_file)
+ self.assertEqual(conf['log']['level'], '3')
+
+ for log_level in range(0, 5):
+ self.set(['log', 'level', str(log_level)])
+ self.cli_commit()
+ # Validate configuration values
+ conf = ConfigParser(allow_no_value=True)
+ conf.read(self._config_file)
+
+ self.assertEqual(conf['log']['level'], str(log_level))
diff --git a/smoketest/scripts/cli/test_load-balancing_reverse-proxy.py b/smoketest/scripts/cli/test_load-balancing_reverse-proxy.py
index 2b2f93cdf..aa796f59f 100755
--- a/smoketest/scripts/cli/test_load-balancing_reverse-proxy.py
+++ b/smoketest/scripts/cli/test_load-balancing_reverse-proxy.py
@@ -338,6 +338,11 @@ class TestLoadBalancingReverseProxy(VyOSUnitTestSHIM.TestCase):
self.assertIn('http-check send meth GET uri /health', config)
self.assertIn('http-check expect string success', config)
+ # Test configuring both http-check & health-check fails validation script
+ self.cli_set(base_path + ['backend', 'bk-01', 'health-check', 'ldap'])
+ with self.assertRaises(ConfigSessionError) as e:
+ self.cli_commit()
+
def test_06_lb_reverse_proxy_tcp_mode(self):
frontend = 'tcp_8443'
mode = 'tcp'
@@ -405,6 +410,54 @@ class TestLoadBalancingReverseProxy(VyOSUnitTestSHIM.TestCase):
with self.assertRaises(ConfigSessionError) as e:
self.cli_commit()
+ def test_08_lb_reverse_proxy_tcp_health_checks(self):
+ # Setup PKI
+ self.configure_pki()
+
+ # Define variables
+ frontend = 'fe_ldaps'
+ mode = 'tcp'
+ health_check = 'ldap'
+ front_port = '636'
+ bk_name = 'bk_ldap'
+ bk_servers = ['192.0.2.11', '192.0.2.12']
+ bk_server_port = '389'
+
+ # Configure frontend
+ self.cli_set(base_path + ['service', frontend, 'mode', mode])
+ self.cli_set(base_path + ['service', frontend, 'port', front_port])
+ self.cli_set(base_path + ['service', frontend, 'ssl', 'certificate', 'smoketest'])
+
+ # Configure backend
+ self.cli_set(base_path + ['backend', bk_name, 'mode', mode])
+ self.cli_set(base_path + ['backend', bk_name, 'health-check', health_check])
+ for index, bk_server in enumerate(bk_servers):
+ self.cli_set(base_path + ['backend', bk_name, 'server', f'srv-{index}', 'address', bk_server])
+ self.cli_set(base_path + ['backend', bk_name, 'server', f'srv-{index}', 'port', bk_server_port])
+
+ # Commit & read config
+ self.cli_commit()
+ config = read_file(HAPROXY_CONF)
+
+ # Validate Frontend
+ self.assertIn(f'frontend {frontend}', config)
+ self.assertIn(f'bind [::]:{front_port} v4v6 ssl crt /run/haproxy/smoketest.pem', config)
+ self.assertIn(f'mode {mode}', config)
+ self.assertIn(f'backend {bk_name}', config)
+
+ # Validate Backend
+ self.assertIn(f'backend {bk_name}', config)
+ self.assertIn(f'option {health_check}-check', config)
+ self.assertIn(f'mode {mode}', config)
+ for index, bk_server in enumerate(bk_servers):
+ self.assertIn(f'server srv-{index} {bk_server}:{bk_server_port}', config)
+
+ # Validate SMTP option renders correctly
+ self.cli_set(base_path + ['backend', bk_name, 'health-check', 'smtp'])
+ self.cli_commit()
+ config = read_file(HAPROXY_CONF)
+ self.assertIn(f'option smtpchk', config)
+
if __name__ == '__main__':
unittest.main(verbosity=2)
diff --git a/smoketest/scripts/cli/test_qos.py b/smoketest/scripts/cli/test_qos.py
index 5977b2f41..b98c0e9b7 100755
--- a/smoketest/scripts/cli/test_qos.py
+++ b/smoketest/scripts/cli/test_qos.py
@@ -759,6 +759,101 @@ class TestQoS(VyOSUnitTestSHIM.TestCase):
self.assertIn('filter parent ffff: protocol all pref 255 basic chain 0', tc_filters)
self.assertIn('action order 1: police 0x2 rate 1Gbit burst 125000000b mtu 2Kb action drop overhead 0b', tc_filters)
+ def test_15_traffic_match_group(self):
+ interface = self._interfaces[0]
+ self.cli_set(['qos', 'interface', interface, 'egress', 'VyOS-HTB'])
+ base_policy_path = ['qos', 'policy', 'shaper', 'VyOS-HTB']
+
+ #old syntax
+ self.cli_set(base_policy_path + ['bandwidth', '100mbit'])
+ self.cli_set(base_policy_path + ['class', '10', 'bandwidth', '40%'])
+ self.cli_set(base_policy_path + ['class', '10', 'match', 'AF11', 'ip', 'dscp', 'AF11'])
+ self.cli_set(base_policy_path + ['class', '10', 'match', 'AF41', 'ip', 'dscp', 'AF41'])
+ self.cli_set(base_policy_path + ['class', '10', 'match', 'AF43', 'ip', 'dscp', 'AF43'])
+ self.cli_set(base_policy_path + ['class', '10', 'match', 'CS4', 'ip', 'dscp', 'CS4'])
+ self.cli_set(base_policy_path + ['class', '10', 'priority', '1'])
+ self.cli_set(base_policy_path + ['class', '10', 'queue-type', 'fair-queue'])
+ self.cli_set(base_policy_path + ['class', '20', 'bandwidth', '30%'])
+ self.cli_set(base_policy_path + ['class', '20', 'match', 'EF', 'ip', 'dscp', 'EF'])
+ self.cli_set(base_policy_path + ['class', '20', 'match', 'CS5', 'ip', 'dscp', 'CS5'])
+ self.cli_set(base_policy_path + ['class', '20', 'priority', '2'])
+ self.cli_set(base_policy_path + ['class', '20', 'queue-type', 'fair-queue'])
+ self.cli_set(base_policy_path + ['default', 'bandwidth', '20%'])
+ self.cli_set(base_policy_path + ['default', 'queue-type', 'fair-queue'])
+ self.cli_commit()
+
+ tc_filters_old = cmd(f'tc -details filter show dev {interface}')
+ self.assertIn('match 00280000/00ff0000', tc_filters_old)
+ self.assertIn('match 00880000/00ff0000', tc_filters_old)
+ self.assertIn('match 00980000/00ff0000', tc_filters_old)
+ self.assertIn('match 00800000/00ff0000', tc_filters_old)
+ self.assertIn('match 00a00000/00ff0000', tc_filters_old)
+ self.assertIn('match 00b80000/00ff0000', tc_filters_old)
+ # delete config by old syntax
+ self.cli_delete(base_policy_path)
+ self.cli_delete(['qos', 'interface', interface, 'egress', 'VyOS-HTB'])
+ self.cli_commit()
+ self.assertEqual('', cmd(f'tc -s filter show dev {interface}'))
+
+ self.cli_set(['qos', 'interface', interface, 'egress', 'VyOS-HTB'])
+ # prepare traffic match group
+ self.cli_set(['qos', 'traffic-match-group', 'VOICE', 'description', 'voice shaper'])
+ self.cli_set(['qos', 'traffic-match-group', 'VOICE', 'match', 'EF', 'ip', 'dscp', 'EF'])
+ self.cli_set(['qos', 'traffic-match-group', 'VOICE', 'match', 'CS5', 'ip', 'dscp', 'CS5'])
+
+ self.cli_set(['qos', 'traffic-match-group', 'REAL_TIME_COMMON', 'description', 'real time common filters'])
+ self.cli_set(['qos', 'traffic-match-group', 'REAL_TIME_COMMON', 'match', 'AF43', 'ip', 'dscp', 'AF43'])
+ self.cli_set(['qos', 'traffic-match-group', 'REAL_TIME_COMMON', 'match', 'CS4', 'ip', 'dscp', 'CS4'])
+
+ self.cli_set(['qos', 'traffic-match-group', 'REAL_TIME', 'description', 'real time shaper'])
+ self.cli_set(['qos', 'traffic-match-group', 'REAL_TIME', 'match', 'AF41', 'ip', 'dscp', 'AF41'])
+ self.cli_set(['qos', 'traffic-match-group', 'REAL_TIME', 'match-group', 'REAL_TIME_COMMON'])
+
+ # new syntax
+ self.cli_set(base_policy_path + ['bandwidth', '100mbit'])
+ self.cli_set(base_policy_path + ['class', '10', 'bandwidth', '40%'])
+ self.cli_set(base_policy_path + ['class', '10', 'match', 'AF11', 'ip', 'dscp', 'AF11'])
+ self.cli_set(base_policy_path + ['class', '10', 'match-group', 'REAL_TIME'])
+ self.cli_set(base_policy_path + ['class', '10', 'priority', '1'])
+ self.cli_set(base_policy_path + ['class', '10', 'queue-type', 'fair-queue'])
+ self.cli_set(base_policy_path + ['class', '20', 'bandwidth', '30%'])
+ self.cli_set(base_policy_path + ['class', '20', 'match-group', 'VOICE'])
+ self.cli_set(base_policy_path + ['class', '20', 'priority', '2'])
+ self.cli_set(base_policy_path + ['class', '20', 'queue-type', 'fair-queue'])
+ self.cli_set(base_policy_path + ['default', 'bandwidth', '20%'])
+ self.cli_set(base_policy_path + ['default', 'queue-type', 'fair-queue'])
+ self.cli_commit()
+
+ self.assertEqual(tc_filters_old, cmd(f'tc -details filter show dev {interface}'))
+
+ def test_16_wrong_traffic_match_group(self):
+ interface = self._interfaces[0]
+ self.cli_set(['qos', 'interface', interface])
+
+ # Can not use both IPv6 and IPv4 in one match
+ self.cli_set(['qos', 'traffic-match-group', '1', 'match', 'one', 'ip', 'dscp', 'EF'])
+ self.cli_set(['qos', 'traffic-match-group', '1', 'match', 'one', 'ipv6', 'dscp', 'EF'])
+ with self.assertRaises(ConfigSessionError) as e:
+ self.cli_commit()
+
+ # check contain itself, should commit success
+ self.cli_delete(['qos', 'traffic-match-group', '1', 'match', 'one', 'ipv6'])
+ self.cli_set(['qos', 'traffic-match-group', '1', 'match-group', '1'])
+ self.cli_commit()
+
+ # check cycle dependency, should commit success
+ self.cli_set(['qos', 'traffic-match-group', '1', 'match-group', '3'])
+ self.cli_set(['qos', 'traffic-match-group', '2', 'match', 'one', 'ip', 'dscp', 'CS4'])
+ self.cli_set(['qos', 'traffic-match-group', '2', 'match-group', '1'])
+
+ self.cli_set(['qos', 'traffic-match-group', '3', 'match', 'one', 'ipv6', 'dscp', 'CS4'])
+ self.cli_set(['qos', 'traffic-match-group', '3', 'match-group', '2'])
+ self.cli_commit()
+
+ # inherit from non exist group, should commit success with warning
+ self.cli_set(['qos', 'traffic-match-group', '3', 'match-group', 'unexpected'])
+ self.cli_commit()
+
if __name__ == '__main__':
unittest.main(verbosity=2)
diff --git a/smoketest/scripts/cli/test_service_dns_forwarding.py b/smoketest/scripts/cli/test_service_dns_forwarding.py
index 079c584ba..4db1d7495 100755
--- a/smoketest/scripts/cli/test_service_dns_forwarding.py
+++ b/smoketest/scripts/cli/test_service_dns_forwarding.py
@@ -291,5 +291,15 @@ class TestServicePowerDNS(VyOSUnitTestSHIM.TestCase):
tmp = get_config_value('edns-subnet-allow-list')
self.assertEqual(tmp, ','.join(options))
+ def test_multiple_ns_records(self):
+ test_zone = 'example.com'
+ self.cli_set(base_path + ['authoritative-domain', test_zone, 'records', 'ns', 'test', 'target', f'ns1.{test_zone}'])
+ self.cli_set(base_path + ['authoritative-domain', test_zone, 'records', 'ns', 'test', 'target', f'ns2.{test_zone}'])
+ self.cli_commit()
+ zone_config = read_file(f'{PDNS_REC_RUN_DIR}/zone.{test_zone}.conf')
+ self.assertRegex(zone_config, fr'test\s+\d+\s+NS\s+ns1\.{test_zone}\.')
+ self.assertRegex(zone_config, fr'test\s+\d+\s+NS\s+ns2\.{test_zone}\.')
+
+
if __name__ == '__main__':
unittest.main(verbosity=2)