Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • Guided learning
      Receive custom learning paths powered by our AI assistant.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

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

    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

    • What GPU kernels mean for your distributed inference

    • Debugging image mode with Red Hat OpenShift 4.20: A practical guide

    • EvalHub: Because "looks good to me" isn't a benchmark

    • SQL Server HA on RHEL: Meet Pacemaker HA Agent v2 (tech preview)

    • Deploy with confidence: Continuous integration and continuous delivery for agentic AI

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    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
    © 2026 Red Hat

    Red Hat legal and privacy links

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

    Chat Support

    Please log in with your Red Hat account to access chat support.