This is an automated email from the ASF dual-hosted git repository.

drazzib pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/gora.git


The following commit(s) were added to refs/heads/master by this push:
     new 6191aea  GORA-668 Allow gora-benchmark to perform proper setup of 
MongoDB
6191aea is described below

commit 6191aeae8fd3bfb1e87525ac3d02d5f5eaf7996e
Author: Damien Raude-Morvan <damien.raude-mor...@verteego.com>
AuthorDate: Sat Oct 31 15:55:29 2020 +0100

    GORA-668 Allow gora-benchmark to perform proper setup of MongoDB
---
 .../org/apache/gora/benchmark/GoraBenchmarkClient.java  |  1 +
 .../java/org/apache/gora/benchmark/GoraClientTest.java  | 17 ++++++++++-------
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git 
a/gora-benchmark/src/main/java/org/apache/gora/benchmark/GoraBenchmarkClient.java
 
b/gora-benchmark/src/main/java/org/apache/gora/benchmark/GoraBenchmarkClient.java
index 79c5840..ecfb377 100644
--- 
a/gora-benchmark/src/main/java/org/apache/gora/benchmark/GoraBenchmarkClient.java
+++ 
b/gora-benchmark/src/main/java/org/apache/gora/benchmark/GoraBenchmarkClient.java
@@ -84,6 +84,7 @@ public class GoraBenchmarkClient extends DB {
           GoraBenchmarkUtils.generateMappingFile(dataStoreName);
           GoraBenchmarkUtils.generateDataBeans();
         }
+        properties.putAll(prop);
         String keyClass = prop.getProperty(Constants.KEY_CLASS_KEY, 
Constants.KEY_CLASS_VALUE);
         String persistentClass = 
prop.getProperty(Constants.PERSISTENCE_CLASS_KEY, 
Constants.PERSISTENCE_CLASS_VALUE);
         dataStore = DataStoreFactory.getDataStore(keyClass, persistentClass, 
properties, new Configuration());
diff --git 
a/gora-benchmark/src/test/java/org/apache/gora/benchmark/GoraClientTest.java 
b/gora-benchmark/src/test/java/org/apache/gora/benchmark/GoraClientTest.java
index b6a5cce..91a7c07 100644
--- a/gora-benchmark/src/test/java/org/apache/gora/benchmark/GoraClientTest.java
+++ b/gora-benchmark/src/test/java/org/apache/gora/benchmark/GoraClientTest.java
@@ -35,7 +35,6 @@ import site.ycsb.workloads.CoreWorkload;
 import java.io.File;
 import java.util.*;
 
-import static org.apache.gora.mongodb.MongoContainer.MONGO_PORT;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
@@ -51,6 +50,7 @@ public class GoraClientTest {
   private static HashMap<String, ByteIterator> DATA_TO_UPDATE;
   private static HashMap<String, ByteIterator> INTEGER_DATA;
   private static boolean isMongoDBSetupDone = false;
+  private static MongoContainer mongo;
 
   /**
    * Setup MongoDB embed cluster. This function will auto provision a MongoDB
@@ -59,11 +59,13 @@ public class GoraClientTest {
    */
   private void setupMongoDBCluster() {
     try {
-      MongoContainer mongo = new MongoContainer("3.6")
-              .withFixedExposedPort(MONGO_PORT, MONGO_PORT);
-      mongo.start();
+      if (!isMongoDBSetupDone) {
+        mongo = new MongoContainer("3.6");
+        mongo.start();
+      }
       ServerAddress address = mongo.getServerAddress();
       LOG.info("Started MongoDB Server on " + address.getHost() + ":" + 
address.getPort());
+      isMongoDBSetupDone = true;
     } catch (Exception e) {
       LOG.info("Cannot Start MongoDB Server {}", e.getMessage(), e);
     }
@@ -95,11 +97,12 @@ public class GoraClientTest {
     //Setup and start embedded MongoDB, make sure local mongodb is not running.
     Properties dataStoreProperties = DataStoreFactory.createProps();
     String dataStoreToTest = 
GoraBenchmarkUtils.getDataBase(dataStoreProperties);
-    if (!isMongoDBSetupDone && dataStoreToTest == Constants.MONGODB) {
+    if (Constants.MONGODB.equals(dataStoreToTest)) {
       setupMongoDBCluster();
-      isMongoDBSetupDone = true;
+      ServerAddress address = mongo.getServerAddress();
+      properties.setProperty("gora.mongodb.servers", address.getHost() + ":" + 
address.getPort());
     }
-    
+
     benchmarkClient = new GoraBenchmarkClient();
     benchmarkClient.setProperties(properties);
     benchmarkClient.init();

Reply via email to