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 226727b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 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 }}
25 changes: 14 additions & 11 deletions .github/workflows/rosa-scaling-benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,20 @@ 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 "active_sessions=$(awk "BEGIN {print $USERS_PER_SEC*$TIME_IN_SEC; exit}")" >> $GITHUB_OUTPUT

- 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

Expand Down Expand Up @@ -218,8 +224,8 @@ jobs:
uses: ./.github/actions/prometheus-metrics-calc
with:
input: user_logins_vCpu
performedTestName: 'Testing CPU usage for user logins'
criteriaName: 'User Logins Per Second'
performedTestName: 'CPU usage for user logins'
calculatedMetricName: 'User Logins per second per 1vCPU'
criteriaValue: ${{ inputs.numberOfUsersPerSecond }}
measurementInterval: ${{ inputs.measurement }}
isvCPU: true
Expand Down Expand Up @@ -259,8 +265,8 @@ jobs:
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'
performedTestName: 'CPU usage for client credential grants'
calculatedMetricName: 'Client Credential Grants per second per 1vCPU'
criteriaValue: ${{ inputs.numberOfClientsPerSecond }}
measurementInterval: ${{ inputs.measurement }}
isvCPU: true
Expand All @@ -287,9 +293,6 @@ jobs:
name: Calculated environment conclusion
path: |
results.json
memory_create_sessions
user_logins_vCpu
client_credential_grants_vCpu
retention-days: 5

- name: Delete EC2 instances
Expand Down

0 comments on commit 226727b

Please sign in to comment.