Overview
TheOpenshiftDeployable interface extends Deployable to provide OpenShift-specific deployment capabilities. It adds pod management, readiness checks, and OpenShift resource lifecycle methods.
Package: software.tnb.common.deployment
Extends: Deployable
Core methods
create()
deploy() if the service is not already deployed.
Implement this method to define your OpenShift resource creation logic (deployments, services, routes, etc.).
isReady()
Returns
true if service pods exist and all are ready, false otherwise.The default implementation checks that
servicePods() returns a non-empty list and all pods are ready.isDeployed()
Returns
true if the service resources exist in the cluster, false otherwise.podSelector()
A predicate that returns
true for pods belonging to this service.This is used internally by
servicePods() to filter the pods in the namespace. Typically implemented using labels.Pod management
servicePod()
The first pod resource, or
null if no pods are available.Useful for services that run a single pod. For multi-pod services, use
servicePods() instead.servicePods()
A list of pod resources matching the
podSelector(), or null on transient errors.getLogs()
The pod logs as a string.
Configuration methods
waitTime()
The wait time in milliseconds. Default is 300,000ms (5 minutes).
Override this method to customize the deployment timeout for services with different startup characteristics.
Overridden lifecycle methods
deploy()
- Calls
create()ifisDeployed()returnsfalse - Waits for
isReady()to returntrueusingwaitTime()as the timeout - Throws
TimeoutExceptionif the service doesn’t become ready in time
restart()
- Calls
closeResources() - Deletes the service pod
- Waits for new pods to be ready and not marked for deletion
- Calls
openResources()
This performs a pod restart without recreating the entire deployment, which is faster than a full redeploy.
afterAll()
The JUnit extension context.
In parallel execution mode, this method automatically deletes the test namespace to ensure isolation.
enabled()
Returns
true if OpenShift is configured, false otherwise.priority()
Returns
1, giving OpenShift deployables lower priority than the default Deployable priority of 0.Usage example
Implementation notes
Implementations must provide
create(), podSelector(), and isDeployed(). Consider implementing WithName to get default implementations of podSelector() and isDeployed().The interface handles deployment waiting and readiness checks automatically, reducing boilerplate in implementations.
Related interfaces
- WithName - Provides default implementations of
podSelector()andisDeployed()based on deployment name - WithLogs - Base interface for log retrieval
- Deployable - Parent interface defining the core deployment lifecycle