Closed xenoterracide closed 3 years ago
I'm sorry, @xenoterracide, I don't understand what you're asking for. pg_prove
is not a service…
I'm running pg_prove like this in CI, I forget how I'm running it locally
docker run -v $PWD/migrations/pgtap/test/script:/t -e "PGPASSWORD=$PGPASSWORD" \
--network=host xenoterracide/pg_prove:latest \
pg_prove --host localhost --dbname production --username postgres --ext .sql --recurse --color /t
but I just wanted to be able to write pg_prove service=localhost --ext .sql --recurse --color ...
which uses ~/.pg_service.conf
and ~/.pgpass.conf
https://www.postgresql.org/docs/9.0/libpq-pgservice.html
To have psql
read those files on your host, you need to mount your home directory into the home directory inside the container. Here's a simple shell script that should get you on the road to what you want. I haven't tested it, but it follows the example from docker-sqitch.sh
:
#!/usr/bin/env bash
docker run -it --rm --network host \
--mount "type=bind,src=$(pwd),dst=/repo" \
--mount "type=bind,src=$HOME,dst=/root" \
--entrypoint '' \
xenoterracide/pg_prove:latest \
/bin/sh -c "cd /repo && pg_prove $@"
Save that as docker_pg_prove
or something, then you can run
docker_pg_prove --host localhost --dbname production --username postgres --ext .sql --recurse --color migrations/pgtap/test/script
pg_service.conf doesn't work for pg_prove installed outside of the container either, with pg_service.conf you shouldn't need to pass host/dbname/username/postgres it should just be the service alias.
It should if you have it in your home directory and mount it to the home directory inside the container, assuming the privileges work out to be correct for the client to use.
this doesn't work, but you can see the psql connection work
> psql service=briggo-local # services -> feature/RS2-1221-version $ RC=1
psql (12.4, server 11.9)
Type "help" for help.
briggo_production=# \q
> pg_prove service=briggo-local --ext .sql --recurse migrations/pgtap/test/script/ # services -> feature/RS2-1221-version $
Cannot detect source of 'service=briggo-local'! at /usr/local/Cellar/perl/5.32.0/lib/perl5/5.32.0/TAP/Parser/IteratorFactory.pm line 256.
TAP::Parser::IteratorFactory::detect_source(TAP::Parser::IteratorFactory=HASH(0x7ffa4b443530), TAP::Parser::Source=HASH(0x7ffa4b393928)) called at /usr/local/Cellar/perl/5.32.0/lib/perl5/5.32.0/TAP/Parser/IteratorFactory.pm line 211
TAP::Parser::IteratorFactory::make_iterator(TAP::Parser::IteratorFactory=HASH(0x7ffa4b443530), TAP::Parser::Source=HASH(0x7ffa4b393928)) called at /usr/local/Cellar/perl/5.32.0/lib/perl5/5.32.0/TAP/Parser.pm line 472
TAP::Parser::_initialize(TAP::Parser=HASH(0x7ffa4b3936e8), HASH(0x7ffa4b285310)) called at /usr/local/Cellar/perl/5.32.0/lib/perl5/5.32.0/TAP/Object.pm line 55
TAP::Object::new("TAP::Parser", HASH(0x7ffa4b285310)) called at /usr/local/Cellar/perl/5.32.0/lib/perl5/5.32.0/TAP/Object.pm line 130
TAP::Object::_construct(TAP::Harness=HASH(0x7ffa4b20a520), "TAP::Parser", HASH(0x7ffa4b285310)) called at /usr/local/Cellar/perl/5.32.0/lib/perl5/5.32.0/TAP/Harness.pm line 852
TAP::Harness::make_parser(TAP::Harness=HASH(0x7ffa4b20a520), TAP::Parser::Scheduler::Job=HASH(0x7ffa4b3938b0)) called at /usr/local/Cellar/perl/5.32.0/lib/perl5/5.32.0/TAP/Harness.pm line 651
TAP::Harness::_aggregate_single(TAP::Harness=HASH(0x7ffa4b20a520), TAP::Parser::Aggregator=HASH(0x7ffa4b2024f0), TAP::Parser::Scheduler=HASH(0x7ffa4b393838)) called at /usr/local/Cellar/perl/5.32.0/lib/perl5/5.32.0/TAP/Harness.pm line 743
TAP::Harness::aggregate_tests(TAP::Harness=HASH(0x7ffa4b20a520), TAP::Parser::Aggregator=HASH(0x7ffa4b2024f0), "service=briggo-local", "migrations/pgtap/test/script/location/v_active_device.sql", "migrations/pgtap/test/script/order/v_available_pickup_method.sql", "migrations/pgtap/test/script/order/v_order.sql") called at /usr/local/Cellar/perl/5.32.0/lib/perl5/5.32.0/TAP/Harness.pm line 558
TAP::Harness::__ANON__() called at /usr/local/Cellar/perl/5.32.0/lib/perl5/5.32.0/TAP/Harness.pm line 571
TAP::Harness::runtests(TAP::Harness=HASH(0x7ffa4b20a520), "service=briggo-local", "migrations/pgtap/test/script/location/v_active_device.sql", "migrations/pgtap/test/script/order/v_available_pickup_method.sql", "migrations/pgtap/test/script/order/v_order.sql") called at /usr/local/Cellar/perl/5.32.0/lib/perl5/5.32.0/App/Prove.pm line 548
App::Prove::_runtests(App::Prove::pgTAP=HASH(0x7ffa4a01d630), HASH(0x7ffa4a0c39d8), "service=briggo-local", "migrations/pgtap/test/script/location/v_active_device.sql", "migrations/pgtap/test/script/order/v_available_pickup_method.sql", "migrations/pgtap/test/script/order/v_order.sql") called at /usr/local/Cellar/perl/5.32.0/lib/perl5/5.32.0/App/Prove.pm line 506
App::Prove::run(App::Prove::pgTAP=HASH(0x7ffa4a01d630)) called at /Users/calebcushing/perl5/bin/pg_prove line 13
> # services -> feature/RS2-1221-version $ RC=2
this ticket is to make the latter work.
Oh, try
pg_prove -d service=briggo-local
that works... for some reason... it doesn't really make sense from pg_prove --help
and I didn't find it in any other documentation either
wtf... it worked the other day...
> pg_prove -d service=briggo-local --ext .sql --recurse test
test/location/v_active_device.sql ......... psql: error: could not connect to server: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
> psql service=briggo-local
psql (12.4, server 11.9)
Type "help" for help.
briggo_production=#
very strange...
is it possible use services now? if so is it possible to add a little bit of documentation? if not could it happen? tried
pg_prove service=name
that exploded wonderfly (no you should try it, massive stacktrace)