yandex-qatools / postgresql-embedded

Embedded PostgreSQL Server
Other
494 stars 90 forks source link

Running postgres-embedded in gitlab ci. #130

Open jCalamari opened 6 years ago

jCalamari commented 6 years ago

I am having difficulties with running the embedded version of postgres from within my test suit. Here is the error I am getting:

Download Version{10.3-1}:Linux:B64 DONE
Extract /root/.embedpostgresql/postgresql-10.3-1-linux-x64-binaries.tar.gz START
/root/.embedpostgresql/postgresql-10.3-1-linux-x64-binaries.tar.gz DONE
2018-04-18 18:12:12 [pool-5-thread-3] ERROR r.y.q.e.postgresql.PostgresProcess  - Failed to read PID file (File '/builds/team-dir/project-dir/postgres/postmaster.pid' does not exist)

This is how I instantiate the database:

  private lazy val postgres = new EmbeddedPostgres(Version.V10_3, System.getenv("POSTGRES_TEST_DIR"))

And the environment variable in the gitlab ci config file is set to:

variables:
  POSTGRES_TEST_DIR: "postgres"

Does anyone have experience with running postgres in gitlab container and would like to shed some light on the issue?

Many thanks!

smecsia commented 6 years ago

It looks like the container is using root user, which is a known limitation of Postgres server (please refer the respective section of a readme file for more info). If you can start your process under unprivileged user, you should be fine.

osigida commented 6 years ago

same issue here, does not run inside a docker container (tested alpine and debian) failed with:

[main] WARN ru.yandex.qatools.embed.postgresql.PostgresProcess - Possibly failed to run initdb:
initdb: cannot be run as root
Please log in (using, e.g., "su") as the (unprivileged) user that will own the server process.

[main] ERROR ru.yandex.qatools.embed.postgresql.PostgresProcess - Failed to read PID file (File '/tmp/postgresql-embed-5bc587a2-1a99-4269-bad7-da8cc1c73cc5/db-content-67cb119f-81d4-472e-b517-2d9d7c6a8902/postmaster.pid' does not exist)

Postgres have been started as a part of unit tests on a CI server Any ideas how to work around the issue?

osigida commented 6 years ago

to workaround the issue I had to

and then it was able to start postgres