diff --git a/nix/tools/generate_targets.py b/nix/tools/generate_targets.py index 9ece166ca..5c434b96d 100644 --- a/nix/tools/generate_targets.py +++ b/nix/tools/generate_targets.py @@ -18,7 +18,6 @@ import random import jwt from typing import Optional from pathlib import Path -from enum import Enum URL = "http://postgrest" @@ -49,21 +48,8 @@ def generate_jwt( return jwt.encode(payload, key, alg) -HTTP_METHODS = ( - "GET", - "OPTIONS", -) - -HttpMethod = Enum( - "HttpMethod", - {method: method for method in HTTP_METHODS}, - type=str, - module=__name__, -) - - -def append_targets(lines: list[str], token: str, http_method: HttpMethod): - lines.append(f"{http_method.value} {URL}/authors_only") +def append_targets(lines: list[str], token: str): + lines.append(f"OPTIONS {URL}/authors_only") lines.append(f"Authorization: Bearer {token}") lines.append("") # blank line to separate requests @@ -121,13 +107,6 @@ def main(): default=None, help="Path to an existing RSA JWK file used for signing tokens", ) - parser.add_argument( - "--method", - dest="http_method", - choices=list(HTTP_METHODS), - required=True, - help="HTTP method for the vegeta targets", - ) args = parser.parse_args() @@ -135,8 +114,6 @@ def main(): is_hs = args.jwk_path is None - http_method = HttpMethod(args.http_method) - nsamples = 1000 if is_hs: @@ -184,13 +161,13 @@ def main(): for i in range(ntargets): token = generate_jwt(now, run_postgrest_time + i // 1000, rsa_private_key) - append_targets(lines, token, http_method) + append_targets(lines, token) else: tokens = [generate_jwt(now, None, rsa_private_key) for _ in range(nsamples)] for i in range(ntargets): token = random.choice(tokens) - append_targets(lines, token, http_method) + append_targets(lines, token) try: with open(args.targets_path, "w") as f: diff --git a/nix/tools/loadtest.nix b/nix/tools/loadtest.nix index 47150e2e3..d7a1ee0f4 100644 --- a/nix/tools/loadtest.nix +++ b/nix/tools/loadtest.nix @@ -45,9 +45,7 @@ let "ARG_OPTIONAL_SINGLE([output], [o], [Filename to dump json output to], [./loadtest/result.bin])" "ARG_OPTIONAL_SINGLE([testdir], [t], [Directory to load tests and fixtures from], [./test/load])" "ARG_OPTIONAL_SINGLE([kind], [k], [Kind of loadtest], [mixed])" - "ARG_OPTIONAL_SINGLE([method],, [HTTP method used for the jwt loadtests], [OPTIONS])" "ARG_TYPE_GROUP_SET([KIND], [KIND], [kind], [mixed,jwt-hs,jwt-hs-cache,jwt-hs-cache-worst,jwt-rsa,jwt-rsa-cache,jwt-rsa-cache-worst])" - "ARG_TYPE_GROUP_SET([METHOD], [METHOD], [method], [OPTIONS,GET])" "ARG_OPTIONAL_SINGLE([monitor], [m], [Monitoring file], [./loadtest/result.csv])" "ARG_LEFTOVERS([additional vegeta arguments])" ]; @@ -69,7 +67,7 @@ let jwt-hs) export PGRST_JWT_CACHE_MAX_ENTRIES="0" - ${genTargets} --method "$_arg_method" "$_arg_testdir"/gen_targets.http + ${genTargets} "$_arg_testdir"/gen_targets.http # shellcheck disable=SC2145 ${withTools.withPg} -f "$_arg_testdir"/fixtures.sql \ @@ -79,7 +77,7 @@ let ;; jwt-hs-cache) - ${genTargets} --method "$_arg_method" "$_arg_testdir"/gen_targets.http + ${genTargets} "$_arg_testdir"/gen_targets.http # shellcheck disable=SC2145 ${withTools.withPg} -f "$_arg_testdir"/fixtures.sql \ @@ -89,7 +87,7 @@ let ;; jwt-hs-cache-worst) - ${libfaketime}/bin/faketime '2000-01-01 00:00:00' ${genTargets} --method "$_arg_method" --worst "$_arg_testdir"/gen_targets.http + ${libfaketime}/bin/faketime '2000-01-01 00:00:00' ${genTargets} --worst "$_arg_testdir"/gen_targets.http # shellcheck disable=SC2145 ${withTools.withPg} -f "$_arg_testdir"/fixtures.sql \ @@ -104,7 +102,7 @@ let ${genRsaMaterials} --rsa="$_arg_testdir"/gen_jwk.json --private-key="$_arg_testdir"/gen_private.json export PGRST_JWT_SECRET="@$_arg_testdir/gen_jwk.json" - ${genTargets} --method "$_arg_method" --rsa="$_arg_testdir"/gen_jwk.json --private-key="$_arg_testdir"/gen_private.json "$_arg_testdir"/gen_targets.http + ${genTargets} --rsa="$_arg_testdir"/gen_jwk.json --private-key="$_arg_testdir"/gen_private.json "$_arg_testdir"/gen_targets.http # shellcheck disable=SC2145 ${withTools.withPg} -f "$_arg_testdir"/fixtures.sql \ @@ -117,7 +115,7 @@ let ${genRsaMaterials} --rsa="$_arg_testdir"/gen_jwk.json --private-key="$_arg_testdir"/gen_private.json export PGRST_JWT_SECRET="@$_arg_testdir/gen_jwk.json" - ${genTargets} --method "$_arg_method" --rsa="$_arg_testdir"/gen_jwk.json --private-key="$_arg_testdir"/gen_private.json "$_arg_testdir"/gen_targets.http + ${genTargets} --rsa="$_arg_testdir"/gen_jwk.json --private-key="$_arg_testdir"/gen_private.json "$_arg_testdir"/gen_targets.http # shellcheck disable=SC2145 ${withTools.withPg} -f "$_arg_testdir"/fixtures.sql \ @@ -130,7 +128,7 @@ let ${genRsaMaterials} --rsa="$_arg_testdir"/gen_jwk.json --private-key="$_arg_testdir"/gen_private.json export PGRST_JWT_SECRET="@$_arg_testdir/gen_jwk.json" - ${libfaketime}/bin/faketime '2000-01-01 00:00:00' ${genTargets} --method "$_arg_method" --worst --rsa="$_arg_testdir"/gen_jwk.json --private-key="$_arg_testdir"/gen_private.json "$_arg_testdir"/gen_targets.http + ${libfaketime}/bin/faketime '2000-01-01 00:00:00' ${genTargets} --worst --rsa="$_arg_testdir"/gen_jwk.json --private-key="$_arg_testdir"/gen_private.json "$_arg_testdir"/gen_targets.http # shellcheck disable=SC2145 ${withTools.withPg} -f "$_arg_testdir"/fixtures.sql \