diff options
| -rw-r--r-- | data/templates/mdns-repeater/avahi-daemon.conf.j2 | 3 | ||||
| -rw-r--r-- | interface-definitions/service_mdns_repeater.xml.in | 17 | ||||
| -rwxr-xr-x | smoketest/scripts/cli/test_service_mdns_repeater.py | 76 | 
3 files changed, 79 insertions, 17 deletions
| diff --git a/data/templates/mdns-repeater/avahi-daemon.conf.j2 b/data/templates/mdns-repeater/avahi-daemon.conf.j2 index cc6495817..a5031945c 100644 --- a/data/templates/mdns-repeater/avahi-daemon.conf.j2 +++ b/data/templates/mdns-repeater/avahi-daemon.conf.j2 @@ -6,6 +6,9 @@ allow-interfaces={{ interface | join(', ') }}  {% if browse_domain is vyos_defined and browse_domain | length %}  browse-domains={{ browse_domain | join(', ') }}  {% endif %} +{% if cache_entries is vyos_defined %} +cache-entries-max={{ cache_entries }} +{% endif %}  disallow-other-stacks=no  [wide-area] diff --git a/interface-definitions/service_mdns_repeater.xml.in b/interface-definitions/service_mdns_repeater.xml.in index 5d6f61d74..9d626bf6a 100644 --- a/interface-definitions/service_mdns_repeater.xml.in +++ b/interface-definitions/service_mdns_repeater.xml.in @@ -67,6 +67,23 @@                    <multi/>                  </properties>                </leafNode> +              <leafNode name="cache-entries"> +                <properties> +                  <help>Number of resource records cached per interface</help> +                  <valueHelp> +                    <format>u32:0</format> +                    <description>Disable caching</description> +                  </valueHelp> +                  <valueHelp> +                    <format>u32:1-65535</format> +                    <description>Resource records to cache per interface</description> +                  </valueHelp> +                  <constraint> +                    <validator name="numeric" argument="--range 0-65535"/> +                  </constraint> +                </properties> +                <defaultValue>4096</defaultValue> +              </leafNode>                <leafNode name="vrrp-disable">                  <properties>                    <help>Disables mDNS repeater on VRRP interfaces not in MASTER state</help> diff --git a/smoketest/scripts/cli/test_service_mdns_repeater.py b/smoketest/scripts/cli/test_service_mdns_repeater.py index f2fb3b509..30e48683f 100755 --- a/smoketest/scripts/cli/test_service_mdns_repeater.py +++ b/smoketest/scripts/cli/test_service_mdns_repeater.py @@ -21,36 +21,45 @@ from base_vyostest_shim import VyOSUnitTestSHIM  from configparser import ConfigParser  from vyos.configsession import ConfigSessionError  from vyos.utils.process import process_named_running +from vyos.xml_ref import default_value  base_path = ['service', 'mdns', 'repeater']  intf_base = ['interfaces', 'dummy']  config_file = '/run/avahi-daemon/avahi-daemon.conf' -  class TestServiceMDNSrepeater(VyOSUnitTestSHIM.TestCase): -    def setUp(self): -        # Start with a clean CLI instance -        self.cli_delete(base_path) +    @classmethod +    def setUpClass(cls): +        super(TestServiceMDNSrepeater, cls).setUpClass() -        # Service required a configured IP address on the interface -        self.cli_set(intf_base + ['dum10', 'address', '192.0.2.1/30']) -        self.cli_set(intf_base + ['dum10', 'ipv6', 'address', 'no-default-link-local']) -        self.cli_set(intf_base + ['dum20', 'address', '192.0.2.5/30']) -        self.cli_set(intf_base + ['dum20', 'address', '2001:db8:0:2::5/64']) -        self.cli_set(intf_base + ['dum30', 'address', '192.0.2.9/30']) -        self.cli_set(intf_base + ['dum30', 'address', '2001:db8:0:2::9/64']) -        self.cli_set(intf_base + ['dum40', 'address', '2001:db8:0:2::11/64']) -        self.cli_commit() +        # ensure we can also run this test on a live system - so lets clean +        # out the current configuration :) +        cls.cli_delete(cls, base_path) + +        cls.cli_set(cls, intf_base + ['dum10', 'address', '192.0.2.1/30']) +        cls.cli_set(cls, intf_base + ['dum10', 'ipv6', 'address', 'no-default-link-local']) +        cls.cli_set(cls, intf_base + ['dum20', 'address', '192.0.2.5/30']) +        cls.cli_set(cls, intf_base + ['dum20', 'address', '2001:db8:0:2::5/64']) +        cls.cli_set(cls, intf_base + ['dum30', 'address', '192.0.2.9/30']) +        cls.cli_set(cls, intf_base + ['dum30', 'address', '2001:db8:0:2::9/64']) +        cls.cli_set(cls, intf_base + ['dum40', 'address', '2001:db8:0:2::11/64']) + +        cls.cli_commit(cls) + +    @classmethod +    def tearDownClass(cls): +        cls.cli_delete(cls, intf_base + ['dum10']) +        cls.cli_delete(cls, intf_base + ['dum20']) +        cls.cli_delete(cls, intf_base + ['dum30']) +        cls.cli_delete(cls, intf_base + ['dum40']) + +        cls.cli_commit(cls)      def tearDown(self):          # Check for running process          self.assertTrue(process_named_running('avahi-daemon'))          self.cli_delete(base_path) -        self.cli_delete(intf_base + ['dum10']) -        self.cli_delete(intf_base + ['dum20']) -        self.cli_delete(intf_base + ['dum30']) -        self.cli_delete(intf_base + ['dum40'])          self.cli_commit()          # Check that there is no longer a running process @@ -130,5 +139,38 @@ class TestServiceMDNSrepeater(VyOSUnitTestSHIM.TestCase):          self.assertEqual(conf['server']['allow-interfaces'], 'dum30, dum40')          self.assertEqual(conf['reflector']['enable-reflector'], 'yes') +    def test_service_max_cache_entries(self): +        cli_default_max_cache = default_value(base_path + ['cache-entries']) +        self.cli_set(base_path) + +        # Need at least two interfaces +        with self.assertRaises(ConfigSessionError): +            self.cli_commit() +        self.cli_set(base_path + ['interface', 'dum20']) + +        # Need at least two interfaces +        with self.assertRaises(ConfigSessionError): +            self.cli_commit() +        self.cli_set(base_path + ['interface', 'dum30']) + +        self.cli_commit() + +        # Validate configuration values +        conf = ConfigParser(delimiters='=') +        conf.read(config_file) +        self.assertEqual(conf['server']['cache-entries-max'], cli_default_max_cache) + +        # Set max cache entries +        cache_entries = '1234' +        self.cli_set(base_path + ['cache-entries', cache_entries]) + +        self.cli_commit() + +        # Validate configuration values +        conf = ConfigParser(delimiters='=') +        conf.read(config_file) + +        self.assertEqual(conf['server']['cache-entries-max'], cache_entries) +  if __name__ == '__main__':      unittest.main(verbosity=2) | 
