Skip to content

Commit

Permalink
Rosa Scaling Benchmark: JSON Update with environment data (keycloak#637
Browse files Browse the repository at this point in the history
…) (keycloak#679)

Signed-off-by: Anna Manukyan <amanukya@redhat.com>
Co-authored-by: Anna Manukyan <amanukya@redhat.com>
  • Loading branch information
andyuk1986 and Anna Manukyan authored Jan 22, 2024
1 parent 6781194 commit 62c8cd7
Show file tree
Hide file tree
Showing 9 changed files with 265 additions and 24 deletions.
33 changes: 33 additions & 0 deletions .github/actions/prepare-horreum-report/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Prepare Horreum Report
description: Prepares JSON report before further processing, i.e. creates the JSON with the env data which gets from the configmap.

inputs:
project:
description: 'The project namespace.'
required: true

runs:
using: composite
steps:
- id: prepare-report-file
name: Create and Prepare Report File
shell: bash
# language=bash
run: |
output_file_prefix="result-"
cur_date=$(date)
cur_date_iso=$(date -d "$cur_date" --iso-8601=seconds)
cur_date_iso_compressed=$(date -d "$cur_date" '+%Y%m%d-%H%M%S')
uuid=$(uuidgen)
OUTPUT_FILE_NAME="${output_file_prefix}${cur_date_iso_compressed}-${uuid}.json"
echo "HORREUM_OUTPUT_FILE_NAME=$OUTPUT_FILE_NAME" >> $GITHUB_ENV
jq -n --arg current_date "${cur_date_iso}" --arg id "${uuid}" \
'{"$schema": "urn:keycloak-benchmark:0.1", "uuid": ($id), "name": "ROSA Scalability Benchmark Run Results",
"start_dttm": ($current_date)}' > ${OUTPUT_FILE_NAME}
#Reading configmap with environment data
configJson=$(oc get configmap env-config -n ${{ env.PROJECT }} -o "jsonpath={ .data['environment_data\.json']}'" | rev | cut -d\' -f2- | rev | jq)
jq '. + {"context":{}}' ${OUTPUT_FILE_NAME} > tmp.json && \
mv tmp.json ${OUTPUT_FILE_NAME}
#Putting environment parameters into JSON
jq --argjson configJson "${configJson}" '.context = ($configJson)' ${OUTPUT_FILE_NAME} > tmp.json && \
mv tmp.json ${OUTPUT_FILE_NAME}
21 changes: 5 additions & 16 deletions .github/actions/prometheus-metrics-calc/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,22 +79,11 @@ runs:
name: Stores got information in JSON file.
env:
CALCULATED_METRIC_VALUE: ${{ env.CALCULATED_METRIC_VALUE }}
OUTPUT_FILE_NAME: ${{ env.OUTPUT_FILE_NAME }}
HORREUM_OUTPUT_FILE_NAME: ${{ env.HORREUM_OUTPUT_FILE_NAME }}
shell: bash
# language=bash
run: |
#Preparing and storing all information in JSON using jq library
description="${{ inputs.calculatedMetricName }} per Pod in ${{ inputs.replicas }} Pod cluster"
if [[ -z "${OUTPUT_FILE_NAME}" ]]; then
output_file_prefix="result-"
cur_date_iso=$(date --iso-8601=seconds)
cur_date_iso_compressed=$(date '+%Y%m%d-%H%M%S')
uuid=$(uuidgen)
OUTPUT_FILE_NAME="${output_file_prefix}${cur_date_iso_compressed}-${uuid}.json"
echo "OUTPUT_FILE_NAME=$OUTPUT_FILE_NAME" >> $GITHUB_ENV
jq -n --arg current_date "${cur_date_iso}" --arg id "${uuid}" \
'{"uuid": ($id), "name": "ROSA Scalability Benchmark Run Results", "Execution Date and Time": ($current_date)}' > ${OUTPUT_FILE_NAME}
fi
jq --arg testName "${{ inputs.performedTestName }}" --arg key "${description}" \
--arg val ${CALCULATED_METRIC_VALUE} '. + {($testName): {($key):($val|tonumber)}}' ${OUTPUT_FILE_NAME} > tmp.json && \
mv tmp.json ${OUTPUT_FILE_NAME}
#Storing all information in JSON using jq library
jq --arg testName "${{ inputs.performedTestName }}" --arg key "${{ inputs.calculatedMetricName }}" \
--arg val ${CALCULATED_METRIC_VALUE} '. + {($testName): {($key):($val|tonumber)}}' ${HORREUM_OUTPUT_FILE_NAME} > tmp.json && \
mv tmp.json ${HORREUM_OUTPUT_FILE_NAME}
12 changes: 12 additions & 0 deletions .github/workflows/rosa-multi-az-cluster-create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ on:
region:
description: 'The AWS region to create both clusters in. Defaults to "vars.AWS_DEFAULT_REGION" if omitted.'
type: string
createCluster:
description: 'Property showing if the cluster should be created or only software deployment should be performed.'
type: boolean
default: true
workflow_call:
inputs:
clusterPrefix:
Expand All @@ -17,6 +21,10 @@ on:
region:
description: 'The AWS region to create both clusters in. Defaults to "vars.AWS_DEFAULT_REGION" if omitted.'
type: string
createCluster:
description: 'Property showing if the cluster should be created or only software deployment should be performed.'
type: boolean
default: true

env:
CLUSTER_PREFIX: ${{ inputs.clusterPrefix || format('gh-{0}', github.repository_owner) }}
Expand All @@ -33,6 +41,7 @@ jobs:
- run: echo ""

cluster:
if: ${{ inputs.createCluster }}
needs: meta
strategy:
matrix:
Expand All @@ -48,6 +57,7 @@ jobs:

deploy-keycloak:
runs-on: ubuntu-latest
if: ${{ (always() && needs.cluster.result == 'skipped' && !inputs.createCluster) || success()}}
needs: [cluster]

steps:
Expand Down Expand Up @@ -112,3 +122,5 @@ jobs:
KC_DB_POOL_INITIAL_SIZE: 30
KC_DB_POOL_MAX_SIZE: 30
KC_DB_POOL_MIN_SIZE: 30
KC_DATABASE: "aurora-postgres"
MULTI_AZ: "true"
7 changes: 6 additions & 1 deletion .github/workflows/rosa-multi-az-cluster-delete.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,15 @@ jobs:
with:
project: runner-keycloak

- name: Set SUBDOMAIN env variable for route53 processing
run: |
echo "SUBDOMAIN=$(echo $KEYCLOAK_URL | grep -oP '(?<=client.).*?(?=.keycloak-benchmark.com)')" >> $GITHUB_ENV
- name: Delete Route53 Records
run: |
SUBDOMAIN=$(echo $KEYCLOAK_URL | grep -oP '(?<=client.).*?(?=.keycloak-benchmark.com)')
./provision/aws/route53/route53_delete.sh
env:
SUBDOMAIN: ${{ env.SUBDOMAIN }}

cluster1:
uses: ./.github/workflows/rosa-cluster-delete.yml
Expand Down
83 changes: 83 additions & 0 deletions .github/workflows/rosa-multi-az-cluster-undeploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Multi-AZ Clusters - Undeploy

on:
workflow_dispatch:
inputs:
clusterPrefix:
description: 'The prefix to be used when cleaning the clusters'
type: string
region:
description: 'The AWS region to create both clusters in. Defaults to "vars.AWS_DEFAULT_REGION" if omitted.'
type: string
skipAuroraDeletion:
description: 'Skip Aurora database deletion.'
type: boolean
default: false

env:
CLUSTER_PREFIX: ${{ inputs.clusterPrefix || format('gh-{0}', github.repository_owner) }}
REGION: ${{ github.event.inputs.region || vars.AWS_DEFAULT_REGION }}

jobs:
clear-keycloak-and-infinispan-deployment-with-aurora:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup ROSA CLI
uses: ./.github/actions/rosa-cli-setup
with:
aws-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-default-region: ${{ vars.AWS_DEFAULT_REGION }}
rosa-token: ${{ secrets.ROSA_TOKEN }}

- name: Setup Go Task
uses: ./.github/actions/task-setup

- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: maven

- name: Login to OpenShift cluster
uses: ./.github/actions/oc-keycloak-login
with:
clusterName: ${{ inputs.clusterPrefix }}-a

- name: Get Keycloak Domain
uses: ./.github/actions/get-keycloak-url
with:
project: runner-keycloak

- name: Undeploy infinispan and keycloak
working-directory: provision/rosa-cross-dc
run: |
task undeploy
env:
ROSA_CLUSTER_NAME_1: ${{ env.CLUSTER_PREFIX }}-a
ROSA_CLUSTER_NAME_2: ${{ env.CLUSTER_PREFIX }}-b

- name: Undeploy aurora database
if: ${{ !inputs.skipAuroraDeletion }}
working-directory: provision/rosa-cross-dc
run: |
task delete-aurora
env:
AURORA_CLUSTER: ${{ env.CLUSTER_PREFIX }}
AURORA_REGION: ${{ env.REGION }}
ROSA_CLUSTER_NAME_1: ${{ env.CLUSTER_PREFIX }}-a
ROSA_CLUSTER_NAME_2: ${{ env.CLUSTER_PREFIX }}-b

- name: Set SUBDOMAIN env variable for route53 processing
run: |
echo "SUBDOMAIN=$(echo $KEYCLOAK_URL | grep -oP '(?<=client.).*?(?=.keycloak-benchmark.com)')" >> $GITHUB_ENV
- name: Delete Route53 Records
run: |
./provision/aws/route53/route53_delete.sh
env:
SUBDOMAIN: ${{ env.SUBDOMAIN }}
15 changes: 9 additions & 6 deletions .github/workflows/rosa-scaling-benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ jobs:
with:
region: ${{ inputs.region }}

- name: Prepare horreum report
uses: ./.github/actions/prepare-horreum-report

- name: Run Memory Usage Total Query Before Benchmark
uses: ./.github/actions/prometheus-run-queries
with:
Expand Down Expand Up @@ -243,8 +246,8 @@ jobs:
uses: ./.github/actions/prometheus-metrics-calc
with:
input: memory_create_sessions
performedTestName: 'Memory usage for sessions'
calculatedMetricName: 'Active sessions per 500 MB memory' #as a unit for memory calculation is chosen 500MB memory size to find out how much user sessions so much memory can handle.
performedTestName: 'memory-usage-test'
calculatedMetricName: 'active-sessions-per-500Mb-per-pod' #as a unit for memory calculation is chosen 500MB memory size to find out how much user sessions so much memory can handle.
criteriaValue: ${{ steps.active_sessions_count.outputs.active_sessions }}
isvCPU: false
isMemory: true
Expand Down Expand Up @@ -284,8 +287,8 @@ jobs:
uses: ./.github/actions/prometheus-metrics-calc
with:
input: user_logins_vCpu
performedTestName: 'CPU usage for user logins'
calculatedMetricName: 'User Logins per second per 1vCPU'
performedTestName: 'cpu-usage-for-logins-test'
calculatedMetricName: 'user-logins-per-sec-per-1vCpu-per-pod'
criteriaValue: ${{ inputs.numberOfUsersPerSecond }}
measurementInterval: ${{ inputs.measurement }}
isvCPU: true
Expand Down Expand Up @@ -325,8 +328,8 @@ jobs:
uses: ./.github/actions/prometheus-metrics-calc
with:
input: client_credential_grants_vCpu
performedTestName: 'CPU usage for client credential grants'
calculatedMetricName: 'Client Credential Grants per second per 1vCPU'
performedTestName: 'cpu-usage-for-credential-grants-test'
calculatedMetricName: 'credential-grants-per-sec-per-1vCpu'
criteriaValue: ${{ inputs.numberOfClientsPerSecond }}
measurementInterval: ${{ inputs.measurement }}
isvCPU: true
Expand Down
35 changes: 35 additions & 0 deletions provision/common/Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ vars:
KC_REMOTE_STORE_HOST: '{{default "localhost" .KC_REMOTE_STORE_HOST}}'
KC_REMOTE_STORE_PORT: '{{default "11222" .KC_REMOTE_STORE_PORT}}'
KC_DISABLE_STICKY_SESSION: '{{default "false" .KC_DISABLE_STICKY_SESSION}}'
MULTI_AZ: '{{default "false" .MULTI_AZ}}'
ENV_DATA_JSON_PATH: "{{.ROOT_DIR}}/../environment_data.json"

tasks:

Expand Down Expand Up @@ -73,6 +75,39 @@ tasks:
- echo {{.KC_DISABLE_STICKY_SESSION}} > .task/var-KC_DISABLE_STICKY_SESSION
- echo {{.KC_HOSTNAME_OVERRIDE}} > .task/var-KC_HOSTNAME_OVERRIDE
- echo {{.KC_HEALTH_HOSTNAME}} > .task/var-KC_HEALTH_HOSTNAME
- |
jq -n --arg cpu_limit "{{ .KC_CPU_REQUESTS }}" --arg num_of_pods "{{ .KC_INSTANCES }}" \
--arg sticky_sessions "{{ .KC_DISABLE_STICKY_SESSION }}" \
--arg mem_req_per_pod "{{ .KC_MEMORY_REQUESTS_MB }}" \
--arg mem_limit_per_pod "{{ .KC_MEMORY_LIMITS_MB }}" \
--arg heap_init "{{ .KC_HEAP_INIT_MB }}" \
--arg heap_max "{{ .KC_HEAP_MAX_MB }}" \
--arg db_pool_init "{{ .KC_DB_POOL_INITIAL_SIZE }}" \
--arg db_pool_max "{{ .KC_DB_POOL_MAX_SIZE }}" \
--arg db_pool_min "{{ .KC_DB_POOL_MIN_SIZE }}" \
--arg meta_spc_init "{{ .KC_METASPACE_INIT_MB }}" \
--arg meta_spc_max "{{ .KC_METASPACE_MAX_MB }}" \
--arg database "{{ .KC_DATABASE }}" \
--arg is_multi_az "{{ .MULTI_AZ }}" \
'. + { "num_of_pods": ($num_of_pods|tonumber), "cpu_limit_per_pod": ($cpu_limit|tonumber),
"sticky_session_disabled": ($sticky_sessions),
"mem_requests_per_pod": ($mem_req_per_pod|tonumber),
"mem_limit_per_pod": ($mem_limit_per_pod|tonumber),
"heap": {
"init": ($heap_init|tonumber),
"max": ($heap_max|tonumber)
},
"db_pool": {
"init": ($db_pool_init|tonumber),
"min": ($db_pool_min|tonumber),
"max": ($db_pool_max)
},
"metaspace": {
"init": ($meta_spc_init|tonumber),
"max": ($meta_spc_max)
},
"is_multi_az": ($is_multi_az),
"keycloak_database": ($database) }' > {{ .ENV_DATA_JSON_PATH }}
run: once
sources:
- .task/subtask-{{.TASK}}.yaml
Expand Down
6 changes: 6 additions & 0 deletions provision/infinispan/Utils.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ tasks:
- task: wait-cluster
vars:
NAMESPACE: "{{.OC_NAMESPACE}}"
- echo {{.TASK}} > ".task/kubecfg/ispn-{{.ROSA_CLUSTER_NAME_1}}"
- echo {{.TASK}} > ".task/kubecfg/ispn-{{.ROSA_CLUSTER_NAME_2}}"

crossdc-single:
internal: true
Expand Down Expand Up @@ -305,6 +307,8 @@ tasks:
- task: wait-crossdc
vars:
NAMESPACE: "{{.OC_NAMESPACE_2}}"
- echo {{.TASK}} > ".task/kubecfg/ispn-{{.ROSA_CLUSTER_NAME_1}}"
- echo {{.TASK}} > ".task/kubecfg/ispn-{{.ROSA_CLUSTER_NAME_2}}"

crossdc:
internal: true
Expand Down Expand Up @@ -402,6 +406,8 @@ tasks:
vars:
ROSA_CLUSTER_NAME: "{{.ROSA_CLUSTER_NAME_2}}"
NAMESPACE: "{{.OC_NAMESPACE_2}}"
- echo {{.TASK}} > ".task/kubecfg/ispn-{{.ROSA_CLUSTER_NAME_1}}"
- echo {{.TASK}} > ".task/kubecfg/ispn-{{.ROSA_CLUSTER_NAME_2}}"

delete-infinispan:
internal: true
Expand Down
Loading

0 comments on commit 62c8cd7

Please sign in to comment.