From bc7e9971908157bd76c328b2d932d069ca43631d Mon Sep 17 00:00:00 2001 From: Gareth Sylvester-Bradley Date: Mon, 14 Aug 2023 15:23:57 +0100 Subject: [PATCH 1/2] python-zeroconf 0.75.0 strict=False for _nmos-registration._tcp --- nmostesting/suites/IS0401Test.py | 20 ++++++++++---------- requirements.txt | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/nmostesting/suites/IS0401Test.py b/nmostesting/suites/IS0401Test.py index 64c53e67..1325b1cb 100644 --- a/nmostesting/suites/IS0401Test.py +++ b/nmostesting/suites/IS0401Test.py @@ -32,10 +32,6 @@ from ..IS04Utils import IS04Utils from ..TestHelper import get_default_ip, is_ip_address, load_resolved_schema, check_content_type -# monkey patch zeroconf to allow us to advertise "_nmos-registration._tcp" -from zeroconf import service_type_name -service_type_name.__kwdefaults__['strict'] = False - NODE_API_KEY = "node" RECEIVER_CAPS_KEY = "receiver-caps" CAPS_REGISTER_KEY = "caps-register" @@ -94,6 +90,10 @@ def tear_down_tests(self): if self.dns_server: self.dns_server.reset() + def _strict_service_name(self, info): + # avoid zeroconf._exceptions.BadTypeInNameException: Service name (nmos-registration) must be <= 15 bytes + return len(info.type[1:info.type.find('.')]) <= 15 + def _mdns_info(self, port, service_type, txt={}, api_ver=None, api_proto=None, api_auth=None, ip=None): """Get an mDNS ServiceInfo object in order to create an advertisement""" if api_ver is None: @@ -192,9 +192,9 @@ def do_registry_basics_prereqs(self): if CONFIG.DNS_SD_MODE == "multicast": # Advertise the primary registry and invalid ones at pri 0, and allow the Node to do a basic registration if self.is04_utils.compare_api_version(self.apis[NODE_API_KEY]["version"], "v1.0") != 0: - self.zc.register_service(registry_mdns[0]) - self.zc.register_service(registry_mdns[1]) - self.zc.register_service(registry_mdns[2]) + self.zc.register_service(registry_mdns[0], strict=self._strict_service_name(registry_mdns[0])) + self.zc.register_service(registry_mdns[1], strict=self._strict_service_name(registry_mdns[1])) + self.zc.register_service(registry_mdns[2], strict=self._strict_service_name(registry_mdns[2])) # Wait for n seconds after advertising the service for the first POST from a Node start_time = time.time() @@ -226,7 +226,7 @@ def do_registry_basics_prereqs(self): if CONFIG.DNS_SD_MODE == "multicast": for info in registry_mdns[3:]: - self.zc.register_service(info) + self.zc.register_service(info, strict=self._strict_service_name(info)) # Kill registries one by one to collect data around failover self.invalid_registry.disable() @@ -1455,7 +1455,7 @@ def test_21(self, test): if CONFIG.DNS_SD_MODE == "multicast": # Advertise a registry at pri 0 and allow the Node to do a basic registration - self.zc.register_service(registry_info) + self.zc.register_service(registry_info, strict=self._strict_service_name(registry_info)) # Wait for n seconds after advertising the service for the first POST and then DELETE from a Node self.primary_registry.wait_for_registration(CONFIG.DNS_SD_ADVERT_TIMEOUT) @@ -2160,7 +2160,7 @@ def collect_mdns_announcements(self): if CONFIG.DNS_SD_MODE == "multicast": # Advertise a registry at pri 0 and allow the Node to do a basic registration - self.zc.register_service(registry_info) + self.zc.register_service(registry_info, strict=self._strict_service_name(registry_info)) # Wait for n seconds after advertising the service for the first POST from a Node self.primary_registry.wait_for_registration(CONFIG.DNS_SD_ADVERT_TIMEOUT) diff --git a/requirements.txt b/requirements.txt index 5a51fa50..93bb689e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ flask>=2.0.0 wtforms jsonschema -zeroconf>=0.32.0 +zeroconf>=0.75.0 requests netifaces gitpython From b10ff7157f3e0e97e736e5a820c57a6a4cc0383f Mon Sep 17 00:00:00 2001 From: Gareth Sylvester-Bradley Date: Fri, 18 Aug 2023 14:00:25 +0100 Subject: [PATCH 2/2] Python 3.6 (and 3.7!) is End-Of-Life, and so is Node.js 14.x Libraries like python-zeroconf are starting to depend on more recent Python features --- Dockerfile | 10 +++++----- docs/1.1. Installation - Local.md | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 08fcfef8..8c000875 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:bionic +FROM ubuntu:focal WORKDIR /home/nmos-testing ADD . . @@ -7,9 +7,9 @@ ADD .git .git RUN apt-get update \ && export DEBIAN_FRONTEND=noninteractive \ && apt-get install -y wget \ - && wget https://deb.nodesource.com/setup_14.x \ - && chmod 755 setup_14.x \ - && /home/nmos-testing/setup_14.x \ + && wget https://deb.nodesource.com/setup_16.x \ + && chmod 755 setup_16.x \ + && /home/nmos-testing/setup_16.x \ && apt-get install -y --no-install-recommends \ gcc openssl libssl-dev wget ca-certificates avahi-daemon avahi-utils libnss-mdns libavahi-compat-libdnssd-dev \ python3 python3-pip python3-dev nodejs \ @@ -26,7 +26,7 @@ RUN apt-get update \ && rm v3.0.7.tar.gz \ && npm config set unsafe-perm true \ && npm install -g AMWA-TV/sdpoker#v0.3.0 \ - && rm /home/nmos-testing/setup_14.x \ + && rm /home/nmos-testing/setup_16.x \ && apt-get remove -y wget \ && apt-get clean -y --no-install-recommends \ && apt-get autoclean -y --no-install-recommends \ diff --git a/docs/1.1. Installation - Local.md b/docs/1.1. Installation - Local.md index d7249421..57fd68fa 100644 --- a/docs/1.1. Installation - Local.md +++ b/docs/1.1. Installation - Local.md @@ -4,7 +4,7 @@ Please ensure that the following dependencies are installed on your system first. -- Python 3.6 or higher, including the 'pip' package manager +- Python 3.8 or higher, including the 'pip' package manager - Git - [testssl.sh](https://testssl.sh) (required for BCP-003-01 testing, see our [README](../testssl/README.md) for instructions) - [OpenSSL](https://www.openssl.org/) (required for BCP-003-01 OCSP testing)