Message ID | 20180806065639.23094-2-daniel@linux.ibm.com |
---|---|
State | Accepted |
Headers | show |
Series | [v2,1/3] travis: test against postgresql 10 and 11 | expand |
Daniel Black <daniel@linux.ibm.com> writes: > An empty environment variable resulted in localhost, meaning > posgresql connecting to domain sockets wasn't available. It took me a long time to understand how this works (e.g. that PGPORT is still required to be set for psql to find the correct domain socket.) But I think I'm now a bit clearer. > Signed-off-by: Daniel Black <daniel@linux.ibm.com> > --- > .travis.yml | 3 +++ > patchwork/settings/dev.py | 1 + > 2 files changed, 4 insertions(+) > > diff --git a/.travis.yml b/.travis.yml > index 58e0b08..0c6e79d 100644 > --- a/.travis.yml > +++ b/.travis.yml > @@ -22,6 +22,7 @@ env: > - PW_TEST_DB_TYPE=mysql PW_TEST_DB_USER=root > global: > - PW_TEST_DB_PASS="" > + - PW_TEST_DB_HOST="localhost" I tried setting this to "" globally and it seemed to work; is there any reason to treat postgres 10 and 11 specially? More fundamentally, is there any reason we particuarly want to do things this way on Travis? Regards, Daniel
On Fri, 10 Aug 2018 01:08:48 +1000 Daniel Axtens <dja@axtens.net> wrote: > Daniel Black <daniel@linux.ibm.com> writes: > > > An empty environment variable resulted in localhost, meaning > > posgresql connecting to domain sockets wasn't available. > > It took me a long time to understand how this works (e.g. that PGPORT > is still required to be set for psql to find the correct domain > socket.) But I think I'm now a bit clearer. > > > Signed-off-by: Daniel Black <daniel@linux.ibm.com> > > --- > > .travis.yml | 3 +++ > > patchwork/settings/dev.py | 1 + > > 2 files changed, 4 insertions(+) > > > > diff --git a/.travis.yml b/.travis.yml > > index 58e0b08..0c6e79d 100644 > > --- a/.travis.yml > > +++ b/.travis.yml > > @@ -22,6 +22,7 @@ env: > > - PW_TEST_DB_TYPE=mysql PW_TEST_DB_USER=root > > global: > > - PW_TEST_DB_PASS="" > > + - PW_TEST_DB_HOST="localhost" > > I tried setting this > to "" globally and it seemed to work; is there > any reason to treat postgres 10 and 11 specially? I was preserving PW_TEST_DB_HOST=localhost so the previous 9.6 test was run the same way as it did previously. > More fundamentally, is there any reason we particuarly want to do > things this way on Travis? No idea which "things" you're exactly referring to. > > Regards, > Daniel >
Daniel Black <daniel@linux.ibm.com> writes: > On Fri, 10 Aug 2018 01:08:48 +1000 > Daniel Axtens <dja@axtens.net> wrote: > >> Daniel Black <daniel@linux.ibm.com> writes: >> >> > An empty environment variable resulted in localhost, meaning >> > posgresql connecting to domain sockets wasn't available. >> >> It took me a long time to understand how this works (e.g. that PGPORT >> is still required to be set for psql to find the correct domain >> socket.) But I think I'm now a bit clearer. >> >> > Signed-off-by: Daniel Black <daniel@linux.ibm.com> >> > --- >> > .travis.yml | 3 +++ >> > patchwork/settings/dev.py | 1 + >> > 2 files changed, 4 insertions(+) >> > >> > diff --git a/.travis.yml b/.travis.yml >> > index 58e0b08..0c6e79d 100644 >> > --- a/.travis.yml >> > +++ b/.travis.yml >> > @@ -22,6 +22,7 @@ env: >> > - PW_TEST_DB_TYPE=mysql PW_TEST_DB_USER=root >> > global: >> > - PW_TEST_DB_PASS="" >> > + - PW_TEST_DB_HOST="localhost" >> >> I tried setting this >> to "" globally and it seemed to work; is there >> any reason to treat postgres 10 and 11 specially? > > I was preserving PW_TEST_DB_HOST=localhost so the previous 9.6 test was > run the same way as it did previously. > >> More fundamentally, is there any reason we particuarly want to do >> things this way on Travis? > > No idea which "things" you're exactly referring to. Sorry, I wasn't clear. Why should we test with local domain sockets rather than with localhost? Regards, Daniel > >> >> Regards, >> Daniel >>
> >> > diff --git a/.travis.yml b/.travis.yml > >> > index 58e0b08..0c6e79d 100644 > >> > --- a/.travis.yml > >> > +++ b/.travis.yml > >> > @@ -22,6 +22,7 @@ env: > >> > - PW_TEST_DB_TYPE=mysql PW_TEST_DB_USER=root > >> > global: > >> > - PW_TEST_DB_PASS="" > >> > + - PW_TEST_DB_HOST="localhost" > >> > >> I tried setting this > >> to "" globally and it seemed to work; is there > >> any reason to treat postgres 10 and 11 specially? > > > > I was preserving PW_TEST_DB_HOST=localhost so the previous 9.6 test > > was run the same way as it did previously. > > > >> More fundamentally, is there any reason we particuarly want to do > >> things this way on Travis? > > > > No idea which "things" you're exactly referring to. > > Sorry, I wasn't clear. > > Why should we test with local domain sockets rather than with > localhost? You should test both connection types are possible in patchwork. Obviously the end result is the same however.
>> Why should we test with local domain sockets rather than with >> localhost? > > You should test both connection types are possible in patchwork. > Obviously the end result is the same however. OK, I understand now, thank you for your patience! I think this probably falls into the category of testing Django rather than testing Patchwork: db connection handling is something we directly inherit from Django and don't mess with. However, it seems that postgres by default will only accept passwordless auth over a unix socket. This has been tweaked on the versions supplied in the Travis image, allowing passwordless connections over the network as well, but because Postgres 10/11 aren't part of the image, this tweaking isn't done for them - [1]. This causes failures such as [2]. So what I have done is squashed this patch into patch 1 and applied the combined patch and patch 3. You can see it in action at https://travis-ci.org/getpatchwork/patchwork/builds/418771098 Welcome to the Patchwork Contributors Club, and thank you :) Regards, Daniel [1] https://github.com/travis-ci/travis-ci/issues/9624 [2] https://travis-ci.org/daxtens/patchwork/jobs/418742513#L603
diff --git a/.travis.yml b/.travis.yml index 58e0b08..0c6e79d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,6 +22,7 @@ env: - PW_TEST_DB_TYPE=mysql PW_TEST_DB_USER=root global: - PW_TEST_DB_PASS="" + - PW_TEST_DB_HOST="localhost" matrix: include: @@ -33,6 +34,7 @@ matrix: - postgresql-client-10 env: - PGPORT=5433 + - PW_TEST_DB_HOST="" - PW_TEST_DB_PORT=5433 - PW_TEST_DB_TYPE=postgres - PW_TEST_DB_USER=travis @@ -43,6 +45,7 @@ matrix: - sudo -u postgres psql -c "grant ALL on DATABASE postgres to travis WITH GRANT OPTION;" - env: - PGPORT=5433 + - PW_TEST_DB_HOST="" - PW_TEST_DB_PORT=5433 - PW_TEST_DB_TYPE=postgres - PW_TEST_DB_USER=travis diff --git a/patchwork/settings/dev.py b/patchwork/settings/dev.py index 7bdfdff..0f79b61 100644 --- a/patchwork/settings/dev.py +++ b/patchwork/settings/dev.py @@ -41,6 +41,7 @@ DATABASES = { if os.getenv('PW_TEST_DB_TYPE', None) == 'postgres': DATABASES['default']['ENGINE'] = 'django.db.backends.postgresql_psycopg2' + DATABASES['default']['HOST'] = os.getenv('PW_TEST_DB_HOST', '') EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
An empty environment variable resulted in localhost, meaning posgresql connecting to domain sockets wasn't available. Signed-off-by: Daniel Black <daniel@linux.ibm.com> --- .travis.yml | 3 +++ patchwork/settings/dev.py | 1 + 2 files changed, 4 insertions(+)