PostGISHStoreOnlineTest fails when database user not superuser

Description

Database extension creation should be external to GeoTools fixture setup.

Environment

None

Activity

Show:
Ben Caradoc-Davies
November 18, 2017, 2:31 AM

Fixture setup already has a guard, so will auto-upgrade database if superuser:
run("CREATE EXTENSION IF NOT EXISTS HSTORE;")
https://github.com/geotools/geotools/blob/master/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostGISHStoreTestSetup.java#L35

Fixture configurations for non-superuser database users can be fixed by the one-time procedure of connecting to the database as a superuser and running "create extension hstore;"

Andrea Aime
November 18, 2017, 10:34 AM

Ben, I don't fully understand your last statement.... if an error happens during the one time setup, doesn't it disable all tests?

Ben Caradoc-Davies
November 18, 2017, 11:37 AM

my fixture has skip.on.failure=false set so I see a hard failure rather than a silent failure (which in my view is better).

For the record, the full list of extension creation commands for my test database is now:

(Needed because I test with a non-super-user.)

Andrea Aime
November 18, 2017, 11:59 AM

I still don't understand this sentence:

> Fixture configurations for non-superuser database users can be fixed by the one-time procedure of connecting to the database as a superuser and running "create extension hstore;"

Ben Caradoc-Davies
November 18, 2017, 8:51 PM
Edited

a non-superuser database user will not have database permissions to run "create extension hstore;". A test fixture with skip.on.failure=false and a non-superuser database user and no hstore extension will cause PostGISHStoreOnlineTest to fail because PSQLException will be thrown when the test setup tries to run "CREATE EXTENSION IF NOT EXISTS HSTORE;".

The fix is to manually create the hstore extension. This example uses a database called test on a cluster that accepts superuser psql connections over Unix domain sockets ("peer" connections):

Once this command has completed the run line above succeeds because no attempt it made by the non-superuser to create the extension because it already exists.

Not a Bug

Assignee

Ben Caradoc-Davies

Reporter

Ben Caradoc-Davies

Triage

None

Components

Affects versions

Priority

Medium
Configure