summaryrefslogtreecommitdiff
path: root/src/mongo/embedded
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/embedded')
-rw-r--r--src/mongo/embedded/SConscript3
-rw-r--r--src/mongo/embedded/embedded.cpp8
-rw-r--r--src/mongo/embedded/mongo_embedded/SConscript1
-rw-r--r--src/mongo/embedded/mongo_embedded/mongo_embedded_test.cpp126
-rw-r--r--src/mongo/embedded/replication_coordinator_embedded.cpp3
-rw-r--r--src/mongo/embedded/replication_coordinator_embedded.h2
-rw-r--r--src/mongo/embedded/stitch_support/SConscript2
7 files changed, 125 insertions, 20 deletions
diff --git a/src/mongo/embedded/SConscript b/src/mongo/embedded/SConscript
index c98aa087db4..879b5033969 100644
--- a/src/mongo/embedded/SConscript
+++ b/src/mongo/embedded/SConscript
@@ -88,7 +88,8 @@ env.Library(
'$BUILD_DIR/mongo/db/commands/standalone',
'$BUILD_DIR/mongo/db/concurrency/lock_manager',
'$BUILD_DIR/mongo/db/fcv_op_observer',
- '$BUILD_DIR/mongo/db/index/index_access_method',
+ '$BUILD_DIR/mongo/db/index/index_access_method_factory',
+ '$BUILD_DIR/mongo/db/index/index_access_methods',
'$BUILD_DIR/mongo/db/index_builds_coordinator_interface',
'$BUILD_DIR/mongo/db/logical_session_cache',
'$BUILD_DIR/mongo/db/logical_session_cache_impl',
diff --git a/src/mongo/embedded/embedded.cpp b/src/mongo/embedded/embedded.cpp
index 53954a9f07e..20395926254 100644
--- a/src/mongo/embedded/embedded.cpp
+++ b/src/mongo/embedded/embedded.cpp
@@ -39,6 +39,7 @@
#include "mongo/db/catalog/collection_catalog.h"
#include "mongo/db/catalog/collection_impl.h"
#include "mongo/db/catalog/database_holder_impl.h"
+#include "mongo/db/catalog/health_log.h"
#include "mongo/db/catalog/index_key_validate.h"
#include "mongo/db/client.h"
#include "mongo/db/commands/feature_compatibility_version.h"
@@ -46,6 +47,7 @@
#include "mongo/db/concurrency/lock_state.h"
#include "mongo/db/dbdirectclient.h"
#include "mongo/db/global_settings.h"
+#include "mongo/db/index/index_access_method_factory_impl.h"
#include "mongo/db/kill_sessions_local.h"
#include "mongo/db/logical_session_cache_impl.h"
#include "mongo/db/op_observer_impl.h"
@@ -101,6 +103,7 @@ MONGO_INITIALIZER_GENERAL(ForkServer, ("EndStartupOptionHandling"), ("default"))
void setUpCatalog(ServiceContext* serviceContext) {
DatabaseHolder::set(serviceContext, std::make_unique<DatabaseHolderImpl>());
+ IndexAccessMethodFactory::set(serviceContext, std::make_unique<IndexAccessMethodFactoryImpl>());
Collection::Factory::set(serviceContext, std::make_unique<CollectionImpl::FactoryImpl>());
}
@@ -125,7 +128,7 @@ GlobalInitializerRegisterer filterAllowedIndexFieldNamesEmbeddedInitializer(
"FilterAllowedIndexFieldNamesEmbedded",
[](InitializerContext* service) {
index_key_validate::filterAllowedIndexFieldNames =
- [](std::map<StringData, std::set<IndexType>>& allowedIndexFieldNames) {
+ [](std::set<StringData>& allowedIndexFieldNames) {
allowedIndexFieldNames.erase(IndexDescriptor::kBackgroundFieldName);
allowedIndexFieldNames.erase(IndexDescriptor::kExpireAfterSecondsFieldName);
};
@@ -166,8 +169,7 @@ void shutdown(ServiceContext* srvContext) {
LogicalSessionCache::set(serviceContext, nullptr);
- repl::ReplicationCoordinator::get(serviceContext)
- ->shutdown(shutdownOpCtx.get(), nullptr /* shutdownTimeElapsedBuilder */);
+ repl::ReplicationCoordinator::get(serviceContext)->shutdown(shutdownOpCtx.get());
IndexBuildsCoordinator::get(serviceContext)->shutdown(shutdownOpCtx.get());
// Global storage engine may not be started in all cases before we exit
diff --git a/src/mongo/embedded/mongo_embedded/SConscript b/src/mongo/embedded/mongo_embedded/SConscript
index 7a5f2043d6b..8f84ee065d5 100644
--- a/src/mongo/embedded/mongo_embedded/SConscript
+++ b/src/mongo/embedded/mongo_embedded/SConscript
@@ -94,7 +94,6 @@ if get_option('link-model') != 'dynamic-sdk':
],
LIBDEPS=[
'$BUILD_DIR/mongo/base',
- '$BUILD_DIR/mongo/bson/bson_validate',
'$BUILD_DIR/mongo/db/commands/test_commands_enabled',
'$BUILD_DIR/mongo/db/server_options_core',
'$BUILD_DIR/mongo/rpc/message',
diff --git a/src/mongo/embedded/mongo_embedded/mongo_embedded_test.cpp b/src/mongo/embedded/mongo_embedded/mongo_embedded_test.cpp
index 4a9945875f9..7d728bf451a 100644
--- a/src/mongo/embedded/mongo_embedded/mongo_embedded_test.cpp
+++ b/src/mongo/embedded/mongo_embedded/mongo_embedded_test.cpp
@@ -35,7 +35,6 @@
#include <yaml-cpp/yaml.h>
#include "mongo/base/initializer.h"
-#include "mongo/bson/bson_validate.h"
#include "mongo/bson/bsonobjbuilder.h"
#include "mongo/db/commands/test_commands_enabled.h"
#include "mongo/db/json.h"
@@ -195,7 +194,7 @@ protected:
// convert the message into an OpMessage to examine its BSON
auto outputOpMsg = mongo::OpMsg::parseOwned(outputMessage);
- ASSERT_OK(mongo::validateBSON(outputOpMsg.body));
+ ASSERT(outputOpMsg.body.valid());
return outputOpMsg.body;
}
@@ -408,7 +407,7 @@ TEST_F(MongodbCAPITest, ReadDB) {
auto outputBSON = performRpc(client, findMsg);
- ASSERT_OK(mongo::validateBSON(outputBSON));
+ ASSERT(outputBSON.valid());
ASSERT(outputBSON.hasField("cursor"));
ASSERT(outputBSON.getField("cursor").embeddedObject().hasField("firstBatch"));
mongo::BSONObj arrObj =
@@ -433,7 +432,7 @@ TEST_F(MongodbCAPITest, InsertAndRead) {
"{insert: 'collection_name', documents: [{firstName: 'Mongo', lastName: 'DB', age: 10}]}");
auto insertOpMsg = mongo::OpMsgRequest::fromDBAndBody("db_name", insertObj);
auto outputBSON1 = performRpc(client, insertOpMsg);
- ASSERT_OK(mongo::validateBSON(outputBSON1));
+ ASSERT(outputBSON1.valid());
ASSERT(outputBSON1.hasField("n"));
ASSERT(outputBSON1.getIntField("n") == 1);
ASSERT(outputBSON1.hasField("ok"));
@@ -442,7 +441,7 @@ TEST_F(MongodbCAPITest, InsertAndRead) {
mongo::BSONObj findObj = mongo::fromjson("{find: 'collection_name', limit: 1}");
auto findMsg = mongo::OpMsgRequest::fromDBAndBody("db_name", findObj);
auto outputBSON2 = performRpc(client, findMsg);
- ASSERT_OK(mongo::validateBSON(outputBSON2));
+ ASSERT(outputBSON2.valid());
ASSERT(outputBSON2.hasField("cursor"));
ASSERT(outputBSON2.getField("cursor").embeddedObject().hasField("firstBatch"));
mongo::BSONObj arrObj =
@@ -468,7 +467,7 @@ TEST_F(MongodbCAPITest, InsertAndReadDifferentClients) {
"{insert: 'collection_name', documents: [{firstName: 'Mongo', lastName: 'DB', age: 10}]}");
auto insertOpMsg = mongo::OpMsgRequest::fromDBAndBody("db_name", insertObj);
auto outputBSON1 = performRpc(client1, insertOpMsg);
- ASSERT_OK(mongo::validateBSON(outputBSON1));
+ ASSERT(outputBSON1.valid());
ASSERT(outputBSON1.hasField("n"));
ASSERT(outputBSON1.getIntField("n") == 1);
ASSERT(outputBSON1.hasField("ok"));
@@ -477,7 +476,7 @@ TEST_F(MongodbCAPITest, InsertAndReadDifferentClients) {
mongo::BSONObj findObj = mongo::fromjson("{find: 'collection_name', limit: 1}");
auto findMsg = mongo::OpMsgRequest::fromDBAndBody("db_name", findObj);
auto outputBSON2 = performRpc(client2, findMsg);
- ASSERT_OK(mongo::validateBSON(outputBSON2));
+ ASSERT(outputBSON2.valid());
ASSERT(outputBSON2.hasField("cursor"));
ASSERT(outputBSON2.getField("cursor").embeddedObject().hasField("firstBatch"));
mongo::BSONObj arrObj =
@@ -502,7 +501,7 @@ TEST_F(MongodbCAPITest, InsertAndDelete) {
"age: 10}]}");
auto insertOpMsg = mongo::OpMsgRequest::fromDBAndBody("db_name", insertObj);
auto outputBSON1 = performRpc(client, insertOpMsg);
- ASSERT_OK(mongo::validateBSON(outputBSON1));
+ ASSERT(outputBSON1.valid());
ASSERT(outputBSON1.hasField("n"));
ASSERT(outputBSON1.getIntField("n") == 1);
ASSERT(outputBSON1.hasField("ok"));
@@ -515,7 +514,7 @@ TEST_F(MongodbCAPITest, InsertAndDelete) {
"1}]}");
auto deleteOpMsg = mongo::OpMsgRequest::fromDBAndBody("db_name", deleteObj);
auto outputBSON2 = performRpc(client, deleteOpMsg);
- ASSERT_OK(mongo::validateBSON(outputBSON2));
+ ASSERT(outputBSON2.valid());
ASSERT(outputBSON2.hasField("n"));
ASSERT(outputBSON2.getIntField("n") == 1);
ASSERT(outputBSON2.hasField("ok"));
@@ -531,7 +530,7 @@ TEST_F(MongodbCAPITest, InsertAndUpdate) {
"age: 10}]}");
auto insertOpMsg = mongo::OpMsgRequest::fromDBAndBody("db_name", insertObj);
auto outputBSON1 = performRpc(client, insertOpMsg);
- ASSERT_OK(mongo::validateBSON(outputBSON1));
+ ASSERT(outputBSON1.valid());
ASSERT(outputBSON1.hasField("n"));
ASSERT(outputBSON1.getIntField("n") == 1);
ASSERT(outputBSON1.hasField("ok"));
@@ -544,13 +543,118 @@ TEST_F(MongodbCAPITest, InsertAndUpdate) {
"{age: 5}}}]}");
auto updateOpMsg = mongo::OpMsgRequest::fromDBAndBody("db_name", updateObj);
auto outputBSON2 = performRpc(client, updateOpMsg);
- ASSERT_OK(mongo::validateBSON(outputBSON2));
+ ASSERT(outputBSON2.valid());
ASSERT(outputBSON2.hasField("ok"));
ASSERT(outputBSON2.getField("ok").numberDouble() == 1.0);
ASSERT(outputBSON2.hasField("nModified"));
ASSERT(outputBSON2.getIntField("nModified") == 1);
}
+TEST_F(MongodbCAPITest, RunListCommands) {
+ auto client = createClient();
+
+ std::vector<std::string> allowlist = {"_hashBSONElement",
+ "_killOperations",
+ "aggregate",
+ "buildInfo",
+ "collMod",
+ "collStats",
+ "configureFailPoint",
+ "count",
+ "create",
+ "createIndexes",
+ "currentOp",
+ "dataSize",
+ "dbStats",
+ "delete",
+ "distinct",
+ "drop",
+ "dropDatabase",
+ "dropIndexes",
+ "echo",
+ "endSessions",
+ "explain",
+ "find",
+ "findAndModify",
+ "getLastError",
+ "getMore",
+ "getParameter",
+ "httpClientRequest",
+ "insert",
+ "isMaster",
+ "killCursors",
+ "killOp",
+ "killSessions",
+ "killAllSessions",
+ "killAllSessionsByPattern",
+ "listCollections",
+ "listCommands",
+ "listDatabases",
+ "listIndexes",
+ "lockInfo",
+ "logMessage",
+ "ping",
+ "planCacheClear",
+ "planCacheClearFilters",
+ "planCacheListFilters",
+ "planCacheSetFilter",
+ "reIndex",
+ "refreshLogicalSessionCacheNow",
+ "refreshSessions",
+ "renameCollection",
+ "repairDatabase",
+ "serverStatus",
+ "setParameter",
+ "sleep",
+ "startSession",
+ "update",
+ "validate",
+ "validateDBMetadata",
+ "waitForFailPoint",
+ "whatsmysni"};
+
+ std::sort(allowlist.begin(), allowlist.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(allowlist.begin(),
+ allowlist.end(),
+ commands.begin(),
+ commands.end(),
+ std::back_inserter(missing));
+ std::set_difference(commands.begin(),
+ commands.end(),
+ allowlist.begin(),
+ allowlist.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()) << mongo::StringSplitter::join(missing, ", ");
+ ASSERT(unsupported.empty()) << mongo::StringSplitter::join(unsupported, ", ");
+}
+
// 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) {
diff --git a/src/mongo/embedded/replication_coordinator_embedded.cpp b/src/mongo/embedded/replication_coordinator_embedded.cpp
index 236ed60aded..d0182bfce59 100644
--- a/src/mongo/embedded/replication_coordinator_embedded.cpp
+++ b/src/mongo/embedded/replication_coordinator_embedded.cpp
@@ -60,8 +60,7 @@ bool ReplicationCoordinatorEmbedded::inQuiesceMode() const {
return false;
}
-void ReplicationCoordinatorEmbedded::shutdown(OperationContext* opCtx,
- BSONObjBuilder* shutdownTimeElapsedBuilder) {}
+void ReplicationCoordinatorEmbedded::shutdown(OperationContext* opCtx) {}
const ReplSettings& ReplicationCoordinatorEmbedded::getSettings() const {
static ReplSettings _settings;
diff --git a/src/mongo/embedded/replication_coordinator_embedded.h b/src/mongo/embedded/replication_coordinator_embedded.h
index 09b5de25111..f2d29ddea37 100644
--- a/src/mongo/embedded/replication_coordinator_embedded.h
+++ b/src/mongo/embedded/replication_coordinator_embedded.h
@@ -54,7 +54,7 @@ public:
bool inQuiesceMode() const override;
- void shutdown(OperationContext* opCtx, BSONObjBuilder* shutdownTimeElapsedBuilder) override;
+ void shutdown(OperationContext* opCtx) override;
// Returns the ServiceContext where this instance runs.
ServiceContext* getServiceContext() override {
diff --git a/src/mongo/embedded/stitch_support/SConscript b/src/mongo/embedded/stitch_support/SConscript
index 7206c33a1ce..8ab94cb83c9 100644
--- a/src/mongo/embedded/stitch_support/SConscript
+++ b/src/mongo/embedded/stitch_support/SConscript
@@ -43,7 +43,7 @@ stitchSupportTargets = stitchSupportEnv.Library(
'stitch_support.cpp',
],
LIBDEPS_PRIVATE=[
- '$BUILD_DIR/mongo/db/index/index_access_method',
+ '$BUILD_DIR/mongo/db/index/index_access_methods',
'$BUILD_DIR/mongo/db/matcher/expressions',
'$BUILD_DIR/mongo/db/ops/parsed_update',
'$BUILD_DIR/mongo/db/query/collation/collator_factory_icu',