Skip to content

Commit 9624157

Browse files
committed
Adding more lcore skips and fixing some tests to pass with lcore
1 parent 23555c9 commit 9624157

6 files changed

Lines changed: 103 additions & 48 deletions

File tree

tests/e2e/test_api.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ def test_one_default_model_provider():
135135
), "one model and provider should be selected as default"
136136

137137

138-
@pytest.mark.skip_with_lcore
139138
@pytest.mark.cluster
140139
def test_improper_token():
141140
"""Test accessing /v1/query endpoint using improper auth. token."""
@@ -145,7 +144,10 @@ def test_improper_token():
145144
timeout=NON_LLM_REST_API_TIMEOUT,
146145
headers={"Authorization": "Bearer wrong-token"},
147146
)
148-
assert response.status_code == requests.codes.forbidden
147+
if os.getenv("LCORE", "False").lower() not in ("true", "1", "t"):
148+
assert response.status_code == requests.codes.forbidden
149+
else:
150+
assert response.status_code == requests.codes.unauthorized
149151

150152

151153
@pytest.mark.skip_with_lcore

tests/e2e/test_attachments.py

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import pytest
88
import requests
9+
import os
910

1011
from tests.e2e.utils import metrics as metrics_utils
1112
from tests.e2e.utils import response as response_utils
@@ -202,7 +203,7 @@ def test_valid_question_with_wrong_attachment_format_field_of_different_type() -
202203
assert details["msg"] == "Input should be a valid string"
203204
assert details["type"] == "string_type"
204205

205-
206+
import ipdb
206207
@retry(max_attempts=3, wait_between_runs=10)
207208
def test_valid_question_with_wrong_attachment_format_unknown_attachment_type() -> None:
208209
"""Check the REST API /v1/query with POST HTTP method using attachment with wrong type."""
@@ -231,16 +232,26 @@ def test_valid_question_with_wrong_attachment_format_unknown_attachment_type() -
231232

232233
# the attachment should not be processed correctly
233234
assert response.status_code == requests.codes.unprocessable_entity
234-
235235
json_response = response.json()
236-
expected_response = {
237-
"detail": {
238-
"response": "Invalid attribute value",
239-
"cause": "Invalid attatchment type unknown_type: must be one of frozenset" \
240-
"({'alert', 'log', 'event', 'api object', 'error message', 'configuration', 'stack trace'})",
236+
if os.getenv("LCORE", "False").lower() not in ("true", "1", "t"):
237+
expected_response = {
238+
"detail": {
239+
"response": "Invalid attribute value",
240+
"cause": "Invalid attatchment type unknown_type: must be one of frozenset" \
241+
"({'alert', 'log', 'event', 'api object', 'error message', 'configuration', 'stack trace'})",
242+
}
241243
}
242-
}
243-
assert json_response == expected_response
244+
assert json_response == expected_response
245+
else:
246+
assert "Invalid attribute value" in json_response["detail"]["response"]
247+
assert "Invalid attatchment type unknown_type: must be one of frozenset" in json_response["detail"]["cause"]
248+
assert "event" in json_response["detail"]["cause"]
249+
assert "log" in json_response["detail"]["cause"]
250+
assert "stack trace" in json_response["detail"]["cause"]
251+
assert "alert" in json_response["detail"]["cause"]
252+
assert "configuration" in json_response["detail"]["cause"]
253+
assert "api object" in json_response["detail"]["cause"]
254+
assert "error message" in json_response["detail"]["cause"]
244255

245256

246257
@retry(max_attempts=3, wait_between_runs=10)
@@ -271,13 +282,9 @@ def test_valid_question_with_wrong_attachment_format_unknown_content_type() -> N
271282

272283
# the attachment should not be processed correctly
273284
assert response.status_code == requests.codes.unprocessable_entity
274-
275285
json_response = response.json()
276-
expected_response = {
277-
"detail": {
278-
"response": "Invalid attribute value",
279-
"cause": "Invalid attatchment content type unknown/type: must be one of frozenset" \
280-
"({'application/json', 'application/xml', 'application/yaml', 'text/plain'})",
281-
}
282-
}
283-
assert json_response == expected_response
286+
assert "Invalid attribute value" in json_response["detail"]["response"]
287+
assert "application/json" in json_response["detail"]["cause"]
288+
assert "application/xml" in json_response["detail"]["cause"]
289+
assert "application/yaml" in json_response["detail"]["cause"]
290+
assert "text/plain" in json_response["detail"]["cause"]

tests/e2e/test_query_endpoint.py

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -207,29 +207,42 @@ def test_too_long_question() -> None:
207207
assert json_response["detail"]["response"] == "Prompt is too long"
208208

209209

210-
@pytest.mark.skip_with_lcore
211210
@pytest.mark.smoketest
212211
@pytest.mark.rag
213212
def test_valid_question() -> None:
214213
"""Check the REST API /v1/query with POST HTTP method for valid question and no yaml."""
215214
with metrics_utils.RestAPICallCounterChecker(pytest.metrics_client, QUERY_ENDPOINT):
216-
cid = suid.get_suid()
217-
response = pytest.client.post(
218-
QUERY_ENDPOINT,
219-
json={
220-
"conversation_id": cid,
221-
"query": "what is kubernetes in the context of OpenShift?",
222-
},
223-
timeout=test_api.LLM_REST_API_TIMEOUT,
224-
)
225-
assert response.status_code == requests.codes.ok
226-
227-
response_utils.check_content_type(response, "application/json")
228-
print(vars(response))
229-
json_response = response.json()
230-
231-
# checking a few major information from response
232-
assert json_response["conversation_id"] == cid
215+
if os.getenv("LCORE", "False").lower() not in ("true", "1", "t"):
216+
cid = suid.get_suid()
217+
response = pytest.client.post(
218+
QUERY_ENDPOINT,
219+
json={
220+
"conversation_id": cid,
221+
"query": "what is kubernetes in the context of OpenShift?",
222+
},
223+
timeout=test_api.LLM_REST_API_TIMEOUT,
224+
)
225+
assert response.status_code == requests.codes.ok
226+
227+
response_utils.check_content_type(response, "application/json")
228+
print(vars(response))
229+
json_response = response.json()
230+
231+
# checking a few major information from response
232+
assert json_response["conversation_id"] == cid
233+
else:
234+
response = pytest.client.post(
235+
QUERY_ENDPOINT,
236+
json={
237+
"query": "what is kubernetes in the context of OpenShift?",
238+
},
239+
timeout=test_api.LLM_REST_API_TIMEOUT,
240+
)
241+
assert response.status_code == requests.codes.ok
242+
243+
response_utils.check_content_type(response, "application/json")
244+
print(vars(response))
245+
json_response = response.json()
233246
assert re.search(
234247
r"kubernetes|openshift",
235248
json_response["response"],
@@ -474,6 +487,7 @@ def test_conversation_history() -> None:
474487
assert "ingress" in response_text, debug_msg
475488

476489

490+
@pytest.mark.skip_with_lcore
477491
def test_query_with_provider_but_not_model() -> None:
478492
"""Check the REST API /v1/query with POST HTTP method for provider specified, but no model."""
479493
with metrics_utils.RestAPICallCounterChecker(
@@ -503,6 +517,7 @@ def test_query_with_provider_but_not_model() -> None:
503517
)
504518

505519

520+
@pytest.mark.skip_with_lcore
506521
def test_query_with_model_but_not_provider() -> None:
507522
"""Check the REST API /v1/query with POST HTTP method for model specified, but no provider."""
508523
with metrics_utils.RestAPICallCounterChecker(
@@ -531,6 +546,7 @@ def test_query_with_model_but_not_provider() -> None:
531546
)
532547

533548

549+
@pytest.mark.skip_with_lcore
534550
def test_query_with_unknown_provider() -> None:
535551
"""Check the REST API /v1/query with POST HTTP method for unknown provider specified."""
536552
# retrieve currently selected model
@@ -568,6 +584,7 @@ def test_query_with_unknown_provider() -> None:
568584
)
569585

570586

587+
@pytest.mark.skip_with_lcore
571588
def test_query_with_unknown_model() -> None:
572589
"""Check the REST API /v1/query with POST HTTP method for unknown model specified."""
573590
# retrieve currently selected provider

tests/e2e/test_streaming_query_endpoint.py

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import json
88
import re
9+
import os
910

1011
import pytest
1112
import requests
@@ -53,6 +54,7 @@ def construct_response_from_streamed_events(events: dict) -> str:
5354
return response
5455

5556

57+
@pytest.mark.skip_with_lcore
5658
def test_invalid_question():
5759
"""Check the endpoint POST method for invalid question."""
5860
with metrics_utils.RestAPICallCounterChecker(
@@ -98,7 +100,8 @@ def test_invalid_question_without_conversation_id():
98100
# new conversation ID should be generated
99101
assert events[0]["event"] == "start"
100102
assert events[0]["data"]
101-
assert suid.check_suid(events[0]["data"]["conversation_id"])
103+
if os.getenv("LCORE", "False").lower() not in ("true", "1", "t"):
104+
assert suid.check_suid(events[0]["data"]["conversation_id"])
102105

103106

104107
def test_query_call_without_payload():
@@ -139,6 +142,7 @@ def test_query_call_with_improper_payload():
139142
assert "missing" in response.text
140143

141144

145+
@pytest.mark.skip_with_lcore
142146
def test_valid_question_improper_conversation_id() -> None:
143147
"""Check the endpoint with POST HTTP method for improper conversation ID."""
144148
with metrics_utils.RestAPICallCounterChecker(
@@ -163,6 +167,7 @@ def test_valid_question_improper_conversation_id() -> None:
163167
assert json_response == expected_response
164168

165169

170+
@pytest.mark.skip_with_lcore
166171
def test_too_long_question() -> None:
167172
"""Check the endpoint with too long question."""
168173
# let's make the query really large, larger that context window size
@@ -200,11 +205,24 @@ def test_valid_question() -> None:
200205
with metrics_utils.RestAPICallCounterChecker(
201206
pytest.metrics_client, STREAMING_QUERY_ENDPOINT
202207
):
203-
cid = suid.get_suid()
204-
response = post_with_defaults(
205-
STREAMING_QUERY_ENDPOINT,
206-
json={"conversation_id": cid, "query": "what is kubernetes?"},
207-
)
208+
if os.getenv("LCORE", "False").lower() not in ("true", "1", "t"):
209+
cid = suid.get_suid()
210+
response = pytest.client.post(
211+
STREAMING_QUERY_ENDPOINT,
212+
json={
213+
"conversation_id": cid,
214+
"query": "what is kubernetes in the context of OpenShift?",
215+
},
216+
timeout=test_api.LLM_REST_API_TIMEOUT,
217+
)
218+
else:
219+
response = pytest.client.post(
220+
STREAMING_QUERY_ENDPOINT,
221+
json={
222+
"query": "what is kubernetes in the context of OpenShift?",
223+
},
224+
timeout=test_api.LLM_REST_API_TIMEOUT,
225+
)
208226
assert response.status_code == requests.codes.ok
209227

210228
response_utils.check_content_type(response, constants.MEDIA_TYPE_TEXT)
@@ -244,6 +262,7 @@ def test_ocp_docs_version_same_as_cluster_version() -> None:
244262
)
245263

246264

265+
@pytest.mark.skip_with_lcore
247266
def test_valid_question_tokens_counter() -> None:
248267
"""Check how the tokens counter are updated accordingly."""
249268
model, provider = metrics_utils.get_enabled_model_and_provider(
@@ -264,6 +283,7 @@ def test_valid_question_tokens_counter() -> None:
264283
response_utils.check_content_type(response, constants.MEDIA_TYPE_TEXT)
265284

266285

286+
@pytest.mark.skip_with_lcore
267287
def test_invalid_question_tokens_counter() -> None:
268288
"""Check how the tokens counter are updated accordingly."""
269289
model, provider = metrics_utils.get_enabled_model_and_provider(
@@ -284,6 +304,7 @@ def test_invalid_question_tokens_counter() -> None:
284304
response_utils.check_content_type(response, constants.MEDIA_TYPE_TEXT)
285305

286306

307+
@pytest.mark.skip_with_lcore
287308
def test_token_counters_for_query_call_without_payload() -> None:
288309
"""Check how the tokens counter are updated accordingly."""
289310
model, provider = metrics_utils.get_enabled_model_and_provider(
@@ -311,6 +332,7 @@ def test_token_counters_for_query_call_without_payload() -> None:
311332
response_utils.check_content_type(response, constants.MEDIA_TYPE_JSON)
312333

313334

335+
@pytest.mark.skip_with_lcore
314336
def test_token_counters_for_query_call_with_improper_payload() -> None:
315337
"""Check how the tokens counter are updated accordingly."""
316338
model, provider = metrics_utils.get_enabled_model_and_provider(
@@ -372,6 +394,7 @@ def test_rag_question() -> None:
372394
assert len(set(docs_urls)) == len(docs_urls)
373395

374396

397+
@pytest.mark.skip_with_lcore
375398
@pytest.mark.cluster
376399
def test_query_filter() -> None:
377400
"""Ensure responses does not include filtered words and redacted words are not logged."""
@@ -463,6 +486,7 @@ def test_conversation_history() -> None:
463486
assert "ingress" in response_text, scenario_fail_msg
464487

465488

489+
@pytest.mark.skip_with_lcore
466490
def test_query_with_provider_but_not_model() -> None:
467491
"""Check the endpoint with POST HTTP method for provider specified, but no model."""
468492
with metrics_utils.RestAPICallCounterChecker(
@@ -491,6 +515,7 @@ def test_query_with_provider_but_not_model() -> None:
491515
)
492516

493517

518+
@pytest.mark.skip_with_lcore
494519
def test_query_with_model_but_not_provider() -> None:
495520
"""Check the endpoint with POST HTTP method for model specified, but no provider."""
496521
with metrics_utils.RestAPICallCounterChecker(
@@ -518,6 +543,7 @@ def test_query_with_model_but_not_provider() -> None:
518543
)
519544

520545

546+
@pytest.mark.skip_with_lcore
521547
def test_query_with_unknown_provider() -> None:
522548
"""Check the endpoint with POST HTTP method for unknown provider specified."""
523549
# retrieve currently selected model
@@ -554,6 +580,7 @@ def test_query_with_unknown_provider() -> None:
554580
)
555581

556582

583+
@pytest.mark.skip_with_lcore
557584
def test_query_with_unknown_model() -> None:
558585
"""Check the endpoint with POST HTTP method for unknown model specified."""
559586
# retrieve currently selected provider

tests/e2e/test_user_feedback.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import pytest
88
import requests
9+
import os
910

1011
from tests.e2e.utils import cluster as cluster_utils
1112
from tests.e2e.utils import response as response_utils
@@ -27,7 +28,10 @@ def test_feedback_can_post_with_wrong_token():
2728
timeout=test_api.BASIC_ENDPOINTS_TIMEOUT,
2829
headers={"Authorization": "Bearer wrong-token"},
2930
)
30-
assert response.status_code == requests.codes.forbidden
31+
if os.getenv("LCORE", "False").lower() not in ("true", "1", "t"):
32+
assert response.status_code == requests.codes.forbidden
33+
else:
34+
assert response.status_code == requests.codes.unauthorized
3135

3236

3337
@pytest.mark.data_export

tests/e2e/utils/metrics.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,10 @@ def get_metric_labels(lines, info_node_name, value=None) -> dict:
9292
# info node was not found
9393
return {}
9494

95-
import ipdb
95+
9696
def get_enabled_model_and_provider(client):
9797
"""Read configured model and provider from metrics."""
9898

99-
ipdb.set_trace()
100-
10199
if os.getenv("LCORE", 'False').lower() in ('true', '1', 't'):
102100
response = client.get("/v1/models", timeout=BASIC_ENDPOINTS_TIMEOUT)
103101
assert response.status_code == requests.codes.ok

0 commit comments

Comments
 (0)