66import uuid
77from unittest .mock import MagicMock
88
9+ import oracledb as _oracledb
910import pytest
1011from haystack .dataclasses import Document
1112from haystack .utils import Secret
1213
1314from haystack_integrations .document_stores .oracle import OracleConnectionConfig , OracleDocumentStore
1415
16+ _ORACLE_FEATURE_INTEGRATION_FILE = "test_oracle_features_integration.py"
17+ _ORACLE_FEATURE_SKIP_REASONS = {
18+ "ORA-00904" : "Oracle vector APIs are unavailable in this live database" ,
19+ "ORA-51962" : "Oracle vector memory area is exhausted in this live database" ,
20+ }
21+
1522
1623def _env_value (* names : str , default : str | None = None ) -> str | None :
1724 for name in names :
@@ -21,6 +28,39 @@ def _env_value(*names: str, default: str | None = None) -> str | None:
2128 return default
2229
2330
31+ def _oracle_feature_skip_reason (exc : BaseException ) -> str | None :
32+ if not isinstance (exc , _oracledb .DatabaseError ):
33+ return None
34+ message = str (exc )
35+ for error_code , reason in _ORACLE_FEATURE_SKIP_REASONS .items ():
36+ if error_code in message :
37+ return reason
38+ if "PLS-00201" in message and "DBMS_VECTOR_CHAIN" in message :
39+ return "Oracle DBMS_VECTOR_CHAIN APIs are unavailable in this live database"
40+ return None
41+
42+
43+ def _is_oracle_feature_integration_test (item ) -> bool :
44+ return item .path .name == _ORACLE_FEATURE_INTEGRATION_FILE and item .get_closest_marker ("integration" ) is not None
45+
46+
47+ @pytest .hookimpl (hookwrapper = True )
48+ def pytest_runtest_makereport (item , call ):
49+ outcome = yield
50+ report = outcome .get_result ()
51+ if call .when != "call" or not report .failed or call .excinfo is None :
52+ return
53+ if not _is_oracle_feature_integration_test (item ):
54+ return
55+
56+ reason = _oracle_feature_skip_reason (call .excinfo .value )
57+ if reason is None :
58+ return
59+
60+ report .outcome = "skipped"
61+ report .longrepr = (str (item .path ), report .location [1 ], f"Skipped: { reason } " )
62+
63+
2464def connection_config (* , secret_source : str = "token" ) -> OracleConnectionConfig :
2565 wallet_location = _env_value ("ORACLE_WALLET_LOCATION" )
2666 if secret_source == "env_var" :
0 commit comments