Chapter 5. Testing S2I Images
5.1. Overview
As an Source-to-Image (S2I) builder image author, you can test your S2I image locally and use the OpenShift Online build system for automated testing and continuous integration.
Check the S2I Requirements topic to learn more about the S2I architecture before proceeding.
As described in the S2I Requirements topic, S2I requires the assemble and run scripts to be present in order to successfully execute the S2I build. Providing the save-artifacts script reuses the build artifacts, and providing the usage script ensures that usage information is printed to console when someone runs the container image outside of the S2I.
The goal of testing an S2I image is to make sure that all of these described commands work properly, even if the base container image has changed or the tooling used by the commands was updated.
5.2. Testing Requirements
The standard location for the test script is test/run. This script is invoked by the OpenShift Online S2I image builder and it could be a simple Bash script or a static Go binary.
The test/run script performs the S2I build, so you must have the S2I binary available in your $PATH
. If required, follow the installation instructions in the S2I README.
S2I combines the application source code and builder image, so in order to test it you need a sample application source to verify that the source successfully transforms into a runnable container image. The sample application should be simple, but it should exercise the crucial steps of assemble
and run
scripts.
5.3. Generating Scripts and Tools
The S2I tooling comes with powerful generation tools to speed up the process of creating a new S2I image. The s2i create
command produces all the necessary S2I scripts and testing tools along with the Makefile:
The generated test/run script must be adjusted to be useful, but it provides a good starting point to begin developing.
The test/run script produced by the s2i create
command requires that the sample application sources are inside the test/test-app directory.