summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/pipeline_test.cpp
diff options
context:
space:
mode:
authorMatthew Russotto <matthew.russotto@10gen.com>2018-03-19 10:19:05 -0400
committerMatthew Russotto <matthew.russotto@10gen.com>2018-03-19 13:45:22 -0400
commit4ce3eca38b5e8c786c33242c1a625728e1c1dcfe (patch)
tree7d6944ca8f913f07c17d74063f70dec7026bc9af /src/mongo/db/pipeline/pipeline_test.cpp
parentf7492502bfb24d1067e810ba9fd08e62f9a11c13 (diff)
downloadmongo-4ce3eca38b5e8c786c33242c1a625728e1c1dcfe.tar.gz
SERVER-33551 Switch Pipeline to use session interface to determine if in a transaction or snapshot read.
Diffstat (limited to 'src/mongo/db/pipeline/pipeline_test.cpp')
-rw-r--r--src/mongo/db/pipeline/pipeline_test.cpp88
1 files changed, 44 insertions, 44 deletions
diff --git a/src/mongo/db/pipeline/pipeline_test.cpp b/src/mongo/db/pipeline/pipeline_test.cpp
index 19df0485811..23497f83e41 100644
--- a/src/mongo/db/pipeline/pipeline_test.cpp
+++ b/src/mongo/db/pipeline/pipeline_test.cpp
@@ -1088,20 +1088,20 @@ TEST(PipelineOptimizationTest,
// optimizations, but it currently does not.
TEST(PipelineOptimizationTest, MatchOnArrayIndexShouldNotSwapSinceCategoryIsArrayMatching) {
string inputPipe = R"(
- [{$project: {_id: true, a: '$b'}},
- {$match: {a: {$_internalSchemaMatchArrayIndex:
+ [{$project: {_id: true, a: '$b'}},
+ {$match: {a: {$_internalSchemaMatchArrayIndex:
{index: 0, namePlaceholder: 'i', expression: {i: {$lt: 0}}}}}}])";
assertPipelineOptimizesTo(inputPipe, inputPipe);
inputPipe = R"(
- [{$project: {redacted: false}},
- {$match: {a: {$_internalSchemaMatchArrayIndex:
+ [{$project: {redacted: false}},
+ {$match: {a: {$_internalSchemaMatchArrayIndex:
{index: 0, namePlaceholder: 'i', expression: {i: {$lt: 0}}}}}}])";
assertPipelineOptimizesTo(inputPipe, inputPipe);
inputPipe = R"(
- [{$addFields : {a : {$const: 1}}},
- {$match: {a: {$_internalSchemaMatchArrayIndex:
+ [{$addFields : {a : {$const: 1}}},
+ {$match: {a: {$_internalSchemaMatchArrayIndex:
{index: 0, namePlaceholder: 'i', expression: {i: {$lt: 0}}}}}}])";
assertPipelineOptimizesTo(inputPipe, inputPipe);
}
@@ -1207,79 +1207,79 @@ TEST(PipelineOptimizationTest, MatchOnMaxPropertiesShouldNotSwapSinceCategoryIsO
// optimizations, but it currently does not.
TEST(PipelineOptimizationTest, MatchOnAllowedPropertiesShouldNotSwapSinceCategoryIsOther) {
string inputPipe = R"(
- [{$project: {_id: true, a: '$b'}},
+ [{$project: {_id: true, a: '$b'}},
{$match: {$_internalSchemaAllowedProperties: {
- properties: ['b'],
- namePlaceholder: 'i',
- patternProperties: [],
+ properties: ['b'],
+ namePlaceholder: 'i',
+ patternProperties: [],
otherwise: {i: 1}
}}}])";
string outputPipe = R"(
- [{$project: {_id: true, a: '$b'}},
+ [{$project: {_id: true, a: '$b'}},
{$match: {$_internalSchemaAllowedProperties: {
- properties: ['b'],
- namePlaceholder: 'i',
- patternProperties: [],
+ properties: ['b'],
+ namePlaceholder: 'i',
+ patternProperties: [],
otherwise: {i: {$eq : 1}}
}}}])";
string serializedPipe = R"(
- [{$project: {_id: true, a: '$b'}},
+ [{$project: {_id: true, a: '$b'}},
{$match: {$_internalSchemaAllowedProperties: {
- properties: ['b'],
- namePlaceholder: 'i',
- patternProperties: [],
+ properties: ['b'],
+ namePlaceholder: 'i',
+ patternProperties: [],
otherwise: {i : 1}}
}}])";
assertPipelineOptimizesAndSerializesTo(inputPipe, outputPipe, serializedPipe);
inputPipe = R"(
- [{$project: {redacted: false}},
+ [{$project: {redacted: false}},
{$match: {$_internalSchemaAllowedProperties: {
- properties: ['b'],
- namePlaceholder: 'i',
- patternProperties: [],
+ properties: ['b'],
+ namePlaceholder: 'i',
+ patternProperties: [],
otherwise: {i: 1}
}}}])";
outputPipe = R"(
- [{$project: {redacted: false}},
+ [{$project: {redacted: false}},
{$match: {$_internalSchemaAllowedProperties: {
- properties: ['b'],
- namePlaceholder: 'i',
- patternProperties: [],
+ properties: ['b'],
+ namePlaceholder: 'i',
+ patternProperties: [],
otherwise: {i: {$eq: 1}
}}}}])";
serializedPipe = R"(
- [{$project: {redacted: false}},
+ [{$project: {redacted: false}},
{$match: {$_internalSchemaAllowedProperties: {
- properties: ['b'],
- namePlaceholder: 'i',
- patternProperties: [],
+ properties: ['b'],
+ namePlaceholder: 'i',
+ patternProperties: [],
otherwise: {i: 1}
}}}])";
assertPipelineOptimizesAndSerializesTo(inputPipe, outputPipe, serializedPipe);
inputPipe = R"(
- [{$addFields : {a : {$const: 1}}},
+ [{$addFields : {a : {$const: 1}}},
{$match: {$_internalSchemaAllowedProperties: {
- properties: ['b'],
- namePlaceholder: 'i',
- patternProperties: [],
+ properties: ['b'],
+ namePlaceholder: 'i',
+ patternProperties: [],
otherwise: {i: 1}
}}}])";
outputPipe = R"(
- [{$addFields: {a: {$const: 1}}},
+ [{$addFields: {a: {$const: 1}}},
{$match: {$_internalSchemaAllowedProperties: {
- properties: ["b"],
- namePlaceholder: "i",
- patternProperties: [],
+ properties: ["b"],
+ namePlaceholder: "i",
+ patternProperties: [],
otherwise: {i: {$eq: 1}
}}}}])";
serializedPipe = R"(
- [{$addFields : {a : {$const: 1}}},
+ [{$addFields : {a : {$const: 1}}},
{$match: {$_internalSchemaAllowedProperties: {
- properties: ['b'],
- namePlaceholder: 'i',
- patternProperties: [],
+ properties: ['b'],
+ namePlaceholder: 'i',
+ patternProperties: [],
otherwise: {i: 1}
}}}])";
assertPipelineOptimizesAndSerializesTo(inputPipe, outputPipe, serializedPipe);
@@ -2463,7 +2463,7 @@ TEST_F(PipelineValidateTest, TopLevelPipelineValidatedForStagesIllegalWithSnapsh
auto&& readConcernArgs = repl::ReadConcernArgs::get(ctx->opCtx);
ASSERT_OK(readConcernArgs.initialize(readConcernSnapshot["readConcern"]));
ASSERT(readConcernArgs.getLevel() == repl::ReadConcernLevel::kSnapshotReadConcern);
- ctx->opCtx->setWriteUnitOfWork(stdx::make_unique<WriteUnitOfWork>(ctx->opCtx));
+ ctx->inSnapshotReadOrMultiDocumentTransaction = true;
// Make a pipeline with a legal $match, and then an illegal mock stage, and verify that pipeline
// creation fails with the expected error code.
@@ -2481,7 +2481,7 @@ TEST_F(PipelineValidateTest, FacetPipelineValidatedForStagesIllegalWithSnapshotR
auto&& readConcernArgs = repl::ReadConcernArgs::get(ctx->opCtx);
ASSERT_OK(readConcernArgs.initialize(readConcernSnapshot["readConcern"]));
ASSERT(readConcernArgs.getLevel() == repl::ReadConcernLevel::kSnapshotReadConcern);
- ctx->opCtx->setWriteUnitOfWork(stdx::make_unique<WriteUnitOfWork>(ctx->opCtx));
+ ctx->inSnapshotReadOrMultiDocumentTransaction = true;
// Make a pipeline with a legal $match, and then an illegal mock stage, and verify that pipeline
// creation fails with the expected error code.