Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

Test container images in Red Hat OpenShift 4 with Ansible and CI/CD

August 13, 2021
Petr Hracek
Related topics:
CI/CDContainers
Related products:
Red Hat OpenShift

Share:

    Several repositories offer ready-made container images for Red Hat Enterprise Linux and other systems running Linux. The InterOp team at Red Hat tests these application images in Red Hat OpenShift. To simplify the integration of tests into the continuous integration/continuous delivery (CI/CD) process, we are adding Ansible playbooks to the repositories that host the container images. The Red Hat Software Collections GitHub repository currently has the first of these Ansible playbooks, but we will add playbooks to other repositories over time.

    This article shows how to submit a test to a repository, and how to download the tests if you want to run them in your own container environment.

    Parameters for testing a container

    In order to test a container under a Red Hat OpenShift 4 environment, the developer has to provide information about where to download, deploy, and test the container. The necessary information is illustrated in the following playbook for a PostgreSQL container image:

    registry_redhat_io: "rhscl/postgresql-10-rhel7"
    tag_name: "postgresql:10-el7"
    deployment: "oc new-app postgresql:10-el7~https://github.com/sclorg/postgresql-container.git \
          --name new-postgresql \
          --context-dir examples/extending-image/ \
          -e POSTGRESQL_USER=user \
          -e POSTGRESQL_DATABASE=db \
          -e POSTGRESQL_PASSWORD=password"
    pod_name: "new-postgresql"
    add_route: true
    test_exec_command: "./files/check_postgresql_container.sh"
    expected_exec_result: "FINE"
    check_curl_output: “SOMETHING from curl output”
    scl_url: "postgresql-container"
    is_name: "postgresql"

    The meanings of the fields follow:

    • registry_redhat_io: The image in the registry.redhat.io catalog, including the namespace, which is rhscl in this case.
    • tag_name: The tag name of the image.
    • deployment: The command that deploys the image into the OpenShift environment.
    • pod_name: name of the pod in the OpenShift namespace.
    • add_route: Whether the route should be exposed, where the default is not to expose it.
    • test_exec_command: The file that performs the test.
    • expected_exec_result: A string expected from executing the test_exec_command.
    • check_curl_output: A substring from the expected output of a curl command.
    • scl_url: The repository name, for the Software Collections repositories only.
    • is_name: The imagestream of the container.

    To submit a test for public use, file a pull request at the site hosting the tests. There is currently one site at the Software Collections GitHub repository.

    Storing a test locally

    If you want to keep the test in your private environment instead of sharing the test, you can download our test suite and add your test to it as follows.

    Clone the test repository:

    $ git clone https://github.com/sclorg/ansible-tests

    Go to the cloned repository:

    $ cd ansible-tests

    Add your container test suite to the main Ansible playbook.

    Running a test

    This section assumes that you are running an OpenShift 4 cluster.

    Downloading the OpenShift 4 client

    The latest version of the OpenShift 4 client, 4.6.18, can be obtained for your system at this mirror site. Download the ZIP file and unpack it through:

    $ tar -xzvf <FILE>

    The kubeconfig file

    Tests refer to the Kubernetes kubeconfig file, so you need to point the KUBECONFIG environment variable to the file. Ask your OpenShift 4 cluster administrator for the location of the file, then insert the path into the following command:

    $ export KUBECONFIG=<path_to_kubeconfig>/kubeconfig

    Running your test

    Switch to the cloned repository:

    $ cd ansible-tests

    Execute the test as follows:

    $ make ocp4-tests EXT_TEST=<your_test_name>

    More details are available in a README file in the repository.

    Summary

    This article showed a new method that makes it easy to add a test for your container to a test suite and run the test in an OpenShift 4 cluster that has been set up by an administrator. You can keep the test in your own environment, but we recommend that you heed the Red Hat phrase, "It’s better to share."

    By providing your test to the InterOp team, you can get the container tested during each feature freeze or code freeze done by the OpenShift 4 development team. Feel free to contact the InterOp team at Red Hat.

    Last updated: September 26, 2024

    Related Posts

    • Container Images for OpenShift - Part 1: Objectives

    • Using Quay.io to find vulnerabilities in your container images

    • Building .NET Core container images using S2I

    Recent Posts

    • Build container images in CI/CD with Tekton and Buildpacks

    • How to deploy OpenShift AI & Service Mesh 3 on one cluster

    • JVM tuning for Red Hat Data Grid on Red Hat OpenShift 4

    • Exploring Llama Stack with Python: Tool calling and agents

    • Enhance data security in OpenShift Data Foundation

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2025 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue