summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenrik Edin <henrik.edin@mongodb.com>2018-05-17 11:10:26 -0400
committerHenrik Edin <henrik.edin@mongodb.com>2018-05-17 12:04:01 -0400
commitb5f4020637b6a5a1b18a0735c65212fe03b3a60b (patch)
tree80a1d44a696a66725d688192a078b97dfaf5ab89
parent04fc6cc223b1599131d912c7e3654001f561b07b (diff)
downloadmongo-b5f4020637b6a5a1b18a0735c65212fe03b3a60b.tar.gz
SERVER-33889 Embedded listcommands test to verify command list.
-rw-r--r--src/mongo/client/embedded/libmongodbcapi_test.cpp132
1 files changed, 132 insertions, 0 deletions
diff --git a/src/mongo/client/embedded/libmongodbcapi_test.cpp b/src/mongo/client/embedded/libmongodbcapi_test.cpp
index 6b96beb3065..49700732031 100644
--- a/src/mongo/client/embedded/libmongodbcapi_test.cpp
+++ b/src/mongo/client/embedded/libmongodbcapi_test.cpp
@@ -518,6 +518,138 @@ TEST_F(MongodbCAPITest, InsertAndUpdate) {
ASSERT(outputBSON2.getIntField("nModified") == 1);
}
+TEST_F(MongodbCAPITest, RunListCommands) {
+ auto client = createClient();
+
+ std::vector<std::string> whitelist = {"_hashBSONElement",
+ "_isSelf",
+ "aggregate",
+ "authenticate",
+ "buildInfo",
+ "captrunc",
+ "clearLog",
+ "cloneCollectionAsCapped",
+ "collMod",
+ "collStats",
+ "configureFailPoint",
+ "connPoolStats",
+ "connPoolSync",
+ "connectionStatus",
+ "convertToCapped",
+ "count",
+ "create",
+ "createIndexes",
+ "currentOp",
+ "dataSize",
+ "dbStats",
+ "delete",
+ "distinct",
+ "drop",
+ "dropDatabase",
+ "dropIndexes",
+ "echo",
+ "emptycapped",
+ "endSessions",
+ "explain",
+ "features",
+ "find",
+ "findAndModify",
+ "geoNear",
+ "getCmdLineOpts",
+ "getLastError",
+ "getLog",
+ "getMore",
+ "getParameter",
+ "getPrevError",
+ "getShardMap",
+ "getnonce",
+ "godinsert",
+ "hostInfo",
+ "insert",
+ "isMaster",
+ "killAllSessions",
+ "killAllSessionsByPattern",
+ "killCursors",
+ "killOp",
+ "killSessions",
+ "listCollections",
+ "listCommands",
+ "listDatabases",
+ "listIndexes",
+ "lockInfo",
+ "logRotate",
+ "logout",
+ "ping",
+ "planCacheClear",
+ "planCacheClearFilters",
+ "planCacheListFilters",
+ "planCacheListPlans",
+ "planCacheListQueryShapes",
+ "planCacheSetFilter",
+ "reIndex",
+ "reapLogicalSessionCacheNow",
+ "refreshLogicalSessionCacheNow",
+ "refreshSessions",
+ "refreshSessionsInternal",
+ "renameCollection",
+ "repairCursor",
+ "repairDatabase",
+ "replSetGetStatus",
+ "resetError",
+ "saslContinue",
+ "saslStart",
+ "serverStatus",
+ "setBatteryLevel",
+ "setParameter",
+ "shardConnPoolStats",
+ "sleep",
+ "startSession",
+ "trimMemory",
+ "update",
+ "validate",
+ "whatsmyuri"};
+ std::sort(whitelist.begin(), whitelist.end());
+
+ mongo::BSONObj listCommandsObj = mongo::fromjson("{ listCommands: 1 }");
+ auto listCommandsOpMsg = mongo::OpMsgRequest::fromDBAndBody("db_name", listCommandsObj);
+ auto output = performRpc(client, listCommandsOpMsg);
+ auto commandsBSON = output["commands"];
+ std::vector<std::string> commands;
+ for (const auto& element : commandsBSON.Obj()) {
+ commands.push_back(element.fieldNameStringData().toString());
+ }
+ std::sort(commands.begin(), commands.end());
+
+ std::vector<std::string> missing;
+ std::vector<std::string> unsupported;
+ std::set_difference(whitelist.begin(),
+ whitelist.end(),
+ commands.begin(),
+ commands.end(),
+ std::back_inserter(missing));
+ std::set_difference(commands.begin(),
+ commands.end(),
+ whitelist.begin(),
+ whitelist.end(),
+ std::back_inserter(unsupported));
+
+ if (!missing.empty()) {
+ std::cout << "\nMissing commands from the embedded binary:\n";
+ }
+ for (auto&& cmd : missing) {
+ std::cout << cmd << "\n";
+ }
+ if (!unsupported.empty()) {
+ std::cout << "\nUnsupported commands in the embedded binary:\n";
+ }
+ for (auto&& cmd : unsupported) {
+ std::cout << cmd << "\n";
+ }
+
+ ASSERT(missing.empty());
+ ASSERT(unsupported.empty());
+}
+
// This test is temporary to make sure that only one database can be created
// This restriction may be relaxed at a later time
TEST_F(MongodbCAPITest, CreateMultipleDBs) {