diff --git a/mongodb_store/scripts/message_store_node.py b/mongodb_store/scripts/message_store_node.py index f949977..c65500a 100755 --- a/mongodb_store/scripts/message_store_node.py +++ b/mongodb_store/scripts/message_store_node.py @@ -23,9 +23,9 @@ def __init__(self, replicate_on_write=False): self.replicate_on_write = replicate_on_write use_daemon = rospy.get_param('mongodb_use_daemon', False) - db_host = rospy.get_param('mongodb_host') - db_port = rospy.get_param('mongodb_port') - if use_daemon: + if use_daemon: + db_host = rospy.get_param('mongodb_host') + db_port = rospy.get_param('mongodb_port') is_daemon_alive = dc_util.check_connection_to_mongod(db_host, db_port) if not is_daemon_alive: raise Exception("No Daemon?") @@ -33,6 +33,10 @@ def __init__(self, replicate_on_write=False): have_dc = dc_util.wait_for_mongo() if not have_dc: raise Exception("No Datacentre?") + # move these to after the wait_for_mongo check as they may not be set before the db is available + db_host = rospy.get_param('mongodb_host') + db_port = rospy.get_param('mongodb_port') + self._mongo_client=MongoClient(db_host, db_port) diff --git a/mongodb_store/tests/message_store.test b/mongodb_store/tests/message_store.test index af5904d..4f26f11 100644 --- a/mongodb_store/tests/message_store.test +++ b/mongodb_store/tests/message_store.test @@ -1,13 +1,13 @@ - + - + - + diff --git a/mongodb_store/tests/message_store_cpp_client.test b/mongodb_store/tests/message_store_cpp_client.test index f43bd64..7358350 100644 --- a/mongodb_store/tests/message_store_cpp_client.test +++ b/mongodb_store/tests/message_store_cpp_client.test @@ -1,11 +1,11 @@ - + - + \ No newline at end of file diff --git a/mongodb_store/tests/message_store_cpp_test.cpp b/mongodb_store/tests/message_store_cpp_test.cpp index b2f25ab..86deaa6 100644 --- a/mongodb_store/tests/message_store_cpp_test.cpp +++ b/mongodb_store/tests/message_store_cpp_test.cpp @@ -46,7 +46,7 @@ TEST(ROSDatacentre, cppTest) BOOST_FOREACH( boost::shared_ptr p, results) { - //ROS_INFO_STREAM("Got by ID: " << *p); + ROS_INFO_STREAM("Got by ID: " << *p); } } @@ -123,18 +123,20 @@ TEST(ROSDatacentre, cppTest) EXPECT_EQ(0, results.size()); } - results.clear(); - for(int i = 0; i < 100; ++i) { - geometry_msgs::Pose p; - p.orientation.z = i; - messageStore.insert(p); - } - if(messageStore.query(results, mongo::BSONObj(), mongo::BSONObj(), false, 10)){ - EXPECT_EQ(10, results.size()); - } - else { - ADD_FAILURE() << "Documents are not limited"; - } + results.clear(); + for(int i = 0; i < 100; ++i) { + geometry_msgs::Pose p; + p.orientation.z = i; + messageStore.insert(p); + } + if(messageStore.query(results, mongo::BSONObj(), mongo::BSONObj(), false, 10)){ + EXPECT_EQ(10, results.size()); + } + else { + ADD_FAILURE() << "Documents are not limited"; + } + + ROS_INFO_STREAM("happy here"); } /**