zonkyio / embedded-database-spring-test

A library for creating isolated embedded databases for Spring-powered integration tests.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use Zonky provider with PostGIS

cfecherolle opened this issue · comments

Hi,

Some time ago, I tried using making my PostGIS tests work with Zonky provider but could not, as it seems the image used to run the tests cannot be customized.

I have this configuration:

zonky:
  test:
    database:
      postgres:
        docker:
          image: postgis/postgis:11-3.1-alpine

Which works well with provider = DOCKER but is ignored when provider = ZONKY.

I would rather use Zonky because it provides better performance and faster test runs than Docker but, it seems that it is not possible at the moment. Is there a workaround I could use to make it work with PostGIS or other custom images?

Hi @cfecherolle, thanks for the question.

The options you mentioned are backed by completely different solutions for accessing the postgres database. If you want to use docker images, you need to use the provider = DOCKER option. provider = ZONKY relies on an embedded postgres, which is configured using maven or gradle configuration (Using Zonky Provider) and the zonky.test.database.postgres.docker.image property has no effect in that case. Regarding PostGIS support, it's not officially supported at this moment and I'm not sure if it ever will be. You can find more details about it here: zonkyio/embedded-postgres#118

So basically, you have two choices. Either building embedded binaries with unofficial support of PostGIS or using the docker provider. The docker provider is maybe a little slower than the native alternatives, but provides much higher flexibility as extension support and other features.

You can also combine different providers in different tests. So you can choose the Zonky provider as the default provider for most tests and use the Docker provider with the PostGIS extension only for some small part of the specific tests. That way you can achieve good performance with enough flexibility.

I see! Thank you for this detailed explanation 👍 I will think about writing multiple specific test configurations to limit the use of Docker and use it as a provider only when PostGIS is actually necessary.