Testing: WebSphere Liberty Scenarios
Relevant source files
The following files were used as context for generating this wiki page:
Testing for the WebSphere Liberty role within the SPM Middleware collection is primarily driven by Molecule, an Ansible testing framework. The project utilizes Molecule to automate the lifecycle of testing environments, ensuring that roles are idempotent, lint-compliant, and functional across supported platforms like EL 7 and EL 8. These tests verify the installation of IBM WebSphere Liberty, including base installations, fixpacks, and Java Development Kit (JDK) configurations.
The scope of these scenarios covers the end-to-end deployment process: from environment preparation using Python virtual environments or Docker-in-Docker (DinD) containers to the execution of converge playbooks and verification tasks. This rigorous testing approach ensures that the middleware components are suitable for internal test and development environments for Cúram Social Program Management (SPM).
Sources: CONTRIBUTING.md:73-77, README.md:1-5, roles/liberty/meta/main.yml:25-30
Testing Infrastructure and Environment
The testing architecture relies on a structured development environment to execute Molecule scenarios. Developers can choose between a local Python virtual environment or a specialized Docker container.
Environment Setup Flow
The following diagram illustrates the workflow for initializing a Molecule testing environment for Liberty scenarios.
Molecule Lifecycle Stages
Molecule tests follow a specific sequence of actions to validate the Liberty role:
- Dependency: Resolves role dependencies.
- Create/Prepare: Initializes the Docker instance and prepares the OS.
- Converge: Executes the
libertyrole tasks. - Idempotence: Re-runs the role to ensure no changes are made on subsequent executions.
- Verify: Runs verification playbooks to assert the state of the installation.
- Destroy: Cleans up the testing environment (unless
--destroy neveris used).
Sources: CONTRIBUTING.md:17-30, CONTRIBUTING.md:118-125
Liberty Installation Logic
The testing scenarios exercise the roles/liberty/tasks/main.yml file, which contains the logic for multi-stage installation. This includes checking for existing packages via iim_info, installing the base Liberty version, and applying fixpacks.
Installation Sequence Diagram
This diagram represents how the Liberty role processes installation tasks during a Molecule converge run.
Configuration and Variables
Molecule scenarios use variables to define the Liberty version and installation paths. The role supports two primary ways of installing Java: the IIM (IBM Installation Manager) method and the "unzip" method for OpenJDK.
Key Role Variables
| Variable | Description | Default / Example |
|---|---|---|
liberty_version | The version of Liberty to install | 24.0.0.12 |
liberty_install_path | Target directory for installation | /opt/IBM/WebSphere/Liberty |
jdk_installation_way | Defines method (undefined = IIM, defined = unzip) | undefined |
liberty_pid | Product ID suffix for ND version | Variable based on version |
iim_install_path | Path to IBM Installation Manager | /opt/IBM/InstallationManager |
| Sources: roles/liberty/README.md:10-25, roles/liberty/tasks/main.yml:13-35 |
Verification and Quality Standards
To pass Molecule testing, the Liberty scenarios must adhere to strict criteria. The verify.yml playbook (referenced in the molecule/ directory structure) is responsible for validating that the installation was successful.
Acceptance Criteria
- Idempotency: The role must not report changes when run a second time.
- Linting: All code must pass the Ansible linter (
runLint.sh). - Package Verification: Molecule checks if
com.ibm.websphere.liberty.NDis present in theiim_infopackage list. - File System State: Verification includes checking for the existence of
jvm.optionsand correct permissions on/opt/Props.
Sources: CONTRIBUTING.md:83-89, roles/liberty/tasks/main.yml:58-69, README.md:12-25
Code Snippet: Liberty Main Task Entry
# roles/liberty/tasks/main.yml:5-12
- name: Check packages
iim_info:
iim_path: "{{ iim_install_path }}"
product_id: "com.ibm.websphere.liberty.ND_{{ liberty_pid }}"
register: iim_info
- name: Install Base version
include_tasks: base_install.yml
when: not iim_info.base_installed
Sources: roles/liberty/tasks/main.yml:5-12
Summary
Testing WebSphere Liberty scenarios involves a standardized pipeline using Molecule and Docker. By simulating various installation states—such as base installs, fixpack upgrades, and different JDK delivery methods—the project ensures the liberty role remains robust and compatible with the broader SPM Middleware collection requirements. Successful execution of these scenarios is a prerequisite for any contribution to the repository.
Sources: CONTRIBUTING.md:83-85, README.md:1-5