Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(RHIDP-5727): Extend the devsandbox scenario with an instance of Backstage for each user #148

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion ci-scripts/dev-sandbox/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ export RHDH_OLM_CHANNEL ?= fast
export RHDH_OLM_OPERATOR_PACKAGE ?= rhdh
export RHDH_OLM_WATCH_EXT_CONF ?= true

export RHDH_WORKLOADS_TEMPLATE_NAME ?= default
export NUMBER_OF_RUNS ?= 10
export NUMBER_OF_USERS_PER_RUN ?= 2000
export NUMBER_OF_USERS_WITH_WORKLOADS_PER_RUN ?= 2000

export ARTIFACT_DIR ?=

.PHONY: setup-toolchain-e2e
Expand All @@ -22,7 +27,7 @@ undeploy:

.PHONY: run
run:
./run.sh
./run.sh "$(NUMBER_OF_RUNS)" "$(NUMBER_OF_USERS_PER_RUN)" "$(NUMBER_OF_USERS_WITH_WORKLOADS_PER_RUN)"

.PHONY: collect-results
collect-results:
Expand Down
6 changes: 6 additions & 0 deletions ci-scripts/dev-sandbox/collect-results.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

export RHDH_OPERATOR_NAMESPACE=rhdh-operator

SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck disable=SC1090,SC1091
source "$(readlink -m "$SCRIPT_DIR/../../test.env")"
Expand All @@ -14,6 +16,10 @@ TMP_DIR=$(readlink -m "${TMP_DIR:-"$rootdir/.tmp"}")
mkdir -p "${TMP_DIR}"

cli="oc"
clin="$cli -n $RHDH_OPERATOR_NAMESPACE"

$clin logs -l app=rhdh-operator --tail=-1 >& "$ARTIFACT_DIR/rhdh-operator.log"
$clin logs -l app=rhdh-operator --previous=true --tail=-1 >& "$ARTIFACT_DIR/rhdh-operator.previous.log"

out=$ARTIFACT_DIR/summary.csv
rm -rvf "$out"
Expand Down
1 change: 1 addition & 0 deletions ci-scripts/dev-sandbox/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ $cli create namespace "$RHDH_OPERATOR_NAMESPACE" --dry-run=client -o yaml | $cli

until envsubst <"$rootdir/ci-scripts/rhdh-setup/template/backstage/secret-rhdh-pull-secret.yaml" | $clin apply -f -; do $clin delete secret rhdh-pull-secret --ignore-not-found=true; done
pushd "$rootdir/ci-scripts/rhdh-setup" || exit
./deploy.sh -m -o
OLM_CHANNEL="${RHDH_OLM_CHANNEL}" UPSTREAM_IIB="${RHDH_OLM_INDEX_IMAGE}" NAMESPACE_SUBSCRIPTION="${RHDH_OPERATOR_NAMESPACE}" WATCH_EXT_CONF="${RHDH_OLM_WATCH_EXT_CONF}" ./install-rhdh-catalog-source.sh --install-operator "${RHDH_OLM_OPERATOR_PACKAGE:-rhdh}"
popd || exit
202 changes: 202 additions & 0 deletions ci-scripts/dev-sandbox/rhdh-perf-workloads.backstages.template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
kind: Template
apiVersion: template.openshift.io/v1
metadata:
name: user-workloads
objects:
- apiVersion: v1
kind: ConfigMap
metadata:
name: dynamic-plugins-rhdh
data:
dynamic-plugins.yaml: |
includes:
- dynamic-plugins.default.yaml
plugins:
- package: ./dynamic-plugins/dist/backstage-community-plugin-rbac
disabled: false
- apiVersion: v1
kind: ConfigMap
metadata:
name: user-t1-group-g1
data:
user_t1-group_g1.yaml: |
---
apiVersion: backstage.io/v1alpha1
kind: Group
metadata:
name: g1
namespace: default
description: "Group #1"
spec:
type: team
profile:
displayName: "Group #1"
members:
- t1
children: []
---
apiVersion: backstage.io/v1alpha1
kind: User
metadata:
name: t1
namespace: default
description: "Test User #1"
spec:
profile:
displayName: "Test User #1"
email: [email protected]
memberOf:
- g1
- apiVersion: v1
kind: ConfigMap
metadata:
name: rbac-policy
data:
rbac-policy.csv: |
p, role:default/a, kubernetes.proxy, use, allow
p, role:default/a, catalog-entity, read, allow
p, role:default/a, catalog.entity.create, create, allow
p, role:default/a, catalog.location.create, create, allow
p, role:default/a, catalog.location.read, read, allow
g, user:default/guru, role:default/a
g, user:development/guest, role:default/a
g, group:default/g1, role:default/a
- kind: ConfigMap
apiVersion: v1
metadata:
name: app-config-backend-secret
data:
app-config.rhdh.backend-secret.yaml: |
backend:
auth:
externalAccess:
- type: legacy
options:
secret: "secret:${BACKEND_SECRET}"
subject: legacy-catalog
- kind: ConfigMap
apiVersion: v1
metadata:
name: app-config-rhdh
data:
app-config.rhdh.yaml: |
app:
title: Red Hat Developer Hub
organization:
name: RHDH Perf&Scale
integrations:
github:
- host: github.com
catalog:
rules:
- allow: [User, Group, Component, Api]
locations:
- target: /opt/app-root/src/user_t1-group_g1.yaml
type: file
- target: https://github.com/pmacik-testing/rhdh-perf-testing-repo/blob/main/100_components-100-apis.yaml
type: url
enabled:
github: true
auth:
providers:
guest:
dangerouslyAllowOutsideDevelopmet: true
permission:
enabled: true
rbac:
policies-csv-file: "./rbac-policy.csv"
admin:
users:
- name: user:default/t1
logging:
level: debug
backend:
database:
client: better-sqlite3
connection: ':memory:'
- kind: Secret
apiVersion: v1
metadata:
name: rhdh-backend-secret
stringData:
BACKEND_SECRET: b0oySXJaakZhRW8 # notsecret
type: Opaque
- kind: Backstage
apiVersion: rhdh.redhat.com/v1alpha3
metadata:
name: pmacik-rhdh
spec:
application:
appConfig:
configMaps:
- name: app-config-rhdh
key: app-config.rhdh.yaml
- name: app-config-backend-secret
key: app-config.rhdh.backend-secret.yaml
mountPath: /opt/app-root/src
dynamicPluginsConfigMapName: "dynamic-plugins-rhdh"
extraFiles:
configMaps:
- name: rbac-policy
- name: user-t1-group-g1
mountPath: /opt/app-root/src
extraEnvs:
envs:
- name: NODE_TLS_REJECT_UNAUTHORIZED
value: "0"
- name: NODE_ENV
value: development
secrets:
- key: BACKEND_SECRET
name: rhdh-backend-secret
replicas: 1
route:
enabled: true
database:
enableLocalDb: false
deployment:
patch:
spec:
template:
spec:
initcontainers:
- name: install-dynamic-plugins
resources:
limits:
cpu: 100m
ephemeral-storage: 200Mi
memory: 256Mi
requests:
cpu: 100m
ephemeral-storage: 200Mi
memory: 256Mi
containers:
- name: backstage-backend
resources:
limits:
cpu: 400m
ephemeral-storage: 100Mi
memory: 500Mi
requests:
cpu: 400m
ephemeral-storage: 100Mi
memory: 500Mi
readinessProbe:
initialDelaySeconds: 120
timeoutSeconds: 60
periodSeconds: 60
livenessProbe:
initialDelaySeconds: 120
timeoutSeconds: 60
periodSeconds: 60
volumes:
- name: dynamic-plugins-root
ephemeral:
volumeClaimTemplate:
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
volumeMode: Filesystem
148 changes: 148 additions & 0 deletions ci-scripts/dev-sandbox/rhdh-perf-workloads.secrets.template.yaml

Large diffs are not rendered by default.

39 changes: 12 additions & 27 deletions ci-scripts/dev-sandbox/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ mkdir -p "${TMP_DIR}"
WSTC=$(readlink -m "$rootdir/.toolchain-e2e.git")

export RHDH_INSTALL_METHOD=${RHDH_INSTALL_METHOD:-olm}
export RHDH_WORKLOADS_TEMPLATE_NAME=${RHDH_WORKLOADS_TEMPLATE_NAME:-default}
export RHDH_WORKLOADS_TEMPLATE=${RHDH_WORKLOADS_TEMPLATE:-$SCRIPT_DIR/rhdh-perf-workloads.$RHDH_WORKLOADS_TEMPLATE_NAME.template.yaml}

cd "$WSTC" || exit

Expand All @@ -42,38 +44,21 @@ cmd="go run setup/main.go --users 1 --default 1 --custom 0 --username baseline -
yes | $cmd
collect_counts "baseline-counts-post"

# testing env
if [ "$RHDH_INSTALL_METHOD" == "olm" ]; then
if [ "$AUTH_PROVIDER" == "keycloak" ]; then
rhdh_route="rhdh"
else
rhdh_route="backstage-developer-hub"
fi
elif [ "$RHDH_INSTALL_METHOD" == "helm" ]; then
export RHDH_HELM_RELEASE_NAME RHDH_HELM_CHART
number_of_runs=${1:-10}
number_of_users_per_run=${2:-2000}
number_of_users_with_workloads_per_run=${3:-2000}

RHDH_HELM_RELEASE_NAME=${RHDH_HELM_RELEASE_NAME:-rhdh}
RHDH_HELM_CHART=${RHDH_HELM_CHART:-redhat-developer-hub}

rhdh_route="${RHDH_HELM_RELEASE_NAME}-${RHDH_HELM_CHART}"
else
echo "Invalid RHDH install method: $RHDH_INSTALL_METHOD"
exit 1
fi
export RHDH_BASE_URL
RHDH_BASE_URL="https://$(oc get routes "$rhdh_route" -n "${RHDH_NAMESPACE:-rhdh-performance}" -o jsonpath='{.spec.host}')"
# end-of testing env

envsubst <"$SCRIPT_DIR/rhdh-perf-workloads.template.yaml" >"$TMP_DIR/rhdh-perf.workloads.yaml"
template="${1:-"$TMP_DIR/rhdh-perf.workloads.yaml"}"
date --utc -Ins>"${ARTIFACT_DIR}/benchmark-before"
for r in $(seq -w 1 "${2:-10}"); do
template="$TMP_DIR/rhdh-perf.workloads.yaml"
echo "Using $RHDH_WORKLOADS_TEMPLATE template --> $template"
envsubst <"$RHDH_WORKLOADS_TEMPLATE" >"$template"
date --utc -Ins >"${ARTIFACT_DIR}/benchmark-before"
for r in $(seq -w 1 "$number_of_runs"); do
TEST_ID="run$r"
echo "Running $TEST_ID"
make clean-users
collect_counts "$TEST_ID-counts-pre"
cmd="go run setup/main.go --users 2000 --default 2000 --custom 2000 --template=$template $workloads --username $TEST_ID --testname=$TEST_ID --verbose --idler-timeout 15m"
cmd="go run setup/main.go --users $number_of_users_per_run --default $number_of_users_per_run --custom $number_of_users_with_workloads_per_run --template=$template $workloads --username $TEST_ID --testname=$TEST_ID --verbose --idler-timeout 15s --skip-install-operators"
yes | $cmd |& tee "$TEST_ID.log" && out="tmp/results/$(date +%F_%T)-counts.csv"
collect_counts "$TEST_ID-counts-post"
done
date --utc -Ins>"${ARTIFACT_DIR}/benchmark-after"
date --utc -Ins >"${ARTIFACT_DIR}/benchmark-after"
6 changes: 5 additions & 1 deletion ci-scripts/rhdh-setup/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export RHDH_OLM_OPERATOR_RESOURCES_CPU_REQUESTS=${RHDH_OLM_OPERATOR_RESOURCES_CP
export RHDH_OLM_OPERATOR_RESOURCES_CPU_LIMITS=${RHDH_OLM_OPERATOR_RESOURCES_CPU_LIMITS:-}
export RHDH_OLM_OPERATOR_RESOURCES_MEMORY_REQUESTS=${RHDH_OLM_OPERATOR_RESOURCES_MEMORY_REQUESTS:-}
export RHDH_OLM_OPERATOR_RESOURCES_MEMORY_LIMITS=${RHDH_OLM_OPERATOR_RESOURCES_MEMORY_LIMITS:-}
export RHDH_OLM_OPERATOR_RESOURCES_EPHEMERAL_STORAGE_REQUESTS=${RHDH_OLM_OPERATOR_RESOURCES_EPHEMERAL_STORAGE_REQUESTS:-}

export PRE_LOAD_DB="${PRE_LOAD_DB:-true}"
export BACKSTAGE_USER_COUNT="${BACKSTAGE_USER_COUNT:-1}"
Expand Down Expand Up @@ -608,7 +609,7 @@ delete_rhdh_with_olm() {
$cli delete namespace "$RHDH_OPERATOR_NAMESPACE" --ignore-not-found=true --wait
}

while getopts "oi:rd" flag; do
while getopts "oi:mrd" flag; do
case "${flag}" in
o)
export INSTALL_METHOD=olm
Expand All @@ -624,6 +625,9 @@ while getopts "oi:rd" flag; do
AUTH_PROVIDER="$OPTARG"
install
;;
m)
setup_monitoring
;;
\?)
log_warn "Invalid option: ${flag} - defaulting to -i (install)"
install
Expand Down
2 changes: 2 additions & 0 deletions ci-scripts/rhdh-setup/install-rhdh-catalog-source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ RHDH_OLM_OPERATOR_RESOURCES_CPU_REQUESTS=${RHDH_OLM_OPERATOR_RESOURCES_CPU_REQUE
RHDH_OLM_OPERATOR_RESOURCES_CPU_LIMITS=${RHDH_OLM_OPERATOR_RESOURCES_CPU_LIMITS:-}
RHDH_OLM_OPERATOR_RESOURCES_MEMORY_REQUESTS=${RHDH_OLM_OPERATOR_RESOURCES_MEMORY_REQUESTS:-}
RHDH_OLM_OPERATOR_RESOURCES_MEMORY_LIMITS=${RHDH_OLM_OPERATOR_RESOURCES_MEMORY_LIMITS:-}
RHDH_OLM_OPERATOR_RESOURCES_EPHEMERAL_STORAGE_REQUESTS=${RHDH_OLM_OPERATOR_RESOURCES_EPHEMERAL_STORAGE_REQUESTS:-}

errorf() {
echo -e "${RED}$1${NC}"
Expand Down Expand Up @@ -277,5 +278,6 @@ if [ -n "${RHDH_OLM_OPERATOR_RESOURCES_CPU_REQUESTS}" ]; then yq -i '.spec.confi
if [ -n "${RHDH_OLM_OPERATOR_RESOURCES_CPU_LIMITS}" ]; then yq -i '.spec.config.resources.limits.cpu = "'"${RHDH_OLM_OPERATOR_RESOURCES_CPU_LIMITS}"'"' "$subscription"; fi
if [ -n "${RHDH_OLM_OPERATOR_RESOURCES_MEMORY_REQUESTS}" ]; then yq -i '.spec.config.resources.requests.memory = "'"${RHDH_OLM_OPERATOR_RESOURCES_MEMORY_REQUESTS}"'"' "$subscription"; fi
if [ -n "${RHDH_OLM_OPERATOR_RESOURCES_MEMORY_LIMITS}" ]; then yq -i '.spec.config.resources.limits.memory = "'"${RHDH_OLM_OPERATOR_RESOURCES_MEMORY_LIMITS}"'"' "$subscription"; fi
if [ -n "${RHDH_OLM_OPERATOR_RESOURCES_EPHEMERAL_STORAGE_REQUESTS}" ]; then yq -i '.spec.config.resources.requests.ephemeral-storage = "'"${RHDH_OLM_OPERATOR_RESOURCES_EPHEMERAL_STORAGE_REQUESTS}"'"' "$subscription"; fi

oc apply -f "$subscription"
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
locust==2.32.2
locust==2.32.6
7 changes: 6 additions & 1 deletion test.env
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,13 @@
# export RHDH_OLM_WATCH_EXT_CONF=true
# export RHDH_OLM_OPERATOR_RESOURCES_CPU_REQUESTS=
# export RHDH_OLM_OPERATOR_RESOURCES_CPU_LIMITS=
# export RHDH_OLM_OPERATOR__RESOURCES_MEMORY_REQUESTS=
# export RHDH_OLM_OPERATOR_RESOURCES_MEMORY_REQUESTS=
# export RHDH_OLM_OPERATOR_RESOURCES_MEMORY_LIMITS=
# export RHDH_OLM_OPERATOR_RESOURCES_EPHEMERAL_STORAGE_REQUESTS=
# export RHDH_OLM_OPERATOR_RESOURCES_EPHEMERAL_STORAGE_LIMITS=

## RHDH on Developer Sandbox
# export RHDH_WORKLOADS_TEMPLATE_NAME=default

## RHDH horizontal scaling
# export RHDH_DEPLOYMENT_REPLICAS=1
Expand Down