Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/2.1. Usage - Testing Unicast Discovery.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ In order to test unicast discovery, the testing tool launches its own mock DNS s
* Ensure the `DNS_SD_MODE` in the testing tool's `nmostesting/UserConfig.py` file is set to `'unicast'` before running the tool.
* Configure the DNS search domain for your Node to be `testsuite.nmos.tv` (either manually or by providing this to your Node via DHCP).
* Configure the DNS server IP address for your Node to be the IP address of the host which is running the testing tool (either manually or by providing this to your Node via DHCP).
* Additionally, IP address and Port number of DNS mock server can be overridden (file `nmostesting/UserConfig.py`, parameters `CONFIG.DNS_IP` and `CONFIG.DNS_PORT`). This allows for easier testing of client code without requiring elevated permissions for nmos-testing-tool and without interference with existing DNS servers.

Unicast DNS advertisements for registries only become available once tests are running. As a result the unit under test may need prompting to re-scan the DNS server for records at this point. The `DNS_SD_ADVERT_TIMEOUT` config parameter may be used to increase the period which the test suite waits for in this situation.

Expand Down
6 changes: 6 additions & 0 deletions nmostesting/Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@
# This must match the domain name used for certificates in HTTPS mode
DNS_DOMAIN = "testsuite.nmos.tv"

# IP address for Unicast DNS server (to use instead of default one)
DNS_IP = None

# Port number for Unicast DNS server (to use instead of default one)
DNS_PORT = None

# The testing tool uses multiple ports to run mock services. This sets the lowest of these, which also runs the GUI
# Note that changing this from the default of 5000 also requires changes to supporting files such as
# test_data/BCP00301/ca/intermediate/openssl.cnf and any generated certificates.
Expand Down
10 changes: 6 additions & 4 deletions nmostesting/DNS.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ def resolve(self, request, handler):
class DNS(object):
def __init__(self):
self.default_ip = get_default_ip()
self.dns_ip = CONFIG.DNS_IP if CONFIG.DNS_IP else self.default_ip
self.dns_port = CONFIG.DNS_PORT if CONFIG.DNS_PORT else 53
self.resolver = None
self.server = None
self.base_zone_data = None
Expand Down Expand Up @@ -153,15 +155,15 @@ def reset(self):

def start(self):
if not self.server:
print(" * Starting DNS server on {}:53".format(self.default_ip))
print(" * Starting DNS server on {}:{}".format(self.dns_ip, self.dns_port))
try:
self.server = DNSServer(self.resolver, port=53, address=self.default_ip)
self.server = DNSServer(self.resolver, port=self.dns_port, address=self.dns_ip)
self.server.start_thread()
except Exception as e:
print(" * ERROR: Unable to bind to port 53. DNS server could not start: {}".format(e))
print(" * ERROR: Unable to bind to {}:{}. DNS server could not start: {}".format(self.dns_ip, self.dns_port, e))

def stop(self):
if self.server:
print(" * Stopping DNS server on {}:53".format(self.default_ip))
print(" * Stopping DNS server on {}:{}".format(self.dns_ip, self.dns_port))
self.server.stop()
self.server = None
8 changes: 5 additions & 3 deletions nmostesting/NMOSTesting.py
Original file line number Diff line number Diff line change
Expand Up @@ -1282,8 +1282,10 @@ def run_api_tests(args, data_format):

def main(args):
global CMD_ARGS, DNS_SERVER, TOOL_VERSION
# Check if we're testing unicast DNS discovery, and if so ensure we have elevated privileges
if CONFIG.ENABLE_DNS_SD and CONFIG.DNS_SD_MODE == "unicast":
# Check if we're testing unicast DNS discovery with default port number,
# and if so ensure we have elevated privileges
if CONFIG.ENABLE_DNS_SD and CONFIG.DNS_SD_MODE == "unicast" \
and CONFIG.DNS_PORT == None:
is_admin = False
if platform.system() == "Windows":
from ctypes import windll
Expand All @@ -1292,7 +1294,7 @@ def main(args):
elif os.geteuid() == 0:
is_admin = True
if not is_admin:
print(" * ERROR: In order to test DNS-SD in unicast mode, the test suite must be run "
print(" * ERROR: In order to test DNS-SD in unicast mode with default port number, the test suite must be run "
"with elevated permissions")
sys.exit(ExitCodes.ERROR)

Expand Down