nix(loadtest): remove --method argument for JWT loadtests
This is not used by CI and I doubt it's actually used by anyone locally.
This commit is contained in:
@@ -18,7 +18,6 @@ import random
|
|||||||
import jwt
|
import jwt
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from enum import Enum
|
|
||||||
|
|
||||||
URL = "http://postgrest"
|
URL = "http://postgrest"
|
||||||
|
|
||||||
@@ -49,21 +48,8 @@ def generate_jwt(
|
|||||||
return jwt.encode(payload, key, alg)
|
return jwt.encode(payload, key, alg)
|
||||||
|
|
||||||
|
|
||||||
HTTP_METHODS = (
|
def append_targets(lines: list[str], token: str):
|
||||||
"GET",
|
lines.append(f"OPTIONS {URL}/authors_only")
|
||||||
"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")
|
|
||||||
lines.append(f"Authorization: Bearer {token}")
|
lines.append(f"Authorization: Bearer {token}")
|
||||||
lines.append("") # blank line to separate requests
|
lines.append("") # blank line to separate requests
|
||||||
|
|
||||||
@@ -121,13 +107,6 @@ def main():
|
|||||||
default=None,
|
default=None,
|
||||||
help="Path to an existing RSA JWK file used for signing tokens",
|
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()
|
args = parser.parse_args()
|
||||||
|
|
||||||
@@ -135,8 +114,6 @@ def main():
|
|||||||
|
|
||||||
is_hs = args.jwk_path is None
|
is_hs = args.jwk_path is None
|
||||||
|
|
||||||
http_method = HttpMethod(args.http_method)
|
|
||||||
|
|
||||||
nsamples = 1000
|
nsamples = 1000
|
||||||
|
|
||||||
if is_hs:
|
if is_hs:
|
||||||
@@ -184,13 +161,13 @@ def main():
|
|||||||
|
|
||||||
for i in range(ntargets):
|
for i in range(ntargets):
|
||||||
token = generate_jwt(now, run_postgrest_time + i // 1000, rsa_private_key)
|
token = generate_jwt(now, run_postgrest_time + i // 1000, rsa_private_key)
|
||||||
append_targets(lines, token, http_method)
|
append_targets(lines, token)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
tokens = [generate_jwt(now, None, rsa_private_key) for _ in range(nsamples)]
|
tokens = [generate_jwt(now, None, rsa_private_key) for _ in range(nsamples)]
|
||||||
for i in range(ntargets):
|
for i in range(ntargets):
|
||||||
token = random.choice(tokens)
|
token = random.choice(tokens)
|
||||||
append_targets(lines, token, http_method)
|
append_targets(lines, token)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(args.targets_path, "w") as f:
|
with open(args.targets_path, "w") as f:
|
||||||
|
|||||||
@@ -45,9 +45,7 @@ let
|
|||||||
"ARG_OPTIONAL_SINGLE([output], [o], [Filename to dump json output to], [./loadtest/result.bin])"
|
"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([testdir], [t], [Directory to load tests and fixtures from], [./test/load])"
|
||||||
"ARG_OPTIONAL_SINGLE([kind], [k], [Kind of loadtest], [mixed])"
|
"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([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_OPTIONAL_SINGLE([monitor], [m], [Monitoring file], [./loadtest/result.csv])"
|
||||||
"ARG_LEFTOVERS([additional vegeta arguments])"
|
"ARG_LEFTOVERS([additional vegeta arguments])"
|
||||||
];
|
];
|
||||||
@@ -69,7 +67,7 @@ let
|
|||||||
jwt-hs)
|
jwt-hs)
|
||||||
export PGRST_JWT_CACHE_MAX_ENTRIES="0"
|
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
|
# shellcheck disable=SC2145
|
||||||
${withTools.withPg} -f "$_arg_testdir"/fixtures.sql \
|
${withTools.withPg} -f "$_arg_testdir"/fixtures.sql \
|
||||||
@@ -79,7 +77,7 @@ let
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
jwt-hs-cache)
|
jwt-hs-cache)
|
||||||
${genTargets} --method "$_arg_method" "$_arg_testdir"/gen_targets.http
|
${genTargets} "$_arg_testdir"/gen_targets.http
|
||||||
|
|
||||||
# shellcheck disable=SC2145
|
# shellcheck disable=SC2145
|
||||||
${withTools.withPg} -f "$_arg_testdir"/fixtures.sql \
|
${withTools.withPg} -f "$_arg_testdir"/fixtures.sql \
|
||||||
@@ -89,7 +87,7 @@ let
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
jwt-hs-cache-worst)
|
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
|
# shellcheck disable=SC2145
|
||||||
${withTools.withPg} -f "$_arg_testdir"/fixtures.sql \
|
${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
|
${genRsaMaterials} --rsa="$_arg_testdir"/gen_jwk.json --private-key="$_arg_testdir"/gen_private.json
|
||||||
export PGRST_JWT_SECRET="@$_arg_testdir/gen_jwk.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
|
# shellcheck disable=SC2145
|
||||||
${withTools.withPg} -f "$_arg_testdir"/fixtures.sql \
|
${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
|
${genRsaMaterials} --rsa="$_arg_testdir"/gen_jwk.json --private-key="$_arg_testdir"/gen_private.json
|
||||||
export PGRST_JWT_SECRET="@$_arg_testdir/gen_jwk.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
|
# shellcheck disable=SC2145
|
||||||
${withTools.withPg} -f "$_arg_testdir"/fixtures.sql \
|
${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
|
${genRsaMaterials} --rsa="$_arg_testdir"/gen_jwk.json --private-key="$_arg_testdir"/gen_private.json
|
||||||
export PGRST_JWT_SECRET="@$_arg_testdir/gen_jwk.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
|
# shellcheck disable=SC2145
|
||||||
${withTools.withPg} -f "$_arg_testdir"/fixtures.sql \
|
${withTools.withPg} -f "$_arg_testdir"/fixtures.sql \
|
||||||
|
|||||||
Reference in New Issue
Block a user