Skip to content

Commit

Permalink
bump rhdh version and fix keycloak token handling
Browse files Browse the repository at this point in the history
Signed-off-by: Pavel Macík <[email protected]>
  • Loading branch information
pmacik committed Nov 28, 2023
1 parent 2b48697 commit e4f48f5
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 24 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export SPAWN_RATE ?= 20
# RHDH image to deploy
export RHDH_IMAGE_REGISTRY ?= quay.io
export RHDH_IMAGE_REPO ?= rhdh/rhdh-hub-rhel9
export RHDH_IMAGE_TAG ?= 1.0-190
export RHDH_IMAGE_TAG ?= 1.0-191

# RHDH Helm chart to deploy
export RHDH_NAMESPACE ?= rhdh-performance
Expand Down
2 changes: 1 addition & 1 deletion ci-scripts/collect-results.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -o nounset
set -o errexit
set -o pipefail

echo "\n === Collecting test results and metrics ===\n"
echo -e "\n === Collecting test results and metrics ===\n"

ARTIFACT_DIR=${ARTIFACT_DIR:-artifacts}
monitoring_collection_data=$ARTIFACT_DIR/benchmark.json
Expand Down
21 changes: 9 additions & 12 deletions ci-scripts/rhdh-setup/create_resource.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function backstage_url() {
cat $f
}

export -f keycloak_url backstage_url
export keycloak_url backstage_url

function create_per_grp() {
varname=$2
Expand Down Expand Up @@ -81,7 +81,7 @@ function create_cmp() {
}

function create_group() {
token=$(cat $TMP_DIR/token)
token=$(get_token)
curl -s -k --location --request POST "$(keycloak_url)/auth/admin/realms/backstage/groups" \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer '$token \
Expand All @@ -90,8 +90,6 @@ function create_group() {

function create_groups() {
echo "Creating Groups in Keycloak"
export -f get_token
nohup bash -c 'get_token' &
refresh_pid=$!
sleep 5
export -f create_group
Expand All @@ -100,7 +98,7 @@ function create_groups() {
}

function create_user() {
token=$(cat $TMP_DIR/token)
token=$(get_token)
grp=$(echo "${0}%${GROUP_COUNT}" | bc)
[[ $grp -eq 0 ]] && grp=${GROUP_COUNT}
curl -s -k --location --request POST "$(keycloak_url)/auth/admin/realms/backstage/users" \
Expand All @@ -111,9 +109,7 @@ function create_user() {

function create_users() {
echo "Creating Users in Keycloak"
export -f get_token
export GROUP_COUNT
nohup bash -c 'get_token' &
refresh_pid=$!
sleep 5
export -f create_user
Expand All @@ -122,9 +118,10 @@ function create_users() {
}

function get_token() {
keycloak_pass=$(oc -n ${RHDH_NAMESPACE} get secret credential-example-sso -o template --template='{{.data.ADMIN_PASSWORD}}' | base64 -d)
while true; do
curl -s -k "$(keycloak_url)/auth/realms/master/protocol/openid-connect/token" -d "username=admin" -d "password=${keycloak_pass}" -d 'grant_type=password' -d 'client_id=admin-cli' | jq -r .access_token >$TMP_DIR/token
sleep 30
done
token_file=$TMP_DIR/token.json
if [ ! -f $token_file ] || [ $(date +%s) -gt $(jq -rc '.expires_in_timestamp' $token_file) ]; then
keycloak_pass=$(oc -n ${RHDH_NAMESPACE} get secret credential-example-sso -o template --template='{{.data.ADMIN_PASSWORD}}' | base64 -d)
curl -s -k $(keycloak_url)/auth/realms/master/protocol/openid-connect/token -d username=admin -d password=${keycloak_pass} -d 'grant_type=password' -d 'client_id=admin-cli' | jq -r ".expires_in_timestamp = $(date -d '30 seconds' +%s)" >$token_file
fi
jq -rc '.access_token' $token_file
}
6 changes: 5 additions & 1 deletion ci-scripts/rhdh-setup/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export RHDH_KEYCLOAK_REPLICAS=${RHDH_KEYCLOAK_REPLICAS:-1}

export RHDH_IMAGE_REGISTRY=${RHDH_IMAGE_REGISTRY:-quay.io}
export RHDH_IMAGE_REPO=${RHDH_IMAGE_REPO:-rhdh/rhdh-hub-rhel9}
export RHDH_IMAGE_TAG=${RHDH_IMAGE_TAG:-1.0-190}
export RHDH_IMAGE_TAG=${RHDH_IMAGE_TAG:-1.0-191}

export RHDH_HELM_REPO=${RHDH_HELM_REPO:-https://gist.githubusercontent.com/rhdh-bot/63cef5cb6285889527bd6a67c0e1c2a9/raw}
export RHDH_HELM_CHART=${RHDH_HELM_CHART:-developer-hub}
Expand All @@ -32,6 +32,10 @@ export API_COUNT="${API_COUNT:-1}"
export COMPONENT_COUNT="${COMPONENT_COUNT:-1}"

delete() {
if ! $cli get ns $RHDH_NAMESPACE >/dev/null; then
echo "$RHDH_NAMESPACE namespace does not exit... Skipping. "
return
fi
for cr in keycloakusers keycloakclients keycloakrealms keycloaks; do
for res in $($clin get $cr.keycloak.org -o name); do
$clin patch $res -p '{"metadata":{"finalizers":[]}}' --type=merge
Expand Down
18 changes: 10 additions & 8 deletions ci-scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -o nounset
set -o errexit
set -o pipefail

echo "\n === Installing and setting up RHDH ===\n"
echo -e "\n === Installing and setting up RHDH ===\n"

export GITHUB_TOKEN GITHUB_USER GITHUB_REPO QUAY_TOKEN KUBECONFIG

Expand All @@ -13,14 +13,16 @@ GITHUB_USER=$(cat /usr/local/ci-secrets/backstage-performance/github.user)
GITHUB_REPO=$(cat /usr/local/ci-secrets/backstage-performance/github.repo)
QUAY_TOKEN=$(cat /usr/local/ci-secrets/backstage-performance/quay.token)

export RHDH_DEPLOYMENT_REPLICAS=5
export RHDH_DB_REPLICAS=5
export RHDH_KEYCLOAK_REPLICAS=5
export RHDH_DEPLOYMENT_REPLICAS=2
export RHDH_DB_REPLICAS=2
export RHDH_KEYCLOAK_REPLICAS=2

export API_COUNT=10000
export COMPONENT_COUNT=10000
export BACKSTAGE_USER_COUNT=10000
export GROUP_COUNT=1000
export API_COUNT=1000
export COMPONENT_COUNT=1000
export BACKSTAGE_USER_COUNT=1000
export GROUP_COUNT=100

make undeploy-rhdh

echo "$(date --utc -Ins) Running deployment script"
make ci-deploy
2 changes: 1 addition & 1 deletion ci-scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -o nounset
set -o errexit
set -o pipefail

echo "\n === Executing RHDH load test ===\n"
echo -e "\n === Executing RHDH load test ===\n"

export SCENARIO

Expand Down

0 comments on commit e4f48f5

Please sign in to comment.