Skip to content

Conversation

develop7
Copy link
Collaborator

@develop7 develop7 commented Jul 22, 2025

Enables overriding postgrest executable with PGRST_CMD environment variable in postgrest-loadtest script. This enables, for example, running loadtest against profiled executable with simple PGRST_CMD=postgrest-profiled-run postgrest-loadtest, which wasn't possible before, because PGRST_CMD was defined internally.

@develop7 develop7 requested a review from wolfgangwalther July 22, 2025 17:47
@develop7 develop7 marked this pull request as ready for review July 22, 2025 17:48
@steve-chavez
Copy link
Member

PGRST_CMD=postgrest-profiled-run postgrest-loadtest

The above is real nice, we can use it to improve perf.

Looking at this #4220 (comment), is this PR dependent on #4220? Or how do you confirm this PR is working as expected?

@develop7
Copy link
Collaborator Author

Looking at this #4220 (comment), is this PR dependent on #4220? Or how do you confirm this PR is working as expected?

It doesn't depend on #4220, I've merely used PGRST_CMD=postgrest-profiled-run postgrest-loadtest to verify it works. One could use /usr/bin/true just as well.

echo -n "Building postgrest (cabal)... "
postgrest-build
PGRST_CMD=postgrest-run
if [ -z "''${PGRST_CMD:-}" ]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about using argbash ARG_USE_ENV instead?

There's an example on

"ARG_USE_ENV([PGUSER], [postgrest_test_authenticator], [Authenticator PG role])"
"ARG_USE_ENV([PGDATABASE], [postgres], [PG database name])"
"ARG_USE_ENV([PGRST_DB_SCHEMAS], [test], [Schema to expose])"
"ARG_USE_ENV([PGTZ], [utc], [Timezone to use])"
"ARG_USE_ENV([PGOPTIONS], [-c search_path=public,test], [PG options to use])"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This way we also document the command has the PGRST_CMD option when doing --help

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And have it documented too! Thanks for the suggestion, will do!

@develop7 develop7 force-pushed the add-loadtest_override_cmd branch from 2959cb6 to aba9623 Compare August 1, 2025 14:40
@@ -339,6 +339,7 @@ let
"ARG_POSITIONAL_SINGLE([command], [Command to run])"
"ARG_LEFTOVERS([command arguments])"
"ARG_OPTIONAL_SINGLE([monitor], [m], [Enable CPU and memory monitoring of the PostgREST process and output to the designated file as markdown])"
"ARG_USE_ENV([PGRST_CMD], [postgrest-run], [PostgREST executable to run])"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the default of postgrest-run, this will change the logic heavily now. We will now have to explicitly set this to the empty string to get the default behavior from before.

Also, we can't make use of PGRST_BUILD_CABAL anymore.

I think we should not control this via env variable at all, but instead add a --profiled flag to postgrest-loadtest and then use the profiled package in both variants if this is set.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PGRST_CMD env argument doesn't have a default value anymore and should be good to go now

re: separate flag> I agree this is a cleaner behavior, but it'd require to propagate the desired executable name (path) from pgrst-loadtest to postgrest-with-pgrst script, which I'm yet to wrap my head around of.

@develop7 develop7 force-pushed the add-loadtest_override_cmd branch from aba9623 to 03ebc68 Compare August 7, 2025 10:41
Enables `PGRST_CMD=postgrest-profiled-run postgrest-loadtest` running
loadtest against profiled executable, which wasn't available before
@develop7 develop7 force-pushed the add-loadtest_override_cmd branch from 03ebc68 to 0d77a4d Compare August 7, 2025 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants