diff --git a/.travis.yml b/.travis.yml index a6382b721..653e62a68 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,5 @@ language: java -jdk: - - oraclejdk8 - before_install: - mkdir -p downloads - mkdir -p var/db var/log @@ -14,6 +11,14 @@ before_install: downloads/mongodb-linux-x86_64-ubuntu1604-${MONGO_VERSION}/bin/mongo --eval "rs.initiate({_id: 'rs0', members:[{_id: 0, host: '127.0.0.1:27017'}]});" sleep 15 +jdk: + - openjdk13 + - openjdk-ea + +matrix: + allow_failures: + - jdk: openjdk-ea + env: matrix: - MONGO_VERSION=4.1.10 @@ -23,11 +28,6 @@ env: global: - PROFILE=ci -addons: - apt: - packages: - - oracle-java8-installer - sudo: false cache: @@ -35,4 +35,7 @@ cache: - $HOME/.m2 - downloads -script: "mvn clean dependency:list test -P${PROFILE} -Dsort" +install: true + +script: + - "./mvnw clean dependency:list test -Pjava11 -Dsort -U" diff --git a/Jenkinsfile b/Jenkinsfile index 005a15456..c4cb5fb44 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -62,10 +62,106 @@ pipeline { } } } + stage('Publish JDK 11 + MongoDB 4.0') { + when { + changeset "ci/openjdk11-mongodb-4.0/**" + } + agent { label 'data' } + options { timeout(time: 30, unit: 'MINUTES') } + + steps { + script { + def image = docker.build("springci/spring-data-openjdk11-with-mongodb-4.0", "ci/openjdk11-mongodb-4.0/") + docker.withRegistry('', 'hub.docker.com-springbuildmaster') { + image.push() + } + } + } + } + stage('Publish JDK 11 + MongoDB 4.1') { + when { + changeset "ci/openjdk11-mongodb-4.1/**" + } + agent { label 'data' } + options { timeout(time: 30, unit: 'MINUTES') } + + steps { + script { + def image = docker.build("springci/spring-data-openjdk11-with-mongodb-4.1", "ci/openjdk11-mongodb-4.1/") + docker.withRegistry('', 'hub.docker.com-springbuildmaster') { + image.push() + } + } + } + } + stage('Publish JDK 11 + MongoDB 4.2') { + when { + changeset "ci/openjdk11-mongodb-4.2/**" + } + agent { label 'data' } + options { timeout(time: 30, unit: 'MINUTES') } + + steps { + script { + def image = docker.build("springci/spring-data-openjdk11-with-mongodb-4.2", "ci/openjdk11-mongodb-4.2/") + docker.withRegistry('', 'hub.docker.com-springbuildmaster') { + image.push() + } + } + } + } + stage('Publish JDK 13 + MongoDB 4.0') { + when { + changeset "ci/openjdk13-mongodb-4.0/**" + } + agent { label 'data' } + options { timeout(time: 30, unit: 'MINUTES') } + + steps { + script { + def image = docker.build("springci/spring-data-openjdk13-with-mongodb-4.0", "ci/openjdk13-mongodb-4.0/") + docker.withRegistry('', 'hub.docker.com-springbuildmaster') { + image.push() + } + } + } + } + stage('Publish JDK 13 + MongoDB 4.1') { + when { + changeset "ci/openjdk13-mongodb-4.1/**" + } + agent { label 'data' } + options { timeout(time: 30, unit: 'MINUTES') } + + steps { + script { + def image = docker.build("springci/spring-data-openjdk13-with-mongodb-4.1", "ci/openjdk13-mongodb-4.1/") + docker.withRegistry('', 'hub.docker.com-springbuildmaster') { + image.push() + } + } + } + } + stage('Publish JDK 13 + MongoDB 4.2') { + when { + changeset "ci/openjdk13-mongodb-4.2/**" + } + agent { label 'data' } + options { timeout(time: 30, unit: 'MINUTES') } + + steps { + script { + def image = docker.build("springci/spring-data-openjdk13-with-mongodb-4.2", "ci/openjdk13-mongodb-4.2/") + docker.withRegistry('', 'hub.docker.com-springbuildmaster') { + image.push() + } + } + } + } } } - stage("test: baseline") { + stage("test: baseline (jdk8)") { when { anyOf { branch 'master' @@ -99,7 +195,47 @@ pipeline { } } parallel { - stage("test: mongodb 4.0") { + stage("test: baseline (jdk11)") { + agent { + docker { + image 'springci/spring-data-openjdk11-with-mongodb-4.2:latest' + label 'data' + args '-v $HOME:/tmp/jenkins-home' + } + } + options { timeout(time: 30, unit: 'MINUTES') } + steps { + sh 'rm -rf ?' + sh 'mkdir -p /tmp/mongodb/db /tmp/mongodb/log' + sh 'mongod --dbpath /tmp/mongodb/db --replSet rs0 --fork --logpath /tmp/mongodb/log/mongod.log &' + sh 'sleep 10' + sh 'mongo --eval "rs.initiate({_id: \'rs0\', members:[{_id: 0, host: \'127.0.0.1:27017\'}]});"' + sh 'sleep 15' + sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pjava11 clean dependency:list test -Dsort -U -B' + } + } + + stage("test: baseline (jdk13)") { + agent { + docker { + image 'springci/spring-data-openjdk13-with-mongodb-4.2:latest' + label 'data' + args '-v $HOME:/tmp/jenkins-home' + } + } + options { timeout(time: 30, unit: 'MINUTES') } + steps { + sh 'rm -rf ?' + sh 'mkdir -p /tmp/mongodb/db /tmp/mongodb/log' + sh 'mongod --dbpath /tmp/mongodb/db --replSet rs0 --fork --logpath /tmp/mongodb/log/mongod.log &' + sh 'sleep 10' + sh 'mongo --eval "rs.initiate({_id: \'rs0\', members:[{_id: 0, host: \'127.0.0.1:27017\'}]});"' + sh 'sleep 15' + sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pjava11 clean dependency:list test -Dsort -U -B' + } + } + + stage("test: mongodb 4.0 (jdk8)") { agent { docker { image 'springci/spring-data-openjdk8-with-mongodb-4.0:latest' @@ -118,7 +254,48 @@ pipeline { sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw clean dependency:list test -Dsort -U -B' } } - stage("test: mongodb 4.1") { + + stage("test: mongodb 4.0 (jdk11)") { + agent { + docker { + image 'springci/spring-data-openjdk11-with-mongodb-4.0:latest' + label 'data' + args '-v $HOME:/tmp/jenkins-home' + } + } + options { timeout(time: 30, unit: 'MINUTES') } + steps { + sh 'rm -rf ?' + sh 'mkdir -p /tmp/mongodb/db /tmp/mongodb/log' + sh 'mongod --dbpath /tmp/mongodb/db --replSet rs0 --fork --logpath /tmp/mongodb/log/mongod.log &' + sh 'sleep 10' + sh 'mongo --eval "rs.initiate({_id: \'rs0\', members:[{_id: 0, host: \'127.0.0.1:27017\'}]});"' + sh 'sleep 15' + sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pjava11 clean dependency:list test -Dsort -U -B' + } + } + + stage("test: mongodb 4.0 (jdk13)") { + agent { + docker { + image 'springci/spring-data-openjdk13-with-mongodb-4.0:latest' + label 'data' + args '-v $HOME:/tmp/jenkins-home' + } + } + options { timeout(time: 30, unit: 'MINUTES') } + steps { + sh 'rm -rf ?' + sh 'mkdir -p /tmp/mongodb/db /tmp/mongodb/log' + sh 'mongod --dbpath /tmp/mongodb/db --replSet rs0 --fork --logpath /tmp/mongodb/log/mongod.log &' + sh 'sleep 10' + sh 'mongo --eval "rs.initiate({_id: \'rs0\', members:[{_id: 0, host: \'127.0.0.1:27017\'}]});"' + sh 'sleep 15' + sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pjava11 clean dependency:list test -Dsort -U -B' + } + } + + stage("test: mongodb 4.1 (jdk8)") { agent { docker { image 'springci/spring-data-openjdk8-with-mongodb-4.1:latest' @@ -137,6 +314,46 @@ pipeline { sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw clean dependency:list test -Dsort -U -B' } } + + stage("test: mongodb 4.1 (jdk11)") { + agent { + docker { + image 'springci/spring-data-openjdk11-with-mongodb-4.1:latest' + label 'data' + args '-v $HOME:/tmp/jenkins-home' + } + } + options { timeout(time: 30, unit: 'MINUTES') } + steps { + sh 'rm -rf ?' + sh 'mkdir -p /tmp/mongodb/db /tmp/mongodb/log' + sh 'mongod --dbpath /tmp/mongodb/db --replSet rs0 --fork --logpath /tmp/mongodb/log/mongod.log &' + sh 'sleep 10' + sh 'mongo --eval "rs.initiate({_id: \'rs0\', members:[{_id: 0, host: \'127.0.0.1:27017\'}]});"' + sh 'sleep 15' + sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pjava11 clean dependency:list test -Dsort -U -B' + } + } + + stage("test: mongodb 4.1 (jdk13)") { + agent { + docker { + image 'springci/spring-data-openjdk13-with-mongodb-4.1:latest' + label 'data' + args '-v $HOME:/tmp/jenkins-home' + } + } + options { timeout(time: 30, unit: 'MINUTES') } + steps { + sh 'rm -rf ?' + sh 'mkdir -p /tmp/mongodb/db /tmp/mongodb/log' + sh 'mongod --dbpath /tmp/mongodb/db --replSet rs0 --fork --logpath /tmp/mongodb/log/mongod.log &' + sh 'sleep 10' + sh 'mongo --eval "rs.initiate({_id: \'rs0\', members:[{_id: 0, host: \'127.0.0.1:27017\'}]});"' + sh 'sleep 15' + sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pjava11 clean dependency:list test -Dsort -U -B' + } + } } } diff --git a/ci/openjdk11-mongodb-4.0/Dockerfile b/ci/openjdk11-mongodb-4.0/Dockerfile new file mode 100644 index 000000000..8c450a54f --- /dev/null +++ b/ci/openjdk11-mongodb-4.0/Dockerfile @@ -0,0 +1,14 @@ +FROM adoptopenjdk/openjdk11:latest + +RUN apt-get update && apt-get install -y apt-transport-https apt-utils gnupg2 + +RUN apt-key adv --keyserver hkps://keyserver.ubuntu.com:443 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4 + +RUN echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.0.list + +RUN apt-get update + +RUN apt-get install -y mongodb-org=4.0.9 mongodb-org-server=4.0.9 mongodb-org-shell=4.0.9 mongodb-org-mongos=4.0.9 mongodb-org-tools=4.0.9 + +RUN apt-get clean \ + && rm -rf /var/lib/apt/lists/* \ No newline at end of file diff --git a/ci/openjdk11-mongodb-4.1/Dockerfile b/ci/openjdk11-mongodb-4.1/Dockerfile new file mode 100644 index 000000000..9e9fff1f5 --- /dev/null +++ b/ci/openjdk11-mongodb-4.1/Dockerfile @@ -0,0 +1,14 @@ +FROM adoptopenjdk/openjdk11:latest + +RUN apt-get update && apt-get install -y apt-transport-https apt-utils gnupg2 + +RUN apt-key adv --keyserver hkps://keyserver.ubuntu.com:443 --recv 4B7C549A058F8B6B + +RUN echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.1 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.1.list + +RUN apt-get update + +RUN apt-get install -y mongodb-org-unstable=4.1.13 mongodb-org-unstable-server=4.1.13 mongodb-org-unstable-shell=4.1.13 mongodb-org-unstable-mongos=4.1.13 mongodb-org-unstable-tools=4.1.13 + +RUN apt-get clean \ + && rm -rf /var/lib/apt/lists/* \ No newline at end of file diff --git a/ci/openjdk11-mongodb-4.2/Dockerfile b/ci/openjdk11-mongodb-4.2/Dockerfile new file mode 100644 index 000000000..03eeabb62 --- /dev/null +++ b/ci/openjdk11-mongodb-4.2/Dockerfile @@ -0,0 +1,14 @@ +FROM adoptopenjdk/openjdk11:latest + +RUN apt-get update && apt-get install -y apt-transport-https apt-utils gnupg2 + +RUN apt-key adv --keyserver hkps://keyserver.ubuntu.com:443 --recv e162f504a20cdf15827f718d4b7c549a058f8b6b + +RUN echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.2.list + +RUN apt-get update + +RUN apt-get install -y mongodb-org=4.2.0 mongodb-org-server=4.2.0 mongodb-org-shell=4.2.0 mongodb-org-mongos=4.2.0 mongodb-org-tools=4.2.0 + +RUN apt-get clean \ + && rm -rf /var/lib/apt/lists/* diff --git a/ci/openjdk13-mongodb-4.0/Dockerfile b/ci/openjdk13-mongodb-4.0/Dockerfile new file mode 100644 index 000000000..511db028a --- /dev/null +++ b/ci/openjdk13-mongodb-4.0/Dockerfile @@ -0,0 +1,14 @@ +FROM adoptopenjdk/openjdk13:latest + +RUN apt-get update && apt-get install -y apt-transport-https apt-utils gnupg2 + +RUN apt-key adv --keyserver hkps://keyserver.ubuntu.com:443 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4 + +RUN echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.0.list + +RUN apt-get update + +RUN apt-get install -y mongodb-org=4.0.9 mongodb-org-server=4.0.9 mongodb-org-shell=4.0.9 mongodb-org-mongos=4.0.9 mongodb-org-tools=4.0.9 + +RUN apt-get clean \ + && rm -rf /var/lib/apt/lists/* \ No newline at end of file diff --git a/ci/openjdk13-mongodb-4.1/Dockerfile b/ci/openjdk13-mongodb-4.1/Dockerfile new file mode 100644 index 000000000..5f94bb6f2 --- /dev/null +++ b/ci/openjdk13-mongodb-4.1/Dockerfile @@ -0,0 +1,14 @@ +FROM adoptopenjdk/openjdk13:latest + +RUN apt-get update && apt-get install -y apt-transport-https apt-utils gnupg2 + +RUN apt-key adv --keyserver hkps://keyserver.ubuntu.com:443 --recv 4B7C549A058F8B6B + +RUN echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.1 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.1.list + +RUN apt-get update + +RUN apt-get install -y mongodb-org-unstable=4.1.13 mongodb-org-unstable-server=4.1.13 mongodb-org-unstable-shell=4.1.13 mongodb-org-unstable-mongos=4.1.13 mongodb-org-unstable-tools=4.1.13 + +RUN apt-get clean \ + && rm -rf /var/lib/apt/lists/* \ No newline at end of file diff --git a/ci/openjdk13-mongodb-4.2/Dockerfile b/ci/openjdk13-mongodb-4.2/Dockerfile new file mode 100644 index 000000000..3f73cd442 --- /dev/null +++ b/ci/openjdk13-mongodb-4.2/Dockerfile @@ -0,0 +1,14 @@ +FROM adoptopenjdk/openjdk13:latest + +RUN apt-get update && apt-get install -y apt-transport-https apt-utils gnupg2 + +RUN apt-key adv --keyserver hkps://keyserver.ubuntu.com:443 --recv e162f504a20cdf15827f718d4b7c549a058f8b6b + +RUN echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.2.list + +RUN apt-get update + +RUN apt-get install -y mongodb-org=4.2.0 mongodb-org-server=4.2.0 mongodb-org-shell=4.2.0 mongodb-org-mongos=4.2.0 mongodb-org-tools=4.2.0 + +RUN apt-get clean \ + && rm -rf /var/lib/apt/lists/* diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/MongoTemplateTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/MongoTemplateTests.java index 3be4e23d5..7dca9fd5c 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/MongoTemplateTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/MongoTemplateTests.java @@ -32,6 +32,7 @@ import java.math.BigDecimal; import java.math.BigInteger; import java.time.Duration; import java.time.Instant; +import java.time.temporal.ChronoUnit; import java.util.*; import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; @@ -3669,7 +3670,8 @@ public class MongoTemplateTests { ImmutableAudited read = template.findOne(query(where("id").is(result.getId())), ImmutableAudited.class); - assertThat(read.modified).isEqualTo(result.modified).describedAs("Expected auditing information to be read!"); + assertThat(read.modified).isEqualTo(result.modified.truncatedTo(ChronoUnit.MILLIS)) + .describedAs("Expected auditing information to be read!"); } @Test // DATAMONGO-1798 diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/auditing/MongoTemplateAuditingTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/auditing/MongoTemplateAuditingTests.java index d162fe6cd..e98a4136b 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/auditing/MongoTemplateAuditingTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/auditing/MongoTemplateAuditingTests.java @@ -18,6 +18,7 @@ package org.springframework.data.mongodb.core.auditing; import static org.assertj.core.api.Assertions.*; import java.time.Instant; +import java.time.temporal.ChronoUnit; import java.util.concurrent.TimeUnit; import org.junit.Test; @@ -80,7 +81,7 @@ public class MongoTemplateAuditingTests { assertThat(updated.modificationDate).isAfter(inserted.modificationDate); assertThat(fetched.modificationDate).isAfter(inserted.modificationDate); - assertThat(fetched.modificationDate).isEqualTo(updated.modificationDate); + assertThat(fetched.modificationDate).isEqualTo(updated.modificationDate.truncatedTo(ChronoUnit.MILLIS)); } @Test // DATAMONGO-2346 @@ -101,7 +102,7 @@ public class MongoTemplateAuditingTests { assertThat(updated.getModificationDate()).isAfter(inserted.getModificationDate()); assertThat(fetched.getModificationDate()).isAfter(inserted.getModificationDate()); - assertThat(fetched.getModificationDate()).isEqualTo(updated.getModificationDate()); + assertThat(fetched.getModificationDate()).isEqualTo(updated.getModificationDate().truncatedTo(ChronoUnit.MILLIS)); } static class ImmutableAuditableEntityWithVersion { diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/auditing/ReactiveMongoTemplateAuditingTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/auditing/ReactiveMongoTemplateAuditingTests.java index b0219a10b..3095799f7 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/auditing/ReactiveMongoTemplateAuditingTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/auditing/ReactiveMongoTemplateAuditingTests.java @@ -22,6 +22,7 @@ import reactor.util.function.Tuples; import java.time.Duration; import java.time.Instant; +import java.time.temporal.ChronoUnit; import org.junit.Before; import org.junit.Test; @@ -96,7 +97,8 @@ public class ReactiveMongoTemplateAuditingTests { assertThat(tuple3.getT2().modificationDate).isAfter(tuple3.getT1().modificationDate); assertThat(tuple3.getT3().modificationDate).isAfter(tuple3.getT1().modificationDate); - assertThat(tuple3.getT3().modificationDate).isEqualTo(tuple3.getT2().modificationDate); + assertThat(tuple3.getT3().modificationDate) + .isEqualTo(tuple3.getT2().modificationDate.truncatedTo(ChronoUnit.MILLIS)); }) // .verifyComplete(); } @@ -117,7 +119,8 @@ public class ReactiveMongoTemplateAuditingTests { assertThat(tuple3.getT2().getModificationDate()).isAfter(tuple3.getT1().getModificationDate()); assertThat(tuple3.getT3().getModificationDate()).isAfter(tuple3.getT1().getModificationDate()); - assertThat(tuple3.getT3().getModificationDate()).isEqualTo(tuple3.getT2().getModificationDate()); + assertThat(tuple3.getT3().getModificationDate()) + .isEqualTo(tuple3.getT2().getModificationDate().truncatedTo(ChronoUnit.MILLIS)); }) // .verifyComplete(); } diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/MappingMongoConverterUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/MappingMongoConverterUnitTests.java index b889bdf36..5fdd8e185 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/MappingMongoConverterUnitTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/MappingMongoConverterUnitTests.java @@ -28,6 +28,7 @@ import java.math.BigDecimal; import java.math.BigInteger; import java.net.URL; import java.time.LocalDateTime; +import java.time.temporal.ChronoUnit; import java.util.*; import org.bson.types.Code; @@ -1663,7 +1664,8 @@ public class MappingMongoConverterUnitTests { converter.write(source, result); assertThat(result.get("date")).isInstanceOf(Date.class); - assertThat(converter.read(TypeWithLocalDateTime.class, result).date).isEqualTo(reference); + assertThat(converter.read(TypeWithLocalDateTime.class, result).date) + .isEqualTo(reference.truncatedTo(ChronoUnit.MILLIS)); } @Test // DATAMONGO-1128