Skip to content

Commit

Permalink
feat: add benchmark demo (#3325)
Browse files Browse the repository at this point in the history
* feat: add benchmark initial work

* feat: add benchmark initial work

* test: jmeter - use "topsecret" + number for generated password

* fix: missing envs

* fix: parsing the authz jmx

* fix: parsing the authz jmx

* fix: adjust jmx

* docs: add envs description

* fix: add benchmark doc and yaml

* ci: fix conditional on updating dates inside dockerfile

* docs: proofreaad

Co-authored-by: YuriyZ <yzabrovarniy@gmail.com>
  • Loading branch information
moabu and yuriyz authored Jan 2, 2023
1 parent be4e272 commit 26bbb0c
Show file tree
Hide file tree
Showing 39 changed files with 2,289 additions and 8,701 deletions.
27 changes: 16 additions & 11 deletions .github/workflows/docker_build_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ on:
workflow_dispatch:
inputs:
services:
description: 'One or set of the docker images. Format as following: "docker-jans-auth-server docker-jans-certmanager docker-jans-config-api docker-jans-configurator docker-jans-fido2 docker-jans-persistence-loader docker-jans-scim docker-jans-monolith"'
description: 'One or set of the docker images. Format as following: "docker-jans-auth-server docker-jans-certmanager docker-jans-config-api docker-jans-configurator docker-jans-fido2 docker-jans-persistence-loader docker-jans-scim docker-jans-monolith docker-jans-loadtesting-jmeter"'
required: true
default: 'docker-jans-auth-server docker-jans-certmanager docker-jans-config-api docker-jans-configurator docker-jans-fido2 docker-jans-persistence-loader docker-jans-scim docker-jans-monolith'
default: 'docker-jans-auth-server docker-jans-certmanager docker-jans-config-api docker-jans-configurator docker-jans-fido2 docker-jans-persistence-loader docker-jans-scim docker-jans-monolith docker-jans-loadtesting-jmeter'
cn_version:
description: 'The war version to build the image off'
required: false
Expand All @@ -44,7 +44,7 @@ jobs:
strategy:
max-parallel: 8
matrix:
docker-images: ["auth-server", "certmanager", "config-api", "configurator", "fido2", "persistence-loader", "scim", "monolith"]
docker-images: ["auth-server", "certmanager", "config-api", "configurator", "fido2", "persistence-loader", "scim", "monolith", "loadtesting-jmeter"]
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -58,15 +58,15 @@ jobs:
DEFAULT_ALL=${{ github.event.inputs.services }}
if [ -z "$DEFAULT_ALL" ]
then
DEFAULT_ALL="docker-jans-auth-server docker-jans-certmanager docker-jans-config-api docker-jans-configurator docker-jans-fido2 docker-jans-persistence-loader docker-jans-scim docker-jans-monolith"
DEFAULT_ALL="docker-jans-auth-server docker-jans-certmanager docker-jans-config-api docker-jans-configurator docker-jans-fido2 docker-jans-persistence-loader docker-jans-scim docker-jans-monolith docker-jans-loadtesting-jmeter"
else
echo "$DEFAULT_ALL"
fi
# Detect actual docker folders that changed if error arises default to all images
pull_number=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH")
DIRECTORIES_CHANGED=$(gh pr view $pull_number --json files --jq '.files.[].path' | cut -d/ -f1 | sort -u | grep "docker-jans" || echo "$DEFAULT_ALL")
if [[ "$DIRECTORIES_CHANGED" =~ "${{ matrix.docker-images }}" ]]; then
echo "A change in this images directory has occured"
echo "A change in this images directory has occurred"
echo ::set-output name=build::${BUILD}
fi
Expand All @@ -84,7 +84,11 @@ jobs:
if: steps.build_docker_image.outputs.build || github.event_name == 'tags'
id: prep
run: |
MAIN_VERSION=$(python3 -c "from dockerfile_parse import DockerfileParser ; dfparser = DockerfileParser('./docker-jans-${{ matrix.docker-images }}') ; print(dfparser.labels['version'])")
DOCKER_FILE_LOCATION=./docker-jans-${{ matrix.docker-images }}
if [[ "loadtesting-jmeter" =~ "${{ matrix.docker-images }}" ]]; then
DOCKER_FILE_LOCATION=./demos/benchmarking/docker-jans-loadtesting-jmeter
fi
MAIN_VERSION=$(python3 -c "from dockerfile_parse import DockerfileParser ; dfparser = DockerfileParser('$DOCKER_FILE_LOCATION') ; print(dfparser.labels['version'])")
DOCKER_IMAGE=janssenproject/${{ matrix.docker-images }}
VERSION=${MAIN_VERSION}_dev
BUILD=true
Expand Down Expand Up @@ -118,16 +122,17 @@ jobs:
fi
echo ::set-output name=tags::${TAGS}
echo ::set-output name=build::${BUILD}
echo ::set-output name=dockerfilelocation::${DOCKER_FILE_LOCATION}
# UPDATE BUILD DATES INSIDE THE DOCKERFILE BEFORE BUILDING THE DEV IMAGES TRIGGERED BY JENKINS
- name: Setup Python 3.7
if: github.event_name == 'workflow_dispatch'
if: github.event_name == 'workflow_dispatch' && ${{ matrix.docker-images }} != 'loadtesting-jmeter'
uses: actions/setup-python@v4
with:
python-version: 3.7

- name: Install Python dependencies
if: github.event_name == 'workflow_dispatch'
if: github.event_name == 'workflow_dispatch' && ${{ matrix.docker-images }} != 'loadtesting-jmeter'
run: |
sudo apt-get update
sudo python3 -m pip install --upgrade pip
Expand All @@ -137,7 +142,7 @@ jobs:
sudo apt-get install jq
- name: Update Build date in Dockerfile
if: github.event_name == 'workflow_dispatch'
if: github.event_name == 'workflow_dispatch' && ${{ matrix.docker-images }} != 'loadtesting-jmeter'
id: update_build_date_in_dockerfile
run: |
sudo python3 ./automation/auto_update_build_date.py
Expand Down Expand Up @@ -177,8 +182,8 @@ jobs:
uses: docker/build-push-action@v3
with:
builder: ${{ steps.buildx.outputs.name }}
context: ./docker-jans-${{ matrix.docker-images }}
file: ./docker-jans-${{ matrix.docker-images }}/Dockerfile
context: ${{ steps.prep.outputs.dockerfilelocation }}
file: ${{ steps.prep.outputs.dockerfilelocation }}/Dockerfile
#target: prod
# add to platforms comma seperated linux/ppc64leL Issue: py3-grpcio
# add to platforms comma seperated linux/386 : Issue: openjdk11-jre-headless alpine package not
Expand Down
4 changes: 2 additions & 2 deletions charts/janssen/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -367,12 +367,12 @@ config-api:
# -- CPU limit.
cpu: 1000m
# -- Memory limit.
memory: 400Mi
memory: 1000Mi
requests:
# -- CPU request.
cpu: 1000m
# -- Memory request.
memory: 400Mi
memory: 1000Mi
# -- Configure the liveness healthcheck for the auth server if needed.
livenessProbe:
# -- http liveness probe endpoint
Expand Down
11 changes: 11 additions & 0 deletions demos/benchmarking/docker-jans-loadtesting-jmeter/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# exclude everything
*

# include required files/directories
!certs
!conf
!jetty
!libs
!scripts
!LICENSE
!requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
105 changes: 105 additions & 0 deletions demos/benchmarking/docker-jans-loadtesting-jmeter/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# dotenv
.env

# virtualenv
.venv
venv/
ENV/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# PyCharm project settings
.idea
# mkdocs documentation
/site

# mypy
.mypy_cache/

.DS_STORE
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ignored:
- DL3018 # Pin versions in apk add
- DL3013 # Pin versions in pip
- DL3003 # Use WORKDIR to switch to a directory
77 changes: 77 additions & 0 deletions demos/benchmarking/docker-jans-loadtesting-jmeter/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
FROM blazemeter/taurus:master-f96971fa-2022-12-12

# ===============
# Ubuntu packages
# ===============

RUN apt-get clean \
&& mv /var/lib/apt/lists /tmp \
&& mkdir -p /var/lib/apt/lists/partial \
&& apt-get clean

RUN apt-get update \
&& apt-get install openjdk-8-jre-headless wget git bash python3 python3-dev lsb-core python3-setuptools cmake build-essential apt-utils python3-pip -y

# ===============
# Environmental Variables
# ===============

ENV FQDN="https://demoexample.jans.io" \
AUTHZ_CLIENT_ID="" \
AUTHZ_CLIENT_SECRET="" \
ROPC_CLIENT_ID="" \
ROPC_CLIENT_SECRET="" \
RUN_AUTHZ_TEST=false \
RUN_ROPC_TEST=false \
TEST_USERS_PREFIX_STRING="test_user" \
THREAD_COUNT=200 \
COUCHBASE_URL="" \
COUCHBASE_PW="" \
USER_NUMBER_STARTING_POINT=0 \
USER_NUMBER_ENDING_POINT=50000000 \
LOAD_USERS_TO_COUCHBASE=false \
LOAD_USERS_TO_LDAP=false \
LOAD_USERS_TO_SPANNER=false \
LOAD_USERS_TO_RDBMS=false \
USER_SPLIT_PARALLEL_THREADS=20 \
GOOGLE_APPLICATION_CREDENTIALS=""\
GOOGLE_PROJECT_ID=""\
GOOGLE_SPANNER_INSTANCE_ID=""\
GOOGLE_SPANNER_DATABASE_ID=""\
LDAP_URL="opendj:1636" \
LDAP_PW="" \
LDAP_DN="cn=directory manager" \
# pgsql or mysql
RDBMS_TYPE="mysql" \
RDBMS_DB="jans" \
RDBMS_USER="jans" \
RDBMS_PASSWORD="" \
RDBMS_HOST="localhost"



# ======
# Python
# ======

COPY requirements.txt /scripts/requirements.txt
RUN pip install --no-cache-dir -U pip wheel \
&& pip3 install --no-cache-dir --default-timeout=300 -r /scripts/requirements.txt \
&& pip3 uninstall -y pip wheel

COPY scripts /scripts

RUN mkdir -p /root/.bzt/jmeter-taurus \
&& wget -q https://dlcdn.apache.org//jmeter/binaries/apache-jmeter-5.5.tgz -O /scripts/apache-jmeter-5.5.tgz \
&& tar zxvf /scripts/apache-jmeter-5.5.tgz -C /root/.bzt/jmeter-taurus \
&& mv /root/.bzt/jmeter-taurus/apache-jmeter-5.5 /root/.bzt/jmeter-taurus/5.5

LABEL name="janssenproject/demo_loadtesting" \
maintainer="Janssen Project <support@jans.io>" \
vendor="Janssen Project" \
version="1.0.6" \
release="dev" \
summary="Janssen Jmeter tests" \
description="Janssen Jmeter and user loader image"

ENTRYPOINT ["bash", "/scripts/entrypoint.sh"]
Loading

0 comments on commit 26bbb0c

Please sign in to comment.