mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
Test: Configure test case priorities to reduce CI execution time (#7532)
### What problem does this PR solve? Configure test case priorities to reduce CI execution time ### Type of change - [x] Test cases update
This commit is contained in:
@ -20,6 +20,7 @@ from common import INVALID_API_TOKEN, SESSION_WITH_CHAT_NAME_LIMIT, create_sessi
|
||||
from libs.auth import RAGFlowHttpApiAuth
|
||||
|
||||
|
||||
@pytest.mark.p1
|
||||
class TestAuthorization:
|
||||
@pytest.mark.parametrize(
|
||||
"auth, expected_code, expected_message",
|
||||
@ -40,6 +41,7 @@ class TestAuthorization:
|
||||
|
||||
@pytest.mark.usefixtures("clear_session_with_chat_assistants")
|
||||
class TestSessionWithChatAssistantCreate:
|
||||
@pytest.mark.p1
|
||||
@pytest.mark.parametrize(
|
||||
"payload, expected_code, expected_message",
|
||||
[
|
||||
@ -66,6 +68,7 @@ class TestSessionWithChatAssistantCreate:
|
||||
else:
|
||||
assert res["message"] == expected_message
|
||||
|
||||
@pytest.mark.p3
|
||||
@pytest.mark.parametrize(
|
||||
"chat_assistant_id, expected_code, expected_message",
|
||||
[
|
||||
@ -78,7 +81,7 @@ class TestSessionWithChatAssistantCreate:
|
||||
assert res["code"] == expected_code
|
||||
assert res["message"] == expected_message
|
||||
|
||||
@pytest.mark.slow
|
||||
@pytest.mark.p3
|
||||
def test_concurrent_create_session(self, get_http_api_auth, add_chat_assistants):
|
||||
chunk_num = 1000
|
||||
_, _, chat_assistant_ids = add_chat_assistants
|
||||
@ -104,6 +107,7 @@ class TestSessionWithChatAssistantCreate:
|
||||
assert False, res
|
||||
assert len(res["data"]) == chunks_count + chunk_num
|
||||
|
||||
@pytest.mark.p3
|
||||
def test_add_session_to_deleted_chat_assistant(self, get_http_api_auth, add_chat_assistants):
|
||||
_, _, chat_assistant_ids = add_chat_assistants
|
||||
res = delete_chat_assistants(get_http_api_auth, {"ids": [chat_assistant_ids[0]]})
|
||||
|
||||
@ -20,6 +20,7 @@ from common import INVALID_API_TOKEN, batch_add_sessions_with_chat_assistant, de
|
||||
from libs.auth import RAGFlowHttpApiAuth
|
||||
|
||||
|
||||
@pytest.mark.p1
|
||||
class TestAuthorization:
|
||||
@pytest.mark.parametrize(
|
||||
"auth, expected_code, expected_message",
|
||||
@ -39,6 +40,7 @@ class TestAuthorization:
|
||||
|
||||
|
||||
class TestSessionWithChatAssistantDelete:
|
||||
@pytest.mark.p3
|
||||
@pytest.mark.parametrize(
|
||||
"chat_assistant_id, expected_code, expected_message",
|
||||
[
|
||||
@ -59,9 +61,9 @@ class TestSessionWithChatAssistantDelete:
|
||||
@pytest.mark.parametrize(
|
||||
"payload",
|
||||
[
|
||||
lambda r: {"ids": ["invalid_id"] + r},
|
||||
lambda r: {"ids": r[:1] + ["invalid_id"] + r[1:5]},
|
||||
lambda r: {"ids": r + ["invalid_id"]},
|
||||
pytest.param(lambda r: {"ids": ["invalid_id"] + r}, marks=pytest.mark.p3),
|
||||
pytest.param(lambda r: {"ids": r[:1] + ["invalid_id"] + r[1:5]}, marks=pytest.mark.p1),
|
||||
pytest.param(lambda r: {"ids": r + ["invalid_id"]}, marks=pytest.mark.p3),
|
||||
],
|
||||
)
|
||||
def test_delete_partial_invalid_id(self, get_http_api_auth, add_sessions_with_chat_assistant_func, payload):
|
||||
@ -77,6 +79,7 @@ class TestSessionWithChatAssistantDelete:
|
||||
assert False, res
|
||||
assert len(res["data"]) == 0
|
||||
|
||||
@pytest.mark.p3
|
||||
def test_repeated_deletion(self, get_http_api_auth, add_sessions_with_chat_assistant_func):
|
||||
chat_assistant_id, session_ids = add_sessions_with_chat_assistant_func
|
||||
payload = {"ids": session_ids}
|
||||
@ -87,6 +90,7 @@ class TestSessionWithChatAssistantDelete:
|
||||
assert res["code"] == 102
|
||||
assert "The chat doesn't own the session" in res["message"]
|
||||
|
||||
@pytest.mark.p3
|
||||
def test_duplicate_deletion(self, get_http_api_auth, add_sessions_with_chat_assistant_func):
|
||||
chat_assistant_id, session_ids = add_sessions_with_chat_assistant_func
|
||||
res = delete_session_with_chat_assistants(get_http_api_auth, chat_assistant_id, {"ids": session_ids * 2})
|
||||
@ -99,7 +103,7 @@ class TestSessionWithChatAssistantDelete:
|
||||
assert False, res
|
||||
assert len(res["data"]) == 0
|
||||
|
||||
@pytest.mark.slow
|
||||
@pytest.mark.p3
|
||||
def test_concurrent_deletion(self, get_http_api_auth, add_chat_assistants):
|
||||
sessions_num = 100
|
||||
_, _, chat_assistant_ids = add_chat_assistants
|
||||
@ -118,7 +122,7 @@ class TestSessionWithChatAssistantDelete:
|
||||
responses = [f.result() for f in futures]
|
||||
assert all(r["code"] == 0 for r in responses)
|
||||
|
||||
@pytest.mark.slow
|
||||
@pytest.mark.p3
|
||||
def test_delete_1k(self, get_http_api_auth, add_chat_assistants):
|
||||
sessions_num = 1_000
|
||||
_, _, chat_assistant_ids = add_chat_assistants
|
||||
@ -136,17 +140,11 @@ class TestSessionWithChatAssistantDelete:
|
||||
"payload, expected_code, expected_message, remaining",
|
||||
[
|
||||
pytest.param(None, 0, """TypeError("argument of type \'NoneType\' is not iterable")""", 0, marks=pytest.mark.skip),
|
||||
({"ids": ["invalid_id"]}, 102, "The chat doesn't own the session invalid_id", 5),
|
||||
pytest.param(
|
||||
"not json",
|
||||
100,
|
||||
"""AttributeError("\'str\' object has no attribute \'get\'")""",
|
||||
5,
|
||||
marks=pytest.mark.skip,
|
||||
),
|
||||
(lambda r: {"ids": r[:1]}, 0, "", 4),
|
||||
(lambda r: {"ids": r}, 0, "", 0),
|
||||
({"ids": []}, 0, "", 0),
|
||||
pytest.param({"ids": ["invalid_id"]}, 102, "The chat doesn't own the session invalid_id", 5, marks=pytest.mark.p3),
|
||||
pytest.param("not json", 100, """AttributeError("\'str\' object has no attribute \'get\'")""", 5, marks=pytest.mark.skip),
|
||||
pytest.param(lambda r: {"ids": r[:1]}, 0, "", 4, marks=pytest.mark.p3),
|
||||
pytest.param(lambda r: {"ids": r}, 0, "", 0, marks=pytest.mark.p1),
|
||||
pytest.param({"ids": []}, 0, "", 0, marks=pytest.mark.p3),
|
||||
],
|
||||
)
|
||||
def test_basic_scenarios(
|
||||
|
||||
@ -21,6 +21,7 @@ from libs.auth import RAGFlowHttpApiAuth
|
||||
from libs.utils import is_sorted
|
||||
|
||||
|
||||
@pytest.mark.p1
|
||||
class TestAuthorization:
|
||||
@pytest.mark.parametrize(
|
||||
"auth, expected_code, expected_message",
|
||||
@ -40,6 +41,7 @@ class TestAuthorization:
|
||||
|
||||
|
||||
class TestSessionsWithChatAssistantList:
|
||||
@pytest.mark.p1
|
||||
@pytest.mark.parametrize(
|
||||
"params, expected_code, expected_page_size, expected_message",
|
||||
[
|
||||
@ -61,6 +63,7 @@ class TestSessionsWithChatAssistantList:
|
||||
else:
|
||||
assert res["message"] == expected_message
|
||||
|
||||
@pytest.mark.p1
|
||||
@pytest.mark.parametrize(
|
||||
"params, expected_code, expected_page_size, expected_message",
|
||||
[
|
||||
@ -82,6 +85,7 @@ class TestSessionsWithChatAssistantList:
|
||||
else:
|
||||
assert res["message"] == expected_message
|
||||
|
||||
@pytest.mark.p3
|
||||
@pytest.mark.parametrize(
|
||||
"params, expected_code, assertions, expected_message",
|
||||
[
|
||||
@ -110,6 +114,7 @@ class TestSessionsWithChatAssistantList:
|
||||
else:
|
||||
assert res["message"] == expected_message
|
||||
|
||||
@pytest.mark.p3
|
||||
@pytest.mark.parametrize(
|
||||
"params, expected_code, assertions, expected_message",
|
||||
[
|
||||
@ -142,6 +147,7 @@ class TestSessionsWithChatAssistantList:
|
||||
else:
|
||||
assert res["message"] == expected_message
|
||||
|
||||
@pytest.mark.p1
|
||||
@pytest.mark.parametrize(
|
||||
"params, expected_code, expected_num, expected_message",
|
||||
[
|
||||
@ -163,6 +169,7 @@ class TestSessionsWithChatAssistantList:
|
||||
else:
|
||||
assert res["message"] == expected_message
|
||||
|
||||
@pytest.mark.p1
|
||||
@pytest.mark.parametrize(
|
||||
"session_id, expected_code, expected_num, expected_message",
|
||||
[
|
||||
@ -189,6 +196,7 @@ class TestSessionsWithChatAssistantList:
|
||||
else:
|
||||
assert res["message"] == expected_message
|
||||
|
||||
@pytest.mark.p3
|
||||
@pytest.mark.parametrize(
|
||||
"session_id, name, expected_code, expected_num, expected_message",
|
||||
[
|
||||
@ -212,7 +220,7 @@ class TestSessionsWithChatAssistantList:
|
||||
else:
|
||||
assert res["message"] == expected_message
|
||||
|
||||
@pytest.mark.slow
|
||||
@pytest.mark.p3
|
||||
def test_concurrent_list(self, get_http_api_auth, add_sessions_with_chat_assistant):
|
||||
chat_assistant_id, _ = add_sessions_with_chat_assistant
|
||||
with ThreadPoolExecutor(max_workers=5) as executor:
|
||||
@ -220,6 +228,7 @@ class TestSessionsWithChatAssistantList:
|
||||
responses = [f.result() for f in futures]
|
||||
assert all(r["code"] == 0 for r in responses)
|
||||
|
||||
@pytest.mark.p3
|
||||
def test_invalid_params(self, get_http_api_auth, add_sessions_with_chat_assistant):
|
||||
chat_assistant_id, _ = add_sessions_with_chat_assistant
|
||||
params = {"a": "b"}
|
||||
@ -227,6 +236,7 @@ class TestSessionsWithChatAssistantList:
|
||||
assert res["code"] == 0
|
||||
assert len(res["data"]) == 5
|
||||
|
||||
@pytest.mark.p3
|
||||
def test_list_chats_after_deleting_associated_chat_assistant(self, get_http_api_auth, add_sessions_with_chat_assistant):
|
||||
chat_assistant_id, _ = add_sessions_with_chat_assistant
|
||||
res = delete_chat_assistants(get_http_api_auth, {"ids": [chat_assistant_id]})
|
||||
|
||||
@ -21,6 +21,7 @@ from common import INVALID_API_TOKEN, SESSION_WITH_CHAT_NAME_LIMIT, delete_chat_
|
||||
from libs.auth import RAGFlowHttpApiAuth
|
||||
|
||||
|
||||
@pytest.mark.p1
|
||||
class TestAuthorization:
|
||||
@pytest.mark.parametrize(
|
||||
"auth, expected_code, expected_message",
|
||||
@ -43,12 +44,12 @@ class TestSessionWithChatAssistantUpdate:
|
||||
@pytest.mark.parametrize(
|
||||
"payload, expected_code, expected_message",
|
||||
[
|
||||
({"name": "valid_name"}, 0, ""),
|
||||
pytest.param({"name": "valid_name"}, 0, "", marks=pytest.mark.p1),
|
||||
pytest.param({"name": "a" * (SESSION_WITH_CHAT_NAME_LIMIT + 1)}, 102, "", marks=pytest.mark.skip(reason="issues/")),
|
||||
pytest.param({"name": 1}, 100, "", marks=pytest.mark.skip(reason="issues/")),
|
||||
({"name": ""}, 102, "`name` can not be empty."),
|
||||
({"name": "duplicated_name"}, 0, ""),
|
||||
({"name": "case insensitive"}, 0, ""),
|
||||
pytest.param({"name": ""}, 102, "`name` can not be empty.", marks=pytest.mark.p3),
|
||||
pytest.param({"name": "duplicated_name"}, 0, "", marks=pytest.mark.p3),
|
||||
pytest.param({"name": "case insensitive"}, 0, "", marks=pytest.mark.p3),
|
||||
],
|
||||
)
|
||||
def test_name(self, get_http_api_auth, add_sessions_with_chat_assistant_func, payload, expected_code, expected_message):
|
||||
@ -66,6 +67,7 @@ class TestSessionWithChatAssistantUpdate:
|
||||
else:
|
||||
assert res["message"] == expected_message
|
||||
|
||||
@pytest.mark.p3
|
||||
@pytest.mark.parametrize(
|
||||
"chat_assistant_id, expected_code, expected_message",
|
||||
[
|
||||
@ -79,6 +81,7 @@ class TestSessionWithChatAssistantUpdate:
|
||||
assert res["code"] == expected_code
|
||||
assert res["message"] == expected_message
|
||||
|
||||
@pytest.mark.p3
|
||||
@pytest.mark.parametrize(
|
||||
"session_id, expected_code, expected_message",
|
||||
[
|
||||
@ -92,6 +95,7 @@ class TestSessionWithChatAssistantUpdate:
|
||||
assert res["code"] == expected_code
|
||||
assert res["message"] == expected_message
|
||||
|
||||
@pytest.mark.p3
|
||||
def test_repeated_update_session(self, get_http_api_auth, add_sessions_with_chat_assistant_func):
|
||||
chat_assistant_id, session_ids = add_sessions_with_chat_assistant_func
|
||||
res = update_session_with_chat_assistant(get_http_api_auth, chat_assistant_id, session_ids[0], {"name": "valid_name_1"})
|
||||
@ -100,6 +104,7 @@ class TestSessionWithChatAssistantUpdate:
|
||||
res = update_session_with_chat_assistant(get_http_api_auth, chat_assistant_id, session_ids[0], {"name": "valid_name_2"})
|
||||
assert res["code"] == 0
|
||||
|
||||
@pytest.mark.p3
|
||||
@pytest.mark.parametrize(
|
||||
"payload, expected_code, expected_message",
|
||||
[
|
||||
@ -115,7 +120,7 @@ class TestSessionWithChatAssistantUpdate:
|
||||
if expected_code != 0:
|
||||
assert expected_message in res["message"]
|
||||
|
||||
@pytest.mark.slow
|
||||
@pytest.mark.p3
|
||||
def test_concurrent_update_session(self, get_http_api_auth, add_sessions_with_chat_assistant_func):
|
||||
chunk_num = 50
|
||||
chat_assistant_id, session_ids = add_sessions_with_chat_assistant_func
|
||||
@ -134,6 +139,7 @@ class TestSessionWithChatAssistantUpdate:
|
||||
responses = [f.result() for f in futures]
|
||||
assert all(r["code"] == 0 for r in responses)
|
||||
|
||||
@pytest.mark.p3
|
||||
def test_update_session_to_deleted_chat_assistant(self, get_http_api_auth, add_sessions_with_chat_assistant_func):
|
||||
chat_assistant_id, session_ids = add_sessions_with_chat_assistant_func
|
||||
delete_chat_assistants(get_http_api_auth, {"ids": [chat_assistant_id]})
|
||||
|
||||
Reference in New Issue
Block a user