diff --git a/tests/e2e/test_api.py b/tests/e2e/test_api.py index 38d2d036..8544d3c8 100644 --- a/tests/e2e/test_api.py +++ b/tests/e2e/test_api.py @@ -98,7 +98,7 @@ def postgres_connection(): return retrieve_connection() -@pytest.mark.smoketest() +@pytest.mark.smoketest @retry(max_attempts=3, wait_between_runs=10) def test_readiness(): """Test handler for /readiness REST API endpoint.""" @@ -110,7 +110,7 @@ def test_readiness(): assert response.json() == {"ready": True, "reason": "service is ready"} -@pytest.mark.smoketest() +@pytest.mark.smoketest def test_liveness(): """Test handler for /liveness REST API endpoint.""" endpoint = "/liveness" @@ -169,7 +169,7 @@ def test_one_default_model_provider(): ), "one model and provider should be selected as default" -@pytest.mark.cluster() +@pytest.mark.cluster def test_improper_token(): """Test accessing /v1/query endpoint using improper auth. token.""" response = client.post( @@ -181,7 +181,7 @@ def test_improper_token(): assert response.status_code == requests.codes.forbidden -@pytest.mark.cluster() +@pytest.mark.cluster def test_forbidden_user(): """Test scenarios where we expect an unauthorized response. @@ -198,7 +198,7 @@ def test_forbidden_user(): assert response.status_code == requests.codes.forbidden -@pytest.mark.cluster() +@pytest.mark.cluster def test_transcripts_storing_cluster(): """Test if the transcripts are stored properly.""" transcripts_path = OLS_USER_DATA_PATH + "/transcripts" @@ -364,7 +364,7 @@ def test_conversation_in_postgres_cache(postgres_connection) -> None: assert "OpenShift" in deserialized[3].content -@pytest.mark.cluster() +@pytest.mark.cluster def test_user_data_collection(): """Test user data collection. @@ -475,7 +475,7 @@ def get_last_log_line(logs: str) -> str: cluster_utils.create_file(pod_name, OLS_COLLECTOR_DISABLING_FILE, "") -@pytest.mark.cluster() +@pytest.mark.cluster def test_http_header_redaction(): """Test that sensitive HTTP headers are redacted from the logs.""" for header in HTTP_REQUEST_HEADERS_TO_REDACT: @@ -499,7 +499,7 @@ def test_http_header_redaction(): assert f'"{header}":"some_value"' not in container_log -@pytest.mark.response_evaluation() +@pytest.mark.response_evaluation def test_model_response(request) -> None: """Evaluate model response.""" args = Namespace(**vars(request.config.option)) @@ -514,14 +514,14 @@ def test_model_response(request) -> None: assert val_success_flag -@pytest.mark.model_evaluation() +@pytest.mark.model_evaluation def test_model_evaluation(request) -> None: """Evaluate model.""" # TODO: Use this to assert. ResponseEvaluation(request.config.option, client).evaluate_models() -@pytest.mark.azure_entra_id() +@pytest.mark.azure_entra_id def test_azure_entra_id(): """Test single question via Azure Entra ID credentials.""" response = client.post( diff --git a/tests/e2e/test_query_endpoint.py b/tests/e2e/test_query_endpoint.py index 696f263f..a694a860 100644 --- a/tests/e2e/test_query_endpoint.py +++ b/tests/e2e/test_query_endpoint.py @@ -199,8 +199,8 @@ def test_too_long_question() -> None: assert json_response["detail"]["response"] == "Prompt is too long" -@pytest.mark.smoketest() -@pytest.mark.rag() +@pytest.mark.smoketest +@pytest.mark.rag def test_valid_question() -> None: """Check the REST API /v1/query with POST HTTP method for valid question and no yaml.""" endpoint = "/v1/query" @@ -228,7 +228,7 @@ def test_valid_question() -> None: ) -@pytest.mark.rag() +@pytest.mark.rag def test_ocp_docs_version_same_as_cluster_version() -> None: """Check that the version of OCP docs matches the cluster we're on.""" endpoint = "/v1/query" @@ -354,7 +354,7 @@ def test_token_counters_for_query_call_with_improper_payload() -> None: response_utils.check_content_type(response, "application/json") -@pytest.mark.rag() +@pytest.mark.rag @retry(max_attempts=3, wait_between_runs=10) def test_rag_question() -> None: """Ensure responses include rag references.""" @@ -382,7 +382,7 @@ def test_rag_question() -> None: assert len(doc_urls_list) == len(set(doc_urls_list)) -@pytest.mark.cluster() +@pytest.mark.cluster def test_query_filter() -> None: """Ensure responses does not include filtered words and redacted words are not logged.""" endpoint = "/v1/query" diff --git a/tests/e2e/test_user_feedback.py b/tests/e2e/test_user_feedback.py index 53f03681..064d9af1 100644 --- a/tests/e2e/test_user_feedback.py +++ b/tests/e2e/test_user_feedback.py @@ -9,7 +9,7 @@ from . import test_api -@pytest.mark.cluster() +@pytest.mark.cluster def test_feedback_can_post_with_wrong_token(): """Test posting feedback with improper auth. token.""" response = test_api.client.post( @@ -26,7 +26,7 @@ def test_feedback_can_post_with_wrong_token(): assert response.status_code == requests.codes.forbidden -@pytest.mark.cluster() +@pytest.mark.cluster def test_feedback_storing_cluster(): """Test if the feedbacks are stored properly.""" feedbacks_path = test_api.OLS_USER_DATA_PATH + "/feedback" diff --git a/tests/integration/test_ols.py b/tests/integration/test_ols.py index aed06759..6a5cc628 100644 --- a/tests/integration/test_ols.py +++ b/tests/integration/test_ols.py @@ -487,7 +487,7 @@ def validate_question(_conversation_id, query): "ols.app.endpoints.ols.config.ols_config.query_validation_method", constants.QueryValidationMethod.LLM, ) -@pytest.mark.attachment() +@pytest.mark.attachment def test_post_question_with_empty_list_of_attachments(_setup) -> None: """Check the REST API /v1/query with POST HTTP method with empty list of attachments.""" answer = constants.SUBJECT_ALLOWED @@ -527,7 +527,7 @@ def validate_question(_conversation_id, query): assert query_passed == "test query" -@pytest.mark.attachment() +@pytest.mark.attachment @patch( "ols.app.endpoints.ols.config.ols_config.query_validation_method", constants.QueryValidationMethod.LLM, @@ -584,7 +584,7 @@ def validate_question(_conversation_id, query): assert query_passed == expected -@pytest.mark.attachment() +@pytest.mark.attachment @patch( "ols.app.endpoints.ols.config.ols_config.query_validation_method", constants.QueryValidationMethod.LLM, @@ -650,7 +650,7 @@ def validate_question(_conversation_id, query): assert query_passed == expected -@pytest.mark.attachment() +@pytest.mark.attachment @patch( "ols.app.endpoints.ols.config.ols_config.query_validation_method", constants.QueryValidationMethod.LLM, @@ -736,7 +736,7 @@ def validate_question(_conversation_id, query): assert query_passed == expected -@pytest.mark.attachment() +@pytest.mark.attachment @patch( "ols.app.endpoints.ols.config.ols_config.query_validation_method", constants.QueryValidationMethod.LLM, @@ -800,7 +800,7 @@ def validate_question(_conversation_id, query): assert query_passed == expected -@pytest.mark.attachment() +@pytest.mark.attachment @patch( "ols.app.endpoints.ols.config.ols_config.query_validation_method", constants.QueryValidationMethod.LLM, @@ -866,7 +866,7 @@ def validate_question(_conversation_id, query): assert query_passed == expected -@pytest.mark.attachment() +@pytest.mark.attachment @patch( "ols.app.endpoints.ols.config.ols_config.query_validation_method", constants.QueryValidationMethod.LLM, @@ -932,7 +932,7 @@ def validate_question(_conversation_id, query): assert query_passed == expected -@pytest.mark.attachment() +@pytest.mark.attachment def test_post_question_with_large_attachment(_setup) -> None: """Check the REST API /v1/query with POST HTTP method with large attachment.""" answer = constants.SUBJECT_ALLOWED diff --git a/tests/integration/test_redis.py b/tests/integration/test_redis.py index 71329448..b24f6a7f 100644 --- a/tests/integration/test_redis.py +++ b/tests/integration/test_redis.py @@ -12,7 +12,7 @@ redis_cache: RedisCache -@pytest.mark.redis() +@pytest.mark.redis def setup(): """Setups the Redis client.""" global redis_cache @@ -32,7 +32,7 @@ def setup(): redis_cache = RedisCache(redis_config) -@pytest.mark.redis() +@pytest.mark.redis def test_conversation_in_redis(): """Check the elementary GET operation and insert_or_append operation.""" # make sure the cache is empty diff --git a/tests/unit/auth/test_k8s.py b/tests/unit/auth/test_k8s.py index 0d5ff22a..3cc8973b 100644 --- a/tests/unit/auth/test_k8s.py +++ b/tests/unit/auth/test_k8s.py @@ -42,7 +42,7 @@ def test_singleton_pattern(): @pytest.mark.usefixtures("_setup") -@pytest.mark.asyncio() +@pytest.mark.asyncio @patch("ols.src.auth.k8s.K8sClientSingleton.get_authn_api") @patch("ols.src.auth.k8s.K8sClientSingleton.get_authz_api") async def test_auth_dependency_valid_token(mock_authz_api, mock_authn_api): @@ -68,7 +68,7 @@ async def test_auth_dependency_valid_token(mock_authz_api, mock_authn_api): @pytest.mark.usefixtures("_setup") -@pytest.mark.asyncio() +@pytest.mark.asyncio @patch("ols.src.auth.k8s.K8sClientSingleton.get_authn_api") @patch("ols.src.auth.k8s.K8sClientSingleton.get_authz_api") async def test_auth_dependency_invalid_token(mock_authz_api, mock_authn_api): @@ -95,7 +95,7 @@ async def test_auth_dependency_invalid_token(mock_authz_api, mock_authn_api): @pytest.mark.usefixtures("_setup") -@pytest.mark.asyncio() +@pytest.mark.asyncio @patch("ols.src.auth.k8s.K8sClientSingleton.get_authz_api") async def test_cluster_id_is_used_for_kube_admin(mock_authz_api): """Test the cluster id is used as user_id when user is kube:admin."""