Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the need for Docker for a default run [take 2] #386

Merged
merged 10 commits into from
Dec 31, 2018
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/)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Build section could mention some details from description of this PR:

MariaDB and PostgreSQL examples are built by default but not tested. You need to use -Dtest-postgresql
and -Dtest-mariadb to enable testing (+ -Ddocker if you want to rely on the Docker containers).

The strict example is executed with H2 by default but can be executed with PostgreSQL using -Dtest-postgresql.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I wasn't sure we should enter into this level of details here. @cescoffier WDYT?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if these instructions should not be added to the README of these modules. If we add all the details for all modules, it would quickly become out of track.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a README.md in each example explaining how to run the tests.


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");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be System.out.println suppressed in this class ? Line 19 + 29

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, in the end, the idea would be to have the possibility to inject a logger here, e.g. when you are in a Maven build, you could get the Maven logger and log the info properly.

For now, we don't have anything better than this.

} 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;
}
}
}
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
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