Skip to content

Commit

Permalink
Fix integration tests with Docker image for PostgreSQL 10.5
Browse files Browse the repository at this point in the history
The `postgres:10` tag is not fixed, but updated every time a new
`postgres:10.X` image is released. Thus, the integration tests run in
Drone always use the latest Docker image for PostgreSQL 10.

The parameters used for the Docker container of PostgreSQL relied on a
bug in both the Nextcloud installer and in the Docker image for
PostgreSQL; the bug in the image was fixed in "postgres:10.5", so the
tests started to fail due to not being able to install Nextcloud.

The database user created in the image did not have "create role"
privileges, so that user was the one used by the Nextcloud installer.
After the fix it does, so the Nextcloud installer creates and uses a new
user instead. However, if an existing database name is given to the
installer the installer does not grant privileges to that new user on
the existing database.

By default the container creates a new database with the same name as
the database user ("oc_autotest"), and that database was passed to the
installer. Thus, as the new user was not granted privileges on the
existing database it could not connect to it and the installation failed.

Now the container creates a dummy database with a different name to the
one passed to the installer, so now the "oc_autotest" database is
created by the installer and the new user is made owner of that new
database.

Note that this fix is backwards compatible with PostgreSQL images prior
to the fix, so no special handling is needed in `run-docker.sh` when
older images are used.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
  • Loading branch information
danxuliu committed Sep 21, 2018
1 parent b590dae commit ce32abe
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ services:
image: postgres:10
environment:
- POSTGRES_USER=oc_autotest
- POSTGRES_DB=oc_autotest_dummy
- POSTGRES_PASSWORD=
when:
matrix:
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/run-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function prepareDatabase() {

DATABASE_CONTAINER_OPTIONS="--env MYSQL_ROOT_PASSWORD=nextcloud_root --env MYSQL_USER=$DATABASE_USER --env MYSQL_PASSWORD=$DATABASE_PASSWORD --env MYSQL_DATABASE=$DATABASE_NAME"
if [ "$DATABASE" = "pgsql" ]; then
DATABASE_CONTAINER_OPTIONS=" --env POSTGRES_USER=$DATABASE_USER --env POSTGRES_PASSWORD=$DATABASE_PASSWORD"
DATABASE_CONTAINER_OPTIONS=" --env POSTGRES_USER=$DATABASE_USER --env POSTGRES_PASSWORD=$DATABASE_PASSWORD --env POSTGRES_DB=$DATABASE_NAME_dummy"
fi

echo "Starting database server"
Expand Down

0 comments on commit ce32abe

Please sign in to comment.