Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: benchmark test run in a pod #422

Merged
merged 6 commits into from
Jan 23, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: ocp templates for keycloak benchmark
NithinKuruba committed Jan 22, 2025
commit 01e5d504341c252a9b76dc8b32ee4780263fb164
63 changes: 63 additions & 0 deletions .github/workflows/publish-image-benchmark-runner.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Create and publish Benchmark Runner Docker image

on:
push:
branches:
- main
- dev
- SSOTEAM-2187
paths:
- 'benchmark/**'
- '.github/workflows/publish-image-benchmark-runner.yml'

env:
GITHUB_REGISTRY: ghcr.io
REDHAT_REGISTRY: registry.redhat.io
IMAGE_NAME: bcgov/sso-benchmark-runner

jobs:
build-and-push-image:
runs-on: ubuntu-20.04
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Log in to the GitHub Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.GITHUB_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-

- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: benchmark
push: true
tags: ${{ env.GITHUB_REGISTRY }}/${{env.IMAGE_NAME}}:dev
file: benchmark/Dockerfile
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new

# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
22 changes: 22 additions & 0 deletions benchmark/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM eclipse-temurin:21

RUN apt-get update \
&& apt-get install -y wget tar gzip bash jq uuid-runtime curl

ENV KEYCLOAK_BENCHMARK_VERSION=keycloak-benchmark-0.15-SNAPSHOT

# Set working directory
WORKDIR /app

RUN wget https://github.com/keycloak/keycloak-benchmark/releases/download/0.15-SNAPSHOT/${KEYCLOAK_BENCHMARK_VERSION}.tar.gz

# Extract the archive
RUN tar -xzf ${KEYCLOAK_BENCHMARK_VERSION}.tar.gz

RUN rm ${KEYCLOAK_BENCHMARK_VERSION}.tar.gz

RUN chmod +x /app/${KEYCLOAK_BENCHMARK_VERSION}/bin/*.sh

WORKDIR /app/${KEYCLOAK_BENCHMARK_VERSION}/bin

ENTRYPOINT ["./kcb.sh"]
12 changes: 12 additions & 0 deletions benchmark/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
SHELL := /usr/bin/env bash

# make <comand> NAMESPACE="<namespace>"

.PHONY: run_job
run_job:
oc -n $(NAMESPACE) process -f ./openshift/dc.yaml | oc -n $(NAMESPACE) apply -f -

.PHONY: cleanup
cleanup:
oc -n $(NAMESPACE) delete job sso-benchmark-runner
oc -n $(NAMESPACE) delete pvc sso-benchmark-runner-pvc
58 changes: 58 additions & 0 deletions benchmark/openshift/dc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
kind: Template
apiVersion: v1
objects:
- apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ${NAME}-pvc
spec:
accessModes:
- ReadWriteMany
storageClassName: netapp-file-standard
resources:
requests:
storage: 200Mi
- apiVersion: batch/v1
kind: Job
spec:
backoffLimit: 0
template:
metadata:
creationTimestamp: null
spec:
volumes:
- name: ${NAME}-pvc
persistentVolumeClaim:
claimName: ${NAME}-pvc
containers:
- image: ${IMAGE_REPOSITORY}:${IMAGE_TAG}
name: ${NAME}
args:
- ${CONFIG}
resources:
limits:
cpu: 2
memory: 5Gi
requests:
cpu: 500m
memory: 500Mi
volumeMounts:
- name: ${NAME}-pvc
mountPath: /app/${KEYCLOAK_BENCHMARK_VERSION}/results
restartPolicy: Never
metadata:
name: ${NAME}
labels:
app: ${NAME}
component: ${NAME}-job
parameters:
- name: NAME
value: sso-benchmark-runner
- name: IMAGE_TAG
value: dev
- name: IMAGE_REPOSITORY
value: ghcr.io/bcgov/sso-benchmark-runner
- name: KEYCLOAK_BENCHMARK_VERSION
value: keycloak-benchmark-0.15-SNAPSHOT
- name: CONFIG
description: Configuration set of parameters for the test