matrei commented on code in PR #16192: URL: https://github.com/apache/grails-core/pull/16192#discussion_r3836044893
########## grails-data-mongodb/embedded/src/main/java/org/grails/datastore/gorm/mongodb/embedded/ReplicaSetInitiator.java: ########## @@ -0,0 +1,116 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 + * + * https://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. + */ +package org.grails.datastore.gorm.mongodb.embedded; + +import java.time.Duration; +import java.util.Collections; +import java.util.List; + +import com.mongodb.MongoCommandException; +import com.mongodb.client.MongoClient; +import com.mongodb.client.MongoClients; +import org.bson.Document; + +/** + * Turns a mongod started with a replica set name into one that answers. + * + * <p>A replica set of one is what a single machine can offer, and it is enough for everything a + * standalone server refuses: a multi-document transaction, a change stream, a causally consistent + * read. MongoDB does not configure it from the command line - the set is initiated by a command + * sent to the server it names - so this is the step between starting the process and handing the + * server to an application. + * + * <p>Every reference to the MongoDB driver lives here, so a standalone embedded server needs + * nothing of it on the class path. + * + * @author Grails Review Comment: Remove `@author`? ########## build.gradle: ########## @@ -112,6 +112,14 @@ subprojects { tasks.withType(Test).configureEach { testTask -> testTask.jvmArgumentProviders.add(new ActiveProcessorCountArgumentProvider( Runtime.runtime.availableProcessors(), gradle.startParameter.maxWorkerCount)) + + // The server a test starts is chosen by the build, and the test reads it as a system + // property: a project property named on the command line reaches the Gradle JVM and stops + // there, so a matrix asking for one version and a test defaulting to another agree only by + // accident. CI passes -PmongodbContainerVersion for exactly this. + if (rootProject.hasProperty('mongodbContainerVersion')) { + testTask.systemProperty('mongodbContainerVersion', rootProject.property('mongodbContainerVersion')) + } } Review Comment: Should this be moved to the mongodb specific test-config files in the `gradle` directory? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
