Skip to content

Commit dcc9452

Browse files
jonathan-r-thorpelo-simongarethsbalabou
authored
IS-12 Test Suites (#810)
* [IS-12] Initial Commit for IS-12 Test Suite (#800) * Initial commit * Added IS-12 spec to Config * Updated specs for IS-12-01 test suite Co-authored-by: jonathan-r-thorpe <64410119+jonathan-r-thorpe@users.noreply.github.com> Co-authored-by: lo-simon <simon.lo@sony.com> Co-authored-by: Gareth Sylvester-Bradley <garethsb@nvidia.com> * [IS-12] Check Root Block and ClassManager (#814) * Initial commit * Added IS-12 spec to Config * Updated specs for IS-12-01 test suite * Implement NCP endpoint and create WebSocket tests * Updated API name * Updated test definition. * Improve control endpoint checking * Use of compare_urls to test Control Protocol `href` * Corrected formatting. Improved WebSocket handling * Refactored control API checking * Corrected failure case in test_02 * Use NMOSUtils.do_test_device_control * Test WebSocket services and controls are as secure as HTTP endpoints * Fix protocol bug, remove stripping of trailing slash * Add is_message_received to WebsocketWorker * Added IS12Utils * Add Root Block tests * Check Root Block and check Class Manager OID and Role --------- Co-authored-by: lo-simon <simon.lo@sony.com> Co-authored-by: Gareth Sylvester-Bradley <garethsb@nvidia.com> * [IS-12] Add auto tests for validating MS-05 standard class and datatype definitions (#819) Auto validation of classes and datatypes Testing of error conditions Validation of device model against advertised classes and datatypes Checking of Managers Checking that roles are unique within a block Checking that oids are unique Co-authored-by: lo-simon <simon.lo@sony.com> Co-authored-by: Gareth Sylvester-Bradley <garethsb@nvidia.com> * Merge pull request #812 from AMWA-TV/zeroconf-marmoset [IS-04-01] Much smaller zeroconf monkey patch (cherry picked from commit aa58b5e) * [IS 12] Add Get/Set/Add/Remove/Find methods (#822) * Fixed error reporting * Added Set user label test * Validate touchpoints * Validate NcTouchpointNmos or NcTouchpointNmosChannelMapping depending on contextNamespace * Sequence command JSON helper functions * Build device model object tree when validating device model * Check FindMembersByRole * Recursively check each block's role paths * find members by role test * Find members by class id test * GetMemberDescriptors test * removed protocolVersion * GetSequenceLength test * Subscribe to all objects and test changing all user labels * Add Class Manager method tests * Added illegal command handle test * IndexOutOfBounds test. WebSocket kept open test * Updated comments and links to specification --------- Co-authored-by: Gareth Sylvester-Bradley <garethsb@nvidia.com> Co-authored-by: Gareth Sylvester-Bradley <31761158+garethsb@users.noreply.github.com> * [IS-12] Specify explicit URL path for WebSocket endpoint (#827) * Specify explicit URL path for WebSocket endpoint * Default to array, not dict * Linting tweaks * Handle leading slash on URL path parameter * Update comment. Rename helper function * Rollback tentative changes * Check response from Find methods is an array * Handle errors where control classes are not advertised by Class Manager * Fixed detection of authority keys in non-standard classes * Handle missing device model properties * Defend against missing properties or datatype definitions * Improved error handling, * Bump Node 12.x to Node 16.x (cherry picked from commit 4caeca4) * python-zeroconf 0.75.0 strict=False for _nmos-registration._tcp (cherry picked from commit bc7e997) * 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 (cherry picked from commit b10ff71) * Pass IP address of API under test to testssl.sh So that same one is used by Python tests and testssl.sh tests Co-authored-by: Simon Lo <simon.lo@sony.com> (cherry picked from commit 3f10a8d) * Add MOCK_SERVICES_WARM_UP_DELAY (cherry picked from commit 796a115) * Delay running tests until after MOCK_SERVICES_WARM_UP_DELAY Co-authored-by: Simon Lo <simon.lo@sony.com> (cherry picked from commit 43a1f76) * Tweak message Co-authored-by: jonathan-r-thorpe <64410119+jonathan-r-thorpe@users.noreply.github.com> (cherry picked from commit 215f736) * Fixed send_command function as per suggestion from @alabou (cherry picked from commit a3df644) * Add config option to bypass IS12 interactive testing * Add constraints classes * added xeger library * Add IS1202 test suite * Add primitives to datatype models * Enhance test_35 (subscription and notification mechanism test) to all… (#839) * Since jstasiak/zeroconf#666 (0.32.0) it needs a much much smaller monkeypatch to be able to advertise the overlong service type "_nmos-registration._tcp" * Fix flake8/pycodestyle E721 do not compare types * Bump Node 12.x to Node 16.x * python-zeroconf 0.75.0 strict=False for _nmos-registration._tcp * 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 * Pass IP address of API under test to testssl.sh So that same one is used by Python tests and testssl.sh tests Co-authored-by: Simon Lo <simon.lo@sony.com> * Add MOCK_SERVICES_WARM_UP_DELAY * Delay running tests until after MOCK_SERVICES_WARM_UP_DELAY Co-authored-by: Simon Lo <simon.lo@sony.com> * Tweak message Co-authored-by: jonathan-r-thorpe <64410119+jonathan-r-thorpe@users.noreply.github.com> * Enhance test_35 (subscription and notification mechanism test) to allow interference notifications while running test * Update IS1201Test.py shorten line for flake8 --------- Co-authored-by: Gareth Sylvester-Bradley <garethsb@nvidia.com> Co-authored-by: Gareth Sylvester-Bradley <31761158+garethsb@users.noreply.github.com> Co-authored-by: jonathan-r-thorpe <64410119+jonathan-r-thorpe@users.noreply.github.com> * Tweaked test_35 * Pass **kwargs to ControllerTest * Pass **kwargs to ControllerTest * Test sequences; remove non UTF-8 character from comment * Added constrained sequence tests * Additional sequence checks * Add runtime constraints to device model. Fix handling of primitive types in schema generation * Added property and datatype constraints checking * Removed disabled tests * make datatype_schemas an object property * Check for default value sequences when validating class descriptors (cherry picked from commit 70f633c56cf55481cf440f4d76ced36b3273cd6e) * Flake8 formatting * Cache class_manager. Simplify constraint checking. * Fix Block object construction. Fix Test_02 * add missing primitive descriptor path * reorder specs in NMOS Testing interface * Fix constraint violation error message * Disable Testing Facade host and port if not interactively testing * Flake8 formatting * Fix constraint violation error message (cherry picked from commit c5d43f7) * Refactor property testing * Handle property and method deprecated status codes * Check deprecated properties * Report unchecked device model in tests * Renumbered tests * updated spec URLs in comments * Handle property and method deprecated status codes (cherry picked from commit 5f2cb63) * Check deprecated properties (cherry picked from commit 7c93b49) * Report unchecked device model in tests (cherry picked from commit 12f556b) * Renumbered tests (cherry picked from commit 738021f) * updated spec URLs in comments (cherry picked from commit ef33d0f) * Updated to conform merged branch * Guard against missing class properties * Add annotation to check properties test * Better error reporting for test_22 and test_23 * formatting * Fix spelling mistake in interactive testing config * Fixed Blocks with no members being set to None * Fixed config spelling error * Rename _execute_command to execute_command * Test discovered methods in Device Model * Only test non-standard methods. * Moved some functions to IS12Utils * Added more error reporting * Guard against ControllerTest being run in non-interactive mode * Added check constraints hierarchy test * Fixed do_check_property_test * Add check read only properties and sequences * Made sequence tests tolerant to empty or null sequences * Typo and formatting * Initial add of IS-14-01 test suite (cherry picked from commit e870bcef1052a0eaea28e54748c6ede52a6e8cce) * Flake8 formatting * Added Node API to IS-14 (for testing control endpoint) * Initial refactoring * Added additional specs to IS-14-01 test suite definition * Move common functions from IS12Utils to MS05Utils * Delegate to MS0501Test for auto tests * API key now required when loading resources * Delegate to MS0501Test for auto tests * flake8 formatting * Move MS-05 tests into MS0501Test Move MS-05 utility functions into MS05Utils * Fixed get_sequence_item * Refactor IS-14 API utility functions * generalize get_control_class and get_datatype. Improve error handling. * Implement IS-14 http request helper functions * Formatting * Moved error handling tests to MS0501Test * Add invoke method utility function. Added MS0502Test and IS1402Test * Do not cache spec_branch in construction * Simplify utilities initialization * Add reset so that state is reset on set_up_tests * Initiailize IS-12 websocket on set_up_tests so failure is reported on the UI * make base class generic * Updated comments * Changed " embedd3ed in f-strings to ' * Changed SET to PUT * Changed " embedded in f-strings to ' * Fix IS-14 utility functions * Add missing sequence methods * Add role_path to get_sequence_length call * Add device-configuration feature set to feature set tests * Add additional validation of class descriptors * Add is_block helper. * Add initial IS-14 tests * Improve error reporting * Fix linting errors * Add testing of enum ans struct sequences Refactor error message handling * Moved _get_datatyoe_schema into MS05Utils * Make TestMetadata an inner class * Use TestMetadata inner class. Remove unneeded data members. * Added NcDescriptor and NcPropertyDescriptor classes * Refactor to use NcPropertyDescriptor class * Refactored NcPropertyId and NcTouchpoint types * Refactor dictionaries into classes * Update formatting of strings * Consistent quotes * Renamed test_data directory from IS1201 to MS05 * Refactored names of functions, improved consistency of strings * Create NcFieldDescriptor, NcParameterDescriptor and NcMethodDescriptor classes * Introduced constraint domain classes. Refactored test logic. * Handle 'any' datatype in method descriptors * Consistent formatting of strings. Refactor to use domain classes * Utility functions to format class ids and role paths. Create NcMethosId class. Replace "context" parameters with role paths * Remove context parameter and use role_path instead * Remove MS-05-02 error handling from IS12Utils * Add NcMethodResult types * Remove redundant imports * Formatting * Handle MS-05-02 errors * get_property returns NcMethodResult object * set_property returns NcMethodResult * invoke_method returns NcMethodResult * get_sequence_item returns NcMethodResult * get_sequence_length returns NcMethodResult * set_sequence_item returns NcMethodResult * add_sequence_item returns NcMethodResultId * remove_sequence_item returns NcMethodResult * get_member_descriptor returns NcMethodResult * find_members_by_path returns NcMethodResult * find_members_by_role returns NcMethodResult * find_members_by_class_id returns NcMethodResult * get_control_class returns NcMethodResult * get_datatype returns NcMethodResult * Use NcPropertyId and NcMethodId instead of raw dict * Implement IS12Notification class * Implement NcPropertyChangedEventData * Implement IS12CommandResponse class * Check subscription response * Refactor checking of Block members * Formatting * Implement IS12Error class. Formatting * Refine IS14Utils error handling * Fix method invocation JSON * Simplify property constraints checking * Fix dicts embedded in f-strings * Add spec links to test failures * Fix dicts embedded in f-strings * Fix embedded code strings in f-strings * Fix embedded code strings in f-strings * Format error messages * Refactored constraints testing * Improve notifications handling * Flake8 formatting * Rename context to error_msg_base * consistent format of error messages * Better handling of IS-12 errors * Add robustness for missing classes and datatype definitions * Consistent formatting of error messages * Improve constraints testing * Add NcEventDescriptor * Validate parameter constraints. Check for illegal non-standard datatypes * Minor bug fixes * Update comments * Clearly indicate private helper functions * Simplify constraints checking tests * Clearly indicate private helper functions * Improve error message * Allow calling test to explicitly set test method name reported in Testing Facade * Fix interaction with Testing Facade * Format error message * Remove IS-14 test suites * Improve descriptor validation error reporting * Better handling of TestFacade errors. Add config to switch off invasive tests * Move MS0502 tests to MS0501 * Remove MS0502 and IS1202 * Enable running of auto tests in test suites derived from ControllerTest * Move auto_tests into MS05Utils * Removed IS14Utils from IS-12 test * Fixed typo * Fixes _get_methods function * Update documentation * Typos * Fix crash when running IS-12 test suite with unicast DNS mode enabled * Fix linting --------- Co-authored-by: lo-simon <simon.lo@sony.com> Co-authored-by: Gareth Sylvester-Bradley <garethsb@nvidia.com> Co-authored-by: Gareth Sylvester-Bradley <31761158+garethsb@users.noreply.github.com> Co-authored-by: alabou <abouchar@matrox.com>
1 parent abe4ac4 commit dcc9452

29 files changed

+5062
-44
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ The following test suites are currently supported.
3232
| IS-09-01 | IS-09 System API | | (X) | | System Parameters Server |
3333
| IS-09-02 | IS-09 System API Discovery | X | | | |
3434
| IS-10-01 | IS-10 Authorization API | | | | Authorization Server |
35+
| IS-12-01 | IS 12 Control Protocol API | X | | | See [Invasive Device Model Testing](docs/2.10%20Usage%20-%20Invasive%20Device%20Model%20Testing.md) |
3536
| - | BCP-002-01 Natural Grouping | X | | | Included in IS-04 Node API suite |
3637
| - | BCP-002-02 Asset Distinguishing Information | X | | | Included in IS-04 Node API suite |
3738
| BCP-003-01 | BCP-003-01 Secure Communication | X | X | | See [Testing TLS](docs/2.2.%20Usage%20-%20Testing%20BCP-003-01%20TLS.md) |

docs/2.0. Usage.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ The following pages provide information on additional instructions for testing s
4444
- [SDP Files](2.4.%20Usage%20-%20Testing%20of%20SDP%20Files.md)
4545
- [IS-07 MQTT](2.7.%20Usage%20-%20Testing%20IS-07%20MQTT.md)
4646
- [Controllers](2.8.%20Usage%20-%20Testing%20Controllers.md)
47+
- [Invasive Device Model Testing](2.10%20Usage%20-%20Invasive%20Device%20Model%20Testing.md)
4748

4849
## Non-interactive Testing
4950

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Invasive Device Model Testing
2+
3+
## Running Invasive Device Model Tests
4+
5+
Invasive tests are those that attempt to change the values of properties, and execute methods on the Device Model of a Node under Test (NuT).
6+
Non-invasive tests are limited to changing only the value of User Labels in the NuT's Device Model.
7+
8+
By default, the `IS-12-01` test suite will __NOT__ execute invasive tests; these can be enabled by setting `MS05_INVASIVE_TESTING` to `True` in your `UserConfig.py` file as described in [Installation](1.0.%20Installation.md).
9+
10+
## Running Interactive Invasive Tests
11+
12+
When running invasive tests, the Testing Façade can be used by a user to interactively select which properties and methods of the NuT's Device Model are subject to invasive testing.
13+
14+
Interactive mode is disabled by default, but can be enabled by setting `MS05_INTERACTIVE_TESTING` to `True` in your `UserConfig.py` file.
15+
16+
Use the following command to launch the Testing Façade:
17+
18+
```shell
19+
python3 nmos-testing-facade.py
20+
```
21+
22+
By default the Testing Façade will run on localhost port 5001. This can be altered by adding `TESTING_FACADE_PORT` to your `UserConfig.py` file.
23+
24+
In the NMOS Testing Tool, when running the `IS-12-01` test suite, provide the IP/hostname of the Testing Façade (e.g. localhost) and the port of the Testing Façade (use 5001 by default).

nmostesting/Config.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@
6161
# Number of seconds to wait before timing out Controller test. Set to None to disable timeout mechanism
6262
CONTROLLER_TESTING_TIMEOUT = 120
6363

64+
# When True invasive MS-05 tests will be run as part of MS0501Test test suite
65+
MS05_INVASIVE_TESTING = False
66+
67+
# Used when MS05_INVASIVE_TESTING is set to True.
68+
# When True invasive MS-05 tests will use the TestingFacade to allow user interaction
69+
MS05_INTERACTIVE_TESTING = False
70+
6471
# Set a Query API hostname/IP and port for use when operating without DNS-SD
6572
QUERY_API_HOST = "127.0.0.1"
6673
QUERY_API_PORT = 80
@@ -280,6 +287,37 @@
280287
}
281288
}
282289
},
290+
"is-12": {
291+
"repo": "is-12",
292+
"versions": ["v1.0"],
293+
"default_version": "v1.0",
294+
"apis": {
295+
"ncp": {
296+
"name": "Control Protocol"
297+
},
298+
}
299+
},
300+
"ms-05-02": {
301+
"repo": "ms-05-02",
302+
"versions": ["v1.0"],
303+
"default_version": "v1.0",
304+
"apis": {
305+
"controlframework": {
306+
"name": "Control Framework"
307+
},
308+
}
309+
},
310+
"nmos-control-feature-sets": {
311+
"repo": "nmos-control-feature-sets",
312+
"versions": ["main"],
313+
"default_version": "main",
314+
"apis": {
315+
"featuresets": {
316+
"name": "Control Feature Sets",
317+
"repo_paths": ["identification", "monitoring"]
318+
}
319+
}
320+
},
283321
"bcp-002-01": {
284322
"repo": "bcp-002-01",
285323
"versions": ["v1.0"],

nmostesting/ControllerTest.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,18 @@ class ControllerTest(GenericTest):
7676
"""
7777
Testing initial set up of new test suite for controller testing
7878
"""
79-
def __init__(self, apis, registries, node, dns_server, disable_auto=True):
79+
def __init__(self, apis, registries, node, dns_server, auths, disable_auto=True, **kwargs):
8080
# Remove the spec_path as there are no corresponding GitHub repos for Controller Tests
8181
apis[CONTROLLER_TEST_API_KEY].pop("spec_path", None)
8282
if CONFIG.ENABLE_HTTPS:
8383
# Comms with Testing Facade are http only
84-
apis[CONTROLLER_TEST_API_KEY]["base_url"] \
85-
= apis[CONTROLLER_TEST_API_KEY]["base_url"].replace("https", "http")
86-
apis[CONTROLLER_TEST_API_KEY]["url"] = apis[CONTROLLER_TEST_API_KEY]["url"].replace("https", "http")
87-
GenericTest.__init__(self, apis, disable_auto=disable_auto)
88-
self.authorization = False
84+
if apis[CONTROLLER_TEST_API_KEY]["base_url"] is not None:
85+
apis[CONTROLLER_TEST_API_KEY]["base_url"] \
86+
= apis[CONTROLLER_TEST_API_KEY]["base_url"].replace("https", "http")
87+
if apis[CONTROLLER_TEST_API_KEY]["url"] is not None:
88+
apis[CONTROLLER_TEST_API_KEY]["url"] \
89+
= apis[CONTROLLER_TEST_API_KEY]["url"].replace("https", "http")
90+
GenericTest.__init__(self, apis, auths=auths, disable_auto=disable_auto)
8991
self.primary_registry = registries[1]
9092
self.node = node
9193
self.dns_server = dns_server
@@ -156,11 +158,11 @@ def execute_tests(self, test_names):
156158
if len(test_names) == 1 and test_names[0] == "auto" and self.disable_auto:
157159
return
158160

161+
self.primary_registry.query_api_called = False
162+
159163
self.pre_tests_message()
160164

161-
for test_name in test_names:
162-
self.primary_registry.query_api_called = False
163-
self.execute_test(test_name)
165+
super().execute_tests(test_names)
164166

165167
self.post_tests_message()
166168

@@ -242,9 +244,11 @@ def _wait_for_testing_facade(self, question_id, test_type):
242244

243245
return answer_response
244246

245-
def _invoke_testing_facade(self, question, answers, test_type, multipart_test=None, metadata=None):
247+
def _invoke_testing_facade(self, question, answers, test_type,
248+
multipart_test=None, metadata=None, test_method_name=None):
246249
# Get the name of the calling test method to use as an identifier
247-
test_method_name = inspect.currentframe().f_back.f_code.co_name
250+
test_method_name = test_method_name if test_method_name \
251+
else inspect.currentframe().f_back.f_code.co_name
248252

249253
json_out = self._send_testing_facade_questions(
250254
test_method_name, question, answers, test_type, multipart_test, metadata)

0 commit comments

Comments
 (0)