bucardo / dbdpg

Perl Postgres driver DBD::Pg aka dbdpg
48 stars 36 forks source link

Tests fail when run in a directory with a long name #78

Closed dakkar closed 2 years ago

dakkar commented 3 years ago

On many unix-like system, the length of a unix socket pathname is limited to about 100 bytes (see for example https://unix.stackexchange.com/questions/367008/why-is-socket-path-length-limited-to-a-hundred-chars )

If DBD::Pg is installed from a directory that already has a long name, the socket name will be too long and make the tests fail. This is more likely to happen in CI systems (e.g. in our Jenkins, running cpanm inside the workspace, the socket path ends up being something like /home/jenkins/workspace/$JOBNAME/.cpanm/work/$TIMESTAMP/DBD-Pg-$VERSION/dbdpg_test_database/data/socket/.s.PGSQL.$$)

I understand why the tempdir is kept inside the build directory: so it will persist across the various tests, and get cleaned up by whatever is doing the build / install.

Would it be possible to have it (optionally via an env variable?) created somewhere else, like under /tmp/?

Thanks in advance.

ilmari commented 3 years ago

I suggest that dbdpg_test_setup.pl's get_test_settings() could do $testdir = File::Temp::tempdir(DIR => $ENV{DBDPG_TESTDIR}) if that environment variable is set.

turnstep commented 3 years ago

Good idea @ilmari I tweaked a little to make it DBDPG_TEMPDIR so the caller can just set /tmp and not worry about XXXX placeholders. See 0fab27eced25067727c3b686a030913e393ac0a2

jplindstrom commented 2 years ago

Will this be in the next release?

dpryan79 commented 2 years ago

Any chance of getting a release pushed out with this in it soon?

esabol commented 2 years ago

Is this issue resolved in the 3.15.1 release? If so, please close.

dakkar commented 2 years ago

from the diff https://metacpan.org/release/TURNSTEP/DBD-Pg-3.15.1/diff/TURNSTEP%2FDBD-Pg-3.15.0#t/dbdpg_test_setup.pl it looks fixed enough

turnstep commented 2 years ago

Thanks, will close this now. Please feel free to re-open if needed.

erezschatz commented 1 year ago

I just experienced the same issue:


Manifying 2 pod documents
"/usr/local/Cellar/perl/5.38.0/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- Pg.bs blib/arch/auto/DBD/Pg/Pg.bs 644
PGINITDB="/usr/local/Cellar/postgresql@14/14.9/bin/initdb" PERL_DL_NONLAZY=1 "/usr/local/Cellar/perl/5.38.0/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/00_signature.t ....... skipped: Set the environment variable TEST_SIGNATURE to enable this test
t/00basic.t ............ ok
Please wait, creating new database (version 14.9) for testing
pg_ctl: could not start server
Examine the log output.
# 
# DBI                         Version 1.643
# DBD::Pg                     Version 3.17.0
# Perl                        Version 5.38.0
# OS                          darwin
# PostgreSQL (compiled)       ?
# PostgreSQL (target)         ?
# PostgreSQL (reported)       ?
# Default port                ?
# DBI_DSN                     ?
# DBI_USER                    <not set>
# Test schema                 dbd_pg_testschema
# LANG                        C
# Adjusted:                   initdb
# Error was: Unix-domain socket path "/Users/erezschatz/.cpanm/work/1696228600.62264/DBD-Pg-3.17.0/dbdpg_test_database/data/socket/.s.PGSQL.5440" is too long (maximum 103 bytes) at t/dbdpg_test_setup.pl line 608.
Bailout called.  Further testing stopped:  Cannot continue: connection failed
t/01connect.t .......... skipped: Connection to database failed, cannot continue testing
FAILED--Further testing stopped: Cannot continue: connection failed
make: *** [test_dynamic] Error 255
-> FAIL Installing DBD::Pg failed. See /Users/erezschatz/.cpanm/work/1696228600.62264/build.log for details. Retry with --force to force install it.```
esabol commented 1 year ago

@erezschatz wrote:

I just experienced the same issue:

It doesn't look like you set the DBDPG_TEMPDIR environment variable?

erezschatz commented 1 year ago

Right you are, I'll update my installation scripts :)