nix(loadtest): remove jwt-cache-worst
This test is not really functional (anymore?). It depends on some tokens expiring - but they don't, really. This is because: 1) Before merging the RSA and HS variants earlier in this patch series, they ran roughly 15s and 34s respectively in CI. 2) Since PostgREST takes a clock skew of up to 30 seconds into account, there would be *at most* 4s of expiring tokens in a test run - and *only* in the HS case, not for RSA.
This commit is contained in:
@@ -131,7 +131,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
kind: ['mixed', 'jwt-cache', 'jwt-cache-worst']
|
kind: ['mixed', 'jwt-cache']
|
||||||
name: Loadtest
|
name: Loadtest
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import time
|
|||||||
import argparse
|
import argparse
|
||||||
import random
|
import random
|
||||||
import jwcrypto.jwt as jwt
|
import jwcrypto.jwt as jwt
|
||||||
from typing import Optional
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
URL = "http://postgrest"
|
URL = "http://postgrest"
|
||||||
@@ -24,7 +23,6 @@ secret_key = "reallyreallyreallyreallyverysafe"
|
|||||||
|
|
||||||
def generate_target(
|
def generate_target(
|
||||||
now: int,
|
now: int,
|
||||||
exp_inc: Optional[int],
|
|
||||||
key: jwt.JWK,
|
key: jwt.JWK,
|
||||||
) -> list[str]:
|
) -> list[str]:
|
||||||
"""Generate a target using an HS256 or RS256 JWT"""
|
"""Generate a target using an HS256 or RS256 JWT"""
|
||||||
@@ -33,9 +31,6 @@ def generate_target(
|
|||||||
"iat": now,
|
"iat": now,
|
||||||
}
|
}
|
||||||
|
|
||||||
if exp_inc is not None:
|
|
||||||
headers["exp"] = now + exp_inc
|
|
||||||
|
|
||||||
claims = {
|
claims = {
|
||||||
"role": "postgrest_test_author",
|
"role": "postgrest_test_author",
|
||||||
}
|
}
|
||||||
@@ -62,13 +57,6 @@ def main():
|
|||||||
help="Path to write the generated files",
|
help="Path to write the generated files",
|
||||||
type=Path,
|
type=Path,
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
|
||||||
"--worst",
|
|
||||||
dest="worst",
|
|
||||||
action=argparse.BooleanOptionalAction,
|
|
||||||
default=False,
|
|
||||||
help="Generate worst case targets for a JWT cache",
|
|
||||||
)
|
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
@@ -98,27 +86,11 @@ def main():
|
|||||||
|
|
||||||
lines = []
|
lines = []
|
||||||
|
|
||||||
# We want to ensure 401 Unauthorized responses don't happen during
|
hs_targets = [generate_target(now, hs) for _ in range(nsamples)]
|
||||||
# JWT validation, this can happen when the jwt `exp` is too short.
|
rsa_targets = [generate_target(now, rsa) for _ in range(nsamples)]
|
||||||
# At the same time, we want to ensure the `exp` is not too big,
|
for i in range(ntargets):
|
||||||
# so expires will occur and postgREST needs to
|
target = random.choice(hs_targets if i % 2 == 0 else rsa_targets)
|
||||||
# clean cached expired JWTs
|
lines.extend(target)
|
||||||
if args.worst:
|
|
||||||
# estimated time it takes to run postgrest itself
|
|
||||||
run_postgrest_time = 2
|
|
||||||
|
|
||||||
for i in range(ntargets):
|
|
||||||
target = generate_target(
|
|
||||||
now, run_postgrest_time + i // 1000, rsa if i % 2 == 0 else hs
|
|
||||||
)
|
|
||||||
lines.extend(target)
|
|
||||||
|
|
||||||
else:
|
|
||||||
hs_targets = [generate_target(now, None, hs) for _ in range(nsamples)]
|
|
||||||
rsa_targets = [generate_target(now, None, rsa) for _ in range(nsamples)]
|
|
||||||
for i in range(ntargets):
|
|
||||||
target = random.choice(hs_targets if i % 2 == 0 else rsa_targets)
|
|
||||||
lines.extend(target)
|
|
||||||
|
|
||||||
with open(targets_path, "w") as f:
|
with open(targets_path, "w") as f:
|
||||||
f.write("\n".join(lines))
|
f.write("\n".join(lines))
|
||||||
|
|||||||
@@ -76,18 +76,6 @@ let
|
|||||||
${runner} -lazy -targets gen_targets.http -output \"$abs_output\" \"''${_arg_leftovers[@]}\""
|
${runner} -lazy -targets gen_targets.http -output \"$abs_output\" \"''${_arg_leftovers[@]}\""
|
||||||
;;
|
;;
|
||||||
|
|
||||||
jwt-cache-worst)
|
|
||||||
export PGRST_JWT_SECRET="@$_arg_testdir/gen_jwks.json"
|
|
||||||
|
|
||||||
${libfaketime}/bin/faketime '2000-01-01 00:00:00' ${genTargets} --worst "$_arg_testdir"
|
|
||||||
|
|
||||||
# shellcheck disable=SC2145
|
|
||||||
${withTools.withPg} -f "$_arg_testdir"/fixtures.sql \
|
|
||||||
${withTools.withPgrst} --faketime '2000-01-01 00:00:00' -m "$_arg_monitor" \
|
|
||||||
sh -c "cd \"$_arg_testdir\" && \
|
|
||||||
${runner} -lazy -targets gen_targets.http -output \"$abs_output\" \"''${_arg_leftovers[@]}\""
|
|
||||||
;;
|
|
||||||
|
|
||||||
# here we sleep purposefully to check how much memory does the schema cache consume in the final report
|
# here we sleep purposefully to check how much memory does the schema cache consume in the final report
|
||||||
mixed)
|
mixed)
|
||||||
# shellcheck disable=SC2145
|
# shellcheck disable=SC2145
|
||||||
|
|||||||
Reference in New Issue
Block a user