Testing: WebSphere Scenarios
Relevant source files
The following files were used as context for generating this wiki page:
Testing for WebSphere Scenarios in this project is facilitated through Molecule, a testing framework designed to aid in the development and testing of Ansible roles. These scenarios ensure that IBM WebSphere Application Server (Network Deployment) is correctly installed, patched, and configured to meet the requirements of Cúram Social Program Management (SPM).
The testing infrastructure supports multiple versions of WebSphere (v8.5 and v9.0) across different operating systems, such as Rocky Linux 8. The scenarios encompass the entire lifecycle of a test environment, including dependency management, environment creation, convergence (applying roles), and verification of the final state.
Sources: CONTRIBUTING.md:1-15, README.md:1-10, roles/websphere/README.md:1-10
Test Environment Architecture
The testing architecture utilizes Docker containers to simulate target environments. Developers can run tests locally using a Python virtual environment or within a specialized "Development Container" (DinD - Docker in Docker) to ensure consistency across different development machines.
The diagram above illustrates how Molecule orchestrates test instances within a containerized environment.
Sources: CONTRIBUTING.md:46-65, README.md:37-55
Development Environment Setup
To maintain isolation, the project recommends using a Python virtual environment. Key requirements include:
- Python >= 3.6
- Docker CE
- Molecule with
ansible,docker, andlintplugins.
Sources: CONTRIBUTING.md:105-135
Molecule Test Lifecycle
Every contribution to the WebSphere roles must pass a Molecule test suite. The suite follows a specific sequence of actions to ensure the role is both functional and idempotent.
| Step | Action | Description |
|---|---|---|
| 1 | create | Provisions the Docker container based on the scenario's molecule.yml. |
| 2 | prepare | Sets up prerequisites such as IBM Installation Manager (IIM). |
| 3 | converge | Executes the websphere role tasks to install and configure the server. |
| 4 | idempotence | Re-runs the playbook to ensure no changes are made on the second pass. |
| 5 | verify | Executes verification playbooks to validate the installation. |
| 6 | destroy | Cleans up the test environment (unless --destroy never is used). |
Sources: CONTRIBUTING.md:21-35, CONTRIBUTING.md:100-104
Verification Logic
The verification phase uses verify.yml playbooks to assert that the WebSphere environment meets specific technical criteria. This involves checking installed packages via the iim_info module and validating configuration files.
Verification Criteria for WebSphere v9.0
For version 9.0, the test verifies the presence of the Network Deployment (ND) package and the associated JDK 8.
- name: Check that the correct packages are installed
assert:
that:
- "iim_info.packages | select('match', 'com.ibm.websphere.ND.v90.*') | list | length > 0"
- "iim_info.packages | select('match', 'com.ibm.java.jdk.v8.*') | list | length > 0"
Sources: molecule/__websphere-v90/verify.yml:21-26
Configuration Validation
Testing includes slurping files to check for specific patches or environment variables:
- JspBatchCompiler Patch: Verifies memory settings (e.g.,
-Xmx1600mfor v9.0 or-Xmx1024mfor v8.5). - Environment Variables: Checks
/opt/profile.d/websphere.shfor correctWAS_HOMEandJAVA_HOMEpaths. - Property Files: Ensures
/opt/Props/AppServer.propertiesis created correctly.
Sources: molecule/__websphere-v90/verify.yml:28-39, molecule/__websphere-v85/verify.yml:27-37, roles/websphere/tasks/main.yml:27-38
Scenario Execution Flows
The execution flow for a WebSphere scenario involves conditional task inclusion based on the detected state of the target system.
The flow shows how the role determines whether to perform a base installation or a fixpack upgrade before verification.
Sources: roles/websphere/tasks/main.yml:1-25
Automated Testing Commands
Tests can be triggered for specific scenarios using the molecule test -s command.
- Standard Test:
molecule test -s websphere-v90-rockylinux8 - Debug Mode (Keep Container):
molecule test -s websphere-v90-rockylinux8 --destroy never - Verbose Execution:
molecule test -s websphere-v90-rockylinux8 -- -vvv
Sources: CONTRIBUTING.md:36-45, README.md:70-75
Summary
Testing WebSphere scenarios is a critical requirement for maintaining the spm-middleware collection. By leveraging Molecule and Docker, the project ensures that WebSphere installations are consistent, idempotent, and correctly configured for Cúram SPM. Verification playbooks act as the final gate, programmatically asserting that software versions, memory patches, and environment paths are exactly as required by the application architecture.