Skip to content

Commit

Permalink
Update ROSA scalability workflow to commit the result numbers to github
Browse files Browse the repository at this point in the history
Added Schedule run config for Rosa scalability benchmark
  • Loading branch information
Anna Manukyan committed Aug 23, 2023
1 parent b4f4d32 commit 552c5c0
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 10 deletions.
24 changes: 14 additions & 10 deletions .github/actions/prometheus-metrics-calc/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ inputs:
default: '3'
measurementInterval:
description: 'A specific time period over which we want to calculate the required metrics.'
output:
description: 'The name of the output to store data in JSON format'
default: 'results.json'

runs:
using: composite
Expand Down Expand Up @@ -82,16 +79,23 @@ runs:
name: Stores got information in JSON file.
env:
CALCULATED_METRIC_VALUE: ${{ env.CALCULATED_METRIC_VALUE }}
OUTPUT_FILE_NAME: ${{ env.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 [ -f ${{ inputs.output }} ]; then
cat ${{ inputs.output }} | jq --arg testName "${{ inputs.performedTestName }}" --arg key "${description}" \
--arg val ${CALCULATED_METRIC_VALUE} '. + {($testName): {($key):($val|tonumber)}}' \
| tee ${{ inputs.output }}
else
jq -n --arg testName "${{ inputs.performedTestName }}" --arg key "${description}" \
--arg val ${CALCULATED_METRIC_VALUE} '{($testName): {($key):($val|tonumber)}}' > ${{ inputs.output }}
echo $OUTPUT_FILE_NAME
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
cat ${OUTPUT_FILE_NAME} | jq --arg testName "${{ inputs.performedTestName }}" --arg key "${description}" \
--arg val ${CALCULATED_METRIC_VALUE} '. + {($testName): {($key):($val|tonumber)}}' \
| tee ${OUTPUT_FILE_NAME}
18 changes: 18 additions & 0 deletions .github/workflows/rosa-scaling-benchmark-on-schedule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: ROSA Cluster - Scaling Benchmark on Schedule

on:
schedule:
- cron: '0 7 * * 1-5' # Runs At 07:00 UTC on every day-of-week from Monday through Friday.

jobs:

checkout:
name: ROSA Scheduled Scaling Benchmark Run
runs-on: ubuntu-latest
steps:
- name: Run ROSA Scaling Benchmark
run: |
gh workflow run -R keycloak/keycloak-benchmark rosa-scaling-benchmark.yml
if: github.event_name != 'schedule' || github.repository == 'keycloak/keycloak-benchmark'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39 changes: 39 additions & 0 deletions .github/workflows/rosa-scaling-benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -310,3 +310,42 @@ jobs:
- name: Scale down the cluster
if: ${{ (success() || failure()) && !inputs.skipDeleteProject }}
run: rosa edit machinepool -c ${{ inputs.clusterName }} --min-replicas 0 --max-replicas 0 scaling

archive:
name: Commit results to Git repository
runs-on: ubuntu-latest
permissions:
contents: write
needs:
- run
steps:
- name: Checkout repository for results
uses: actions/checkout@v3
with:
ref: 'result-data'

- uses: actions/download-artifact@v3
with:
name: Calculated environment conclusion

- name: Commit result-summary
shell: bash
env:
GITHUB_OAUTH: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
DATE_FOLDER=rosa_scalability/$(date +"%Y/%m/%d")
mkdir -p ${DATE_FOLDER}
mv *.json ${DATE_FOLDER}
git add .
git commit -m "generated"
git push
- name: Trigger data aggregation
if: github.repository == 'keycloak/keycloak-benchmark'
env:
GH_TOKEN: ${{ github.token }}
# manually trigger the run, as a push with a standard GitHub action token doesn't trigger any workflow run on GitHub
run: gh workflow run -R keycloak/keycloak-benchmark aggregate-results.yaml --ref result-data
53 changes: 53 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Test

on:
workflow_dispatch:
inputs:
clusterName:
description: 'Name of the cluster'
type: string

concurrency: cluster_${{ github.event.inputs.clusterName || format('gh-{0}', github.repository_owner) }}

env:
OPENSHIFT_VERSION: 4.13.6
REGION: ${{ github.event.inputs.region || vars.AWS_DEFAULT_REGION }}

jobs:

checkout:
name: Test jq
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- 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: Calculate and Store CPU usage For Ran Benchmark
uses: ./.github/actions/prometheus-metrics-calc
with:
input: test_out
performedTestName: 'CPU usage for client credential grants'
calculatedMetricName: 'Client Credential Grants per second per 1vCPU'
criteriaValue: 200
measurementInterval: 600
isvCPU: false
isMemory: true

- name: Calculate and Store CPU usage For Ran Benchmark
uses: ./.github/actions/prometheus-metrics-calc
with:
input: test_out
performedTestName: 'CPU usage for client credential grants'
calculatedMetricName: 'Test per 1vCPU'
criteriaValue: 1000
measurementInterval: 600
isvCPU: true
isMemory: false
2 changes: 2 additions & 0 deletions test_out
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
4628.35
4870.23

0 comments on commit 552c5c0

Please sign in to comment.