add graphs

Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>
This commit is contained in:
Marc 'risson' Schmitt
2024-04-08 17:29:58 +02:00
parent ca7cc30504
commit 6babf0f1c4
8 changed files with 75 additions and 11 deletions

1
.gitignore vendored
View File

@ -212,6 +212,7 @@ source_docs/
### Benchmark ### ### Benchmark ###
tests/benchmark/k6 tests/benchmark/k6
tests/benchmark/prometheus
tests/benchmark/**/*.json tests/benchmark/**/*.json
tests/benchmark/**/*.ndjson tests/benchmark/**/*.ndjson
tests/benchmark/**/*.html tests/benchmark/**/*.html

View File

@ -289,12 +289,14 @@ benchmark-install:
mv k6 tests/benchmark/k6 mv k6 tests/benchmark/k6
benchmark-fixtures-create: benchmark-fixtures-create:
./tests/benchmark/fixtures.py create tests/benchmark/fixtures.py create
benchmark-run: benchmark-run:
./tests/benchmark/run.sh docker compose -f tests/benchmark/docker-compose.yml up -d
sleep 5
tests/benchmark/run.sh
benchmark-fixtures-delete: benchmark-fixtures-delete:
./tests/benchmark/fixtures.py delete tests/benchmark/fixtures.py delete
benchmark: benchmark-install benchmark-fixtures-create benchmark-run benchmark-fixtures-delete benchmark: benchmark-install benchmark-fixtures-create benchmark-run benchmark-fixtures-delete

View File

@ -0,0 +1,31 @@
---
services:
prometheus:
image: quay.io/prometheus/prometheus:latest
command:
- --enable-feature=native-histograms
- --web.enable-remote-write-receiver
- --config.file=/etc/prometheus/prometheus.yml
- --storage.tsdb.path=/prometheus
- --web.console.libraries=/usr/share/prometheus/console_libraries
- --web.console.templates=/usr/share/prometheus/consoles
ports:
- 127.0.0.1:9090:9090
volumes:
- ./prometheus:/prometheus
user: root
grafana:
image: grafana/grafana:latest
environment:
GF_AUTH_ANONYMOUS_ENABLED: "true"
GF_AUTH_ANONYMOUS_ORG_ROLE: Admin
# GF_INSTALL_PLUGINS: grafana-image-renderer
# GF_RENDERING_SERVER_URL: http://renderer:8081/render
# GF_RENDERING_CALLBACK_URL: http://grafana:3000/
# GF_LOG_FILTERS: rendering:debug
ports:
- 127.0.0.1:3000:3000
volumes:
- ./grafana/provisioning:/etc/grafana/provisioning:ro
- ./grafana/dashboards:/var/lib/grafana/dashboards:ro

View File

@ -21,6 +21,7 @@ settings.CELERY["task_always_eager"] = True
def user_list(): def user_list():
print("user_list")
# Number of users, groups per user, parents per groups # Number of users, groups per user, parents per groups
tenants = [ tenants = [
(10, 0, 0), (10, 0, 0),
@ -38,26 +39,31 @@ def user_list():
] ]
for tenant in tenants: for tenant in tenants:
print(tenant)
user_count = tenant[0] user_count = tenant[0]
groups_per_user = tenant[1] groups_per_user = tenant[1]
parents_per_group = tenant[2] parents_per_group = tenant[2]
tenant_name = f"user-list-{user_count}-{groups_per_user}-{parents_per_group}" tenant_name = f"user-list-{user_count}-{groups_per_user}-{parents_per_group}"
print("tenant")
t = Tenant.objects.create(schema_name=f"t_{tenant_name.replace('-', '_')}", name=uuid4()) t = Tenant.objects.create(schema_name=f"t_{tenant_name.replace('-', '_')}", name=uuid4())
Domain.objects.create(tenant=t, domain=f"{tenant_name}.localhost") Domain.objects.create(tenant=t, domain=f"{tenant_name}.localhost")
with t: with t:
for _ in range(user_count): print("groups")
User.objects.create(username=uuid4(), name=uuid4()) for _ in range(groups_per_user * 5):
for user in User.objects.exclude_anonymous().exclude(username="akadmin"): group = Group.objects.create(name=uuid4())
for _ in range(groups_per_user):
user.ak_groups.add(Group.objects.create(name=uuid4()))
for group in Group.objects.exclude(name="authentik Admins"):
for _ in range(parents_per_group): for _ in range(parents_per_group):
new_group = Group.objects.create(name=uuid4()) new_group = Group.objects.create(name=uuid4())
group.parent = new_group group.parent = new_group
group.save() group.save()
group = new_group group = new_group
print("users")
for _ in range(user_count):
user = User.objects.create(username=uuid4(), name=uuid4())
user.ak_groups.set(
Group.objects.exclude(name="authentik Admins").order_by("?")[:groups_per_user]
)
def delete(): def delete():

View File

@ -0,0 +1,8 @@
---
apiVersion: 1
providers:
- name: default
folder: k6
type: file
options:
path: /var/lib/grafana/dashboards

View File

@ -0,0 +1,11 @@
---
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
access: proxy
orgId: 1
uid: prometheus
url: http://prometheus:9090
jsonData:
timeInterval: 1s

View File

@ -7,8 +7,12 @@ BASE_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)"
function _k6 { function _k6 {
local filename="${1}" local filename="${1}"
K6_PROMETHEUS_RW_SERVER_URL=http://localhost:9090/api/v1/write \
K6_PROMETHEUS_RW_TREND_AS_NATIVE_HISTOGRAM=true \
K6_PROMETHEUS_RW_PUSH_INTERVAL=1s \
"${BASE_DIR}/k6" \ "${BASE_DIR}/k6" \
run \ run \
--out experimental-prometheus-rw \
--out "web-dashboard=port=-1&report=${filename%.*}.html&period=1s&tag=name&tag=group&tag=user_count&tag=page_size" \ --out "web-dashboard=port=-1&report=${filename%.*}.html&period=1s&tag=name&tag=group&tag=user_count&tag=page_size" \
--out "json=${filename%.*}.json" \ --out "json=${filename%.*}.json" \
"${@}" "${@}"

View File

@ -29,8 +29,8 @@ export const options = {
{ {
executor: "constant-vus", executor: "constant-vus",
vus: 10, vus: 10,
duration: "30s", duration: "300s",
startTime: `${30 * i}s`, startTime: `${315 * i}s`,
env: { env: {
USER_COUNT: `${obj[0]}`, USER_COUNT: `${obj[0]}`,
GROUPS_PER_USER: `${obj[1]}`, GROUPS_PER_USER: `${obj[1]}`,
@ -38,6 +38,7 @@ export const options = {
PAGE_SIZE: `${obj[3]}`, PAGE_SIZE: `${obj[3]}`,
}, },
tags: { tags: {
testid: `user_list_${obj[0]}_${obj[1]}_${obj[2]}_${obj[3]}`,
user_count: `${obj[0]}`, user_count: `${obj[0]}`,
groups_per_user: `${obj[1]}`, groups_per_user: `${obj[1]}`,
parents_per_group: `${obj[2]}`, parents_per_group: `${obj[2]}`,