diff options
author | Jack Mulrow <jack.mulrow@mongodb.com> | 2018-08-29 14:37:23 -0400 |
---|---|---|
committer | Jack Mulrow <jack.mulrow@mongodb.com> | 2018-09-06 18:46:12 -0400 |
commit | 3257bb958a29a23d5101a16c49d97536e5fba056 (patch) | |
tree | 54871c65289f89b954e2e91f183aac00ea730443 /src/mongo/s/commands/cluster_insert_test.cpp | |
parent | b4f3327901f58083d376064a6d89680325b26964 (diff) | |
download | mongo-3257bb958a29a23d5101a16c49d97536e5fba056.tar.gz |
SERVER-36557 Compute atClusterTime for cluster batch writes and findAndModify
Diffstat (limited to 'src/mongo/s/commands/cluster_insert_test.cpp')
-rw-r--r-- | src/mongo/s/commands/cluster_insert_test.cpp | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/src/mongo/s/commands/cluster_insert_test.cpp b/src/mongo/s/commands/cluster_insert_test.cpp new file mode 100644 index 00000000000..652b9bada42 --- /dev/null +++ b/src/mongo/s/commands/cluster_insert_test.cpp @@ -0,0 +1,76 @@ +/** + * Copyright (C) 2018 MongoDB Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * As a special exception, the copyright holders give permission to link the + * code of portions of this program with the OpenSSL library under certain + * conditions as described in each individual source file and distribute + * linked combinations including the program with the OpenSSL library. You + * must comply with the GNU Affero General Public License in all respects + * for all of the code used other than as permitted herein. If you modify + * file(s) with this exception, you may extend this exception to your + * version of the file(s), but you are not obligated to do so. If you do not + * wish to do so, delete this exception statement from your version. If you + * delete this exception statement from all source files in the program, + * then also delete it in the license file. + */ + +#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kDefault + +#include "mongo/platform/basic.h" + +#include "mongo/db/commands.h" +#include "mongo/s/commands/cluster_command_test_fixture.h" +#include "mongo/util/log.h" + +namespace mongo { +namespace { + +class ClusterInsertTest : public ClusterCommandTestFixture { +protected: + const BSONObj kInsertCmdTargeted{fromjson("{insert: 'coll', documents: [{'_id': -1}]}")}; + + const BSONObj kInsertCmdScatterGather{ + fromjson("{insert: 'coll', documents: [{'_id': -1}, {'_id': 1}], ordered: false}")}; + + void expectInspectRequest(int shardIndex, InspectionCallback cb) override { + onCommandForPoolExecutor([&](const executor::RemoteCommandRequest& request) { + ASSERT_EQ(kNss.coll(), request.cmdObj.firstElement().valueStringData()); + cb(request); + return BSON("nInserted" << 1); + }); + } + + void expectReturnsSuccess(int shardIndex) override { + onCommandForPoolExecutor([this, shardIndex](const executor::RemoteCommandRequest& request) { + ASSERT_EQ(kNss.coll(), request.cmdObj.firstElement().valueStringData()); + return BSON("nInserted" << 1); + }); + } +}; + +TEST_F(ClusterInsertTest, NoErrors) { + testNoErrors(kInsertCmdTargeted, kInsertCmdScatterGather); +} + +TEST_F(ClusterInsertTest, AttachesAtClusterTimeForSnapshotReadConcern) { + testAttachesAtClusterTimeForSnapshotReadConcern(kInsertCmdTargeted, kInsertCmdScatterGather); +} + +TEST_F(ClusterInsertTest, SnapshotReadConcernWithAfterClusterTime) { + testSnapshotReadConcernWithAfterClusterTime(kInsertCmdTargeted, kInsertCmdScatterGather); +} + +} // namespace +} // namespace mongo |