Skip to content

Commit 606c62d

Browse files
committed
Functionality to adapt to OLSConfig for multi-provider support.
#Restructuring and adding new logs. #Linter fix. #trial fix for roopa pr
1 parent 8faa93c commit 606c62d

File tree

8 files changed

+501
-49
lines changed

8 files changed

+501
-49
lines changed

tests/e2e/conftest.py

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818

1919
from scripts.upload_artifact_s3 import upload_artifact_s3
2020
from tests.e2e.utils import client as client_utils
21-
from tests.e2e.utils import ols_installer
21+
from tests.e2e.utils import cluster, ols_installer
22+
from tests.e2e.utils.adapt_ols_config import adapt_ols_config
2223
from tests.e2e.utils.wait_for_ols import wait_for_ols
2324
from tests.scripts.must_gather import must_gather
2425

@@ -45,11 +46,38 @@ def pytest_sessionstart():
4546
# OLS_URL env only needs to be set when running against a local ols instance,
4647
# when ols is run against a cluster the url is retrieved from the cluster.
4748
ols_url = os.getenv("OLS_URL", "")
48-
4949
if "localhost" not in ols_url:
5050
on_cluster = True
5151
try:
52-
ols_url, token, metrics_token = ols_installer.install_ols()
52+
result = cluster.run_oc(
53+
[
54+
"get",
55+
"clusterserviceversion",
56+
"-n",
57+
"openshift-lightspeed",
58+
"-o",
59+
"json",
60+
]
61+
)
62+
csv_data = json.loads(result.stdout)
63+
print(csv_data)
64+
65+
if not csv_data["items"]:
66+
print("OLS Operator is not installed yet.")
67+
ols_url, token, metrics_token = ols_installer.install_ols()
68+
else:
69+
print("OLS Operator is already installed. Skipping install.")
70+
provider = os.getenv("PROVIDER", "openai")
71+
creds = os.getenv("PROVIDER_KEY_PATH", "empty")
72+
# create the llm api key secret ols will mount
73+
provider_list = provider.split()
74+
creds_list = creds.split()
75+
for i, prov in enumerate(provider_list):
76+
ols_installer.create_secrets(
77+
prov, creds_list[i], len(provider_list)
78+
)
79+
ols_url, token, metrics_token = adapt_ols_config()
80+
5381
except Exception as e:
5482
print(f"Error setting up OLS on cluster: {e}")
5583
must_gather()
@@ -271,8 +299,8 @@ def get_secret_value(env: str) -> str:
271299

272300
def pytest_sessionfinish(session):
273301
"""Create datarouter compatible archive to upload into report portal."""
274-
# Gather OLS artifacts at the end of tests
275-
if on_cluster:
302+
# Gather OLS artifacts only if there were failures
303+
if on_cluster and session.testsfailed > 0:
276304
must_gather()
277305
# Sending reports to report portal
278306
try:

0 commit comments

Comments
 (0)