Skip to content

Commit

Permalink
Merge branch 'AMWA-TV:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
gwgeorgea authored Feb 27, 2024
2 parents f4559b7 + 17df30d commit a84324d
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v1
with:
node-version: '12.x'
node-version: '16.x'
- name: Setup for python lint
run: pip install flake8
- name: Lint python
Expand Down
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:bionic
FROM ubuntu:focal

WORKDIR /home/nmos-testing
ADD . .
Expand All @@ -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 \
Expand All @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion docs/1.1. Installation - Local.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions nmostesting/Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
# Please consult the documentation for instructions on how to adjust these values for common testing setups including
# unicast DNS-SD and HTTPS testing.

# Number of seconds to wait after starting the mock DNS server, authorization server, etc. before running tests.
# This gives the API or client under test a chance to use these services before any test case is run.
MOCK_SERVICES_WARM_UP_DELAY = 0

# Enable or disable DNS-SD advertisements. Browsing is always permitted.
# The IS-04 Node tests create a mock registry on the network unless the `ENABLE_DNS_SD` parameter is set to `False`.
Expand Down
17 changes: 16 additions & 1 deletion nmostesting/NMOSTesting.py
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,14 @@ def run_noninteractive_tests(args):
return exit_code


def get_package_name(requirement):
pattern = r'^([^\s>=<]+)'
match = re.match(pattern, requirement)
if match:
return match.group(1)
return None


def check_internal_requirements():
corrections = {"gitpython": "git",
"pyopenssl": "OpenSSL",
Expand All @@ -976,7 +984,7 @@ def check_internal_requirements():
installed_pkgs = [pkg[1] for pkg in pkgutil.iter_modules()]
with open("requirements.txt") as requirements_file:
for requirement in requirements_file.readlines():
requirement_name = requirement.strip().split(">")[0]
requirement_name = get_package_name(requirement)
if requirement_name in corrections:
corrected_req = corrections[requirement_name]
else:
Expand Down Expand Up @@ -1139,6 +1147,13 @@ def main(args):
print(" * Testing tool running on 'http://{}:{}'. Version '{}'"
.format(get_default_ip(), core_app.config['PORT'], TOOL_VERSION))

# Give an API or client that is already running a chance to use the mock services
# before running any test cases
if CONFIG.MOCK_SERVICES_WARM_UP_DELAY:
print(" * Waiting for {} seconds to allow discovery of mock services"
.format(CONFIG.MOCK_SERVICES_WARM_UP_DELAY))
time.sleep(CONFIG.MOCK_SERVICES_WARM_UP_DELAY)

exit_code = 0
if "suite" not in vars(CMD_ARGS):
# Interactive testing mode. Await user input.
Expand Down
4 changes: 3 additions & 1 deletion nmostesting/suites/BCP00301Test.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ def perform_test_ssl(self, test, args=None):
"--openssl-timeout",
str(CONFIG.HTTP_TIMEOUT),
"--add-ca",
CONFIG.CERT_TRUST_ROOT_CA
CONFIG.CERT_TRUST_ROOT_CA,
"--ip",
self.apis[SECURE_API_KEY]["ip"]
] + args + ["{}:{}".format(self.apis[SECURE_API_KEY]["hostname"],
self.apis[SECURE_API_KEY]["port"])]
)
Expand Down
20 changes: 10 additions & 10 deletions nmostesting/suites/IS0401Test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
flask>=2.0.0
wtforms
jsonschema
zeroconf>=0.32.0
zeroconf>=0.75.0
requests
netifaces
gitpython
ramlfications
ramlfications==0.1.9
websocket-client>=1.0.0,!=1.2.2
jsonref>=1.0.0
dnslib
Expand Down
4 changes: 2 additions & 2 deletions utilities/dut-data-exporter/dutDataExporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ def url_port_number(url):
response = requests.get(url)
mac_addresses = response.json()["interfaces"]
for address in mac_addresses:
if type(address["port_id"]) == str:
if isinstance(address["port_id"], str):
address["port_id"] = address["port_id"].replace("-", ":")
if type(address["chassis_id"]) == str:
if isinstance(address["chassis_id"], str):
address["chassis_id"] = address["chassis_id"].replace("-", ":")
node_id = response.json()["id"]
print("Host: {}".format(response.json()["description"]))
Expand Down

0 comments on commit a84324d

Please sign in to comment.