nix(loadtest): refactor genTargets argument
Instead of passing a path to the output target file, just pass the directory in which to create the file. This allows the script to create multiple files later.
This commit is contained in:
@@ -58,9 +58,10 @@ def main():
|
||||
description="Generate Vegeta targets with unique JWTs"
|
||||
)
|
||||
parser.add_argument(
|
||||
"targets_path",
|
||||
metavar="TARGETS_PATH",
|
||||
help="Path to write the generated targets file",
|
||||
"generated_path",
|
||||
metavar="GENERATED_PATH",
|
||||
help="Path to write the generated files",
|
||||
type=Path,
|
||||
)
|
||||
parser.add_argument(
|
||||
"--private-key",
|
||||
@@ -79,6 +80,8 @@ def main():
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
targets_path = args.generated_path / "gen_targets.http"
|
||||
|
||||
rsa_private_key: Optional[jwt.algorithms.RSAAlgorithm] = None
|
||||
|
||||
nsamples = 500 # per algorithm
|
||||
@@ -134,10 +137,10 @@ def main():
|
||||
lines.extend(target)
|
||||
|
||||
try:
|
||||
with open(args.targets_path, "w") as f:
|
||||
with open(targets_path, "w") as f:
|
||||
f.write("\n".join(lines))
|
||||
except IOError as e:
|
||||
print(f"Error writing to {args.targets_path}: {e}", file=sys.stderr)
|
||||
print(f"Error writing to {targets_path}: {e}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
print(f"Created {ntargets} targets", end=" ")
|
||||
|
||||
@@ -70,7 +70,7 @@ let
|
||||
${genKeyMaterials} --jwks="$_arg_testdir"/gen_jwks.json --private-key="$_arg_testdir"/gen_private.json
|
||||
export PGRST_JWT_SECRET="@$_arg_testdir/gen_jwks.json"
|
||||
|
||||
${genTargets} --private-key="$_arg_testdir"/gen_private.json "$_arg_testdir"/gen_targets.http
|
||||
${genTargets} --private-key="$_arg_testdir"/gen_private.json "$_arg_testdir"
|
||||
|
||||
# shellcheck disable=SC2145
|
||||
${withTools.withPg} -f "$_arg_testdir"/fixtures.sql \
|
||||
@@ -83,7 +83,7 @@ let
|
||||
${genKeyMaterials} --jwks="$_arg_testdir"/gen_jwks.json --private-key="$_arg_testdir"/gen_private.json
|
||||
export PGRST_JWT_SECRET="@$_arg_testdir/gen_jwks.json"
|
||||
|
||||
${genTargets} --private-key="$_arg_testdir"/gen_private.json "$_arg_testdir"/gen_targets.http
|
||||
${genTargets} --private-key="$_arg_testdir"/gen_private.json "$_arg_testdir"
|
||||
|
||||
# shellcheck disable=SC2145
|
||||
${withTools.withPg} -f "$_arg_testdir"/fixtures.sql \
|
||||
@@ -96,7 +96,7 @@ let
|
||||
${genKeyMaterials} --jwks="$_arg_testdir"/gen_jwks.json --private-key="$_arg_testdir"/gen_private.json
|
||||
export PGRST_JWT_SECRET="@$_arg_testdir/gen_jwks.json"
|
||||
|
||||
${libfaketime}/bin/faketime '2000-01-01 00:00:00' ${genTargets} --worst --private-key="$_arg_testdir"/gen_private.json "$_arg_testdir"/gen_targets.http
|
||||
${libfaketime}/bin/faketime '2000-01-01 00:00:00' ${genTargets} --worst --private-key="$_arg_testdir"/gen_private.json "$_arg_testdir"
|
||||
|
||||
# shellcheck disable=SC2145
|
||||
${withTools.withPg} -f "$_arg_testdir"/fixtures.sql \
|
||||
|
||||
Reference in New Issue
Block a user