summaryrefslogtreecommitdiff
path: root/src/mongo/dbtests/config_server_fixture.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/dbtests/config_server_fixture.cpp')
-rw-r--r--src/mongo/dbtests/config_server_fixture.cpp158
1 files changed, 76 insertions, 82 deletions
diff --git a/src/mongo/dbtests/config_server_fixture.cpp b/src/mongo/dbtests/config_server_fixture.cpp
index c92f521d433..ed7bbeaaa2a 100644
--- a/src/mongo/dbtests/config_server_fixture.cpp
+++ b/src/mongo/dbtests/config_server_fixture.cpp
@@ -47,106 +47,100 @@
namespace mongo {
- using boost::scoped_ptr;
- using std::endl;
- using std::list;
- using std::string;
-
- ConfigServerFixture::ConfigServerFixture()
- : _client(&_txn),
- _connectHook(NULL) {
-
- }
-
- void ConfigServerFixture::setUp() {
- DBException::traceExceptions = true;
-
- // Make all connections redirect to the direct client
- _connectHook = new CustomConnectHook(&_txn);
- ConnectionString::setConnectionHook(_connectHook);
- // Disable the lock pinger
- setLockPingerEnabled(false);
-
- // Create the default config database before querying, necessary for direct connections
- clearServer();
- _client.insert("config.test", BSON( "hello" << "world" ));
- _client.dropCollection("config.test");
-
- // Create an index over the chunks, to allow correct diffing
- ASSERT_OK(dbtests::createIndex(&_txn,
- ChunkType::ConfigNS,
- BSON( ChunkType::ns() << 1 <<
- ChunkType::DEPRECATED_lastmod() << 1 )));
- configServer.init(configSvr().toString());
- }
-
- void ConfigServerFixture::clearServer() {
- _client.dropDatabase("config");
- }
+using boost::scoped_ptr;
+using std::endl;
+using std::list;
+using std::string;
+
+ConfigServerFixture::ConfigServerFixture() : _client(&_txn), _connectHook(NULL) {}
+
+void ConfigServerFixture::setUp() {
+ DBException::traceExceptions = true;
+
+ // Make all connections redirect to the direct client
+ _connectHook = new CustomConnectHook(&_txn);
+ ConnectionString::setConnectionHook(_connectHook);
+ // Disable the lock pinger
+ setLockPingerEnabled(false);
+
+ // Create the default config database before querying, necessary for direct connections
+ clearServer();
+ _client.insert("config.test",
+ BSON("hello"
+ << "world"));
+ _client.dropCollection("config.test");
+
+ // Create an index over the chunks, to allow correct diffing
+ ASSERT_OK(
+ dbtests::createIndex(&_txn,
+ ChunkType::ConfigNS,
+ BSON(ChunkType::ns() << 1 << ChunkType::DEPRECATED_lastmod() << 1)));
+ configServer.init(configSvr().toString());
+}
- void ConfigServerFixture::clearVersion() {
- _client.dropCollection(VersionType::ConfigNS);
- }
+void ConfigServerFixture::clearServer() {
+ _client.dropDatabase("config");
+}
- void ConfigServerFixture::clearShards() {
- _client.dropCollection(ShardType::ConfigNS);
- }
+void ConfigServerFixture::clearVersion() {
+ _client.dropCollection(VersionType::ConfigNS);
+}
- void ConfigServerFixture::clearDatabases() {
- _client.dropCollection(DatabaseType::ConfigNS);
- }
+void ConfigServerFixture::clearShards() {
+ _client.dropCollection(ShardType::ConfigNS);
+}
- void ConfigServerFixture::clearCollections() {
- _client.dropCollection(CollectionType::ConfigNS);
- }
+void ConfigServerFixture::clearDatabases() {
+ _client.dropCollection(DatabaseType::ConfigNS);
+}
- void ConfigServerFixture::clearChunks() {
- _client.dropCollection(ChunkType::ConfigNS);
- }
+void ConfigServerFixture::clearCollections() {
+ _client.dropCollection(CollectionType::ConfigNS);
+}
- void ConfigServerFixture::clearPings() {
- _client.dropCollection(MongosType::ConfigNS);
- }
+void ConfigServerFixture::clearChunks() {
+ _client.dropCollection(ChunkType::ConfigNS);
+}
- void ConfigServerFixture::clearChangelog() {
- _client.dropCollection(ChangelogType::ConfigNS);
- }
+void ConfigServerFixture::clearPings() {
+ _client.dropCollection(MongosType::ConfigNS);
+}
- void ConfigServerFixture::dumpServer() {
+void ConfigServerFixture::clearChangelog() {
+ _client.dropCollection(ChangelogType::ConfigNS);
+}
- log() << "Dumping virtual config server to log..." << endl;
+void ConfigServerFixture::dumpServer() {
+ log() << "Dumping virtual config server to log..." << endl;
- list<string> collectionNames(_client.getCollectionNames("config"));
+ list<string> collectionNames(_client.getCollectionNames("config"));
- for (list<string>::iterator it = collectionNames.begin(); it != collectionNames.end(); ++it)
- {
- const string& collection = *it;
+ for (list<string>::iterator it = collectionNames.begin(); it != collectionNames.end(); ++it) {
+ const string& collection = *it;
- scoped_ptr<DBClientCursor> cursor(_client.query(collection, BSONObj()).release());
- ASSERT(cursor.get() != NULL);
+ scoped_ptr<DBClientCursor> cursor(_client.query(collection, BSONObj()).release());
+ ASSERT(cursor.get() != NULL);
- log() << "Dumping collection " << collection << endl;
+ log() << "Dumping collection " << collection << endl;
- while (cursor->more()) {
- BSONObj obj = cursor->nextSafe();
- log() << obj.toString() << endl;
- }
+ while (cursor->more()) {
+ BSONObj obj = cursor->nextSafe();
+ log() << obj.toString() << endl;
}
}
+}
- void ConfigServerFixture::tearDown() {
-
- clearServer();
-
- // Reset the pinger
- setLockPingerEnabled(true);
+void ConfigServerFixture::tearDown() {
+ clearServer();
- // Make all connections redirect to the direct client
- ConnectionString::setConnectionHook(NULL);
- delete _connectHook;
- _connectHook = NULL;
+ // Reset the pinger
+ setLockPingerEnabled(true);
- DBException::traceExceptions = false;
- }
+ // Make all connections redirect to the direct client
+ ConnectionString::setConnectionHook(NULL);
+ delete _connectHook;
+ _connectHook = NULL;
+ DBException::traceExceptions = false;
+}
}