Skip to content

Commit

Permalink
Mod: removal of unnecessary todos, cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
MateuszGrabuszynski committed Feb 17, 2025
1 parent f545a4d commit a83e2a2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 55 deletions.
39 changes: 13 additions & 26 deletions tests/validation/Engine/engine_mcm.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,15 @@ def create_connection_json(build: str, connection: ConnectionJson, filename: str


def run_rx_app(
client_cfg_file: str,
connection_cfg_file: str,
path_to_output_file: str,
cwd: str,
timeout: int = 0,
mcm_media_proxy_port: int = -1
) -> AsyncProcess:
client_cfg_file: str, connection_cfg_file: str,
path_to_output_file: str, cwd: str, timeout: int = 0,
mcm_media_proxy_port: int = -1) -> AsyncProcess:
env = ({"MCM_MEDIA_PROXY_PORT": str(mcm_media_proxy_port)} if mcm_media_proxy_port != -1 else {})
return call(
f"./RxApp {client_cfg_file} {connection_cfg_file} {path_to_output_file}",
cwd=cwd,
timeout=timeout,
env=env
)
env=env)


def run_tx_app(
Expand All @@ -72,8 +67,7 @@ def run_tx_app(
return run(
f"./TxApp {client_cfg_file} {connection_cfg_file} {path_to_input_file}",
cwd=cwd,
env=env
)
env=env)


def handle_tx_failure(tx: subprocess.CompletedProcess) -> None:
Expand Down Expand Up @@ -108,17 +102,12 @@ def remove_sent_file(full_path: Path) -> None:


def run_rx_tx_with_file(
file_path: str,
build: str,
timeout: int = 0,
media_info = {},
rx_mp_port: int = -1,
tx_mp_port: int = -1,
rx_client_filename: str = "client.json",
tx_client_filename: str = "client.json",
rx_connection_filename: str = "connection.json",
tx_connection_filename: str = "connection.json",
) -> None:
file_path: str, build: str, timeout: int = 0, media_info = {},
rx_mp_port: int = -1, tx_mp_port: int = -1,
rx_client_filename: str = "client.json",
tx_client_filename: str = "client.json",
rx_connection_filename: str = "connection.json",
tx_connection_filename: str = "connection.json") -> None:
app_path = Path(build, "tests", "tools", "TestApp", "build")

try:
Expand All @@ -134,16 +123,14 @@ def run_rx_tx_with_file(
path_to_output_file=str(output_file_path),
cwd=app_path,
timeout=timeout,
mcm_media_proxy_port=rx_mp_port
)
mcm_media_proxy_port=rx_mp_port)
time.sleep(2) # 2 seconds for RxApp to spin up
tx = run_tx_app(
client_cfg_file=tx_client_cfg_file,
connection_cfg_file=tx_connection_cfg_file,
path_to_input_file=file_path,
cwd=app_path,
mcm_media_proxy_port=tx_mp_port
)
mcm_media_proxy_port=tx_mp_port)
time.sleep(5) # 5 seconds for TxApp to shut down before handling it as a failure
handle_tx_failure(tx)
stop_rx_app(rx)
Expand Down
4 changes: 2 additions & 2 deletions tests/validation/Engine/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ def call(command: str, cwd: str, timeout: int = 60, sigint: bool = False, env: d


def calls(
commands: List[str], cwd: str = None, timeout: int = 60, sigint: bool = False, env: dict = None
) -> List[AsyncProcess]:
commands: List[str], cwd: str = None, timeout: int = 60,
sigint: bool = False, env: dict = None) -> List[AsyncProcess]:
ret = []
for command in commands:
process = subprocess.Popen(
Expand Down
35 changes: 8 additions & 27 deletions tests/validation/Engine/fixtures_mcm.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,30 +46,14 @@ def kill_all_existing_media_proxies() -> None:

@pytest.fixture(scope="function", autouse=False)
def media_proxy_single() -> None:
kill_existing = True
# TODO: This assumes the way previous media_proxy worked will not change in the new version, which is unlikely
# TODO: Re-add the parameters properly
"""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()
kill_all_existing_media_proxies()

# mesh-agent start
mesh_agent_proc = call(f"mesh-agent", cwd=".")
time.sleep(0.2) # short sleep used for mesh-agent to spin up
if mesh_agent_proc.process.returncode:
logging.debug(f"mesh-agent's return code: {mesh_agent_proc.returncode} of type {type(mesh_agent_proc.returncode)}")
# single media_proxy start
# TODO: Add parameters to media_proxy
sender_mp_proc = call(f"media_proxy", cwd=".")
time.sleep(0.2) # short sleep used for media_proxy to spin up
if sender_mp_proc.process.returncode:
Expand All @@ -89,17 +73,14 @@ def media_proxy_single() -> None:
# Run dual media proxy
@pytest.fixture(scope="function", autouse=False)
def media_proxy_cluster(
tx_mp_port: int = 8002,
rx_mp_port: int = 8003,
tx_rdma_ip: str = "192.168.95.1",
rx_rdma_ip: str = "192.168.95.2",
tx_rdma_port_range: str = "9100-9119",
rx_rdma_port_range: str = "9120-9139",
) -> None:
tx_mp_port: int = 8002,
rx_mp_port: int = 8003,
tx_rdma_ip: str = "192.168.95.1",
rx_rdma_ip: str = "192.168.95.2",
tx_rdma_port_range: str = "9100-9119",
rx_rdma_port_range: str = "9120-9139") -> None:
# kill all existing media proxies first
kill_existing = True # TODO: Make it parametrized
if kill_existing:
kill_all_existing_media_proxies()
kill_all_existing_media_proxies()

# start mesh-agent
mesh_agent_proc = call(f"mesh-agent", cwd=".")
Expand Down

0 comments on commit a83e2a2

Please sign in to comment.