Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 41 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,22 @@ pipeline {
stages {
stage("Docker images") {
parallel {
stage('Publish JDK 8 + MongoDB 5.0') {
when {
changeset "ci/openjdk8-mongodb-5.0/**"
}
agent { label 'data' }
options { timeout(time: 30, unit: 'MINUTES') }

steps {
script {
def image = docker.build("springci/spring-data-openjdk8-with-mongodb-5.0.0", "ci/openjdk8-mongodb-5.0/")
docker.withRegistry('', 'hub.docker.com-springbuildmaster') {
image.push()
}
}
}
}
stage('Publish JDK 8 + MongoDB 4.0') {
when {
changeset "ci/openjdk8-mongodb-4.0/**"
Expand Down Expand Up @@ -98,7 +114,7 @@ pipeline {
stage("Test other configurations") {
when {
allOf {
branch 'main'
branch 'issue/3696'
not { triggeredBy 'UpstreamCause' }
}
}
Expand Down Expand Up @@ -151,6 +167,30 @@ pipeline {
}
}

stage("test: mongodb 5.0 (jdk8)") {
agent {
label 'data'
}
options { timeout(time: 30, unit: 'MINUTES') }
environment {
ARTIFACTORY = credentials('02bd1690-b54f-4c9f-819d-a77cb7a9822c')
}
steps {
script {
docker.withRegistry('', 'hub.docker.com-springbuildmaster') {
docker.image('springci/spring-data-openjdk8-with-mongodb-5.0.0:latest').inside('-v $HOME:/tmp/jenkins-home') {
sh 'mkdir -p /tmp/mongodb/db /tmp/mongodb/log'
sh 'mongod --setParameter transactionLifetimeLimitSeconds=90 --setParameter maxTransactionLockRequestTimeoutMillis=10000 --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 -s settings.xml clean dependency:list test -Duser.name=jenkins -Dsort -U -B'
}
}
}
}
}

stage("test: baseline (jdk16)") {
agent {
label 'data'
Expand Down
17 changes: 17 additions & 0 deletions ci/openjdk8-mongodb-5.0/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM adoptopenjdk/openjdk8:latest

ENV TZ=Etc/UTC
ENV DEBIAN_FRONTEND=noninteractive

RUN set -eux; \
apt-get update && apt-get install -y apt-transport-https apt-utils gnupg2 wget ; \
# MongoDB 5.0 release signing key
apt-key adv --keyserver hkps://keyserver.ubuntu.com:443 --recv B00A0BD1E2C63C11 ; \
# Needed when MongoDB creates a 5.0 folder.
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/5.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-5.0.list; \
echo ${TZ} > /etc/timezone;

RUN apt-get update; \
apt-get install -y mongodb-org=5.0.0 mongodb-org-server=5.0.0 mongodb-org-shell=5.0.0 mongodb-org-mongos=5.0.0 mongodb-org-tools=5.0.0; \
apt-get clean; \
rm -rf /var/lib/apt/lists/*;
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb-parent</artifactId>
<version>3.3.0-SNAPSHOT</version>
<version>3.3.0-GH-3696-SNAPSHOT</version>
<packaging>pom</packaging>

<name>Spring Data MongoDB</name>
Expand Down
2 changes: 1 addition & 1 deletion spring-data-mongodb-benchmarks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb-parent</artifactId>
<version>3.3.0-SNAPSHOT</version>
<version>3.3.0-GH-3696-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion spring-data-mongodb-distribution/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb-parent</artifactId>
<version>3.3.0-SNAPSHOT</version>
<version>3.3.0-GH-3696-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion spring-data-mongodb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb-parent</artifactId>
<version>3.3.0-SNAPSHOT</version>
<version>3.3.0-GH-3696-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,17 @@
import java.util.Set;

import org.bson.Document;
import org.junit.After;
import org.junit.Before;
import org.junit.runner.RunWith;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.dao.DataAccessException;
import org.springframework.data.mongodb.core.CollectionCallback;
import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.data.mongodb.test.util.MongoTestUtils;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;

import com.mongodb.MongoException;
import com.mongodb.client.MongoClient;
Expand All @@ -41,7 +40,7 @@
/**
* @author Oliver Gierke
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@ContextConfiguration
public abstract class AbstractIntegrationTests {

Expand Down Expand Up @@ -71,8 +70,8 @@ protected boolean autoIndexCreation() {

@Autowired MongoOperations operations;

@Before
@After
@BeforeEach
@AfterEach
public void cleanUp() {

for (String collectionName : operations.getCollectionNames()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import java.util.List;
import java.util.Map;

import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.data.geo.Point;
Expand All @@ -35,6 +35,7 @@
import org.springframework.data.mongodb.core.index.IndexInfo;
import org.springframework.data.mongodb.core.index.IndexOperations;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.test.util.EnableIfMongoServerVersion;

import com.mongodb.MongoException;
import com.mongodb.WriteConcern;
Expand All @@ -52,7 +53,7 @@ public class GeoSpatialIndexTests extends AbstractIntegrationTests {

@Autowired private MongoTemplate template;

@Before
@BeforeEach
public void setUp() {

template.setWriteConcern(WriteConcern.JOURNALED);
Expand Down Expand Up @@ -82,6 +83,7 @@ public void test2dSphereIndex() {
}

@Test // DATAMONGO-778
@EnableIfMongoServerVersion(isLessThan = "5.0")
public void testHaystackIndex() {

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,11 @@ public void evaluatesTimeoutSpelExpresssionWithBeanReference() {
});

assertThat(indexInfo).isPresent();
assertThat(indexInfo.get()).containsEntry("expireAfterSeconds", 11L);
assertThat(indexInfo.get()).hasEntrySatisfying("expireAfterSeconds", timeout -> {

// MongoDB 5 returns int not long
assertThat(timeout).isIn(11, 11L);
});
}

@Target({ ElementType.FIELD })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,16 @@
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.messaging.ChangeStreamRequest.ChangeStreamRequestOptions;
import org.springframework.data.mongodb.core.messaging.SubscriptionRequest.RequestOptions;
import org.springframework.data.mongodb.test.util.Client;
import org.springframework.data.mongodb.test.util.EnableIfMongoServerVersion;
import org.springframework.data.mongodb.test.util.EnableIfReplicaSetAvailable;
import org.springframework.data.mongodb.test.util.MongoServerCondition;
import org.springframework.data.mongodb.test.util.MongoTemplateExtension;
import org.springframework.data.mongodb.test.util.MongoTestUtils;
import org.springframework.data.mongodb.test.util.Template;
import org.springframework.util.ErrorHandler;

import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.model.CreateCollectionOptions;
import com.mongodb.client.model.changestream.ChangeStreamDocument;
Expand All @@ -60,9 +63,12 @@ public class DefaultMessageListenerContainerTests {
static final String DATABASE_NAME = "change-stream-events";
static final String COLLECTION_NAME = "collection-1";
static final String COLLECTION_2_NAME = "collection-2";
static final String COLLECTION_3_NAME = "collection-3";

static final Duration TIMEOUT = Duration.ofSeconds(2);

@Client static MongoClient client;

@Template(database = DATABASE_NAME, initialEntitySet = Person.class) //
static MongoTemplate template;

Expand All @@ -74,10 +80,13 @@ public class DefaultMessageListenerContainerTests {
private CollectingMessageListener<Object, Object> messageListener;

@BeforeEach
void beforeEach() {
void beforeEach() throws InterruptedException {

MongoTestUtils.dropCollectionNow(DATABASE_NAME, COLLECTION_NAME, client);
MongoTestUtils.dropCollectionNow(DATABASE_NAME, COLLECTION_2_NAME, client);
MongoTestUtils.dropCollectionNow(DATABASE_NAME, COLLECTION_3_NAME, client);

template.dropCollection(COLLECTION_NAME);
template.dropCollection(COLLECTION_2_NAME);
Thread.sleep(100);

messageListener = new CollectingMessageListener<>();
}
Expand Down Expand Up @@ -281,7 +290,7 @@ public void abortsSubscriptionOnError() throws InterruptedException {
@Test // DATAMONGO-1803
public void callsDefaultErrorHandlerOnError() throws InterruptedException {

dbFactory.getMongoDatabase().createCollection(COLLECTION_NAME,
dbFactory.getMongoDatabase().createCollection(COLLECTION_3_NAME,
new CreateCollectionOptions().capped(true).maxDocuments(10000).sizeInBytes(10000));

collection.insertOne(new Document("_id", "id-1").append("value", "foo"));
Expand All @@ -298,10 +307,7 @@ public void callsDefaultErrorHandlerOnError() throws InterruptedException {
Document.class);

SubscriptionUtils.awaitSubscription(subscription);

template.dropCollection(COLLECTION_NAME);

Thread.sleep(20);
dbFactory.getMongoDatabase().drop();

verify(errorHandler, atLeast(1)).handleError(any(DataAccessException.class));
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,23 @@ public static void dropCollectionNow(String dbName, String collectionName,
.verifyComplete();
}

/**
* Create a {@link com.mongodb.client.MongoCollection} if it does not exist, or drop and recreate it if it does and
* verify operation result.
*
* @param dbName must not be {@literal null}.
* @param collectionName must not be {@literal null}.
* @param client must not be {@literal null}.
*/
public static void dropCollectionNow(String dbName, String collectionName,
com.mongodb.client.MongoClient client) {

com.mongodb.client.MongoDatabase database = client.getDatabase(dbName)
.withWriteConcern(WriteConcern.MAJORITY).withReadPreference(ReadPreference.primary());

database.getCollection(collectionName).drop();
}

/**
* Remove all documents from the {@link MongoCollection} with given name in the according {@link MongoDatabase
* database}.
Expand Down