codeconsole commented on code in PR #16192: URL: https://github.com/apache/grails-core/pull/16192#discussion_r3836392690
########## 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: Removed. Its seven neighbours in that module carried the same `@author Grails` placeholder from #16095, so those are gone too, as an isolated commit (e6fa4eb) - tag lines only, nothing else touched. One is left in the repository, in `grails-core/.../CompileStaticArtefactInjector.groovy`, which is outside this PR. ########## 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: Moved, though to three files rather than two. `mongodb-test-config.gradle` and `mongodb-forked-test-config.gradle` cover the `grails-data-mongodb` modules. They do not cover the example applications: `grails-test-examples/mongodb/**` apply `functional-test-config.gradle`, and they read `mongodbContainerVersion` as well - `SpringBootStartMongoExtension` and the test-data-service `Application` both do. Putting it only in the two mongodb configs would have sent those back to their hardcoded `7.0.19` while the matrix asked for 8.0, which is the thing that commit exists to fix. So it is in the functional config too, behind the `isMongo` flag that file already works out for the `onlyMongodbTests` gating. Checked per task with `-PmongodbContainerVersion=8.0`: every `grails-data-mongodb-*` and `grails-test-examples-mongodb-*` test task now sees `8.0`, while `grails-core` and the non-mongo example applications see nothing at all - which was your point. -- 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]
