Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 5 additions & 1 deletion cvs/lib/report_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,11 @@ def _update_environment_config_links(self, html_content):
updated_json = json.dumps(data)
encoded_json = html.escape(updated_json, quote=True)

html_content = re.sub(json_pattern, f'data-jsonblob="{encoded_json}"', html_content)
# Function-form replacement avoids re.sub's backslash-escape
# processing on string replacements (which would convert JSON's
# 2-char `\n` / `\t` escapes into raw 0x0A / 0x09 bytes, breaking
# the data-jsonblob and emptying the results table in the browser).
html_content = re.sub(json_pattern, lambda _m: f'data-jsonblob="{encoded_json}"', html_content)

except json.JSONDecodeError as e:
log.error("Failed to parse JSON data: %s", e)
Expand Down
38 changes: 38 additions & 0 deletions cvs/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""
Comment thread
atnair-amd marked this conversation as resolved.
Copyright 2025 Advanced Micro Devices, Inc.
All rights reserved. This notice is intended as a precaution against inadvertent publication and does not imply publication or any waiver of confidentiality.
The year included in the foregoing notice is the year of creation of the work.
All code contained here is Property of Advanced Micro Devices, Inc.
"""

import pytest

from cvs.core.orchestrators.factory import OrchestratorConfig, OrchestratorFactory
from cvs.lib import globals

log = globals.log


@pytest.fixture(scope="module")
def orch(pytestconfig):
cluster_file = pytestconfig.getoption("cluster_file")
config_file = pytestconfig.getoption("config_file")
if not cluster_file or not config_file:
pytest.fail("orch fixture requires --cluster_file and --config_file")

cfg = OrchestratorConfig.from_configs(cluster_file, config_file)
orch = OrchestratorFactory.create_orchestrator(log, cfg)

if cfg.orchestrator == "container":
if not orch.setup_containers():
pytest.fail(
f"Failed to launch container : "
f"{orch.get_container_name(orch.container_config, orch.container_config['image'])}"
)
if not orch.setup_sshd():
pytest.fail("Failed to setup sshd in container")

yield orch

if cfg.orchestrator == "container":
orch.teardown_containers()
19 changes: 0 additions & 19 deletions cvs/tests/health/rvs_cvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import json
from packaging import version

from cvs.core.orchestrators.factory import OrchestratorConfig, OrchestratorFactory
from cvs.lib.utils_lib import *

from cvs.lib import globals
Expand Down Expand Up @@ -57,24 +56,6 @@ def config_dict(config_file, cluster_dict):
return config_dict


@pytest.fixture(scope="module")
def orch(pytestconfig, request):
cluster_file = pytestconfig.getoption("cluster_file")
config_file = pytestconfig.getoption("config_file")
cfg = OrchestratorConfig.from_configs(cluster_file, config_file)
orch = OrchestratorFactory.create_orchestrator(log, cfg)

if cfg.orchestrator == "container":
container_name = orch.get_container_name(orch.container_config, orch.container_config['image'])
if not orch.setup_containers():
pytest.fail(f"Failed to launch container : {container_name}")
if not orch.setup_sshd():
pytest.fail(f"Failed to setup sshd in container : {container_name}")
request.addfinalizer(orch.teardown_containers)

return orch


@pytest.fixture(scope="module")
def rvs_test_level(config_dict):
"""Get RVS test level from config file, default to 4 if not provided or invalid"""
Expand Down
Loading