summaryrefslogtreecommitdiff
path: root/src/mongo/db/views
diff options
context:
space:
mode:
authorJames Wahlin <james.wahlin@10gen.com>2017-03-15 17:09:33 -0400
committerJames Wahlin <james.wahlin@10gen.com>2017-04-05 13:51:03 -0400
commitc3341d179db1c36722284676d99cb1c664fb1821 (patch)
treef69c9c00fc8df3ccf6db6df50a78319ff1e38950 /src/mongo/db/views
parent8765acc0fcc6ca3dd7158521ba8d864af4e0f2df (diff)
downloadmongo-c3341d179db1c36722284676d99cb1c664fb1821.tar.gz
SERVER-28040 Fix maxTimeMS/readPref/readConcern for sharded view query
Diffstat (limited to 'src/mongo/db/views')
-rw-r--r--src/mongo/db/views/resolved_view.cpp3
-rw-r--r--src/mongo/db/views/resolved_view_test.cpp42
2 files changed, 45 insertions, 0 deletions
diff --git a/src/mongo/db/views/resolved_view.cpp b/src/mongo/db/views/resolved_view.cpp
index 3376c05570d..fa0564113f8 100644
--- a/src/mongo/db/views/resolved_view.cpp
+++ b/src/mongo/db/views/resolved_view.cpp
@@ -85,6 +85,9 @@ AggregationRequest ResolvedView::asExpandedViewAggregation(
expandedRequest.setHint(request.getHint());
expandedRequest.setComment(request.getComment());
+ expandedRequest.setMaxTimeMS(request.getMaxTimeMS());
+ expandedRequest.setReadConcern(request.getReadConcern());
+ expandedRequest.setUnwrappedReadPref(request.getUnwrappedReadPref());
expandedRequest.setBypassDocumentValidation(request.shouldBypassDocumentValidation());
expandedRequest.setAllowDiskUse(request.shouldAllowDiskUse());
expandedRequest.setCollation(request.getCollation());
diff --git a/src/mongo/db/views/resolved_view_test.cpp b/src/mongo/db/views/resolved_view_test.cpp
index cd34a8e6cf4..05c47d3fd51 100644
--- a/src/mongo/db/views/resolved_view_test.cpp
+++ b/src/mongo/db/views/resolved_view_test.cpp
@@ -113,6 +113,48 @@ TEST(ResolvedViewTest, ExpandingAggRequestPreservesAllowDiskUse) {
ASSERT_TRUE(result.shouldAllowDiskUse());
}
+TEST(ResolvedViewTest, ExpandingAggRequestPreservesHint) {
+ const ResolvedView resolvedView{backingNss, emptyPipeline};
+ AggregationRequest aggRequest(viewNss, {});
+ aggRequest.setHint(BSON("a" << 1));
+
+ auto result = resolvedView.asExpandedViewAggregation(aggRequest);
+ ASSERT_BSONOBJ_EQ(result.getHint(), BSON("a" << 1));
+}
+
+TEST(ResolvedViewTest, ExpandingAggRequestPreservesReadPreference) {
+ const ResolvedView resolvedView{backingNss, emptyPipeline};
+ AggregationRequest aggRequest(viewNss, {});
+ aggRequest.setUnwrappedReadPref(BSON("$readPreference"
+ << "nearest"));
+
+ auto result = resolvedView.asExpandedViewAggregation(aggRequest);
+ ASSERT_BSONOBJ_EQ(result.getUnwrappedReadPref(),
+ BSON("$readPreference"
+ << "nearest"));
+}
+
+TEST(ResolvedViewTest, ExpandingAggRequestPreservesReadConcern) {
+ const ResolvedView resolvedView{backingNss, emptyPipeline};
+ AggregationRequest aggRequest(viewNss, {});
+ aggRequest.setReadConcern(BSON("level"
+ << "linearizable"));
+
+ auto result = resolvedView.asExpandedViewAggregation(aggRequest);
+ ASSERT_BSONOBJ_EQ(result.getReadConcern(),
+ BSON("level"
+ << "linearizable"));
+}
+
+TEST(ResolvedViewTest, ExpandingAggRequestPreservesMaxTimeMS) {
+ const ResolvedView resolvedView{backingNss, emptyPipeline};
+ AggregationRequest aggRequest(viewNss, {});
+ aggRequest.setMaxTimeMS(100u);
+
+ auto result = resolvedView.asExpandedViewAggregation(aggRequest);
+ ASSERT_EQ(result.getMaxTimeMS(), 100u);
+}
+
TEST(ResolvedViewTest, ExpandingAggRequestPreservesCollation) {
const ResolvedView resolvedView{backingNss, emptyPipeline};
AggregationRequest aggRequest(viewNss, {});