Skip to content
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

Val: video test stubs and media-proxy related fixtures #304

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
8b4a088
:doc: change libmcm_dp.so dir path in README (#283)
KarolinaPomian Dec 5, 2024
76484e3
Rewrite test app (#284)
zLukas Dec 12, 2024
45364da
[VAL] Initial push for pytest engine (#273)
MateuszGrabuszynski Dec 18, 2024
c332faf
Merge branch 'main' into val-dev
MateuszGrabuszynski Dec 18, 2024
7910275
Modifying validation app's path in CMakeLists.txt
MateuszGrabuszynski Dec 18, 2024
dc48155
Trying to add a fixture to kill existing media_proxies and spawn new …
MateuszGrabuszynski Dec 18, 2024
a6b8945
Properly marking test_video.py with fixtures
MateuszGrabuszynski Dec 18, 2024
439d2a8
Revert "Properly marking test_video.py with fixtures"
MateuszGrabuszynski Dec 19, 2024
4c15ff1
Escapes for paths in subprocess.run() and TODOs for media_proxy-relat…
MateuszGrabuszynski Dec 19, 2024
2e0d5bd
Parametrizing test_video() with yuv_files.keys()
MateuszGrabuszynski Dec 19, 2024
c3835ba
Fix: wrong connection.st2110.transport value
MateuszGrabuszynski Jan 10, 2025
c88c7fd
Add: removal of sent file at the end of test to avoid disk full errors
MateuszGrabuszynski Jan 10, 2025
012268d
Add: tests of mock for cluster and st2110 video transfers
MateuszGrabuszynski Jan 10, 2025
766d8f5
Merge branch 'main' into val-fixtures
MateuszGrabuszynski Jan 13, 2025
4abb4ae
Merge branch 'main' into val-fixtures
MateuszGrabuszynski Jan 16, 2025
276787d
Merge branch 'main' into val-fixtures
MateuszGrabuszynski Jan 21, 2025
1e78523
in tests/validation: Extending copyright with 2024-2025; Removing Int…
MateuszGrabuszynski Jan 22, 2025
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
4 changes: 2 additions & 2 deletions tests/validation/Engine/client_json.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2024 Intel Corporation
# Intel® Media Communications Mesh
# Copyright 2024-2025 Intel Corporation
# Media Communications Mesh

import json

Expand Down
6 changes: 3 additions & 3 deletions tests/validation/Engine/connection.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2024 Intel Corporation
# Intel® Media Communications Mesh
# Copyright 2024-2025 Intel Corporation
# Media Communications Mesh

from enum import Enum

Expand Down Expand Up @@ -72,7 +72,7 @@ def to_dict(self) -> dict:
return {
"connection": {
"st2110": {
"transport": self.transport.value[0],
"transport": self.transport.value,
"remoteIpAddr": self.remoteIpAddr,
"remotePort": self.remotePort,
"pacing": self.pacing,
Expand Down
4 changes: 2 additions & 2 deletions tests/validation/Engine/connection_json.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2024 Intel Corporation
# Intel® Media Communications Mesh
# Copyright 2024-2025 Intel Corporation
# Media Communications Mesh

import json

Expand Down
4 changes: 2 additions & 2 deletions tests/validation/Engine/connection_json_usage_example.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2024 Intel Corporation
# Intel® Media Communications Mesh
# Copyright 2024-2025 Intel Corporation
# Media Communications Mesh

from connection import ConnectionMode, Rdma, St2110, TransportType
from connection_json import ConnectionJson
Expand Down
4 changes: 2 additions & 2 deletions tests/validation/Engine/connection_usage_example.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2024 Intel Corporation
# Intel® Media Communications Mesh
# Copyright 2024-2025 Intel Corporation
# Media Communications Mesh

from connection import ConnectionMode, Rdma, St2110, TransportType

Expand Down
4 changes: 2 additions & 2 deletions tests/validation/Engine/const.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2024 Intel Corporation
# Intel® Media Communications Mesh
# Copyright 2024-2025 Intel Corporation
# Media Communications Mesh

LOG_FOLDER = "logs"
4 changes: 2 additions & 2 deletions tests/validation/Engine/csv_report.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2024 Intel Corporation
# Intel® Media Communications Mesh
# Copyright 2024-2025 Intel Corporation
# Media Communications Mesh

import csv

Expand Down
14 changes: 12 additions & 2 deletions tests/validation/Engine/engine_mcm.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2024 Intel Corporation
# Intel® Media Communications Mesh
# Copyright 2024-2025 Intel Corporation
# Media Communications Mesh

import logging
import os
Expand Down Expand Up @@ -50,6 +50,14 @@ def stop_rx_app(rx: Engine.execute.AsyncProcess):
rx.process.wait()


def remove_sent_file(file_path: str, app_path: str):
# filepath "/x/y/z.yuv", app_path "/a/b/"
# removes /a/b/z.yuv
removal_path = f'{app_path}/{file_path.split("/")[-1]}'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using Pathlib is more convenient I believe

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is, let me change that, thanks for the suggestion :)

logging.debug(f"Removing: {removal_path}")
os.remove(removal_path)


def run_rx_tx_with_file(file_path: str, build: str):
app_path = os.path.join(build, "tests", "tools", "TestApp", "build")

Expand All @@ -59,3 +67,5 @@ def run_rx_tx_with_file(file_path: str, build: str):
handle_tx_failure(tx)
finally:
stop_rx_app(rx)
# TODO: Add checks for transmission errors
remove_sent_file(file_path, app_path)
4 changes: 2 additions & 2 deletions tests/validation/Engine/execute.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2024 Intel Corporation
# Intel® Media Communications Mesh
# Copyright 2024-2025 Intel Corporation
# Media Communications Mesh

import logging
import os
Expand Down
4 changes: 2 additions & 2 deletions tests/validation/Engine/fixtures.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2024 Intel Corporation
# Intel® Media Communications Mesh
# Copyright 2024-2025 Intel Corporation
# Media Communications Mesh

import os
from typing import Dict
Expand Down
42 changes: 34 additions & 8 deletions tests/validation/Engine/fixtures_mcm.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2024 Intel Corporation
# Intel® Media Communications Mesh
# Copyright 2024-2025 Intel Corporation
# Media Communications Mesh
import os
import subprocess

Expand All @@ -10,16 +10,42 @@
@pytest.fixture(scope="session")
def build_TestApp(build):
path = os.path.join(build, "tests", "tools", "TestApp", "build")
subprocess.run(f"rm -rf {path}", shell=True, timeout=10)
subprocess.run(f"mkdir -p {path}", shell=True, timeout=10)
subprocess.run(f'rm -rf "{path}"', shell=True, timeout=10)
subprocess.run(f'mkdir -p "{path}"', shell=True, timeout=10)
subprocess.run("cmake ..", cwd=path, shell=True, timeout=10)
subprocess.run("make", cwd=path, shell=True, timeout=10)


@pytest.fixture(scope="package")
def media_proxy_single():
# Run single media proxy
pass
def kill_all_existing_media_proxies():
# TODO: This assumes the way previous media_proxy worked will not change in the new version, which is unlikely
"Kills all existing media_proxy processes using their PIDs found with px -aux"
existing_mps = subprocess.run("ps -aux | awk '/media_proxy/{print($2)}'", shell=True, capture_output=True)
mp_pids = existing_mps.stdout.decode("utf-8").split() # returns an array of PIDs
(subprocess.run(f"kill -9 {mp_pid}", shell=True) for mp_pid in mp_pids)


@pytest.fixture(scope="package", autouse=False)
def media_proxy_single(sender_mp_port: int, receiver_mp_port: int, kill_existing: bool = True):
# TODO: This assumes the way previous media_proxy worked will not change in the new version, which is unlikely
"""Opens new media_proxies for sender and receiver.
May optionally kill the already-running media_proxies first.

Arguments:
sender_mp_port(int): specifies the port number for sender
receiver_mp_port(int): specifies the port number for receiver

Keyword arguments:
kill_existing(bool, optional): if use kill_all_existing_media_proxies() function to kill -9 all existing
media_proxies before running new instances
"""
if kill_existing:
kill_all_existing_media_proxies()
# create new media_proxy processes for sender and receiver
sender_mp_proc = subprocess.Popen(f"media_proxy -t {sender_mp_port}") # sender's media_proxy
receiver_mp_proc = subprocess.Popen(f"media_proxy -t {receiver_mp_port}") # receiver media_proxy
yield
sender_mp_proc.terminate()
receiver_mp_proc.terminate()


@pytest.fixture(scope="package")
Expand Down
4 changes: 2 additions & 2 deletions tests/validation/Engine/logging.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2024 Intel Corporation
# Intel® Media Communications Mesh
# Copyright 2024-2025 Intel Corporation
# Media Communications Mesh

import datetime
import logging
Expand Down
4 changes: 2 additions & 2 deletions tests/validation/Engine/media_files.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2024 Intel Corporation
# Intel® Media Communications Mesh
# Copyright 2024-2025 Intel Corporation
# Media Communications Mesh

# This file is a copy retreived from an MTL project

Expand Down
4 changes: 2 additions & 2 deletions tests/validation/Engine/payload.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2024 Intel Corporation
# Intel® Media Communications Mesh
# Copyright 2024-2025 Intel Corporation
# Media Communications Mesh

from enum import Enum

Expand Down
4 changes: 2 additions & 2 deletions tests/validation/Engine/payload_usage_example.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2024 Intel Corporation
# Intel® Media Communications Mesh
# Copyright 2024-2025 Intel Corporation
# Media Communications Mesh

from payload import Audio, Video

Expand Down
4 changes: 2 additions & 2 deletions tests/validation/Engine/stash.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2024 Intel Corporation
# Intel® Media Communications Mesh
# Copyright 2024-2025 Intel Corporation
# Media Communications Mesh

import os
from typing import List
Expand Down
4 changes: 2 additions & 2 deletions tests/validation/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2024 Intel Corporation
# Intel® Media Communications Mesh
# Copyright 2024-2025 Intel Corporation
# Media Communications Mesh

pytest_plugins = ["Engine.fixtures", "Engine.logging", "Engine.fixtures_mcm"]

Expand Down
35 changes: 35 additions & 0 deletions tests/validation/functional/cluster/video/test_video.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2024-2025 Intel Corporation
# Media Communications Mesh
import os
import pytest

import Engine.client_json
import Engine.connection
import Engine.connection_json
import Engine.engine_mcm as utils
import Engine.execute
import Engine.payload
from Engine.media_files import yuv_files


@pytest.mark.parametrize("video_type", [k for k in yuv_files.keys()])
def test_video(build_TestApp, build: str, media: str, video_type):
client = Engine.client_json.ClientJson()
conn_mpg = Engine.connection.Rdma()
payload = Engine.payload.Video(
width=yuv_files[video_type]["width"],
height=yuv_files[video_type]["height"],
fps=yuv_files[video_type]["fps"],
pixelFormat=yuv_files[video_type]["format"],
)
connection = Engine.connection_json.ConnectionJson(connection=conn_mpg, payload=payload)

utils.create_client_json(build, client)
utils.create_connection_json(build, connection)

# Use a specified file from media_files.py
media_file = yuv_files[video_type]["filename"]
media_file_path = os.path.join(media, media_file)

utils.run_rx_tx_with_file(file_path=media_file_path, build=build)
17 changes: 12 additions & 5 deletions tests/validation/functional/local/video/test_video.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2024 Intel Corporation
# Intel® Media Communications Mesh
# Copyright 2024-2025 Intel Corporation
# Media Communications Mesh
import os
import pytest

import Engine.client_json
import Engine.connection
Expand All @@ -12,17 +13,23 @@
from Engine.media_files import yuv_files


def test_video(build_TestApp, build: str, media: str):
@pytest.mark.parametrize("video_type", [k for k in yuv_files.keys()])
def test_video(build_TestApp, build: str, media: str, video_type):
client = Engine.client_json.ClientJson()
conn_mpg = Engine.connection.MultipointGroup()
payload = Engine.payload.Video(width=3840, height=2160)
payload = Engine.payload.Video(
width=yuv_files[video_type]["width"],
height=yuv_files[video_type]["height"],
fps=yuv_files[video_type]["fps"],
pixelFormat=yuv_files[video_type]["format"],
)
connection = Engine.connection_json.ConnectionJson(connection=conn_mpg, payload=payload)

utils.create_client_json(build, client)
utils.create_connection_json(build, connection)

# Use a specified file from media_files.py
media_file = yuv_files["i2160p25"]["filename"]
media_file = yuv_files[video_type]["filename"]
media_file_path = os.path.join(media, media_file)

utils.run_rx_tx_with_file(file_path=media_file_path, build=build)
35 changes: 35 additions & 0 deletions tests/validation/functional/st2110/st20/test_video.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2024-2025 Intel Corporation
# Media Communications Mesh
import os
import pytest

import Engine.client_json
import Engine.connection
import Engine.connection_json
import Engine.engine_mcm as utils
import Engine.execute
import Engine.payload
from Engine.media_files import yuv_files


@pytest.mark.parametrize("video_type", [k for k in yuv_files.keys()])
def test_video(build_TestApp, build: str, media: str, video_type):
client = Engine.client_json.ClientJson()
conn_mpg = Engine.connection.St2110()
payload = Engine.payload.Video(
width=yuv_files[video_type]["width"],
height=yuv_files[video_type]["height"],
fps=yuv_files[video_type]["fps"],
pixelFormat=yuv_files[video_type]["format"],
)
connection = Engine.connection_json.ConnectionJson(connection=conn_mpg, payload=payload)

utils.create_client_json(build, client)
utils.create_connection_json(build, connection)

# Use a specified file from media_files.py
media_file = yuv_files[video_type]["filename"]
media_file_path = os.path.join(media, media_file)

utils.run_rx_tx_with_file(file_path=media_file_path, build=build)