pgrx
pgrx copied to clipboard
Is it possible to avoid `initdb` when running cargo pgrx test?
Hi,
we are using pgrx v0.11.2, and for some reason we need to run test with root account with will cause the initdb error.
So is it possible to avoid initdb when running cargo pgrx test?
Please see the --runas and --pgdata flags introduced in 0.11.4
@workingjubilee tried 0.11.4, got the error:
sudo: unable to execute /root/.pgrx/16.2/pgrx-install/bin/initdb: Permission denied
hmm.
@theory What was the pattern we landed on to make things work here?
Oh, just deleting the directory every time? That's a bit silly, but works, I suppose. https://github.com/pgcentralfoundation/pgrx/issues/1671
I got this error the first time I run the test....
the command: cargo pgrx test pg16 --runas $username --pgdata=/tmp/pgrxtest
Those options require v0.11.4.
Hmm.
one more thing, the first time I tried 0.11.4 I used a random user like this:
cargo pgrx test pg16 --runas testuser --pgdata=/tmp/pgrxtest.
And the error is
failed to create the PGDATA directory at `/tmp/pgrxtest/16`:
sudo: unknown user testuser
sudo: error initializing audit plugin sudoers_audit
This looks different from what theory reported...
interesting.
hmm. can I recommend you try using root as the --runas?
The user has to exist; usually it's postgres, such as on a Linux system when you're running as root. If you're not running as root you shouldn't need these options at all. Passing --runas root is unlikely to work because, even if you can sudo to become root, Postgres will refuse to run as root.
yeah theory is right... I ran all tests with as root...
oh right.