-
Notifications
You must be signed in to change notification settings - Fork 17
[Camera] Adds support for camera app yaml test cases through camera-controller #213
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
base: v2.13-develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,10 +14,13 @@ | |
# limitations under the License. | ||
# | ||
import asyncio | ||
import socket | ||
|
||
from fastapi import APIRouter, WebSocket | ||
from fastapi.websockets import WebSocketDisconnect | ||
from loguru import logger | ||
|
||
from app.constants.websockets_constants import UDP_SOCKET_INTERFACE, UDP_SOCKET_PORT | ||
from app.socket_connection_manager import SocketConnectionManager | ||
|
||
router = APIRouter() | ||
|
@@ -41,3 +44,29 @@ async def websocket_endpoint(websocket: WebSocket) -> None: | |
|
||
except WebSocketDisconnect: | ||
socket_connection_manager.disconnect(websocket) | ||
|
||
|
||
@router.websocket("/ws/video") | ||
async def websocket_video_endpoint(websocket: WebSocket) -> None: | ||
try: | ||
await websocket.accept() | ||
logger.info(f'Websocket connected: "{websocket}".') | ||
except RuntimeError as e: | ||
logger.info(f'Failed to connect with error: "{e}".') | ||
raise e | ||
|
||
try: | ||
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, 0) | ||
sock.bind((UDP_SOCKET_INTERFACE, UDP_SOCKET_PORT)) | ||
logger.info("UDP socket bound successfully") | ||
loop = asyncio.get_event_loop() | ||
while True: | ||
data, _ = await loop.run_in_executor(None, sock.recvfrom, 65536) | ||
# send data to ws | ||
await websocket.send_bytes(data) | ||
Comment on lines
+59
to
+66
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible to use |
||
except WebSocketDisconnect: | ||
logger.info(f'Websocket for video stream disconnected: "{websocket}".') | ||
except Exception as e: | ||
logger.info(f"Failed with {e}") | ||
finally: | ||
await websocket.close() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -165,7 +165,8 @@ def _append_automated_test_step(self, yaml_step: MatterTestStep) -> None: | |
Disabled steps are ignored. | ||
(Such tests will be marked as 'Steps Disabled' elsewhere) | ||
|
||
UserPrompt are special cases that will prompt test operator for input. | ||
UserPrompt, PromptWithResponse or VerifyVideoStream are special cases that will | ||
prompt test operator for input. | ||
""" | ||
if yaml_step.disabled: | ||
test_engine_logger.info( | ||
|
@@ -174,7 +175,11 @@ def _append_automated_test_step(self, yaml_step: MatterTestStep) -> None: | |
return | ||
|
||
step = TestStep(yaml_step.label) | ||
if yaml_step.command == "UserPrompt": | ||
if yaml_step.command in [ | ||
"UserPrompt", | ||
"PromptWithResponse", | ||
"VerifyVideoStream", | ||
]: | ||
Comment on lines
+178
to
+182
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think someone mentioned before, but anyway I think that would be good to store this array in a variable to use whenever necessary. |
||
step = ManualVerificationTestStep( | ||
name=yaml_step.label, | ||
verification=yaml_step.verification, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,8 +50,12 @@ def _test_type(test: YamlTest) -> MatterTestType: | |
if all(s.disabled is True for s in steps): | ||
return MatterTestType.MANUAL | ||
|
||
# if any step has a UserPrompt, categorize as semi-automated | ||
if any(s.command == "UserPrompt" for s in steps): | ||
# if any step has a UserPrompt, PromptWithResponse or VerifyVideoStream command, | ||
# categorize as semi-automated | ||
if any( | ||
s.command in ["UserPrompt", "PromptWithResponse", "VerifyVideoStream"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as before: |
||
for s in steps | ||
): | ||
return MatterTestType.SEMI_AUTOMATED | ||
|
||
# Otherwise Automated | ||
|
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.
Is it ok to replace for something similar to the
websocket_endpoint()
?Like: