Skip to content

Commit

Permalink
OGM-827 Setting the mongodb timeout for tests to 1000ms and removing …
Browse files Browse the repository at this point in the history
…retry logic in MongoDBDatastoreProvider
  • Loading branch information
hferentschik committed May 29, 2015
1 parent 047edd6 commit 2fdfcf2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import com.mongodb.MongoClientOptions;
import com.mongodb.MongoCredential;
import com.mongodb.MongoException;
import com.mongodb.MongoTimeoutException;
import com.mongodb.ServerAddress;

/**
Expand Down Expand Up @@ -181,21 +180,7 @@ private DB extractDatabase(MongoClient mongo, MongoDBConfiguration config) {
if ( containsDatabase == null ) {
// force a connection to make sure we do have read access
// otherwise the connection failure happens during the first flush
int retries = 0;
while (true) {
try {
db.collectionExists( "WeDoNotCareWhatItIsWeNeedToConnect" );
break;
}
catch (MongoTimeoutException me) {
// unless we retry twice, the second access will be a TimeoutException error instead of an auth error
// This is a workaround for https://jira.mongodb.org/browse/JAVA-1803
retries++;
if ( retries > 2 ) {
throw me;
}
}
}
db.collectionExists( "WeDoNotCareWhatItIsWeNeedToConnect" );
}
return mongo.getDB( databaseName );
}
Expand Down
3 changes: 1 addition & 2 deletions mongodb/src/test/resources/hibernate.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ hibernate.ogm.datastore.provider = ${datastoreProvider}
hibernate.ogm.datastore.database = ogm_test_database
hibernate.ogm.datastore.create_database=true

#set timeout at 200 milliseconds
hibernate.ogm.mongodb.connection_timeout = 200
hibernate.ogm.mongodb.connection_timeout = 1000

0 comments on commit 2fdfcf2

Please sign in to comment.