Skip to content

Commit

Permalink
Merge pull request #262 from Karm/tests
Browse files Browse the repository at this point in the history
Adds Integration Testsuite for all supported runtimes, upgrades some deps
  • Loading branch information
Karm authored Feb 6, 2020
2 parents cdabc4b + f76add6 commit 6edd815
Show file tree
Hide file tree
Showing 24 changed files with 1,978 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2.1
executors:
maven-builder:
docker:
- image: circleci/openjdk:8u171-jdk
- image: circleci/openjdk:11-jdk
docker-publisher:
environment:
IMAGE_NAME: microprofile/start.microprofile.io
Expand Down
4 changes: 2 additions & 2 deletions Container/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM centos:7
LABEL Author="Michal Karm Babacek <karm@redhat.com>"
ENV JAVA_VERSION 1.8.0
RUN yum install java-${JAVA_VERSION}-openjdk-headless -y && yum clean all && rm -rf /var/cache/yum /tmp/* && \
ENV JAVA_VERSION 11
RUN yum install java-${JAVA_VERSION}-openjdk -y && yum clean all && rm -rf /var/cache/yum /tmp/* && \
useradd -s /sbin/nologin wildfly
EXPOSE 8080/tcp
USER wildfly
Expand Down
8 changes: 4 additions & 4 deletions Container/Dockerfile.CI
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
FROM centos:7 AS build-env
LABEL Author="Michal Karm Babacek <karm@redhat.com>"
WORKDIR /opt
ENV MVN_VERSION 3.3.9
ENV JAVA_VERSION 1.8.0
ENV MVN_VERSION 3.6.0
ENV JAVA_VERSION 11
ENV M2_HOME /opt/apache-maven-${MVN_VERSION}
ENV JAVA_HOME /usr/lib/jvm/jre-${JAVA_VERSION}-openjdk
RUN yum install java-${JAVA_VERSION}-openjdk-devel unzip -y
Expand All @@ -24,8 +24,8 @@ RUN ./apache-maven-${MVN_VERSION}/bin/mvn package -Pthorntail && \
#############
FROM centos:7
LABEL Author="Michal Karm Babacek <karm@redhat.com>"
ENV JAVA_VERSION 1.8.0
RUN yum install java-${JAVA_VERSION}-openjdk-headless -y && yum clean all && \
ENV JAVA_VERSION 11
RUN yum install java-${JAVA_VERSION}-openjdk -y && yum clean all && \
rm -rf /var/cache/yum /tmp/* && useradd -s /sbin/nologin wildfly
EXPOSE 8080/tcp
USER wildfly
Expand Down
91 changes: 85 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
<inceptionYear>2017</inceptionYear>

<properties>
<version.thorntail>2.2.1.Final</version.thorntail>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<version.thorntail>2.6.0.Final</version.thorntail>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.exec.plugin.version>1.6.0</maven.exec.plugin.version>

<failOnMissingWebXml>false</failOnMissingWebXml>
Expand All @@ -51,6 +51,7 @@
<primefaces.version>7.0</primefaces.version>
<thymeleaf.version>3.0.10.RELEASE</thymeleaf.version>
<junit.version>4.12</junit.version>
<resteasy.version>4.3.0.Final</resteasy.version>

<checkstyle.version>2.17</checkstyle.version>
<checkstyle.methodNameFormat>^_?[a-z][a-zA-Z0-9]*$</checkstyle.methodNameFormat>
Expand Down Expand Up @@ -101,6 +102,7 @@
<version>${junit.version}</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
Expand Down Expand Up @@ -221,16 +223,73 @@
</execution>
</executions>
<configuration>
<executable>${basedir}/version.txt.sh</executable>
<executable>${basedir}/version.txt.${script.extension}</executable>
<workingDirectory>${basedir}/target/classes/</workingDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M3</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>add-integration-test-source-as-test-sources</id>
<phase>generate-test-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>src/it/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>Windows</id>
<activation>
<os>
<family>Windows</family>
</os>
</activation>
<properties>
<script.extension>bat</script.extension>
</properties>
</profile>
<profile>
<id>unix</id>
<activation>
<os>
<family>unix</family>
</os>
</activation>
<properties>
<script.extension>sh</script.extension>
</properties>
</profile>
<profile>
<id>thorntail</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>io.thorntail</groupId>
Expand All @@ -247,16 +306,36 @@
<artifactId>jaxrs</artifactId>
</dependency>

<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
<version>${resteasy.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.thorntail</groupId>
<artifactId>arquillian</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>

</dependencies>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.thorntail</groupId>
<artifactId>bom-all</artifactId>
<artifactId>bom</artifactId>
<version>${version.thorntail}</version>
<scope>import</scope>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Expand Down
93 changes: 93 additions & 0 deletions src/it/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Test suite

All tests are contained in a one class called TestMatrixTest, each server runtime
has 4 identical test cases (with special tweaks only for Tomee), e.g. with Thorntail it is:

public void thorntailEmpty() {
testRuntime("THORNTAIL_V2", "thorntail",
SpecSelection.EMPTY, new int[]{9990});
}

public void thorntailAll() {
testRuntime("THORNTAIL_V2", "thorntail",
SpecSelection.ALL, new int[]{9990, 8180, 10090});
}

public void thorntailAllButJWTRest() {
testRuntime("THORNTAIL_V2", "thorntail",
SpecSelection.ALL_BUT_JWT_REST, new int[]{9990});
}

public void thorntailJWTRest() {
testRuntime("THORNTAIL_V2", "thorntail",
SpecSelection.JWT_REST, new int[]{9990, 8180, 10090});
}

* Empty test case does not select any examples, so only the default HelloWorld endpoint is tested.
* All selects all examples and tests them all (expect for Open Tracing as Jaeger is on TODO list).
* AllButJWTRest selects and tests all but JWT and REST; the main purpose is to ensure that no service-a/service-b division takes place.
* JWTRest selects and tests only JWT and REST.

Those additional ports are for the final cleanup after test, for a loop that awaits socket closure.
The main landing application port is parsed from README file, but there are other auxiliary ports that had to be hardcoded here.

# How does it work
REST API is used to download a zip. The zip file is unzipped.
README file(s) are parsed to get the first mvn command,
which is assumed to be the build one. The first java command from README is assumed to be the one to run the server.
Multiple flavours of builds, i.e. multiple ways to build the application is an unsupported feature in the TS at the moment.
Landing page address is also parsed from the README file as the first one beginning with http://.


Build commands are used to build the generated project(s). If you have never run the TS, this might take a long time. Mind
you are downloading all dependencies for THORNTAIL_V2, PAYARA_MICRO, LIBERTY, HELIDON, KUMULUZEE and TOMEE.

Run commands are then used to run the application(s).

A loop awaits them to be available and then each spec is tested, see MPSpec enum for definitions of expected content.

Last but not least, build and runtime logs are checked for errors. See Whitelist enum for whitelisting known and expected error messages.

At the very end of the execution, application(s) are terminated. There is also a loop that waits for a TCP socket to die.
# Platforms
The TS was tested on OpenJDK Java 11 J9 and HotSpot on Linux and with OpenJDK 11 HotSpot on Windows. It also works on Mac OS. With Windows, ```powershell``` is used
instead of ```unzip``` and ```taskkill``` instead of ```kill```. There is also some ```wmic``` heuristics to clean hanging processes.

# Logging and logs
All logs are archived in ```target/archived-logs```. If a build or a server runtime fails,
this is the first place to look for clues. Both maven build logs and runtime logs are archived. Unzip log is archived too.

## Whitelisting errors
See Whitelist enum for currently whitelisted errors per each server runtime.
Examples from the TS execution:

Kumuluzee:
```
Jan 17, 2020 4:14:44 PM org.eclipse.microprofile.starter.utils.Logs checkLog
INFO: Build log for kumuluzeeAllButJWTRest contains whitelisted error:
`[INFO] Copying error_prone_annotations-2.2.0.jar to /dev/shm/kumuluzee/target/classes/lib/error_prone_annotations-2.2.0.jar'
```
Open Liberty:
```
Jan 17, 2020 11:21:21 AM org.eclipse.microprofile.starter.utils.Logs checkLog
INFO: Runtime log for libertyEmpty contains whitelisted error:
`[ERROR ] CWMOT0008E: OpenTracing cannot track JAX-RS requests because an OpentracingTracerFactory class was not provided.'
```

# Running the TS

Run some tests for a specific runtime only:

mvn clean verify -Pthorntail -Dtest=TestMatrixTest#tomee* -Dskip.integration.tests=false -DSTARTER_TS_WORKSPACE=/dev/shm/

Debug a single test:

mvn -DfoforkCount=0 -Dmaven.surefire.debug clean verify -Pthorntail -Dtest=TestMatrixTest#tomeeAll -Dskip.integration.tests=false -DSTARTER_TS_WORKSPACE=/dev/shm/

Starting on Windows, e.g.:

mvn clean verify -Pthorntail -Dskip.integration.tests=false -DSTARTER_TS_WORKSPACE=C:\tmp\

Note that if you don't specify STARTER_TS_WORKSPACE, the fallback is whatever ```java.io.tmpdir``` returns on your system.

Happy testing.
Loading

0 comments on commit 6edd815

Please sign in to comment.