Skip to content

Commit

Permalink
Fixed memory measurement and string format changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Anna Manukyan committed Aug 17, 2023
1 parent 8f7e2a4 commit eb9b965
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 96 deletions.
13 changes: 5 additions & 8 deletions .github/actions/prometheus-metrics-calc/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ inputs:
calculatedMetricName:
description: 'The name of the metric that is calculated for including in JSON file.'
default: '1vCPU'
criteriaName:
description: 'The name of the criteria for which the metric is calculated.'
default: 'users per sec'
criteriaValue:
description: 'The value for the criteria used during benchmark run.'
required: true
Expand Down Expand Up @@ -56,7 +53,7 @@ runs:
metric_per_pod=$(awk "BEGIN {print $metric_count_in_interval/$POD_NUM; exit}")
#Calculating the final number, i.e. how many of specified criteria (e.g. user logins/sec, client credential grants, etc)
#can be handled with requested metric per pod. The result is number rounded down.
result=$(awk "BEGIN {print int($CRITERIA_VALUE/$metric_per_pod); exit}"
result=$(awk "BEGIN {print int($CRITERIA_VALUE/$metric_per_pod); exit}")
echo "CALCULATED_METRIC_VALUE=$result" >> $GITHUB_ENV
- id: calculate-memory-metric
Expand All @@ -78,7 +75,7 @@ runs:
metric_per_pod=$(awk "BEGIN {print $difference/$POD_NUM; exit}")
#Calculating the final number, i.e. based on current environment setup how many of specified criteria (e.g. user active session, etc)
#can be handled with 500Mb per pod based on the number calculated above. The result is number rounded down.
result=$(awk "BEGIN {print int($CRITERIA_VALUE*500/$metric_per_pod); exit}"
result=$(awk "BEGIN {print int($CRITERIA_VALUE*500/$metric_per_pod); exit}")
echo "CALCULATED_METRIC_VALUE=$result" >> $GITHUB_ENV
- id: metric-store-in-result-file
Expand All @@ -89,12 +86,12 @@ runs:
# language=bash
run: |
#Preparing and storing all information in JSON using jq library
description="${{ inputs.calculatedMetricName }} per pod in ${{ inputs.replicas }} node cluster handles"
description="${{ inputs.calculatedMetricName }} per Pod in ${{ inputs.replicas }} Pod cluster"
if [ -f ${{ inputs.output }} ]; then
cat ${{ inputs.output }} | jq --arg testName "${{ inputs.performedTestName }}" --arg key "${description}" \
--arg val "${CALCULATED_METRIC_VALUE} ${{ inputs.criteriaName }}" '. + {($testName): {($ARGS.named["key"]):($ARGS.named["val"])}}' \
--arg val ${CALCULATED_METRIC_VALUE} '. + {($testName): {($ARGS.named["key"]):($ARGS.named["val"])}}' \
| tee ${{ inputs.output }}
else
jq -n --arg testName "${{ inputs.performedTestName }}" --arg key "${description}" \
--arg val "${CALCULATED_METRIC_VALUE} ${{ inputs.criteriaName }}" '{($testName): {($ARGS.named["key"]):($ARGS.named["val"])}}' > ${{ inputs.output }}
--arg val ${CALCULATED_METRIC_VALUE} '{($testName): {($ARGS.named["key"]):($ARGS.named["val"])}}' > ${{ inputs.output }}
fi
4 changes: 2 additions & 2 deletions .github/actions/prometheus-run-queries/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ runs:
name: Memory Usage Total
if: ${{ inputs.runMemoryUsageTotal == 'true' }}
shell: bash
# Converting Bytes to MB before storing to file.
# language=bash
run: >
curl -s -H "Authorization: Bearer $OC_TOKEN" -k "https://$THANOS_HOST/api/v1/query" --data-urlencode
'query=sum(container_memory_working_set_bytes{job="kubelet", namespace="${{ inputs.project }}",container="keycloak"})'
| jq '.data.result[0].value[1]' -r | awk '{print $0/1000/1000}' >> ${{ inputs.output }}
| jq '.data.result[0].value[1]' -r | awk '{print $0/1000/1000}' >> ${{ inputs.output }} # Converting Bytes to MB before storing to file.
env:
THANOS_HOST: ${{ env.THANOS_HOST }}
OC_TOKEN: ${{ env.OC_TOKEN }}
178 changes: 92 additions & 86 deletions .github/workflows/rosa-scaling-benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,99 +172,105 @@ jobs:
runMemoryUsageTotal: true
output: memory_create_sessions

- name: Calculate number of active sessions
id: active_sessions_count
env:
USERS_PER_SEC: ${{ inputs.numberOfUsersPerSecond }}
TIME_IN_SEC: ${{ inputs.measurement }}
run: echo "::set-output name=active_sessions::$(awk "BEGIN {print $USERS_PER_SEC*$TIME_IN_SEC; exit}")"

- name: Calculate and Store Memory Usage Total For Active User Sessions
uses: ./.github/actions/prometheus-metrics-calc
with:
input: memory_create_sessions
performedTestName: 'Testing memory for creating sessions'
calculatedMetricName: '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.
criteriaName: 'Active User Sessions'
criteriaValue: ${{ inputs.numberOfEntitiesInRealm }}
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.
criteriaValue: ${{ steps.active_sessions_count.outputs.active_sessions }}
isvCPU: false
isMemory: true

- name: Run CPU sec Util Query Before Benchmark
uses: ./.github/actions/prometheus-run-queries
with:
project: ${{ env.PROJECT }}
runCpuSecsUtil: true
output: user_logins_vCpu

- name: Testing CPU usage for user logins
id: kcb-authorization-code-2
run: >
./benchmark.sh ${{ inputs.region }}
--scenario=keycloak.scenario.authentication.AuthorizationCode
--server-url=${{ env.KEYCLOAK_URL }}
--realm-name=realm-0
--users-per-sec=${{ inputs.numberOfUsersPerSecond }}
--ramp-up=20
--logout-percentage=100
--measurement=${{ inputs.measurement }}
--users-per-realm=${{ inputs.numberOfEntitiesInRealm }}
--log-http-on-failure
--sla-error-percentage=0.001
continue-on-error: true
working-directory: ansible

- name: Run CPU sec Util Query After Benchmark
uses: ./.github/actions/prometheus-run-queries
with:
project: ${{ env.PROJECT }}
runCpuSecsUtil: true
output: user_logins_vCpu

- name: Calculate and Store CPU sec Util For Ran Benchmark
uses: ./.github/actions/prometheus-metrics-calc
with:
input: user_logins_vCpu
performedTestName: 'Testing CPU usage for user logins'
criteriaName: 'User Logins Per Second'
criteriaValue: ${{ inputs.numberOfUsersPerSecond }}
measurementInterval: ${{ inputs.measurement }}
isvCPU: true
isMemory: false

- name: Run CPU sec Util Query Before Benchmark
uses: ./.github/actions/prometheus-run-queries
with:
project: ${{ env.PROJECT }}
runCpuSecsUtil: true
output: client_credential_grants_vCpu

- name: Testing CPU usage for client credential grants
id: kcb-client-secret
run: >
./benchmark.sh ${{ inputs.region }}
--scenario=keycloak.scenario.authentication.ClientSecret
--server-url=${{ env.KEYCLOAK_URL }}
--realm-name=realm-0
--users-per-sec=${{ inputs.numberOfClientsPerSecond }}
--ramp-up=20
--measurement=${{ inputs.measurement }}
--users-per-realm=${{ inputs.numberOfEntitiesInRealm }}
--log-http-on-failure
--sla-error-percentage=0.001
continue-on-error: true
working-directory: ansible

- name: Run CPU sec Util Query After Benchmark
uses: ./.github/actions/prometheus-run-queries
with:
project: ${{ env.PROJECT }}
runCpuSecsUtil: true
output: client_credential_grants_vCpu

- name: Calculate and Store CPU usage For Ran Benchmark
uses: ./.github/actions/prometheus-metrics-calc
with:
input: client_credential_grants_vCpu
performedTestName: 'Testing CPU usage for client credential grants'
criteriaName: 'Client Credential Grants Per Second'
criteriaValue: ${{ inputs.numberOfClientsPerSecond }}
measurementInterval: ${{ inputs.measurement }}
isvCPU: true
isMemory: false
# - name: Run CPU sec Util Query Before Benchmark
# uses: ./.github/actions/prometheus-run-queries
# with:
# project: ${{ env.PROJECT }}
# runCpuSecsUtil: true
# output: user_logins_vCpu
#
# - name: Testing CPU usage for user logins
# id: kcb-authorization-code-2
# run: >
# ./benchmark.sh ${{ inputs.region }}
# --scenario=keycloak.scenario.authentication.AuthorizationCode
# --server-url=${{ env.KEYCLOAK_URL }}
# --realm-name=realm-0
# --users-per-sec=${{ inputs.numberOfUsersPerSecond }}
# --ramp-up=20
# --logout-percentage=100
# --measurement=${{ inputs.measurement }}
# --users-per-realm=${{ inputs.numberOfEntitiesInRealm }}
# --log-http-on-failure
# --sla-error-percentage=0.001
# continue-on-error: true
# working-directory: ansible
#
# - name: Run CPU sec Util Query After Benchmark
# uses: ./.github/actions/prometheus-run-queries
# with:
# project: ${{ env.PROJECT }}
# runCpuSecsUtil: true
# output: user_logins_vCpu
#
# - name: Calculate and Store CPU sec Util For Ran Benchmark
# uses: ./.github/actions/prometheus-metrics-calc
# with:
# input: user_logins_vCpu
# performedTestName: 'CPU usage for user logins'
# calculatedMetricName: 'User Logins per second per 1vCPU'
# criteriaValue: ${{ inputs.numberOfUsersPerSecond }}
# measurementInterval: ${{ inputs.measurement }}
# isvCPU: true
# isMemory: false
#
# - name: Run CPU sec Util Query Before Benchmark
# uses: ./.github/actions/prometheus-run-queries
# with:
# project: ${{ env.PROJECT }}
# runCpuSecsUtil: true
# output: client_credential_grants_vCpu
#
# - name: Testing CPU usage for client credential grants
# id: kcb-client-secret
# run: >
# ./benchmark.sh ${{ inputs.region }}
# --scenario=keycloak.scenario.authentication.ClientSecret
# --server-url=${{ env.KEYCLOAK_URL }}
# --realm-name=realm-0
# --users-per-sec=${{ inputs.numberOfClientsPerSecond }}
# --ramp-up=20
# --measurement=${{ inputs.measurement }}
# --users-per-realm=${{ inputs.numberOfEntitiesInRealm }}
# --log-http-on-failure
# --sla-error-percentage=0.001
# continue-on-error: true
# working-directory: ansible
#
# - name: Run CPU sec Util Query After Benchmark
# uses: ./.github/actions/prometheus-run-queries
# with:
# project: ${{ env.PROJECT }}
# runCpuSecsUtil: true
# output: client_credential_grants_vCpu
#
# - name: Calculate and Store CPU usage For Ran Benchmark
# 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'
# criteriaValue: ${{ inputs.numberOfClientsPerSecond }}
# measurementInterval: ${{ inputs.measurement }}
# isvCPU: true
# isMemory: false

- name: Archive Gatling reports
if: ${{ always() }}
Expand Down

0 comments on commit eb9b965

Please sign in to comment.