Skip to content

Commit

Permalink
[Java] Refactor integration tests (#845)
Browse files Browse the repository at this point in the history
* refactor into jdk_compatibility_tests and perftests

* lint code

* add integration_tests readme

* Fix headers

* add logs integration_tests

* add logs integration_tests

* fxi groupId

* remove java version

* suppress maven download logs by --no-transfer-progress

* suppress maven download logs by --no-transfer-progress

* fix path

* fix integration_tests
  • Loading branch information
chaokunyang authored Aug 6, 2023
1 parent 6e53f9c commit 9cd196f
Show file tree
Hide file tree
Showing 26 changed files with 107 additions and 34 deletions.
4 changes: 3 additions & 1 deletion ci/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ bump_java_version() {
cd "$ROOT/java"
echo "Set fury java version to $version"
mvn versions:set -DnewVersion="$version"
cd "$ROOT/integration_tests"
echo "Set fury integration_tests version to $version"
cd "$ROOT/integration_tests/jdk_compatibility_tests"
mvn versions:set -DnewVersion="$version"
cd "$ROOT/integration_tests/perftests"
mvn versions:set -DnewVersion="$version"
}

Expand Down
16 changes: 11 additions & 5 deletions ci/run_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,24 @@ install_jdks() {

integration_tests() {
cd "$ROOT"/java
mvn -T10 -B clean install -DskipTests
cd "$ROOT"/integration_tests
mvn -T10 -B clean test
mvn -T10 -B --no-transfer-progress clean install -DskipTests
echo "Start perf tests"
cd "$ROOT"/integration_tests/perftests
mvn -T10 -B --no-transfer-progress clean test
echo "Start jdk compatibility tests"
cd "$ROOT"/integration_tests/jdk_compatibility_tests
mvn -T10 -B --no-transfer-progress clean test
for jdk in "${JDKS[@]}"; do
export JAVA_HOME="$ROOT/$jdk"
export PATH=$JAVA_HOME/bin:$PATH
mvn -T10 clean test -Dtest=io.fury.integration_tests.state.JDKCompatibilityTest
echo "First round for generate data: ${jdk}"
mvn -T10 --no-transfer-progress clean test -Dtest=io.fury.integration_tests.JDKCompatibilityTest
done
for jdk in "${JDKS[@]}"; do
export JAVA_HOME="$ROOT/$jdk"
export PATH=$JAVA_HOME/bin:$PATH
mvn -T10 clean test -Dtest=io.fury.integration_tests.state.JDKCompatibilityTest
echo "Second round for compatibility: ${jdk}"
mvn -T10 --no-transfer-progress clean test -Dtest=io.fury.integration_tests.JDKCompatibilityTest
done
}

Expand Down
21 changes: 4 additions & 17 deletions integration_tests/README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
Module sued to proto/flatbuffers benchmark without pollute core codebase and serve as integration_tests to
ensure java maven shade work and so on.
# Protobuffers/Flatbuffers benchmark
Generate code manually:
```bash
flatc -o src/main/java -j src/main/java/io/fury/integration_tests/state/bench.fbs
protoc -I=src/main/java/io/fury/integration_tests/state --java_out=src/main/java/ bench.proto
```
proto code can be generated by maven plugin.
Flatbuffers generated is short, just add generated files to repo directly.
Integration tests for fury:
- [jdk_compatibility_tests](jdk_compatibility_tests): test fury compatibility across multiple jdk versions.
- [perftests](perftests): benchmark with protobuf/flatbuffers directly.

# Run tests
```bash
cd java && mvn -T10 install -DskipTests -Dcheckstyle.skip -Dlicense.skip -Dmaven.javadoc.skip && cd ../integration_tests
mvn -T10 compile
#mvn exec:java -Dexec.mainClass="io.fury.integration_tests.UserTypeSerializeSuite" -Dexec.args="-f 1 -wi 0 -i 1 -t 1 -w 1s -r 1s -rf csv"
mvn exec:java -Dexec.mainClass="io.fury.integration_tests.UserTypeSerializeSuite"
```
> Note that this integration_tests is not designed as a maven multi-module project on purpose, so we can introduce features of higher jdk version without breaking compilation for lower jdk, and add integration tests for other languages.
63 changes: 63 additions & 0 deletions integration_tests/jdk_compatibility_tests/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2023 The Fury Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.furyio</groupId>
<artifactId>jdk_compatibility_tests</artifactId>
<version>0.2.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>org.furyio</groupId>
<artifactId>fury-benchmark</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.5.0</version>
<configuration>
<java>
<googleJavaFormat>
<version>1.7</version>
<style>GOOGLE</style>
</googleJavaFormat>
<excludes>
<exclude>**/generated/*.java</exclude>
</excludes>
</java>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.fury.integration_tests.state;
package io.fury.integration_tests;

import io.fury.Fury;
import io.fury.benchmark.data.MediaContent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.fury.integration_tests.state;
package io.fury.integration_tests;

import io.fury.Fury;
import io.fury.Language;
Expand All @@ -27,7 +27,6 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;

import org.testng.Assert;
import org.testng.annotations.Test;

Expand All @@ -36,7 +35,7 @@ public class JDKCompatibilityTest {
io.fury.Fury.FuryBuilder builder() {
return Fury.builder().withLanguage(Language.JAVA).requireClassRegistration(false);
}

Object createObject() {
// test non latin1 string
return Arrays.asList("Hello", "Hello,你好", BeanA.createBeanA(2));
Expand Down
18 changes: 18 additions & 0 deletions integration_tests/perftests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Module sued to proto/flatbuffers benchmark without pollute core codebase and serve as integration_tests to
ensure java maven shade work and so on.
# Protobuffers/Flatbuffers benchmark
Generate code manually:
```bash
flatc -o src/main/java -j src/main/java/io/fury/integration_tests/state/bench.fbs
protoc -I=src/main/java/io/fury/integration_tests/state --java_out=src/main/java/ bench.proto
```
proto code can be generated by maven plugin.
Flatbuffers generated is short, just add generated files to repo directly.

# Run tests
```bash
cd java && mvn -T10 install -DskipTests -Dcheckstyle.skip -Dlicense.skip -Dmaven.javadoc.skip && cd ../integration_tests/perftests
mvn -T10 compile
#mvn exec:java -Dexec.mainClass="io.fury.integration_tests.UserTypeSerializeSuite" -Dexec.args="-f 1 -wi 0 -i 1 -t 1 -w 1s -r 1s -rf csv"
mvn exec:java -Dexec.mainClass="io.fury.integration_tests.UserTypeSerializeSuite"
```
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2023 The Fury Authors
Expand All @@ -19,12 +20,9 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.furyio</groupId>
<artifactId>perftests</artifactId>
<version>0.2.0-SNAPSHOT</version>
<artifactId>fury-integration-tests</artifactId>
<packaging>jar</packaging>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jmh.version>1.33</jmh.version>
Expand Down Expand Up @@ -104,7 +102,7 @@
<finalName>${uberjar.name}</finalName>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.openjdk.jmh.Main</mainClass>
</transformer>
</transformers>
Expand Down Expand Up @@ -234,4 +232,4 @@
</extension>
</extensions>
</build>
</project>
</project>
2 changes: 1 addition & 1 deletion licenserc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ excludes = [
"*.txt",

# Generated
"integration_tests/src/main/java/io/fury/integration_tests/state/generated/**",
"integration_tests/perftests/src/main/java/io/fury/integration_tests/state/generated/**",

# Derived
"ci/format.sh",
Expand Down

0 comments on commit 9cd196f

Please sign in to comment.