From 6d625fd1d7c8d09fc3876e7c00be22063050fedf Mon Sep 17 00:00:00 2001 From: Marc 'risson' Schmitt Date: Mon, 15 Apr 2024 14:30:53 +0200 Subject: [PATCH] support other than localhost Signed-off-by: Marc 'risson' Schmitt --- tests/benchmark/fixtures.py | 10 ++++++---- tests/benchmark/login.js | 4 +++- tests/benchmark/provider_oauth2.js | 6 ++++-- tests/benchmark/user_list.js | 4 +++- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/tests/benchmark/fixtures.py b/tests/benchmark/fixtures.py index 91fd9c715d..b07ab787cb 100755 --- a/tests/benchmark/fixtures.py +++ b/tests/benchmark/fixtures.py @@ -25,6 +25,8 @@ from authentik.tenants.models import Domain, Tenant settings.CELERY["task_always_eager"] = True +host = environ.get("BENCH_HOST", "localhost") + def user_list(): # Number of users, groups per user, parents per groups @@ -51,7 +53,7 @@ def user_list(): tenant_name = f"user-list-{user_count}-{groups_per_user}-{parents_per_group}" 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}.{host}") with t: Group.objects.bulk_create([Group(name=uuid4()) for _ in range(groups_per_user * 5)]) @@ -81,7 +83,7 @@ def user_list(): def login(): t = Tenant.objects.create(schema_name=f"t_login_no_mfa", name=uuid4()) - Domain.objects.create(tenant=t, domain=f"login-no-mfa.localhost") + Domain.objects.create(tenant=t, domain=f"login-no-mfa.{host}") with t: user = User(username="test", name=uuid4()) @@ -89,7 +91,7 @@ def login(): user.save() t = Tenant.objects.create(schema_name=f"t_login_with_mfa", name=uuid4()) - Domain.objects.create(tenant=t, domain=f"login-with-mfa.localhost") + Domain.objects.create(tenant=t, domain=f"login-with-mfa.{host}") with t: user = User(username="test", name=uuid4()) @@ -127,7 +129,7 @@ def provider_oauth2(): tenant_name = f"provider-oauth2-{user_policies_count}-{group_policies_count}-{expression_policies_count}" 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}.{host}") with t: user = User(username="test", name=uuid4()) diff --git a/tests/benchmark/login.js b/tests/benchmark/login.js index 34857ba716..e6ccaa3718 100644 --- a/tests/benchmark/login.js +++ b/tests/benchmark/login.js @@ -1,6 +1,8 @@ import http from "k6/http"; import { check, fail } from "k6"; +const host = __ENV.BENCH_HOST ? __ENV.BENCH_HOST : "localhost"; + export const options = { scenarios: Object.fromEntries( ["no-mfa", "with-mfa"].map((obj, i) => [ @@ -23,7 +25,7 @@ export const options = { export default function () { const domain = __ENV.DOMAIN; - const url = `http://${domain}.localhost:9000/api/v3/flows/executor/default-authentication-flow/`; + const url = `http://${domain}.${host}:9000/api/v3/flows/executor/default-authentication-flow/`; const cookieJar = new http.CookieJar(); const params = { jar: cookieJar, diff --git a/tests/benchmark/provider_oauth2.js b/tests/benchmark/provider_oauth2.js index 069c35c83f..1f3aa845d4 100644 --- a/tests/benchmark/provider_oauth2.js +++ b/tests/benchmark/provider_oauth2.js @@ -3,6 +3,8 @@ import exec from "k6/execution"; import http from "k6/http"; import { check, fail } from "k6"; +const host = __ENV.BENCH_HOST ? __ENV.BENCH_HOST : "localhost"; + const testcases = [ [0, 0, 0], [10, 0, 0], @@ -53,7 +55,7 @@ export function setup() { const user_policies_count = testcase[0]; const group_policies_count = testcase[1]; const expression_policies_count = testcase[2]; - const domain = `provider-oauth2-${user_policies_count}-${group_policies_count}-${expression_policies_count}.localhost:9000`; + const domain = `provider-oauth2-${user_policies_count}-${group_policies_count}-${expression_policies_count}.${host}:9000`; const url = `http://${domain}/api/v3/flows/executor/default-authentication-flow/`; const params = { headers: { @@ -119,7 +121,7 @@ export default function (data) { const user_policies_count = Number(__ENV.USER_POLICIES_COUNT); const group_policies_count = Number(__ENV.GROUP_POLICIES_COUNT); const expression_policies_count = Number(__ENV.EXPRESSION_POLICIES_COUNT); - const domain = `provider-oauth2-${user_policies_count}-${group_policies_count}-${expression_policies_count}.localhost:9000`; + const domain = `provider-oauth2-${user_policies_count}-${group_policies_count}-${expression_policies_count}.${host}:9000`; const params = { headers: { "Content-Type": "application/json", diff --git a/tests/benchmark/user_list.js b/tests/benchmark/user_list.js index 3a0c677f3b..6bc1562ea9 100644 --- a/tests/benchmark/user_list.js +++ b/tests/benchmark/user_list.js @@ -2,6 +2,8 @@ import exec from "k6/execution"; import http from "k6/http"; import { check } from "k6"; +const host = __ENV.BENCH_HOST ? __ENV.BENCH_HOST : "localhost"; + export const options = { discardResponseBodies: true, scenarios: Object.fromEntries( @@ -64,7 +66,7 @@ export default function () { const groups_per_user = Number(__ENV.GROUPS_PER_USER); const parents_per_group = Number(__ENV.PARENTS_PER_GROUP); const with_groups = Number(__ENV.WITH_GROUPS); - const domain = `user-list-${user_count}-${groups_per_user}-${parents_per_group}.localhost:9000`; + const domain = `user-list-${user_count}-${groups_per_user}-${parents_per_group}.${host}:9000`; const page_size = Number(__ENV.PAGE_SIZE); const pages = Math.round(user_count / page_size); let requests = [];