The issue is reducing MongoDB thread monitoring time in java .
I would like to run component test code as stated below. For the component test I would like to make asleep(at most 30 sec not 1 minute) and check if expired documents are removed or not. But it doesnt work. If I run thread.sleep(60000) (1 minute) It works but it is too much delay for a component test. Do you have any solution for this?
‘’’
runCommand(new BsonDocument(“setParameter”, new BsonInt32(1)).append(“ttlMonitorEnabled”, new BsonBoolean(false)));
runCommand(new BsonDocument(“setParameter”, new BsonInt32(1)).append(“ttlMonitorSleepSecs”, new BsonInt64(5)));
runCommand(new BsonDocument(“setParameter”, new BsonInt32(1)).append(“ttlMonitorEnabled”, new BsonBoolean(true)));
Thread.sleep(15000);
long afterCount = getCounter(TrainedDbModel.class);
// then
assertThat(afterCount).isEqualTo(1);
public void runCommand(final Bson command) {
final MongoDatabase db = mongoClient.getDatabase(“admin”);
db.runCommand(command);
}
‘’’