Testing: Oracle DB Scenarios
Relevant source files
The following files were used as context for generating this wiki page:
Introduction
The "Testing: Oracle DB Scenarios" framework utilizes Molecule to validate the deployment and configuration of Oracle Database environments within the SPM Middleware project. These scenarios ensure that Oracle roles are idempotent, meet technical requirements for Social Program Management (SPM), and function correctly across different database versions including 12c R1, 12c R2, and 19c.
The testing lifecycle is integrated into the development environment, supporting both local Python virtual environments and containerized (Docker-in-Docker) execution. Each scenario follows a structured sequence: dependency installation, creation, preparation, convergence (deployment), and verification.
Sources: CONTRIBUTING.md:7-13, CONTRIBUTING.md:121-125, README.md:1-5
Testing Architecture and Lifecycle
The testing process for Oracle scenarios follows the standard Molecule lifecycle, ensuring a clean and reproducible environment for every test run.
Execution Flow
- Create/Prepare: Initializes the test instances (usually Docker containers).
- Converge: Applies the Oracle Ansible role to the instance, executing installation, patching, and configuration.
- Verify: Executes specific verification playbooks to assert that the database is operational and correctly configured for SPM.
- Destroy: Cleans up the test environment (unless the
--destroy neverflag is used for debugging).
The diagram shows the sequential stages of a Molecule test scenario applied to Oracle Database roles.
Sources: CONTRIBUTING.md:15-28, CONTRIBUTING.md:127-133
Verification Framework
Verification is handled by verify.yml playbooks unique to each Oracle version. These playbooks perform technical checks using shell commands and Ansible assertions to validate the state of the database engine and the instance.
Key Verification Metrics
| Metric | Verification Method | Supported Versions |
|---|---|---|
| Binary Integrity | Checks for existence of db_inst.rsp or database directories | 12cR1, 12cR2, 19c |
| Version Accuracy | Query v$version or check opatch lspatches | All |
| SPM Configuration | Query DBA_USERS for the 'CURAM' user | All |
| Automation Scripts | Check existence of start_all.sh and stop_all.sh | All |
| System Integration | Validate oracle.service and /etc/oratab | 19c |
Sources: molecule/__oracle-v19c/verify.yml:18-45, molecule/__oracle-v12cR2/verify.yml:17-43, molecule/__oracle-v12cR1/verify.yml:17-43
Verification Logic Flow
The verification playbooks utilize a pre_tasks block to gather information before running assertions.
This diagram illustrates the sequence of checks performed during the verification phase to ensure the database is ready for SPM application use.
Sources: molecule/__oracle-v19c/verify.yml:7-55, molecule/__oracle-v12cR1/verify.yml:7-50
Implementation Details
Version-Specific Testing
Different scenarios target specific versions and patches. For example, Oracle 19c verification includes checks for a specific version string (19.26.0.0.0) and ensures that all /etc/oratab entries are set to 'Y' for autostart.
Sources: molecule/__oracle-v19c/verify.yml:6-8, molecule/__oracle-v19c/verify.yml:85-93
In contrast, 12c scenarios focus on validating specific OPatch numbers, such as 33587128 for 12cR2 and 33477199 for 12cR1, using the opatch lspatches command.
Sources: molecule/__oracle-v12cR2/verify.yml:8, molecule/__oracle-v12cR1/verify.yml:8
Environment Configuration
Tests are executed within environments that mirror production requirements, including specific kernel parameters and user limits defined in roles/oracle/tasks/12c_install.yml.
# Example: Verification of version 19c
- name: Check if correct version installed
become: yes
become_user: oracle
shell: "echo 'SELECT * FROM v$version;' | $ORACLE_HOME/bin/sqlplus / as sysdba | grep -i {{ oracle_version }}"
register: oracle_version_status
environment:
ORACLE_HOME: "/opt/oracle/product/19c/dbhome_1"
ORACLE_SID: "orcl"
Sources: molecule/__oracle-v19c/verify.yml:5-24, roles/oracle/tasks/12c_install.yml:104-118
Summary
Testing Oracle DB Scenarios within the SPM Middleware project provides a robust validation layer for database automation. By combining Molecule’s lifecycle management with version-specific SQL and file-system assertions, the project ensures that Oracle 12c and 19c environments are consistently prepared for Cúram Social Program Management workloads. This process guarantees that every contribution is idempotent and technically accurate across supported platforms.