-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[IS-12] Initial Commit for IS-12 Test Suite #800
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
7338dc0
Initial commit
jonathan-r-thorpe b515423
Added IS-12 spec to Config
jonathan-r-thorpe 011c5c4
Updated specs for IS-12-01 test suite
jonathan-r-thorpe 1497e79
Implement NCP endpoint and create WebSocket tests
jonathan-r-thorpe 11b7711
Merge branch 'AMWA-TV:master' into is-12-jrt
jonathan-r-thorpe f00f937
Updated API name
jonathan-r-thorpe abeef7c
Updated test definition.
jonathan-r-thorpe 16b9392
Improve control endpoint checking
jonathan-r-thorpe ee9b314
Use of compare_urls to test Control Protocol `href`
lo-simon 3ad74e6
Update nmostesting/suites/IS1201Test.py
lo-simon 043c6a0
Update nmostesting/suites/IS1201Test.py
lo-simon 5bb73fd
Merge pull request #3 from jonathan-r-thorpe/is-12-sl
jonathan-r-thorpe 42666cc
Corrected formatting. Improved WebSocket handling
jonathan-r-thorpe ea41b46
Refactored control API checking
jonathan-r-thorpe 16a9b83
Corrected failure case in test_02
jonathan-r-thorpe 6c0ec6f
Merge remote-tracking branch 'origin/master' into is-12-jrt
garethsb 68eac96
Use NMOSUtils.do_test_device_control
garethsb 47763ce
Test WebSocket services and controls are as secure as HTTP endpoints
garethsb 4308aa1
Merge pull request #4 from garethsb/is-12-jrt-patch-1
jonathan-r-thorpe 2c38aba
Fix protocol bug, remove stripping of trailing slash
jonathan-r-thorpe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# Copyright (C) 2023 Advanced Media Workflow Association | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import time | ||
|
||
from .. import Config as CONFIG | ||
from ..GenericTest import GenericTest, NMOSTestException | ||
from ..IS04Utils import IS04Utils | ||
from ..TestHelper import WebsocketWorker | ||
|
||
NODE_API_KEY = "node" | ||
CONTROL_API_KEY = "ncp" | ||
|
||
|
||
class IS1201Test(GenericTest): | ||
|
||
def __init__(self, apis, **kwargs): | ||
# Remove the RAML key to prevent this test suite from auto-testing IS-04 API | ||
apis[NODE_API_KEY].pop("raml", None) | ||
garethsb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
GenericTest.__init__(self, apis, **kwargs) | ||
self.node_url = self.apis[NODE_API_KEY]["url"] | ||
self.ncp_url = self.apis[CONTROL_API_KEY]["url"] | ||
self.is04_utils = IS04Utils(self.node_url) | ||
self.ncp_websocket = None | ||
|
||
def set_up_tests(self): | ||
# Do nothing | ||
pass | ||
|
||
def tear_down_tests(self): | ||
# Clean up Websocket resources | ||
if self.ncp_websocket: | ||
self.ncp_websocket.close() | ||
|
||
def test_01(self, test): | ||
"""At least one Device is showing an IS-12 control advertisement matching the API under test""" | ||
|
||
control_type = "urn:x-nmos:control:ncp/" + self.apis[CONTROL_API_KEY]["version"] | ||
return self.is04_utils.do_test_device_control( | ||
test, | ||
self.node_url, | ||
control_type, | ||
self.ncp_url, | ||
self.authorization | ||
) | ||
|
||
def create_ncp_socket(self, test): | ||
# Reuse socket if connection already established | ||
if self.ncp_websocket: | ||
return True | ||
|
||
# Create a WebSocket connection to NMOS Control Protocol endpoint | ||
self.ncp_websocket = WebsocketWorker(self.apis[CONTROL_API_KEY]["url"]) | ||
self.ncp_websocket.start() | ||
|
||
# Give WebSocket client a chance to start and open its connection | ||
start_time = time.time() | ||
while time.time() < start_time + CONFIG.WS_MESSAGE_TIMEOUT: | ||
if self.ncp_websocket.is_open(): | ||
break | ||
time.sleep(0.2) | ||
|
||
if self.ncp_websocket.did_error_occur(): | ||
raise NMOSTestException(test.FAIL("Error opening WebSocket connection to {}: {}" | ||
.format(self.apis[CONTROL_API_KEY]["url"], | ||
self.ncp_websocket.get_error_message()))) | ||
else: | ||
return self.ncp_websocket.is_open() | ||
|
||
def test_02(self, test): | ||
"""WebSocket successfully opened on advertised urn:x-nmos:control:ncp endpoint""" | ||
|
||
if not self.create_ncp_socket(test): | ||
return test.FAIL("Failed to open WebSocket successfully") | ||
|
||
return test.PASS("WebSocket successfully opened") |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably this is OK for first iteration, but what do you think about whether
websocket
andselector
flags belong in the spec definitions rather than the test suite definitions?