Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-12142

Tests failed because of incorrect mongodb host

    Details

    • Type: Test
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.21.0
    • Labels:
      None
    • Estimated Complexity:
      Unknown

      Description

      Hello,

      The tests have failed in component camel-mongodb, camel-mongodb3, camel-mongodb-gridfs:

      com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting to connect. Client view of cluster state is {type=UNKNOWN, servers=[{address=0.0.0.0:25313, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.SocketTimeoutException: connect timed out}}]
      	at com.mongodb.connection.BaseCluster.getDescription(BaseCluster.java:167)
      	at com.mongodb.Mongo.getConnectedClusterDescription(Mongo.java:881)
      	at com.mongodb.Mongo.createClientSession(Mongo.java:873)
      	at com.mongodb.Mongo$3.getClientSession(Mongo.java:862)
      	at com.mongodb.Mongo$3.execute(Mongo.java:830)
      	at com.mongodb.MongoCollectionImpl.executeDrop(MongoCollectionImpl.java:790)
      	at com.mongodb.MongoCollectionImpl.drop(MongoCollectionImpl.java:780)
      	at org.apache.camel.component.mongodb.AbstractMongoDbTest.doPostSetup(AbstractMongoDbTest.java:60)
      	at org.apache.camel.test.junit4.CamelTestSupport.setUp(CamelTestSupport.java:271)
      

      Because the client is using the wrong address when connecting to mongodb:

      address=0.0.0.0
      

      The MongoClient is created here :

      
       public class EmbedMongoConfiguration {
      
       @Bean
       public MongoClient myDb() throws UnknownHostException {
              return new MongoClient("0.0.0.0", PORT);
          }
      }
      

      I suggest to use the default mongodb host :

      127.0.0.1
      

      As défined in ServerAdress class in mongodb java driver :

      
      public class ServerAddress implements Serializable {
        
          /**
           * Returns the default database host: "127.0.0.1"
           *
           * @return IP address of default host.
           */
          public static String defaultHost() {
              return "127.0.0.1"; // NOPMD
         } 
      }
      

      The EmbedMongoConfiguration class should return a Mongclient object with default mongodb host :

       public class EmbedMongoConfiguration {
      
       @Bean
       public MongoClient myDb() throws UnknownHostException {
              return new MongoClient(defaultHost(), PORT);
          }
      }
      

      Here my configuration :

      Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T09:58:13+02:00)
      Maven home: D:\apache-maven-3.5.2\bin\..
      Java version: 1.8.0_152, vendor: Oracle Corporation
      Java home: D:\jdk1.8.0_152\jre
      Default locale: fr_FR, platform encoding: Cp1252
      OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
      

      Farès

        Attachments

          Activity

            People

            • Assignee:
              acosentino Andrea Cosentino
              Reporter:
              fhassak Farès Hassak
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: