optimize fixtures, better user_list tests

Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>
This commit is contained in:
Marc 'risson' Schmitt
2024-04-09 17:13:24 +02:00
parent 1f789dd4c5
commit 334b183465
3 changed files with 39 additions and 23 deletions

View File

@ -15,8 +15,7 @@ django.setup()
from django.conf import settings
from authentik.core.models import Group, User
from authentik.stages.authenticator_static.models import (StaticDevice,
StaticToken)
from authentik.stages.authenticator_static.models import StaticToken
from authentik.tenants.models import Domain, Tenant
settings.CELERY["task_always_eager"] = True
@ -29,14 +28,15 @@ def user_list():
(100, 0, 0),
(1000, 0, 0),
(10000, 0, 0),
(10, 20, 0),
(100, 3, 0),
(1000, 3, 0),
(10000, 3, 0),
(100, 20, 0),
(1000, 20, 0),
(10000, 20, 0),
(10, 20, 10),
(100, 20, 10),
(1000, 20, 10),
(10000, 20, 10),
(100, 20, 3),
(1000, 20, 3),
(10000, 20, 3),
]
for tenant in tenants:
@ -49,18 +49,29 @@ def user_list():
Domain.objects.create(tenant=t, domain=f"{tenant_name}.localhost")
with t:
for _ in range(groups_per_user * 5):
group = Group.objects.create(name=uuid4())
Group.objects.bulk_create([Group(name=uuid4()) for _ in range(groups_per_user * 5)])
for group in Group.objects.exclude(name="authentik Admins"):
for _ in range(parents_per_group):
new_group = Group.objects.create(name=uuid4())
group.parent = new_group
group.save()
group = new_group
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]
)
User.objects.bulk_create(
[
User(
username=uuid4(),
name=uuid4(),
)
for _ in range(user_count)
]
)
if groups_per_user:
for user in User.objects.exclude_anonymous().exclude(username="akadmin"):
user.ak_groups.set(
Group.objects.exclude(name="authentik Admins").order_by("?")[
:groups_per_user
]
)
def login():
@ -82,7 +93,7 @@ def login():
device = user.staticdevice_set.create()
# Multiple token with same token for all the iterations in the test
device.token_set.bulk_create(
[StaticToken(device=device, token=f"staticToken") for _ in range(10000)]
[StaticToken(device=device, token=f"staticToken") for _ in range(100000)]
)

View File

@ -7,7 +7,7 @@ export const options = {
obj,
{
executor: "constant-vus",
vus: 10,
vus: 12,
duration: "300s",
startTime: `${315 * i}s`,
env: {
@ -42,6 +42,10 @@ export default function () {
check(res, {
"status is 200": (res) => res.status === 200,
});
if (res.status !== 200) {
fail("Endpoint did not return 200.");
break;
}
const component = res.json()["component"];
let payload = {};
@ -55,7 +59,7 @@ export default function () {
};
} else if (component === "ak-stage-authenticator-validate") {
payload = {
code: `staticToken`,
code: "staticToken",
};
} else if (component === "xak-flow-redirect") {
break;

View File

@ -15,19 +15,20 @@ export const options = {
[100, 0, 0, 100],
[1000, 0, 0, 100],
[10000, 0, 0, 100],
[10, 20, 0, 20],
[100, 3, 0, 20],
[1000, 3, 0, 20],
[10000, 3, 0, 20],
[100, 20, 0, 20],
[1000, 20, 0, 20],
[10000, 20, 0, 20],
[10, 20, 10, 20],
[100, 20, 10, 20],
[1000, 20, 10, 20],
[10000, 20, 10, 20],
[100, 20, 3, 20],
[1000, 20, 3, 20],
[10000, 20, 3, 20],
].map((obj, i) => [
`${obj[0]}_${obj[1]}_${obj[2]}_${obj[3]}`,
{
executor: "constant-vus",
vus: 10,
vus: 12,
duration: "300s",
startTime: `${315 * i}s`,
env: {