slavaz / embedded-postgresql-maven-plugin

Embedded PostgreSQL Maven Plugin
13 stars 11 forks source link

Database does not bind to pgServerPort on Windows #11

Open Tibor17 opened 6 years ago

Tibor17 commented 6 years ago

We started the plugin, see POM, via mvn verify. We also added a proxy to settings.xml. We are not able to connect to the port 5432 via telnet localhost 5432 on Windows. On Linux Ubuntu 16 we are able to connect via telnet and PgAdmin too. We think that the command line is not constructed so well on Windows.

After we found the ZIP in user home, we extracted and started the database on command line with our commands, the database was bound to the port 5432 and telnet connected to it on Windows. We used these native commands:

set PGDATA=e:\tmp\zmaz\xx\x\target\data\ pg_ctl initdb pg_ctl start -D e:\tmp\zmaz\xx\x\target\data\ -l logfile

now telnet: telnet localhost 5432

Stop the database after successful connection pg_ctl stop -D e:\tmp\zmaz\xx\x\target\data\ -l logfile

Here is our POM:

<plugin>
    <groupId>com.github.slavaz</groupId>
    <artifactId>embedded-postgresql-maven-plugin</artifactId>
    <version>1.2.2</version>
    <configuration>
        <pgServerVersion>9.6</pgServerVersion>
        <dbName>audit</dbName>
    </configuration>
    <executions>
        <execution>
            <id>start-pgsql</id>
            <phase>pre-integration-test</phase>
            <goals>
                <goal>start</goal>
            </goals>
        </execution>
        <execution>
            <id>stop-pgsql</id>
            <phase>post-integration-test</phase>
            <goals>
                <goal>stop</goal>
            </goals>
        </execution>
    </executions>
</plugin>

Here are Maven Debug logs of plugin configuration:

[DEBUG] Goal:          com.github.slavaz:embedded-postgresql-maven-plugin:1.1.0:start (start-pgsql)
[DEBUG] Style:         Regular
[DEBUG] Configuration: <?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <dbName>audit</dbName>
  <password default-value="postgres"/>
  <pgCharset>${pgCharset}</pgCharset>
  <pgDatabaseDir>${pgDatabasedir}</pgDatabaseDir>
  <pgLocale>${pgLocale}</pgLocale>
  <pgServerPort default-value="5432">${pgPort}</pgServerPort>
  <pgServerVersion default-value="latest">9.6</pgServerVersion>
  <pluginDependencies default-value="${plugin.artifacts}"/>
  <projectBuildDir default-value="${project.build.directory}"/>
  <settings default-value="${settings}"/>
  <skipGoal default-value="false"/>
  <userName default-value="postgres">${username}</userName>
</configuration>
slavaz commented 6 years ago

Did you read 'know issues' sections? https://github.com/yandex-qatools/postgresql-embedded#known-issues Is it your case?

Tibor17 commented 6 years ago

Thx @slavaz , I think it is my case. I tried to change the owner on Windows folder but no luck. I did this in plugin config: <pgDatabaseDir>${project.build.directory}/data</pgDatabaseDir> I launched this command to change owner to postgres: icacls data /grant:rw postgres:F /T and then I run the build with mvn verify Would this make sense and should this solve the issue?

slavaz commented 6 years ago

You need to create new Windows user without admin privileges and try to run 'mvn verify' under the unprivileged user.