Oracle#
Integration with Oracle AI Database (18c XE
and 26ai Free) and Oracle Autonomous AI Database Free
(adb-free:latest-26ai).
Installation#
pip install pytest-databases
Install oracledb in your project if your tests connect from the host. The
service fixtures themselves validate readiness using sqlplus inside the
container and do not require oracledb in the base package.
Usage Example#
import oracledb
from pytest_databases.docker.oracle import OracleService
pytest_plugins = ["pytest_databases.docker.oracle"]
def test(oracle_service: OracleService) -> None:
conn = oracledb.connect(
user=oracle_service.user,
password=oracle_service.password,
service_name=oracle_service.service_name,
host=oracle_service.host,
port=oracle_service.port,
)
with conn.cursor() as cur:
cur.execute("SELECT 1 FROM dual")
res = cur.fetchone()[0]
assert res == 1
Autonomous AI Database Free (26ai)#
oracle_adb_service starts the official
container-registry.oracle.com/database/adb-free:latest-26ai container image,
exposes all four Autonomous Database ports (1521 TLS, 1522 mTLS,
8443 ORDS / APEX / SQL Developer Web HTTPS, and 27017 Oracle Database
API for MongoDB), provisions the test user via the ADMIN account on the
DATA tablespace with DWROLE, REST-enables the schema via
ORDS.ENABLE_SCHEMA, and automatically extracts the TLS/mTLS wallet to
oracle_adb_service.wallet_dir with tnsnames.ora and sqlnet.ora
rewritten for the mapped host and ports. A failure while provisioning the user
or REST-enabling the schema fails the fixture with the SQL*Plus error. An
unknown oracle_adb_workload_type raises ValueError. The container gets
SYS_ADMIN and no devices by default; override oracle_adb_devices (for
example ["/dev/fuse"]) when the container runtime host provides them.
The image’s server parameter file sets filesystemio_options to direct I/O,
which cannot open the control files when the container storage has 4096-byte
logical sectors (for example an overlay2 Docker root on a 4Kn or dm-crypt
device): startup fails with ORA-27072 / ORA-00202 and then ORA-01034.
oracle_adb_service therefore rewrites the server parameter file with
filesystemio_options='NONE' before the image entrypoint starts the database
(CREATE PFILE FROM SPFILE and CREATE SPFILE FROM PFILE against the idle
instance, inside the container). NONE also works on 512-byte storage.
Override oracle_adb_filesystemio_options to choose another value, or return
None to start the image unchanged:
import pytest
@pytest.fixture(scope="session")
def oracle_adb_filesystemio_options() -> str | None:
return None
The wallet and endpoints are available on the service:
from pathlib import Path
from pytest_databases.docker.oracle import OracleADBService, parse_tnsnames
pytest_plugins = ["pytest_databases.docker.oracle"]
def test_adb_wallet_and_endpoints(oracle_adb_service: OracleADBService, tmp_path: Path) -> None:
assert oracle_adb_service.wallet_dir is not None
assert oracle_adb_service.mtls_alias is not None
assert oracle_adb_service.ca_cert_path is not None
assert oracle_adb_service.ords_url.startswith("https://")
assert oracle_adb_service.apex_url.endswith("/ords/apex")
assert oracle_adb_service.sql_developer_url.endswith("/ords/sql-developer")
assert "authMechanism=PLAIN" in oracle_adb_service.mongo_uri
entries = parse_tnsnames((oracle_adb_service.wallet_dir / "tnsnames.ora").read_text(encoding="utf-8"))
assert oracle_adb_service.mtls_alias in entries
wallet_zip = oracle_adb_service.build_wallet_zip(
tmp_path / "wallet.zip",
wallet_password=oracle_adb_service.password,
)
assert wallet_zip.is_file()
mtls_alias selects the
first *_high TCPS alias (or falls back to the first rewritten TCPS
alias), and build_wallet_zip()
archives host-mapped wallet artifacts (including cwallet.sso when
include_sso=True and lazily synthesized PKCS#12 ewallet.p12 from
ewallet.pem when optional cryptography is installed, omitting
ewallet.p12 cleanly otherwise).
Parallel Execution#
By default, xdist_oracle_isolation_level returns "database". Under
pytest-xdist, workers share one container per Oracle flavor
(oracle26ai, oracle18c, and oracle_adb) and each worker receives
an isolated user named <oracle_user>_<worker> (for example app_0 and
app_1). Both single-process and pytest-xdist sessions provision the
active user via ensure_oracle_user()
under a cross-worker file lock with identical CONNECT, RESOURCE, and
DBA roles plus QUOTA UNLIMITED ON USERS, idempotently tolerating
ORA-01920 and retrying transient ORA-* startup or lock errors.
exec_sql(),
exec_oracle_sql(), and public
exec_sqlplus() run SQL or PL/SQL
through in-container sqlplus against either a pluggable database service
or CDB$ROOT (cdb_root=True / sqlplus -L -S / as sysdba). Custom
fixtures calling provide_oracle_service()
or provide_oracle_adb_service() can also
pass host_port, env, volumes, shm_size, mem_limit, and
one-shot init_sql scripts.
High-concurrency suites that open unpooled per-test connections against the
shared container (for example, SQLAlchemy NullPool across large test suites
without oracledb retry_count) can briefly exhaust TNS listener handlers
and fail with ORA-12516 (DPY-6000). Resolve listener contention using
either of the following options:
Enable connection pooling instead of
NullPool, or configureoracledbretry_countandretry_delayin your driver connection arguments so transient listener refusals retry automatically.Override
xdist_oracle_isolation_levelto return"server"so each worker runs a dedicated transient container and listener (at higher memory and startup cost):
import pytest
from pytest_databases.types import XdistIsolationLevel
@pytest.fixture(scope="session")
def xdist_oracle_isolation_level() -> XdistIsolationLevel:
return "server"
Available Fixtures#
oracle_user: The application username created in the Oracle container (default:"app", envORACLE_USER).oracle_password: The application user password (default:"super-secret", envORACLE_PASSWORD).oracle_system_password: The Oracle system password (default:"super-secret", envORACLE_SYSTEM_PASSWORD).oracle_port: Optional pinned host port for the default Oracle container (default:None, envORACLE_PORT).xdist_oracle_isolation_level: Worker isolation mode:"database"(default, shared container with per-worker users) or"server"(one transient container per worker).oracle_startup_timeout: Startup timeout in seconds fororacle_18c_serviceandoracle_26ai_service(default180, envORACLE_STARTUP_TIMEOUT; non-integer or non-positive values raiseValueError).oracle_adb_startup_timeout: Startup timeout in seconds fororacle_adb_service(default420, envORACLE_ADB_STARTUP_TIMEOUT; non-integer or non-positive values raiseValueError).oracle_service: Alias for the latest supported Oracle service (oracle_26ai_service).
The following version-specific and Autonomous Database fixtures are also available:
oracle_18c_image,oracle_18c_service_name,oracle_18c_port(envORACLE_18C_PORT),oracle_18c_service: Oracle 18c XEoracle_26ai_image(defaultgvenzl/oracle-free:23-slim-faststart, delivering the23.26.xOracle AI Database 26ai Free release line; envORACLE_26AI_IMAGE),oracle_26ai_service_name(defaultFREEPDB1, envORACLE_26AI_SERVICE_NAME),oracle_26ai_port(envORACLE_26AI_PORT, falling back tooracle_port),oracle_26ai_service: Oracle AI Database 26ai Free. Thev0.19.0oracle_23ai_image,oracle_23ai_service_name,oracle_23ai_service, andoracle_23ai_connectionfixtures (and external overrides oforacle_23ai_image,oracle_23ai_service_name, andoracle_23ai_service) remain available as deprecated aliases untilv1.0.0.oracle_adb_image,oracle_adb_workload_type(ATP,ADW,AJD,APEX),oracle_adb_hostname,oracle_adb_tz,oracle_adb_password,oracle_adb_admin_password,oracle_adb_wallet_password,oracle_adb_wallet_dir,oracle_adb_volumes,oracle_adb_devices,oracle_adb_filesystemio_options(defaultNONE, envORACLE_ADB_FILESYSTEMIO_OPTIONS),oracle_adb_port(envORACLE_ADB_PORT),oracle_adb_service: Oracle Autonomous AI Database Free (26ai)
Service API#
Oracle Database and Autonomous Database Free container fixtures and wallet helpers.
- class pytest_databases.docker.oracle.OracleADBService(container: docker.models.containers.Container, host: str, port: int, user: str, password: str, system_password: str, service_name: str, tls_port: int, wallet_password: str, workload_type: str, service_names: tuple[str, ...], ords_port: int = 8443, mongo_port: int = 27017, wallet_dir: Path | None = None)[source]#
Bases:
OracleServiceContainer handle for Oracle Autonomous Database Free with TLS/mTLS wallet, ORDS, and MongoDB API support.
- property ca_cert_path: Path | None#
Path to the extracted
adb_container.certCA certificate whenwallet_diris populated.
- extract_wallet(target_dir: Path) Path[source]#
Extract the container wallet files into
target_dirand rewritetnsnames.oraandsqlnet.ora.
- enable_ords_schema(schema: str | None = None, *, url_mapping_pattern: str | None = None, auto_rest_auth: bool = False) None[source]#
REST-enable
schema(defaults toself.user) for ORDS, SQL Developer Web, and MongoDB API.
- property mtls_alias: str | None#
Preferred
TCPSTNS alias fromwallet_dir/tnsnames.ora, if available.
- build_wallet_zip(target_path: str | Path, *, include_sso: bool = True, wallet_password: str | None = None) Path[source]#
Bundle extracted ADB wallet files into a ZIP archive at
target_path.When
ewallet.p12is absent andewallet.pemexists, lazily synthesizes an encrypted PKCS#12ewallet.p12bundle usingcryptographyif installed.- Parameters:
target_path – Destination ZIP archive path.
include_sso – Whether to include
cwallet.ssoin the archive.wallet_password – Optional password override used to encrypt synthesized
ewallet.p12.
- Returns:
Resolved
Pathof the written ZIP archive.- Raises:
RuntimeError – If
wallet_diris unset or does not exist on disk.
- __init__(container: docker.models.containers.Container, host: str, port: int, user: str, password: str, system_password: str, service_name: str, tls_port: int, wallet_password: str, workload_type: str, service_names: tuple[str, ...], ords_port: int = 8443, mongo_port: int = 27017, wallet_dir: Path | None = None) None#
- class pytest_databases.docker.oracle.OracleService(container: docker.models.containers.Container, host: str, port: int, user: str, password: str, system_password: str, service_name: str)[source]#
Bases:
ServiceContainerContainer handle with administrative and application credentials for Oracle.
- exec_sql(sql: str, *, user: str | None = None, password: str | None = None, service_name: str | None = None, as_sysdba: bool = False, cdb_root: bool = False, whenever_sqlerror: str = 'EXIT SQL.SQLCODE', retry_transient: bool = False) tuple[int, bytes][source]#
Execute
sqlvia in-containersqlplusagainst this Oracle service.- Parameters:
sql – SQL statement or PL/SQL script to run.
user – Optional login override (defaults to
"sys"whenas_sysdbais set, elseself.user).password – Optional password override (defaults to
system_passwordfor administrative execution).service_name – Optional TNS/PDB service override (defaults to
self.service_name).as_sysdba – Connect with
AS SYSDBAadministrative privileges over TNS.cdb_root – Connect directly to
CDB$ROOTvia OS authentication (sqlplus -L -S / as sysdba).whenever_sqlerror – SQL*Plus
WHENEVER SQLERRORdirective.retry_transient – Retry boundedly on transient listener/startup/catalog lock errors.
- Returns:
Tuple of
(exit_code, output_bytes).
- pytest_databases.docker.oracle.enable_oracle_ords_schema(container: docker.models.containers.Container, user: str, password: str, service_name: str, *, url_mapping_pattern: str | None = None, auto_rest_auth: bool = False) None[source]#
REST-enable an Oracle Autonomous Database schema for ORDS, SQL Developer Web, and MongoDB API.
- Parameters:
container – Running Oracle ADB-Free container.
user – Database schema owner username.
password – User password.
service_name – Autonomous Database service name.
url_mapping_pattern – Optional URL mapping slug (defaults to
user.lower()).auto_rest_auth – Whether to require authentication on auto-REST metadata endpoints.
- Raises:
RuntimeError – If
ORDS.ENABLE_SCHEMAfails.
- pytest_databases.docker.oracle.ensure_oracle_adb_user(container: docker.models.containers.Container, user: str, password: str, service_name: str, admin_password: str) None[source]#
Provision an Oracle Autonomous Database application user via the
ADMINaccount.An existing user (
ORA-01920) gets its password reset instead of being recreated;ORA-28007from that reset (the ADB password profile rejects reusing the current password) is ignored because the password is already correct. Any other error stops the script.- Parameters:
container – Running Oracle ADB-Free container.
user – Application username to create or update.
password – Password meeting
CLOUD_VERIFY_FUNCTIONcomplexity rules.service_name – Autonomous Database service name (e.g.
myatp_high.adb.oraclecloud.com).admin_password – Password for the
ADMINadministrative account.
- Raises:
RuntimeError – If creating, unlocking, or granting privileges to the user fails.
- pytest_databases.docker.oracle.ensure_oracle_user(container: docker.models.containers.Container, user: str, password: str, service_name: str, system_password: str) bool[source]#
Ensure an Oracle application user exists with appropriate tablespace quota and roles.
Existing users (
ORA-01920) have their password synchronized (toleratingORA-28007when password-reuse rules reject the current password) and unlocked before applying grants and tablespace quota. Transient Oracle startup, listener, or lock errors are retried via_run_sqlplus_with_retry.- Parameters:
container – The container instance.
user – Effective username to create.
password – User password.
service_name – Oracle service or PDB name.
system_password – SYS administrative user password.
- Returns:
Trueif the SQL*Plus provisioning command exited cleanly.
- pytest_databases.docker.oracle.exec_oracle_sql(container: docker.models.containers.Container, sql: str, *, service_name: str | None = None, user: str | None = None, password: str | None = None, as_sysdba: bool = False, whenever_sqlerror: str = 'EXIT SQL.SQLCODE', retry_transient: bool = False) tuple[int, bytes][source]#
Execute SQL or PL/SQL inside a running Oracle container via
sqlplus.Supports both TNS service/PDB execution (
user/password@//localhost:1521/service) and OS-authenticatedCDB$ROOTexecution (sqlplus -L -S / as sysdbawhenas_sysdba=Trueandservice_name,user, andpasswordare omitted). Modulo-256 zero exit codes onORA-/PLS-/SP2-errors are normalized to1unlesswhenever_sqlerror="CONTINUE".- Parameters:
container – Running Oracle container handle.
sql – SQL statement or PL/SQL block.
service_name – Target PDB or service name (omit with
as_sysdba=TrueforCDB$ROOT).user – Database username (omit with
as_sysdba=Truefor OS authentication).password – User password.
as_sysdba – Connect with
AS SYSDBAadministrative privileges.whenever_sqlerror – SQL*Plus
WHENEVER SQLERRORdirective.retry_transient – Retry boundedly on transient listener, startup, or catalog lock errors.
- Returns:
Tuple of
(exit_code, output_bytes).- Raises:
ValueError – If TNS execution is missing
service_name,user, orpassword.
- pytest_databases.docker.oracle.exec_sqlplus(container: docker.models.containers.Container, sql: str, *, connect_as: str = '/ as sysdba', whenever_sqlerror: str = 'EXIT SQL.SQLCODE') tuple[int, str][source]#
Execute SQL or PL/SQL inside an Oracle container via
sqlplusand decode the output.Supports both OS authentication (default
"/ as sysdba") and explicit credential strings such as"user/password@//127.0.0.1:1521/FREEPDB1". Modulo-256 zero exit codes withORA-/PLS-/SP2-output errors are normalized to1.- Parameters:
container – Running Oracle container handle.
sql – SQL statement or PL/SQL block.
connect_as – SQL*Plus connection specifier.
whenever_sqlerror – SQL*Plus
WHENEVER SQLERRORdirective.
- Returns:
Tuple of
(exit_code, decoded_output).- Raises:
ValueError – If
connect_asis empty or whitespace-only.
- pytest_databases.docker.oracle.extract_adb_wallet(container: docker.models.containers.Container, target_dir: Path, *, host: str, port: int, tls_port: int | None = None, container_wallet_path: str = '/u01/app/oracle/wallets/tls_wallet') Path[source]#
Extract the TLS/mTLS wallet directory from an Oracle ADB-Free container and rewrite
tnsnames.oraandsqlnet.ora.- Parameters:
container – Running Oracle ADB-Free container.
target_dir – Destination host directory where wallet files will be written.
host – Mapped container host address.
port – Mapped port for internal port 1521.
tls_port – Optional mapped port for internal port 1522.
container_wallet_path – Path to the wallet directory inside the container.
- Returns:
Path to
target_dircontaining extracted wallet files (cwallet.sso,ewallet.p12,ewallet.pem,keystore.jks,truststore.jks,ojdbc.properties,adb_container.cert,tnsnames.ora,sqlnet.ora).
- pytest_databases.docker.oracle.oracle_18c_connection(oracle_18c_service: OracleService) Generator[Any, None, None][source]#
Deprecated
oracledbconnection fixture for Oracle 18c XE.- Yields:
An open
oracledb.Connection.
- pytest_databases.docker.oracle.oracle_18c_image() str[source]#
Container image for Oracle Database 18c XE.
- pytest_databases.docker.oracle.oracle_18c_port() int | None[source]#
Optional pinned host port for Oracle 18c XE (
ORACLE_18C_PORT).
- pytest_databases.docker.oracle.oracle_18c_service(docker_service: DockerService, xdist_oracle_isolation_level: XdistIsolationLevel, oracle_18c_image: str, oracle_18c_service_name: str, oracle_user: str, oracle_password: str, oracle_system_password: str, oracle_startup_timeout: int, oracle_18c_port: int | None) Generator[OracleService, None, None][source]#
Session fixture providing an Oracle Database 18c XE container service.
- Yields:
An OracleService handle.
- pytest_databases.docker.oracle.oracle_18c_service_name() str[source]#
Default PDB service name for Oracle Database 18c XE.
- pytest_databases.docker.oracle.oracle_23ai_connection(request: pytest.FixtureRequest) Generator[Any, None, None][source]#
Deprecated
oracledbconnection fixture preserved for v0.19.0 callers.Deprecated since version 0.20.0: Create an
oracledbconnection fromoracle_serviceororacle_26ai_serviceinstead.oracle_23ai_connectionwill be removed in v1.0.0.- Yields:
An open
oracledb.Connection.
- pytest_databases.docker.oracle.oracle_23ai_image() str[source]#
Deprecated alias for
oracle_26ai_imagepreserved for v0.19.0 callers.Deprecated since version 0.20.0: Use
oracle_26ai_imageinstead.oracle_23ai_imagewill be removed in v1.0.0.
- pytest_databases.docker.oracle.oracle_23ai_service(oracle_26ai_service: OracleService) OracleService[source]#
Deprecated alias for
oracle_26ai_servicepreserved for v0.19.0 callers.Deprecated since version 0.20.0: Use
oracle_26ai_serviceororacle_serviceinstead.oracle_23ai_servicewill be removed in v1.0.0.
- pytest_databases.docker.oracle.oracle_23ai_service_name() str[source]#
Deprecated alias for
oracle_26ai_service_namepreserved for v0.19.0 callers.Deprecated since version 0.20.0: Use
oracle_26ai_service_nameinstead.oracle_23ai_service_namewill be removed in v1.0.0.
- pytest_databases.docker.oracle.oracle_26ai_connection(oracle_26ai_service: OracleService) Generator[Any, None, None][source]#
Deprecated
oracledbconnection fixture for Oracle AI Database 26ai Free.- Yields:
An open
oracledb.Connection.
- pytest_databases.docker.oracle.oracle_26ai_image(request: FixtureRequest) str[source]#
Container image for Oracle AI Database 26ai Free (
23.26.xtrack ongvenzl/oracle-free).
- pytest_databases.docker.oracle.oracle_26ai_port(oracle_port: int | None) int | None[source]#
Optional pinned host port for Oracle AI Database 26ai Free (
ORACLE_26AI_PORTorORACLE_PORT).
- pytest_databases.docker.oracle.oracle_26ai_service(docker_service: DockerService, xdist_oracle_isolation_level: XdistIsolationLevel, oracle_26ai_image: str, oracle_26ai_service_name: str, oracle_user: str, oracle_password: str, oracle_system_password: str, oracle_startup_timeout: int, oracle_26ai_port: int | None) Generator[OracleService, None, None][source]#
Session fixture providing an Oracle AI Database 26ai Free container service.
- Yields:
An OracleService handle.
- pytest_databases.docker.oracle.oracle_26ai_service_name(request: FixtureRequest) str[source]#
Default PDB service name for Oracle AI Database 26ai Free.
- pytest_databases.docker.oracle.oracle_adb_admin_password() str[source]#
Administrative
ADMINpassword for Oracle Autonomous Database Free.
- pytest_databases.docker.oracle.oracle_adb_devices() list[str] | None[source]#
Optional device mappings for Oracle Autonomous Database Free, such as
["/dev/fuse"].The devices must exist on the container runtime host, which is not necessarily the host running pytest.
- pytest_databases.docker.oracle.oracle_adb_filesystemio_options() str | None[source]#
filesystemio_optionswritten to the ADB-Free server parameter file before the database starts.Defaults to
NONE(envORACLE_ADB_FILESYSTEMIO_OPTIONS) so the instance opens on storage with 4096-byte logical sectors. Override this fixture to returnNoneto keep the image’s own setting.
- pytest_databases.docker.oracle.oracle_adb_hostname() str[source]#
Container hostname for Oracle Autonomous Database Free.
- pytest_databases.docker.oracle.oracle_adb_image() str[source]#
Container image for Oracle Autonomous AI Database Free (26ai).
- pytest_databases.docker.oracle.oracle_adb_password() str[source]#
Application password for Oracle Autonomous Database Free (meets
CLOUD_VERIFY_FUNCTIONrules).
- pytest_databases.docker.oracle.oracle_adb_port() int | None[source]#
Optional pinned host port for Oracle ADB-Free (
ORACLE_ADB_PORT).
- pytest_databases.docker.oracle.oracle_adb_service(docker_service: DockerService, xdist_oracle_isolation_level: XdistIsolationLevel, oracle_adb_image: str, oracle_adb_workload_type: str, oracle_adb_hostname: str, oracle_adb_tz: str, oracle_user: str, oracle_adb_password: str, oracle_adb_admin_password: str, oracle_adb_wallet_password: str, oracle_adb_wallet_dir: Path, oracle_adb_volumes: dict[str, dict[str, str]] | list[str] | None, oracle_adb_devices: list[str] | None, oracle_adb_filesystemio_options: str | None, oracle_adb_startup_timeout: int, oracle_adb_port: int | None) Generator[OracleADBService, None, None][source]#
Session fixture providing an Oracle Autonomous AI Database Free (26ai) container service.
- Yields:
An OracleADBService handle.
- pytest_databases.docker.oracle.oracle_adb_startup_timeout() int[source]#
Startup timeout in seconds for Oracle Autonomous AI Database Free containers.
- pytest_databases.docker.oracle.oracle_adb_tz() str[source]#
Database timezone (
MY_TZ) for Oracle Autonomous Database Free.
- pytest_databases.docker.oracle.oracle_adb_volumes() dict[str, dict[str, str]] | list[str] | None[source]#
Optional volume mounts for Oracle Autonomous Database Free.
- pytest_databases.docker.oracle.oracle_adb_wallet_dir(tmp_path_factory: TempPathFactory) Path[source]#
Host directory where the Oracle Autonomous Database Free wallet is extracted.
- pytest_databases.docker.oracle.oracle_adb_wallet_password() str[source]#
Wallet password for Oracle Autonomous Database Free (meets
CLOUD_VERIFY_FUNCTIONrules).
- pytest_databases.docker.oracle.oracle_adb_workload_type() str[source]#
Workload type for Oracle Autonomous Database Free (
ATP,ADW,AJD, orAPEX).
- pytest_databases.docker.oracle.oracle_password() str[source]#
Default application password for Oracle.
- pytest_databases.docker.oracle.oracle_port() int | None[source]#
Optional pinned host port for the default Oracle container (
ORACLE_PORT).
- pytest_databases.docker.oracle.oracle_responsive(host: str, port: int, service_name: str, user: str, password: str) bool[source]#
Check whether an Oracle instance responds to a
SELECT 1 FROM dualquery viaoracledb.Deprecated since version 0.20.0:
oracle_responsiveis deprecated in v0.20.0 and will be removed in v1.0.0.- Returns:
True when the query returns
1, otherwise False.
- pytest_databases.docker.oracle.oracle_service(request: FixtureRequest) OracleService[source]#
Alias for the latest default Oracle service (26ai).
- pytest_databases.docker.oracle.oracle_startup_connection(oracle_26ai_service: OracleService) Generator[Any, None, None][source]#
Deprecated alias for
oracle_26ai_connectionpreserved for v0.19.0 callers.- Yields:
An open
oracledb.Connection.
- pytest_databases.docker.oracle.oracle_startup_timeout() int[source]#
Startup timeout in seconds for Oracle Database 18c and 26ai containers.
- pytest_databases.docker.oracle.oracle_system_password() str[source]#
Default administrative SYS password for Oracle.
- pytest_databases.docker.oracle.parse_tnsnames(tns_content: str) dict[str, dict[str, str]][source]#
Parse an Oracle
tnsnames.orafile into structured service descriptor dictionaries.- Parameters:
tns_content – Raw text content of
tnsnames.ora.- Returns:
Mapping of lowercase TNS alias names to dictionaries containing
protocol,host,port,service_name, anddescriptor.
- pytest_databases.docker.oracle.provide_oracle_adb_service(docker_service: DockerService, image: str, name: str, workload_type: str, hostname: str, user: str, password: str, system_password: str, wallet_password: str, isolation_level: XdistIsolationLevel = 'database', *, tz: str = 'UTC', host_port: int | None = None, env: Mapping[str, str] | None = None, wallet_dir: Path | None = None, volumes: dict[str, dict[str, str]] | list[str] | None = None, devices: list[str] | None = None, shm_size: int | str | None = None, mem_limit: str | None = None, init_sql: str | Path | Sequence[str | Path] | None = None, filesystemio_options: str | None = 'NONE', timeout: int = 420, pause: float = 2.0) Generator[OracleADBService, None, None][source]#
Start and manage an Oracle Autonomous AI Database Free (26ai) container.
The image’s server parameter file sets
filesystemio_optionsto direct I/O, which cannot open the control files when the container storage has 4096-byte logical sectors (ORA-27072,ORA-00202, thenORA-01034). By default the container command therefore rewrites the server parameter file withfilesystemio_options='NONE'(CREATE PFILE FROM SPFILEandCREATE SPFILE FROM PFILEagainst the idle instance) and then runs the image entrypoint. Passfilesystemio_options=Noneto start the image unchanged.- Parameters:
docker_service – The container service manager.
image – Oracle ADB-Free container image.
name – Logical container service name.
workload_type – Autonomous workload profile (
ATP,ADW,AJD, orAPEX).hostname – Container hostname required by ADB-Free initialization scripts.
user – Default application username.
password – Application user password meeting
CLOUD_VERIFY_FUNCTIONrules.system_password –
ADMINaccount password.wallet_password – Password protecting the container’s TLS/mTLS wallet.
isolation_level – xdist isolation strategy (database or server).
tz – Database timezone passed via
MY_TZ(defaults toUTC).host_port – Optional pinned host TCP port for listener port 1521.
env – Optional extra container environment variables merged over defaults.
wallet_dir – Optional host directory where the container wallet will be extracted automatically.
volumes – Optional container volume mounts (e.g. for
/u01/app/oracle/wallets/tls_wallet).devices – Optional device mappings for the container runtime host (for example
["/dev/fuse"]).shm_size – Optional
/dev/shmsize forwarded to container creation.mem_limit – Optional container memory limit forwarded to container creation.
init_sql – Optional SQL/PLSQL statement, file path, or sequence executed once per target user/service.
filesystemio_options –
filesystemio_optionsvalue written to the server parameter file before the database starts (NONE,ASYNC,DIRECTIO, orSETALL), orNonefor the image default.timeout – Maximum startup wait time in seconds.
pause – Sleep interval in seconds between readiness polling attempts.
- Yields:
An OracleADBService handle configured for the active worker.
- Raises:
ValueError – If
workload_typeis notATP,ADW,AJD, orAPEX,filesystemio_optionsis not a validfilesystemio_optionsvalue,timeoutis not a positive integer, orpauseis not a positive finite number.
- pytest_databases.docker.oracle.provide_oracle_service(docker_service: DockerService, image: str, name: str, service_name: str, user: str, password: str, system_password: str, isolation_level: XdistIsolationLevel = 'database', *, host_port: int | None = None, env: Mapping[str, str] | None = None, volumes: dict[str, dict[str, str]] | list[str] | None = None, shm_size: int | str | None = None, mem_limit: str | None = None, init_sql: str | Path | Sequence[str | Path] | None = None, timeout: int = 180, pause: float = 1.0) Generator[OracleService, None, None][source]#
Start and manage an Oracle database container with consistent privilege provisioning.
Both single-process and
pytest-xdistruns runensure_oracle_user()againsteffective_usersoAPP_USERalways receives identicalCONNECT,RESOURCE,DBA, andQUOTA UNLIMITED ON USERSprivileges regardless of concurrency mode.- Parameters:
docker_service – The container service manager.
image – Container image for Oracle.
name – Logical container service name.
service_name – Oracle PDB or service name.
user – Default application username.
password – Application user password.
system_password – Administrative SYS password.
isolation_level – xdist isolation strategy (database or server).
host_port – Optional pinned host TCP port for listener port 1521.
env – Optional extra container environment variables merged over defaults.
volumes – Optional container volume mounts.
shm_size – Optional
/dev/shmsize (important for larger Oracle SGA configurations).mem_limit – Optional container memory limit (for example
"4g").init_sql – Optional SQL/PLSQL statement, file path, or sequence executed once per target user/PDB.
timeout – Maximum startup wait time in seconds.
pause – Sleep interval in seconds between readiness polling attempts.
- Yields:
An OracleService handle configured for the active worker.
- Raises:
ValueError – If
timeoutis not a positive integer orpauseis not a positive finite number.
- pytest_databases.docker.oracle.rewrite_sqlnet_ora(sqlnet_content: str, wallet_dir: Path) str[source]#
Rewrite
sqlnet.oraWALLET_LOCATIONDIRECTORYtowallet_dirand disable DN matching.- Parameters:
sqlnet_content – Original
sqlnet.oracontent.wallet_dir – Host directory containing the extracted wallet files.
- Returns:
Updated
sqlnet.oratext.
- pytest_databases.docker.oracle.rewrite_tnsnames(tns_content: str, *, host: str, port: int, tls_port: int | None = None) str[source]#
Rewrite
HOST,PORT, andSSL_SERVER_DN_MATCHentries intnsnames.orafor host access.- Parameters:
tns_content – Original
tnsnames.oracontent.host – Mapped host address.
port – Mapped host port for internal port 1521.
tls_port – Optional mapped host port for internal mTLS port 1522.
- Returns:
Updated
tnsnames.oratext.