Running Katalon Studio tests in OpenShift provides a flexible and scalable solution for automated testing. This setup is useful for various scenarios, including:
Creating consistent test environments using OpenShift Container Platform.
Automating test execution as part of a CI/CD pipeline.
Efficiently managing and scaling test resources.
This guide demonstrates how to integrate automated testing into your OpenShift process.
Requirements
Run Katalon tests in OpenShift
Below is the process for running Katalon tests in an OpenShift cluster. This includes gaining access to OpenShift, creating a custom Docker image for Katalon, and deploying the job using the CLI. Follow these steps to set up your environment and run your tests efficiently.
Log in to OpenShift
- Open a terminal and input
crc start
.The output will provide login information for the OpenShift and the oc
command line interface.
- Log in to your OpenShift cluster.
- Configure the
oc
command line interface by running this command: - Log in to OpenShift as an administrator using the provided credentials.
Create a custom Docker Image for Katalon
- Create a directory for your custom image by running these commands:
mkdir ~/katalon-custom-image
cd ~/katalon-custom-image
- Create a file named
Dockerfile
in the terminal.nano Dockerfile
Then, add the following content:
FROM katalonstudio/katalon
USER root
RUN apt-get update && {"\n"} apt-get install -y libxi6 libgconf-2-4 libstdc++6 xvfb && {"\n"} rm -rf /var/lib/apt/lists/*
USER katalon
Save the file and exit the text editor (press Ctrl+X, then Y, and then Enter).
- Build the Docker Image.
docker build -t katalon-custom .
- Tag and push the Docker Image.
docker tag katalon-custom <dockerhub-username>/katalon-custom:latest
docker push <dockerhub-username>/katalon-custom:latest
Deploy and run your Katalon tests in the OpenShift cluster
- Open Visual Studio Code and create a YAML file for the Katalon job.
For example, a file named
katalon-job.yaml
with the following content:
apiVersion: batch/v1
kind: Job
metadata:
name: katalon-job
spec:
template:
spec:
containers:
- name: katalon
image: <dockerhub-username>/katalon-custom:latest
command:
- /bin/bash
- -c
args:
- |
echo "Starting Git Clone" && {"\n"} git clone <your-github-url> /tmp/katalon_execute/project && {"\n"} echo "Git Clone Completed" && {"\n"} cd /tmp/katalon_execute && {"\n"} katalonc.sh -browserType=Chrome -retry=0 -statusDelay=15 -testSuitePath="Test Suites/TS_RegressionTest" -apiKey=<your-apikey> --config -webui.autoUpdateDrivers=true -runMode=console -reportFolder=/tmp/katalon_execute/report -projectPath=/tmp/katalon_execute/project/test.prj -logLevel=DEBUG
resources:
limits:
cpu: 2
memory: 4Gi
requests:
cpu: 1
memory: 2Gi
restartPolicy: Never
backoffLimit: 4
Note: The resources
section in the YAML file specifies the CPU and memory requests and limits for the job. Adjust these values based on the available resources in your OpenShift cluster and the requirements of your Katalon tests.
- Apply the YAML file using the following CLI command in the terminal:
oc apply -f ~/katalon-job.yaml
This command deploys the job configuration defined in the
katalon-job.yaml
file to the OpenShift cluster.
- Get the list of pods.
oc get pods
This command will display a list of all pods along with their names and statuses.
- View the logs of the pod.
oc logs -f <pod-name>
Replace
<pod-name>
with the actual name of the pod. This command will allow you to follow the logs live as the pod runs.
Upon the pod completing its run, you should see the following output indicating the successful test execution:
View the Katalon job in the OpenShift web console
You can also view the Katalon job in the OpenShift web console by accessing the URL provided after starting CRC, for example, https://console-openshift-console.apps-crc.testing
.
- Log in using the provided credentials when starting CRC.
- Open Workloads > Jobs and search your job's name.
- Inside the Jobs, click Pods to see the list of your pods.
- Inside the Pods, you can see the Status is Running.
- Click Logs to view the progress of the job.