Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: sanity tests for primary and replica #3467

Merged
merged 1 commit into from
Apr 30, 2024

Conversation

steve-chavez
Copy link
Member

@steve-chavez steve-chavez commented Apr 30, 2024

  • new --replica option to postgrest-with-postgresql-*
    • replica process is properly logged to usual temporary log files
  • new command postgrest-test-replica
    • runs sanity tests on test_replica.py
  • add postgrest-test-replica to postgrest-check and postgrest-coverage


mkdir -p "$replica_host"

replica_dblog="$tmpdir/db_$replica_slot.log"
Copy link
Member Author

Choose a reason for hiding this comment

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

The replica logs go to a different log file.

log "Running pg_basebackup for $replica_slot"

pg_basebackup -v -h "$PGHOST" -U postgres --wal-method=stream --create-slot --slot="$replica_slot" --write-recovery-conf -D "$replica_dir" \
>> "$setuplog" 2>&1
Copy link
Member Author

Choose a reason for hiding this comment

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

The replica startup process goes to the same $setuplog as the primary. I had dedicated file previously, but seemed better to have it all on one file since $setuplog is already light on details.

if test "$_arg_replica" = "on"; then
replica_slot="replica_$RANDOM"
replica_dir="$tmpdir/$replica_slot"
replica_host="$tmpdir/socket_$replica_slot"
Copy link
Member Author

Choose a reason for hiding this comment

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

A different socket is created for the replica

Comment on lines +107 to +108
export PGREPLICAHOST="$replica_host"
export PGREPLICASLOT="$replica_slot"
Copy link
Member Author

Choose a reason for hiding this comment

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

These are exported so the python tests can use it

* new --replica option to `postgrest-with-postgresql-*`
* new command `postgrest-test-replica`
* new sanity tests on test_replica.py
* add postgrest-test-replica to postgrest-check and postgrest-coverage
@steve-chavez steve-chavez merged commit d9a51f2 into PostgREST:main Apr 30, 2024
27 checks passed
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.

None yet

1 participant