Skip to content

Commit

Permalink
[#8911] Fix testcase failures in MongoDBIT
Browse files Browse the repository at this point in the history
  • Loading branch information
emeroad committed Jun 7, 2022
1 parent 774b544 commit b3b4f45
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 20 deletions.
2 changes: 1 addition & 1 deletion plugins-it/mongodb-it/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<dependency>
<groupId>de.flapdoodle.embed</groupId>
<artifactId>de.flapdoodle.embed.mongo</artifactId>
<version>1.50.5</version>
<version>3.4.6</version>
<scope>test</scope>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
import de.flapdoodle.embed.mongo.MongodExecutable;
import de.flapdoodle.embed.mongo.MongodProcess;
import de.flapdoodle.embed.mongo.MongodStarter;
import de.flapdoodle.embed.mongo.config.IMongodConfig;
import de.flapdoodle.embed.mongo.config.MongodConfigBuilder;
import de.flapdoodle.embed.mongo.config.MongodConfig;
import de.flapdoodle.embed.mongo.config.Net;
import de.flapdoodle.embed.mongo.distribution.Version;
import de.flapdoodle.embed.process.runtime.Network;
Expand Down Expand Up @@ -91,17 +90,18 @@ public abstract class MongoDBITBase {

abstract Class<?> getMongoDatabaseClazz() throws ClassNotFoundException;

abstract void insertComplex(PluginTestVerifier verifier, MongoCollection<Document> collection, Class<?> mongoDatabaseImpl, String collectionInfo, String collectionOption);
abstract void insertComplex(PluginTestVerifier verifier,
MongoCollection<Document> collection, Class<?> mongoDatabaseImpl,
String collectionInfo, String collectionOption);

public void startDB() throws Exception {
MongodStarter starter = MongodStarter.getDefaultInstance();
IMongodConfig mongodConfig = new MongodConfigBuilder()
MongodConfig mongodConfig = MongodConfig.builder()
.version(Version.Main.PRODUCTION)
.net(new Net(MongoDBITConstants.BIND_ADDRESS, MongoDBITConstants.PORT, Network.localhostIsIPv6()))
.build();

MongodExecutable mongodExecutable = starter.prepare(mongodConfig);

// replaced via awaitCompleted()
// //give time for previous DB close to finish and port to be released"
// Thread.sleep(200L);
Expand All @@ -113,7 +113,8 @@ public void startDB() throws Exception {
public void stopDB(MongoCollection<Document> collection) throws Exception {
try {
collection.drop();
} catch (Exception e) {
} catch (Exception ex) {
throw new RuntimeException("drop() failure", ex);
}

// replaced via awaitCompleted()
Expand Down Expand Up @@ -174,10 +175,7 @@ public void insertComlexBsonValueData30(PluginTestVerifier verifier, MongoCollec
}

public NormalizedBson parseBson(Object... documents) {
Object[] objects = new Object[documents.length];
for (int i = 0; i < documents.length; i++) {
objects[i] = documents[i];
}
Object[] objects = Arrays.copyOf(documents, documents.length);
return MongoUtil.parseBson(objects, true);
}

Expand Down Expand Up @@ -211,12 +209,11 @@ private Document createComplexDocument() {
}

private Method getMethod(Class<?> mongoDatabaseImpl, String name, Class<?>... parameterTypes) {
Method method = null;
try {
method = mongoDatabaseImpl.getDeclaredMethod(name, parameterTypes);
} catch (NoSuchMethodException e) {
return mongoDatabaseImpl.getDeclaredMethod(name, parameterTypes);
} catch (NoSuchMethodException ex) {
throw new RuntimeException(ex);
}
return method;
}

public void insertComlexBsonValueData34(PluginTestVerifier verifier, MongoCollection<Document> collection, Class<?> mongoDatabaseImpl, String collectionInfo, String collectionOption) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public final class MongoDBITConstants {

public static final int PORT = 27018;

public static String MONGODB_ADDRESS = BIND_ADDRESS + ":" + PORT;
public static final String MONGODB_ADDRESS = BIND_ADDRESS + ":" + PORT;

public static final String EMBED_MONGODB_VERSION = "de.flapdoodle.embed:de.flapdoodle.embed.mongo:3.4.6";

}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
@ImportPlugin({"com.navercorp.pinpoint:pinpoint-mongodb-driver-plugin"})
@Dependency({
"org.mongodb:mongodb-driver:[3.0.0,3.1.max]",
"de.flapdoodle.embed:de.flapdoodle.embed.mongo:2.0.0"
MongoDBITConstants.EMBED_MONGODB_VERSION
})
public class MongoDBIT_3_0_x_IT extends MongoDBITBase {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
@ImportPlugin({"com.navercorp.pinpoint:pinpoint-mongodb-driver-plugin"})
@Dependency({
"org.mongodb:mongodb-driver:[3.2.0,3.3.max]",
"de.flapdoodle.embed:de.flapdoodle.embed.mongo:2.0.0"
MongoDBITConstants.EMBED_MONGODB_VERSION
})
public class MongoDBIT_3_2_x_IT extends MongoDBITBase {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
@ImportPlugin({"com.navercorp.pinpoint:pinpoint-mongodb-driver-plugin"})
@Dependency({
"org.mongodb:mongodb-driver:[3.4.0,3.6.max]",
"de.flapdoodle.embed:de.flapdoodle.embed.mongo:2.0.0"
MongoDBITConstants.EMBED_MONGODB_VERSION
})
public class MongoDBIT_3_4_x_IT extends MongoDBITBase {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
@ImportPlugin({"com.navercorp.pinpoint:pinpoint-mongodb-driver-plugin"})
@Dependency({
"org.mongodb:mongodb-driver:[3.7.0,]",
"de.flapdoodle.embed:de.flapdoodle.embed.mongo:2.1.1"
MongoDBITConstants.EMBED_MONGODB_VERSION
})
public class MongoDBIT_3_7_x_IT extends MongoDBITBase {

Expand Down

0 comments on commit b3b4f45

Please sign in to comment.