Skip to content

Commit

Permalink
Merge pull request #386 from gsmet/no-docker-take-2
Browse files Browse the repository at this point in the history
Remove the need for Docker for a default run [take 2]
  • Loading branch information
stuartwdouglas authored Dec 31, 2018
2 parents 21f3f4e + e45d6a2 commit 3d35d97
Show file tree
Hide file tree
Showing 32 changed files with 877 additions and 473 deletions.
5 changes: 4 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ If you have not done so on this machine, you need to:
* macOS
* `xcode-select --install`
* Set `GRAALVM_HOME` to your GraalVM Home directory e.g. `/opt/graalvm` on Linux or `$location/JDK/GraalVM/Contents/Home` on macOS
* To build Shamrock, you also need Docker running. Check [the installation guide](https://docs.docker.com/install/), and [the MacOS installation guide](https://docs.docker.com/docker-for-mac/install/)

Docker is not strictly necessary: it is used to run the MariaDB and PostgreSQL tests which are not enabled by default. However it is a recommended install if you plan to work on Shamrock JPA support:

* Check [the installation guide](https://docs.docker.com/install/), and [the MacOS installation guide](https://docs.docker.com/docker-for-mac/install/)
* If you just install docker, be sure that your current user can run a container (no root required).
On Linux, check [the post-installation guide](https://docs.docker.com/install/linux/linux-postinstall/)

Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
displayName: 'Maven Build'
inputs:
goals: 'install'
options: '--settings azure-mvn-settings.xml -Dnative-image.docker-build -Dno-postgres -Dnative-image.xmx=4g -Dnative'
options: '--settings azure-mvn-settings.xml -Dnative-image.docker-build -Dtest-postgresql -Dnative-image.xmx=4g -Dnative'

- script: |
docker build -f docker/strict-example/Dockerfile -t jtgdocker1/shamrock-strict-example examples/strict/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

import static org.junit.Assert.assertEquals;

import org.jboss.shamrock.example.testutils.H2DatabaseLifecycleManager;
import org.jboss.shamrock.test.ShamrockTest;
import org.jboss.shamrock.test.URLTester;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.runner.RunWith;

Expand All @@ -17,9 +15,6 @@
@RunWith(ShamrockTest.class)
public class JPAFunctionalityTest {

@ClassRule
public static final H2DatabaseLifecycleManager h2 = new H2DatabaseLifecycleManager();

@Test
public void testJPAFunctionalityFromServlet() throws Exception {
assertEquals("OK", URLTester.relative("jpa-h2/testfunctionality").invokeURL().asString());
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.jboss.shamrock.example.testutils;

import java.sql.SQLException;

import org.h2.tools.Server;
import org.jboss.shamrock.test.ShamrockTestResource;
import org.jboss.shamrock.test.ShamrockTestResourceLifecycleManager;

@ShamrockTestResource(H2DatabaseTestResourceLifecycleManager.class)
public class H2DatabaseTestResourceLifecycleManager implements ShamrockTestResourceLifecycleManager {

private Server tcpServer;

@Override
public synchronized void start() {
try {
tcpServer = Server.createTcpServer();
tcpServer.start();
System.out.println("[INFO] H2 database started in TCP server mode");
} catch (SQLException e) {
throw new RuntimeException(e);
}
}

@Override
public synchronized void stop() {
if (tcpServer != null) {
tcpServer.stop();
System.out.println("[INFO] H2 database was shut down");
tcpServer = null;
}
}
}
27 changes: 27 additions & 0 deletions examples/jpa-mariadb/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# JPA example with MariaDB

## Running the tests

By default, the tests of this module are disabled.

To run the tests in a standard JVM with MariaDB started as a Docker container, you can run the following command:

```
mvn clean install -Dtest-mariadb -Ddocker
```

Additionaly, you can generate a native image and run the tests for this native image by adding `-Dnative`:

```
mvn clean install -Dtest-mariadb -Ddocker -Dnative
```

If you don't want to run MariaDB as a Docker container, you can start your own MariaDB server. It needs to listen on the default port and have a database called `hibernate_orm_test` accessible to the user `hibernate_orm_test` with the password `hibernate_orm_test`.

You can then run the tests as follows (either with `-Dnative` or not):

```
mvn clean install -Dtest-mariadb
```

If you have specific requirements, you can define a specific connection URL with `-Dmariadb.url=jdbc:mariadb://...`.
41 changes: 39 additions & 2 deletions examples/jpa-mariadb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>${project.groupId}</groupId>
<artifactId>shamrock-maven-plugin</artifactId>
Expand All @@ -83,6 +95,31 @@
</build>

<profiles>
<profile>
<id>test-mariadb</id>
<activation>
<property>
<name>test-mariadb</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
</plugins>
</build>
</profile>

<profile>
<id>native-image</id>
<activation>
Expand Down Expand Up @@ -141,10 +178,10 @@
</profile>

<profile>
<id>mariadb</id>
<id>docker-mariadb</id>
<activation>
<property>
<name>!no-mariadb</name>
<name>docker</name>
</property>
</activation>
<properties>
Expand Down
27 changes: 27 additions & 0 deletions examples/jpa-postgresql/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# JPA example with PostgreSQL

## Running the tests

By default, the tests of this module are disabled.

To run the tests in a standard JVM with PostgreSQL started as a Docker container, you can run the following command:

```
mvn clean install -Dtest-postgresql -Ddocker
```

Additionaly, you can generate a native image and run the tests for this native image by adding `-Dnative`:

```
mvn clean install -Dtest-postgresql -Ddocker -Dnative
```

If you don't want to run PostgreSQL as a Docker container, you can start your own PostgreSQL server. It needs to listen on the default port and have a database called `hibernate_orm_test` accessible to the user `hibernate_orm_test` with the password `hibernate_orm_test`.

You can then run the tests as follows (either with `-Dnative` or not):

```
mvn clean install -Dtest-postgresql
```

If you have specific requirements, you can define a specific connection URL with `-Dpostgres.url=jdbc:postgresql://...`.
41 changes: 39 additions & 2 deletions examples/jpa-postgresql/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>${project.groupId}</groupId>
<artifactId>shamrock-maven-plugin</artifactId>
Expand All @@ -83,6 +95,31 @@
</build>

<profiles>
<profile>
<id>test-postgresql</id>
<activation>
<property>
<name>test-postgresql</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
</plugins>
</build>
</profile>

<profile>
<id>native-image</id>
<activation>
Expand Down Expand Up @@ -140,10 +177,10 @@
</profile>

<profile>
<id>postgres</id>
<id>docker-postgresql</id>
<activation>
<property>
<name>!no-postgres</name>
<name>docker</name>
</property>
</activation>
<properties>
Expand Down
15 changes: 1 addition & 14 deletions examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,7 @@
<module>common-jpa-entities</module>
<module>strict</module>
<module>jpa-postgresql</module>
<module>jpa-mariadb</module>
<module>jpa-h2</module>
</modules>

<profiles>
<profile>
<activation>
<os>
<family>!mac</family>
</os>
</activation>
<modules>
<!-- waiting on the availability of the port does not work on macOS so disabling the module -->
<module>jpa-mariadb</module>
</modules>
</profile>
</profiles>
</project>
Loading

0 comments on commit 3d35d97

Please sign in to comment.