Skip to content
This repository has been archived by the owner on May 12, 2020. It is now read-only.

Running postgres-embedded in gitlab ci. #130

Open
jCalamari opened this issue Apr 18, 2018 · 3 comments
Open

Running postgres-embedded in gitlab ci. #130

jCalamari opened this issue Apr 18, 2018 · 3 comments

Comments

@jCalamari
Copy link

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
Copy link
Member

smecsia commented Apr 18, 2018

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
Copy link

osigida commented Apr 25, 2018

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
Copy link

osigida commented Apr 26, 2018

to workaround the issue I had to

  • create a new user in the build container
  • expose it via USER command in the docker file
  • update the CI pipeline to use that user for the run

and then it was able to start postgres

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants