SERVER-94150 switch to v5 clang-format, reformat server (#34018)

GitOrigin-RevId: ff6b2194e3617a338d83597d96710b1b92a18940
This commit is contained in:
James Bronsted 2025-03-26 19:06:12 -04:00 committed by MongoDB Bot
parent f6640417b3
commit 95b4794340
804 changed files with 17130 additions and 23876 deletions

View File

@ -10,7 +10,7 @@
"--header-insertion=never",
],
"clangd.checkUpdates": true,
"clang-format.executable": "/opt/mongodbtoolchain/v4/bin/clang-format",
"clang-format.executable": "/opt/mongodbtoolchain/v5/bin/clang-format",
"clang-tidy.executable": "buildscripts/clang_tidy_vscode.py",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"

View File

@ -39,17 +39,17 @@ from buildscripts.mongo_toolchain import MongoToolchainError, get_mongo_toolchai
#
# Expected version of clang-format
CLANG_FORMAT_VERSION = "12.0.1"
CLANG_FORMAT_SHORT_VERSION = "12.0"
CLANG_FORMAT_SHORTER_VERSION = "120"
CLANG_FORMAT_VERSION = "19.1.7"
CLANG_FORMAT_SHORT_VERSION = "19.1"
CLANG_FORMAT_SHORTER_VERSION = "191"
# Name of clang-format as a binary
CLANG_FORMAT_PROGNAME = "clang-format"
TOOLCHAIN_VERSION = "v4"
TOOLCHAIN_VERSION = "v5"
CLANG_FORMAT_HTTP_DARWIN_CACHE = (
"http://mongodbtoolchain.build.10gen.cc/toolchain/osx/clang-format-12.0.1"
"https://mdb-build-public.s3.amazonaws.com/clang-format-osx-binaries/clang-format-19.1.7"
)
try:
@ -290,18 +290,23 @@ class ClangFormat(object):
FILES_RE = re.compile("\\.(h|hpp|ipp|cpp|js)$")
TPL_FILES_RE = re.compile("\\.tpl\\.")
def is_interesting_file(file_name):
"""Return true if this file should be checked."""
return (
file_name.startswith("jstests")
or file_name.startswith("src")
and not file_name.startswith("src/third_party/")
and not file_name.startswith("src/mongo/gotools/")
and not file_name.startswith("src/mongo/db/modules/enterprise/src/streams/third_party")
and not file_name.startswith("src/streams/third_party")
) and FILES_RE.search(file_name)
(
file_name.startswith("jstests")
or file_name.startswith("src")
and not file_name.startswith("src/third_party/")
and not file_name.startswith("src/mongo/gotools/")
and not file_name.startswith("src/mongo/db/modules/enterprise/src/streams/third_party")
and not file_name.startswith("src/streams/third_party")
)
and FILES_RE.search(file_name)
and not TPL_FILES_RE.search(file_name)
)
def get_list_from_lines(lines):

View File

@ -5,6 +5,7 @@
*/
// Loads data into the namespace 'aggdb.articles'.
import "jstests/aggregation/data/articles.js";
import {arrayEq} from "jstests/aggregation/extras/utils.js";
const testDB = db.getSiblingDB("aggdb");

View File

@ -4,6 +4,7 @@
* ]
*/
import "jstests/libs/query/sbe_assert_error_override.js";
import {executeAggregationTestCase} from "jstests/libs/query/aggregation_pipeline_utils.js";
const testDB = db.getSiblingDB(jsTestName());

View File

@ -4,6 +4,7 @@
* ]
*/
import "jstests/libs/query/sbe_assert_error_override.js";
import {executeAggregationTestCase} from "jstests/libs/query/aggregation_pipeline_utils.js";
const testDB = db.getSiblingDB(jsTestName());

View File

@ -4,6 +4,7 @@
// assumes_no_implicit_collection_creation_after_drop,
// ]
import "jstests/libs/query/sbe_assert_error_override.js";
import {assertErrorCode} from "jstests/aggregation/extras/utils.js";
const caseSensitive = {

View File

@ -1,6 +1,7 @@
// In SERVER-8951, $indexOfArray was introduced. In this file, we test the correctness and error
// cases of the expression.
import "jstests/libs/query/sbe_assert_error_override.js";
import {assertErrorCode, testExpression} from "jstests/aggregation/extras/utils.js";
var coll = db.indexofarray;

View File

@ -1,4 +1,5 @@
import "jstests/libs/query/sbe_assert_error_override.js";
import {executeAggregationTestCase} from "jstests/libs/query/aggregation_pipeline_utils.js";
const coll = db.regex_error_cases;

View File

@ -1,4 +1,5 @@
import "jstests/libs/query/sbe_assert_error_override.js";
import {assertErrorCode} from "jstests/aggregation/extras/utils.js";
var coll = db.reverseArray;

View File

@ -1,4 +1,5 @@
import "jstests/libs/query/sbe_assert_error_override.js";
import {assertErrorCode} from "jstests/aggregation/extras/utils.js";
let coll = db.sortArray;

View File

@ -1,6 +1,7 @@
// In SERVER-22580 and SERVER-51557, the $substrCP expression was introduced. In this file, we test
// the error cases and the intended behavior of this expression.
import "jstests/libs/query/sbe_assert_error_override.js";
import {assertErrorCode} from "jstests/aggregation/extras/utils.js";
var coll = db.substrCP;

View File

@ -1,5 +1,6 @@
// Aggregation $substrBytes tests.
import "jstests/libs/query/sbe_assert_error_override.js";
import {assertErrorCode} from "jstests/aggregation/extras/utils.js";
let t = db.jstests_aggregation_substr;

View File

@ -7,7 +7,6 @@
// requires_pipeline_optimization,
// ]
import {arrayEq, orderedArrayEq} from "jstests/aggregation/extras/utils.js";
import {aggPlanHasStage} from "jstests/libs/query/analyze_plan.js";
const coll = db.graphlookup_rewrite;

View File

@ -14,13 +14,10 @@ for (let i = 0; i < nItems; i++) {
assert.commandWorked(coll.insert({_id: i}));
}
[1,
nItems,
nItems + 1]
.forEach(function(size) {
const results = coll.aggregate([{$sample: {size: size}}]).toArray();
assert.eq(results.length, Math.min(size, nItems));
});
[1, nItems, nItems + 1].forEach(function(size) {
const results = coll.aggregate([{$sample: {size: size}}]).toArray();
assert.eq(results.length, Math.min(size, nItems));
});
// Multiple $sample stages are allowed.
const results = coll.aggregate([{$sample: {size: nItems}}, {$sample: {size: 1}}]).toArray();

View File

@ -2,6 +2,7 @@
* Test the behavior of $integral.
*/
import "jstests/libs/query/sbe_assert_error_override.js";
import {documentBounds} from "jstests/aggregation/extras/window_function_helpers.js";
const coll = db.setWindowFields_integral;

View File

@ -6,6 +6,7 @@
*/
import "jstests/libs/query/sbe_assert_error_override.js";
import {FixtureHelpers} from "jstests/libs/fixture_helpers.js";
const coll = db.runtime_constants;

View File

@ -76,39 +76,37 @@ function runTest(conn, authEnabled) {
testCases.forEach((test) => runTestcase(conn, test, authEnabled));
}
[true,
false]
.forEach(function(authEnabled) {
{
// Test standalone.
const opts = {useHostname: false};
if (authEnabled) {
opts.auth = '';
}
const m = MongoRunner.runMongod(opts);
// localhostAuthBypass should allow buildInfo to work with auth enabled,
// even though we're not yet authenticated.
runTestcase(m, {mode: null, expect: 'success'}, false);
// Now (order is important), create users and run the tests
// expecting auth-enabled mode failure.
runTest(m, authEnabled);
MongoRunner.stopMongod(m);
[true, false].forEach(function(authEnabled) {
{
// Test standalone.
const opts = {useHostname: false};
if (authEnabled) {
opts.auth = '';
}
const m = MongoRunner.runMongod(opts);
// localhostAuthBypass should allow buildInfo to work with auth enabled,
// even though we're not yet authenticated.
runTestcase(m, {mode: null, expect: 'success'}, false);
{
// Test sharded.
const opts = {shards: 1, mongos: 1, config: 1};
if (authEnabled) {
opts.other = {keyFile: 'jstests/libs/key1'};
}
const st = new ShardingTest(opts);
if (authEnabled) {
// localhostAuthBypass only applies to shards, so we should fail pre-auth.
runTestcase(st.s0, {mode: null, expect: 'fail'}, false);
}
runTest(st.s0, authEnabled);
st.stop();
// Now (order is important), create users and run the tests
// expecting auth-enabled mode failure.
runTest(m, authEnabled);
MongoRunner.stopMongod(m);
}
{
// Test sharded.
const opts = {shards: 1, mongos: 1, config: 1};
if (authEnabled) {
opts.other = {keyFile: 'jstests/libs/key1'};
}
});
const st = new ShardingTest(opts);
if (authEnabled) {
// localhostAuthBypass only applies to shards, so we should fail pre-auth.
runTestcase(st.s0, {mode: null, expect: 'fail'}, false);
}
runTest(st.s0, authEnabled);
st.stop();
}
});

View File

@ -5,8 +5,10 @@ import {
assertCreateCollection,
assertDropCollection
} from "jstests/libs/collection_drop_recreate.js";
import {runCommandChangeStreamPassthroughAware} from "jstests/libs/query/change_stream_util.js";
import {ChangeStreamTest} from "jstests/libs/query/change_stream_util.js";
import {
ChangeStreamTest,
runCommandChangeStreamPassthroughAware
} from "jstests/libs/query/change_stream_util.js";
// Drop the test collections to assure a clean run.
const collName = jsTestName();

View File

@ -18,6 +18,7 @@
*/
import "jstests/libs/override_methods/retry_on_killed_session.js";
import {extendWorkload} from "jstests/concurrency/fsm_libs/extend_workload.js";
import {
$config as $baseConfig

View File

@ -70,7 +70,7 @@ export const $config = (function() {
runQueryStatsWithHmac: (db, collName) => runQueryStats({db: db, options: hmacOptions}),
runQueryStatsWithoutHmac: (db, collName) => runQueryStats({db: db, options: {}}),
init: (db, collName) => { /* no op */ },
init: (db, collName) => {/* no op */},
};
const transitions = {

View File

@ -40,7 +40,7 @@ while (hugeStr.length < 2 * 1024 * 1024) {
coll.find({a: hugeStr}).itcount();
var results = coll.getDB().system.profile.find().toArray();
assertContainsTruncatedCommand(results,
/filter: { a: "a+\.\.\." }//* string value is truncated*/,
/filter: { a: "a+\.\.\." }/ /* string value is truncated*/,
"Document corresponding to 'find' command not found.");
assert.commandWorked(coll.getDB().runCommand({profile: 0}));
@ -53,7 +53,7 @@ assert.commandWorked(coll.update({a: hugeStr}, {}));
var results = coll.getDB().system.profile.find().toArray();
assertContainsTruncatedCommand(
results,
/^{ q: { a: "a+\.\.\." }, u: {}, multi: false, upsert: false }$//* string value is truncated*/,
/^{ q: { a: "a+\.\.\." }, u: {}, multi: false, upsert: false }$/ /* string value is truncated*/,
"Document corresponding to 'update' command not found.");
assert.commandWorked(coll.getDB().runCommand({profile: 0}));
@ -66,7 +66,7 @@ assert.commandWorked(coll.update({}, {a: hugeStr}));
var results = coll.getDB().system.profile.find().toArray();
assertContainsTruncatedCommand(
results,
/^{ q: {}, u: { a: "a+\.\.\." }, multi: false, upsert: false }$//* string value is truncated*/,
/^{ q: {}, u: { a: "a+\.\.\." }, multi: false, upsert: false }$/ /* string value is truncated*/,
"Document corresponding to 'update' command not found.");
assert.commandWorked(coll.getDB().runCommand({profile: 0}));
@ -83,7 +83,7 @@ coll.find(doc).itcount();
var results = coll.getDB().system.profile.find().toArray();
assertContainsTruncatedCommand(
results,
/filter: { a0: 1\.0, a1: .*\.\.\.$//* query object itself is truncated*/,
/filter: { a0: 1\.0, a1: .*\.\.\.$/ /* query object itself is truncated*/,
"Document corresponding to 'find' command not found.");
assert.commandWorked(coll.getDB().runCommand({profile: 0}));

View File

@ -100,13 +100,13 @@ t.insert([{_id: 0}, {_id: 1}]);
opCounters = newdb.serverStatus().opcounters;
res = t.remove({_id: 0});
assert.commandWorked(res);
assert.eq(opCounters.delete + 1, newdb.serverStatus().opcounters.delete);
assert.eq(opCounters.delete +1, newdb.serverStatus().opcounters.delete);
// Delete, with error.
opCounters = newdb.serverStatus().opcounters;
res = t.remove({_id: {$invalidOp: 1}});
assert.writeError(res);
assert.eq(opCounters.delete + 1, newdb.serverStatus().opcounters.delete);
assert.eq(opCounters.delete +1, newdb.serverStatus().opcounters.delete);
//
// 4. Query.

View File

@ -36,21 +36,18 @@ assertIndexResults(coll, {a: {$elemMatch: {$not: {$exists: false}}}}, false, 3);
assertIndexResults(coll, {a: {$elemMatch: {$gt: 0, $not: {$exists: false}}}}, false, 1);
// $geo within $elemMatch should not attempt to use a non-geo index.
assertIndexResults(coll,
{
a: {
$elemMatch: {
$geoWithin: {
$geometry: {
type: "Polygon",
coordinates: [[[0, 0], [0, 1], [1, 0], [0, 0]]]
}
}
}
}
},
false,
1);
assertIndexResults(
coll,
{
a: {
$elemMatch: {
$geoWithin:
{$geometry: {type: "Polygon", coordinates: [[[0, 0], [0, 1], [1, 0], [0, 0]]]}}
}
}
},
false,
1);
// $in with a null value within $elemMatch should use a sparse index.
assertIndexResults(coll, {a: {$elemMatch: {$in: [null]}}}, true, 1);

View File

@ -16,6 +16,7 @@
// ]
import "jstests/libs/query/sbe_assert_error_override.js";
import {getExecutionStats} from "jstests/libs/query/analyze_plan.js";
const coll = db.expr;

View File

@ -37,83 +37,80 @@ function testIndexKeyMetaProjection({
aggExpectedResult);
}
[true,
false]
.forEach((metadataAvailable) => {
let indexSpec;
if (metadataAvailable) {
indexSpec = {a: 1, b: 1};
assert.commandWorked(coll.createIndex(indexSpec));
} else {
indexSpec = {};
assert.commandWorked(coll.dropIndexes());
}
[true, false].forEach((metadataAvailable) => {
let indexSpec;
if (metadataAvailable) {
indexSpec = {a: 1, b: 1};
assert.commandWorked(coll.createIndex(indexSpec));
} else {
indexSpec = {};
assert.commandWorked(coll.dropIndexes());
}
// $meta with an inclusion projection.
testIndexKeyMetaProjection({
matchSpec: {a: {$gt: 20}},
projSpec: {_id: 0, a: 1},
indexSpec: indexSpec,
expectedResult: [Object.assign({a: 30}, metadataAvailable ? {c: {a: 30, b: 'z'}} : {})]
});
// $meta with an inclusion projection.
testIndexKeyMetaProjection({
matchSpec: {a: {$gt: 20}},
projSpec: {_id: 0, a: 1},
indexSpec: indexSpec,
expectedResult: [Object.assign({a: 30}, metadataAvailable ? {c: {a: 30, b: 'z'}} : {})]
});
// $meta with an exclusion projection.
testIndexKeyMetaProjection({
matchSpec: {a: {$gt: 20}},
projSpec: {_id: 0, a: 0},
indexSpec: indexSpec,
expectedResult: [Object.assign({b: 'z'}, metadataAvailable ? {c: {a: 30, b: 'z'}} : {})]
});
// $meta with an exclusion projection.
testIndexKeyMetaProjection({
matchSpec: {a: {$gt: 20}},
projSpec: {_id: 0, a: 0},
indexSpec: indexSpec,
expectedResult: [Object.assign({b: 'z'}, metadataAvailable ? {c: {a: 30, b: 'z'}} : {})]
});
// $meta with _id only (inclusion).
// $meta with _id only (inclusion).
testIndexKeyMetaProjection({
matchSpec: {a: {$gt: 20}},
projSpec: {_id: 1},
indexSpec: indexSpec,
expectedResult: [Object.assign({_id: 3}, metadataAvailable ? {c: {a: 30, b: 'z'}} : {})]
});
// $meta with _id only (exclusion). Note that this type of projection is equivalent to a
// $meta-only projection, which is treated differently in find and aggregate (it's an
// inclusion projection in find, and exclusion in aggregate).
testIndexKeyMetaProjection({
matchSpec: {a: {$gt: 20}},
projSpec: {_id: 0},
indexSpec: indexSpec,
expectedResult:
[Object.assign({a: 30, b: 'z'}, metadataAvailable ? {c: {a: 30, b: 'z'}} : {})],
aggExpectedResult: [metadataAvailable ? {c: {a: 30, b: 'z'}} : {}]
});
// $meta only (see comment above regarding $meta-only projection in find and aggregate).
testIndexKeyMetaProjection({
matchSpec: {a: {$gt: 20}},
indexSpec: indexSpec,
expectedResult:
[Object.assign({_id: 3, a: 30, b: 'z'}, metadataAvailable ? {c: {a: 30, b: 'z'}} : {})],
aggExpectedResult: [Object.assign({_id: 3}, metadataAvailable ? {c: {a: 30, b: 'z'}} : {})]
});
// $meta with sort (when an index is available this should result in a non-blocking sort
// and the index key metadata should be available).
//
// If a collection is sharded, we will split the pipeline and dispatch only a $project
// stage, containing inclusion projection, to each shard, and apply the $meta projection on
// mongos. However, given than no information has been passed to the shard to request to
// include indexKey metadata to a document, the $meta expression won't be able to extract
// the indexKey. So, this scenario currently is not supported and we need to make sure that
// we run this test on an unsharded collection only.
if (!FixtureHelpers.isSharded(coll)) {
testIndexKeyMetaProjection({
matchSpec: {a: {$gt: 20}},
projSpec: {_id: 1},
sortSpec: {a: 1},
indexSpec: indexSpec,
expectedResult: [Object.assign({_id: 3}, metadataAvailable ? {c: {a: 30, b: 'z'}} : {})]
expectedResult: [
Object.assign({_id: 1}, metadataAvailable ? {c: {a: 10, b: 'x'}} : {}),
Object.assign({_id: 2}, metadataAvailable ? {c: {a: 20, b: 'y'}} : {}),
Object.assign({_id: 3}, metadataAvailable ? {c: {a: 30, b: 'z'}} : {})
]
});
// $meta with _id only (exclusion). Note that this type of projection is equivalent to a
// $meta-only projection, which is treated differently in find and aggregate (it's an
// inclusion projection in find, and exclusion in aggregate).
testIndexKeyMetaProjection({
matchSpec: {a: {$gt: 20}},
projSpec: {_id: 0},
indexSpec: indexSpec,
expectedResult:
[Object.assign({a: 30, b: 'z'}, metadataAvailable ? {c: {a: 30, b: 'z'}} : {})],
aggExpectedResult: [metadataAvailable ? {c: {a: 30, b: 'z'}} : {}]
});
// $meta only (see comment above regarding $meta-only projection in find and aggregate).
testIndexKeyMetaProjection({
matchSpec: {a: {$gt: 20}},
indexSpec: indexSpec,
expectedResult: [Object.assign({_id: 3, a: 30, b: 'z'},
metadataAvailable ? {c: {a: 30, b: 'z'}} : {})],
aggExpectedResult:
[Object.assign({_id: 3}, metadataAvailable ? {c: {a: 30, b: 'z'}} : {})]
});
// $meta with sort (when an index is available this should result in a non-blocking sort
// and the index key metadata should be available).
//
// If a collection is sharded, we will split the pipeline and dispatch only a $project
// stage, containing inclusion projection, to each shard, and apply the $meta projection on
// mongos. However, given than no information has been passed to the shard to request to
// include indexKey metadata to a document, the $meta expression won't be able to extract
// the indexKey. So, this scenario currently is not supported and we need to make sure that
// we run this test on an unsharded collection only.
if (!FixtureHelpers.isSharded(coll)) {
testIndexKeyMetaProjection({
projSpec: {_id: 1},
sortSpec: {a: 1},
indexSpec: indexSpec,
expectedResult: [
Object.assign({_id: 1}, metadataAvailable ? {c: {a: 10, b: 'x'}} : {}),
Object.assign({_id: 2}, metadataAvailable ? {c: {a: 20, b: 'y'}} : {}),
Object.assign({_id: 3}, metadataAvailable ? {c: {a: 30, b: 'z'}} : {})
]
});
}
});
}
});

View File

@ -198,29 +198,24 @@ testSingleDocument({a: {b: {c: {$slice: [1, 1]}, d: {$add: [{$abs: "$e"}, -4]}}}
assert.docEq);
// Test multiple $slice operators in the same projection.
testSingleDocument({a: {b: {c: {$slice: [1, 1]}, d: {$slice: -1}}}},
{
a: [
{b: {c: [1, 2, 3], d: [4, 5, 6]}},
[
{b: {c: [1, 2, 3], d: [4, 5, 6]}},
{b: {c: [7, 8, 9], d: [10, 11, 12]}}
],
{b: [{c: [1, 2, 3], d: [4, 5, 6]}, {c: [7, 8, 9], d: [10, 11, 12]}]},
{b: [[{c: [1, 2, 3], d: [4, 5, 6]}], [{c: [7, 8, 9], d: [10, 11, 12]}]]}
]
},
{
a: [
{b: {c: [2], d: [6]}},
[
{b: {c: [1, 2, 3], d: [4, 5, 6]}},
{b: {c: [7, 8, 9], d: [10, 11, 12]}}
],
{b: [{c: [2], d: [6]}, {c: [8], d: [12]}]},
{b: [[{c: [1, 2, 3], d: [4, 5, 6]}], [{c: [7, 8, 9], d: [10, 11, 12]}]]}
]
});
testSingleDocument(
{a: {b: {c: {$slice: [1, 1]}, d: {$slice: -1}}}},
{
a: [
{b: {c: [1, 2, 3], d: [4, 5, 6]}},
[{b: {c: [1, 2, 3], d: [4, 5, 6]}}, {b: {c: [7, 8, 9], d: [10, 11, 12]}}],
{b: [{c: [1, 2, 3], d: [4, 5, 6]}, {c: [7, 8, 9], d: [10, 11, 12]}]},
{b: [[{c: [1, 2, 3], d: [4, 5, 6]}], [{c: [7, 8, 9], d: [10, 11, 12]}]]}
]
},
{
a: [
{b: {c: [2], d: [6]}},
[{b: {c: [1, 2, 3], d: [4, 5, 6]}}, {b: {c: [7, 8, 9], d: [10, 11, 12]}}],
{b: [{c: [2], d: [6]}, {c: [8], d: [12]}]},
{b: [[{c: [1, 2, 3], d: [4, 5, 6]}], [{c: [7, 8, 9], d: [10, 11, 12]}]]}
]
});
testSingleDocument({a: {b: {$slice: [1, 1]}}, c: {d: {$slice: -1}}},
{

View File

@ -36,7 +36,9 @@ qsutils.removeAllQuerySettings();
function testQuerySettingsUsing(params) {
let queryShapeHashA = null;
// Ensure that query settings cluster parameter is empty.
{ qsutils.assertQueryShapeConfiguration([]); }
{
qsutils.assertQueryShapeConfiguration([]);
}
// Ensure that 'querySettings' cluster parameter contains QueryShapeConfiguration after
// invoking setQuerySettings command.

View File

@ -16,20 +16,21 @@
import {assertArrayEq} from "jstests/aggregation/extras/utils.js";
import {TimeseriesTest} from "jstests/core/timeseries/libs/timeseries.js";
TimeseriesTest.run((insert) => {
const testDB = db.getSiblingDB(jsTestName());
assert.commandWorked(testDB.dropDatabase());
const timeFieldName = "time";
const tagFieldName = "tag";
const collOptions = [null, {timeseries: {timeField: timeFieldName, metaField: tagFieldName}}];
const numHosts = 10;
const numDocs = 200;
TimeseriesTest.run(
(insert) => {
const testDB = db.getSiblingDB(jsTestName());
assert.commandWorked(testDB.dropDatabase());
const timeFieldName = "time";
const tagFieldName = "tag";
const collOptions =
[null, {timeseries: {timeField: timeFieldName, metaField: tagFieldName}}];
const numHosts = 10;
const numDocs = 200;
Random.setRandomSeed();
const hosts = TimeseriesTest.generateHosts(numHosts);
Random.setRandomSeed();
const hosts = TimeseriesTest.generateHosts(numHosts);
let
testFunc = function(collAOption, collBOption) {
let testFunc = function(collAOption, collBOption) {
// Prepare two time-series collections.
const collA = testDB.getCollection("a");
const collB = testDB.getCollection("b");
@ -235,19 +236,19 @@ TimeseriesTest.run((insert) => {
assert.eq(numHosts, results.length, results);
};
// Exhaust the combinations of non-time-series and time-series collections for inner and outer
// $lookup collections.
collOptions.forEach(function(collAOption) {
collOptions.forEach(function(collBOption) {
if (collAOption == null && collBOption == null) {
// Normal $lookup call, both inner and outer collections are non-time-series
// collections.
return;
}
testFunc(collAOption, collBOption);
// Exhaust the combinations of non-time-series and time-series collections for inner and
// outer $lookup collections.
collOptions.forEach(function(collAOption) {
collOptions.forEach(function(collBOption) {
if (collAOption == null && collBOption == null) {
// Normal $lookup call, both inner and outer collections are non-time-series
// collections.
return;
}
testFunc(collAOption, collBOption);
});
});
});
});
{
// Test that we get the right results for $lookup on a timeseries collection with an internal

View File

@ -1,4 +1,5 @@
import "jstests/concurrency/fsm_workload_helpers/auto_retry_transaction.js";
import {
withTxnAndAutoRetry
} from "jstests/concurrency/fsm_workload_helpers/auto_retry_transaction.js";

View File

@ -172,7 +172,7 @@ const StepdownThread = function() {
* Overrides the ReplSetTest constructor to start the continuous primary stepdown thread.
*/
function makeReplSetTestWithContinuousPrimaryStepdown(stepdownOptions, verbositySetting) {
return class ReplSetTestWithContinuousPrimaryStepdown extends ReplSetTest {
return class ReplSetTestWithContinuousPrimaryStepdown extends ReplSetTest{
constructor(options) {
super(options);
// Handle for the continuous stepdown thread.
@ -291,7 +291,7 @@ function makeReplSetTestWithContinuousPrimaryStepdown(stepdownOptions, verbosity
* Overrides the ShardingTest constructor to start the continuous primary stepdown thread.
*/
function makeShardingTestWithContinuousPrimaryStepdown(stepdownOptions, verbositySetting) {
return class ShardingTestWithContinuousPrimaryStepdown extends ShardingTest {
return class ShardingTestWithContinuousPrimaryStepdown extends ShardingTest{
constructor(params) {
params.other = params.other || {};
@ -363,7 +363,6 @@ function makeShardingTestWithContinuousPrimaryStepdown(stepdownOptions, verbosit
* This method is disabled because it runs aggregation, which doesn't handle config
* server stepdown correctly.
*/
printShardingStatus() {
}
printShardingStatus() {}
};
}

View File

@ -23,7 +23,7 @@ import {
kOverrideConstructor as kOverrideConstructorForRST
} from "jstests/libs/replsettest.js";
ShardingTest[kOverrideConstructorForST] = class NoSpawnShardingTest extends ShardingTest {
ShardingTest[kOverrideConstructorForST] = class NoSpawnShardingTest extends ShardingTest{
constructor() {
throw new Error("Detected ShardingTest() call in js test from passthrough suite. " +
"Consider moving the test to one of the jstests/noPassthrough/, " +
@ -31,7 +31,7 @@ ShardingTest[kOverrideConstructorForST] = class NoSpawnShardingTest extends Shar
}
};
ReplSetTest[kOverrideConstructorForRST] = class NoSpawnReplSetTest extends ReplSetTest {
ReplSetTest[kOverrideConstructorForRST] = class NoSpawnReplSetTest extends ReplSetTest{
constructor(opts) {
if (typeof opts !== 'string' && !(opts instanceof String)) {
throw new Error("Detected ReplSetTest() call in js test from passthrough suite. " +

View File

@ -5,8 +5,8 @@
* removed when calling any find methods.
*/
import {sysCollNamePrefix} from "jstests/core/timeseries/libs/timeseries_writes_util.js";
import {
sysCollNamePrefix,
transformIndexHintsForTimeseriesCollection
} from "jstests/core/timeseries/libs/timeseries_writes_util.js";
import {OverrideHelpers} from "jstests/libs/override_methods/override_helpers.js";

View File

@ -10,6 +10,7 @@
// For the whole_cluster passthrough, we simply override the necessary methods in the whole_db
// passthrough's ChangeStreamPassthroughHelpers.
import "jstests/libs/override_methods/implicit_whole_db_changestreams.js";
import {ChangeStreamWatchMode} from "jstests/libs/query/change_stream_util.js";
// Any valid single-collection or single-database request is upconvertable to cluster-wide.

View File

@ -11,12 +11,10 @@
import {OverrideHelpers} from "jstests/libs/override_methods/override_helpers.js";
import {
ImplicitlyShardAccessCollSettings,
setTestMayRunDropInParallel,
ShardingOverrideCommon
} from "jstests/libs/override_methods/shard_collection_util.js";
import {
ImplicitlyShardAccessCollSettings
} from "jstests/libs/override_methods/shard_collection_util.js";
// Expose settings for this override on `globalThis`
globalThis.ImplicitlyShardAccessCollSettings = ImplicitlyShardAccessCollSettings;

View File

@ -1,5 +1,5 @@
import {sysCollNamePrefix} from "jstests/core/timeseries/libs/timeseries_writes_util.js";
import {
sysCollNamePrefix,
transformIndexHintsFromTimeseriesToView
} from "jstests/core/timeseries/libs/timeseries_writes_util.js";
import {

View File

@ -10,8 +10,8 @@ import {
ShardingTest
} from "jstests/libs/shardingtest.js";
ReplSetTest[kOverrideConstructorForRST] =
class MultitenantChangeStreamReplSetTest extends ReplSetTest {
ReplSetTest[kOverrideConstructorForRST] = class MultitenantChangeStreamReplSetTest extends
ReplSetTest{
constructor(opts) {
// Setup the 'serverless' environment if the 'opts' is not a connection string, ie. the
// replica-set does not already exist and the replica-set is not part of the sharded
@ -65,8 +65,8 @@ ReplSetTest[kOverrideConstructorForRST] =
}
};
ShardingTest[kOverrideConstructorForST] =
class MultitenantChangeStreamShardingTest extends ShardingTest {
ShardingTest[kOverrideConstructorForST] = class MultitenantChangeStreamShardingTest extends
ShardingTest{
constructor(params) {
super(params);

View File

@ -25,8 +25,8 @@ const {ReplSetTestWithContinuousPrimaryStepdown, ShardingTestWithContinuousPrima
});
ReplSetTest[kOverrideConstructorForRST] = ReplSetTestWithContinuousPrimaryStepdown;
ShardingTest[kOverrideConstructorForST] =
class ShardingTestWithContinuousFailover extends ShardingTestWithContinuousPrimaryStepdown {
ShardingTest[kOverrideConstructorForST] = class ShardingTestWithContinuousFailover extends
ShardingTestWithContinuousPrimaryStepdown{
constructor(params) {
super(params);
// Set the feature on the test configuration; this will allow js tests to selectively

View File

@ -1,6 +1,9 @@
import {anyEq} from "jstests/aggregation/extras/utils.js";
import {getExplainCommand} from "jstests/libs/cmd_object_utils.js";
import {getCollectionName, isTimeSeriesCollection} from "jstests/libs/cmd_object_utils.js";
import {
getCollectionName,
getExplainCommand,
isTimeSeriesCollection
} from "jstests/libs/cmd_object_utils.js";
import {
everyWinningPlan,
formatQueryPlanner,

View File

@ -4,6 +4,7 @@
*/
import "jstests/multiVersion/libs/multi_cluster.js";
import {
assertCreateCollection,
assertDropCollection

View File

@ -11,6 +11,7 @@
*/
import "jstests/multiVersion/libs/multi_cluster.js";
import {ShardingTest} from "jstests/libs/shardingtest.js";
const dbName = jsTestName();

View File

@ -3,6 +3,7 @@
*/
import "jstests/multiVersion/libs/multi_rs.js";
import {ReplSetTest} from "jstests/libs/replsettest.js";
const rst = new ReplSetTest({

View File

@ -3,7 +3,6 @@
*/
import {FeatureFlagUtil} from "jstests/libs/feature_flag_util.js";
import {ShardingTest} from "jstests/libs/shardingtest.js";
import {ProxyProtocolServer} from "jstests/sharding/libs/proxy_protocol.js";

View File

@ -4,6 +4,7 @@
*/
import "jstests/multiVersion/libs/verify_versions.js";
import "jstests/multiVersion/libs/multi_rs.js";
import {assertDropAndRecreateCollection} from "jstests/libs/collection_drop_recreate.js";
import {ReplSetTest} from "jstests/libs/replsettest.js";

View File

@ -13,9 +13,9 @@
*/
import {assertDropAndRecreateCollection} from "jstests/libs/collection_drop_recreate.js";
import {preImagesForOps} from "jstests/libs/query/change_stream_util.js";
import {
assertChangeStreamPreAndPostImagesCollectionOptionIsEnabled
assertChangeStreamPreAndPostImagesCollectionOptionIsEnabled,
preImagesForOps
} from "jstests/libs/query/change_stream_util.js";
import {ReplSetTest} from "jstests/libs/replsettest.js";

View File

@ -6,8 +6,7 @@
import {withTxnAndAutoRetryOnMongos} from "jstests/libs/auto_retry_transaction_in_sharding.js";
import {assertDropAndRecreateCollection} from "jstests/libs/collection_drop_recreate.js";
import {FeatureFlagUtil} from "jstests/libs/feature_flag_util.js";
import {assertChangeStreamEventEq} from "jstests/libs/query/change_stream_util.js";
import {assertNoChanges} from "jstests/libs/query/change_stream_util.js";
import {assertChangeStreamEventEq, assertNoChanges} from "jstests/libs/query/change_stream_util.js";
import {ShardingTest} from "jstests/libs/shardingtest.js";
import {isTimestamp} from "jstests/libs/timestamp_util.js";

View File

@ -5,12 +5,12 @@
*/
import {
aggPlanHasStage,
assertEngine,
getAggPlanStage,
getAggPlanStages,
hasRejectedPlans,
planHasStage,
} from "jstests/libs/query/analyze_plan.js";
import {assertEngine} from "jstests/libs/query/analyze_plan.js";
import {checkSbeRestrictedOrFullyEnabled} from "jstests/libs/query/sbe_util.js";
import {ReplSetTest} from "jstests/libs/replsettest.js";
import {ShardingTest} from "jstests/libs/shardingtest.js";

View File

@ -126,18 +126,17 @@ for (let result of results) {
}
// Test that we can explain() an update command that uses $$NOW and $$CLUSTER_TIME.
assert.commandWorked(
coll.explain().update(
{
$expr: {
$and: [
{$lt: ["$_id", {$min: [_idMidpoint, "$$NOW"]}]},
{$gt: ["$$CLUSTER_TIME", "$insertClusterTime"]}
]
}
},
[{$addFields: {explainDoesNotWrite1: "$$NOW", explainDoesNotWrite2: "$$CLUSTER_TIME"}}],
{multi: true}));
assert.commandWorked(coll.explain().update(
{
$expr: {
$and: [
{$lt: ["$_id", {$min: [_idMidpoint, "$$NOW"]}]},
{$gt: ["$$CLUSTER_TIME", "$insertClusterTime"]}
]
}
},
[{$addFields: {explainDoesNotWrite1: "$$NOW", explainDoesNotWrite2: "$$CLUSTER_TIME"}}],
{multi: true}));
// Test that $$NOW and $$CLUSTER_TIME can be used when issuing updates via the Bulk API, and
// remain constant across all updates within a single bulk operation.

View File

@ -141,18 +141,17 @@ for (let result of results) {
}
// Test that we can explain() an update command that uses $$NOW and $$CLUSTER_TIME.
assert.commandWorked(
coll.explain().update(
{
$expr: {
$and: [
{$lt: ["$_id", {$min: [_idMidpoint, "$$NOW"]}]},
{$gt: ["$$CLUSTER_TIME", "$insertClusterTime"]}
]
}
},
[{$addFields: {explainDoesNotWrite1: "$$NOW", explainDoesNotWrite2: "$$CLUSTER_TIME"}}],
{multi: true}));
assert.commandWorked(coll.explain().update(
{
$expr: {
$and: [
{$lt: ["$_id", {$min: [_idMidpoint, "$$NOW"]}]},
{$gt: ["$$CLUSTER_TIME", "$insertClusterTime"]}
]
}
},
[{$addFields: {explainDoesNotWrite1: "$$NOW", explainDoesNotWrite2: "$$CLUSTER_TIME"}}],
{multi: true}));
// Test that $$NOW and $$CLUSTER_TIME can be used when issuing updates via the Bulk API, and
// remain constant across all updates within a single bulk operation.

View File

@ -1,5 +1,4 @@
import {configureFailPoint} from "jstests/libs/fail_point_util.js";
import {ReplSetTest} from "jstests/libs/replsettest.js";
const rst = new ReplSetTest({nodes: 1});

View File

@ -11,7 +11,6 @@ import {
getWinningPlanFromExplain,
isCollscan
} from "jstests/libs/query/analyze_plan.js";
import {checkSbeFullyEnabled} from "jstests/libs/query/sbe_util.js";
// TODO SERVER-92589: Remove this exemption

View File

@ -7,7 +7,6 @@ import {
getWinningPlanFromExplain,
isCollscan,
} from "jstests/libs/query/analyze_plan.js";
import {checkSbeFullyEnabled} from "jstests/libs/query/sbe_util.js";
// TODO SERVER-92589: Remove this exemption

View File

@ -244,39 +244,23 @@ assertResultsMatchWithAndWithoutPushdown(
coll, pipeline, [{_id: "a", ss: 30}, {_id: "b", ss: 60}, {_id: "c", ss: 10}], 2));
// The second $group stage refers to a top-field below a $switch
assertResultsMatchWithAndWithoutPushdown(coll,
[
{$group: {_id: {$divide: ["$price", 5]}}},
{
$group: {
_id: null,
lowp: {
$sum: {
$switch: {
branches: [{
case: {$lte: ["$_id", 3]},
then: 1
}],
default: 0
}
}
},
highp: {
$sum: {
$switch: {
branches: [{
case: {$gt: ["$_id", 3]},
then: 1
}],
default: 0
}
}
}
}
}
],
[{"_id": null, "lowp": 2, "highp": 1}],
2);
assertResultsMatchWithAndWithoutPushdown(
coll,
[
{$group: {_id: {$divide: ["$price", 5]}}},
{
$group: {
_id: null,
lowp: {
$sum: {$switch: {branches: [{case: {$lte: ["$_id", 3]}, then: 1}], default: 0}}
},
highp:
{$sum: {$switch: {branches: [{case: {$gt: ["$_id", 3]}, then: 1}], default: 0}}}
}
}
],
[{"_id": null, "lowp": 2, "highp": 1}],
2);
// The second $group stage refers to a top-field below a $cond
assertResultsMatchWithAndWithoutPushdown(
@ -295,38 +279,20 @@ assertResultsMatchWithAndWithoutPushdown(
2);
// The second $group stage refers to a top-field below a nested $cond / $ifNull
assertResultsMatchWithAndWithoutPushdown(coll,
[
{$group: {_id: {$divide: ["$price", 5]}}},
{
$group: {
_id: null,
lowp: {
$sum: {
$cond: [
{
$lte:
[{$ifNull: ["$_id", 0]}, 3]
},
1,
0
]
}
},
highp: {
$sum: {
$cond: [
{$gt: [{$ifNull: ["$_id", 0]}, 3]},
1,
0
]
}
}
}
}
],
[{"_id": null, "lowp": 2, "highp": 1}],
2);
assertResultsMatchWithAndWithoutPushdown(
coll,
[
{$group: {_id: {$divide: ["$price", 5]}}},
{
$group: {
_id: null,
lowp: {$sum: {$cond: [{$lte: [{$ifNull: ["$_id", 0]}, 3]}, 1, 0]}},
highp: {$sum: {$cond: [{$gt: [{$ifNull: ["$_id", 0]}, 3]}, 1, 0]}}
}
}
],
[{"_id": null, "lowp": 2, "highp": 1}],
2);
// The second $group stage refers to top-fields below a $let
assertResultsMatchWithAndWithoutPushdown(
@ -349,72 +315,24 @@ assertResultsMatchWithAndWithoutPushdown(
2);
// The second $group stage refers to top-fields below a $and
assertResultsMatchWithAndWithoutPushdown(coll,
[
{
$group: {
_id: "$item",
maxp: {$max: "$price"},
minp: {$min: "$price"}
}
},
{
$group:
{
_id: "$_id",
o:
{
$sum:
{
$and: [
{$gt: ["$maxp", 15]},
{$lt: ["$minp", 10]}
]
}
}
}
}
],
[
{"_id": "a", "o": 0},
{"_id": "c", "o": 0},
{"_id": "b", "o": 0}
],
2);
assertResultsMatchWithAndWithoutPushdown(
coll,
[
{$group: {_id: "$item", maxp: {$max: "$price"}, minp: {$min: "$price"}}},
{$group: {_id: "$_id", o: {$sum: {$and: [{$gt: ["$maxp", 15]}, {$lt: ["$minp", 10]}]}}}}
],
[{"_id": "a", "o": 0}, {"_id": "c", "o": 0}, {"_id": "b", "o": 0}],
2);
// The second $group stage refers to top-fields below a $or
assertResultsMatchWithAndWithoutPushdown(coll,
[
{
$group: {
_id: "$item",
maxp: {$max: "$price"},
minp: {$min: "$price"}
}
},
{
$group:
{
_id: "$_id",
o:
{
$sum:
{
$or: [
{$gt: ["$maxp", 15]},
{$lt: ["$minp", 10]}
]
}
}
}
}
],
[
{"_id": "a", "o": 0},
{"_id": "c", "o": 0},
{"_id": "b", "o": 0}
],
2);
assertResultsMatchWithAndWithoutPushdown(
coll,
[
{$group: {_id: "$item", maxp: {$max: "$price"}, minp: {$min: "$price"}}},
{$group: {_id: "$_id", o: {$sum: {$or: [{$gt: ["$maxp", 15]}, {$lt: ["$minp", 10]}]}}}}
],
[{"_id": "a", "o": 0}, {"_id": "c", "o": 0}, {"_id": "b", "o": 0}],
2);
// The second $group stage refers to both a top-level field and a sub-field twice which does not
// exist.

View File

@ -2,6 +2,7 @@
* Tests for the $$NOW and $$CLUSTER_TIME system variable.
*/
import "jstests/libs/query/sbe_assert_error_override.js";
import {getWinningPlanFromExplain, isIxscan} from "jstests/libs/query/analyze_plan.js";
import {checkSbeFullFeatureFlagEnabled} from "jstests/libs/query/sbe_util.js";

View File

@ -380,11 +380,9 @@ function runMultiBatchTests(collOpts) {
replSet.awaitReplication();
}
[{},
{clusteredIndex: {key: {_id: 1}, unique: true}}]
.forEach(collOpts => {
runMultiBatchTests(collOpts);
});
[{}, {clusteredIndex: {key: {_id: 1}, unique: true}}].forEach(collOpts => {
runMultiBatchTests(collOpts);
});
// Now, test some unusual cases where the command should fail.
function testErrorOnNonexistent() {
@ -451,8 +449,7 @@ function simpleTestCatchesExtra(collOpts) {
JSON.stringify(errors.toArray()));
}
[{validationLevel: "off"},
{validationLevel: "off", clusteredIndex: {key: {_id: 1}, unique: true}}]
[{validationLevel: "off"}, {validationLevel: "off", clusteredIndex: {key: {_id: 1}, unique: true}}]
.forEach(collOpts => {
simpleTestCatchesExtra(collOpts);
});

View File

@ -1110,77 +1110,75 @@ function identicalKeysChangedBeforeHashing(collOpts) {
resetNumMaxIdenticalKeys();
}
[{},
{clusteredIndex: {key: {_id: 1}, unique: true}}]
.forEach(collOpts => {
[null /* no errors */,
"skipUnindexingDocumentWhenDeleted", /* recordNotFound and inconsistent batch errors are
* caught
*/
"skipUpdatingIndexDocument" /* recordDoesNotMatch errors are caught.*/]
.forEach((failpoint) => {
// Check maxIdenticalKeys > numDocs > batch/snapshot size - all keys should be
// checked in one batch/snapshot.
onlyIdenticalKeys(11 /*numDocs*/,
10 /*batchSize*/,
5 /*snapshotSize*/,
defaultNumMaxIdenticalKeys,
collOpts,
failpoint);
[{}, {clusteredIndex: {key: {_id: 1}, unique: true}}].forEach(collOpts => {
[null /* no errors */,
"skipUnindexingDocumentWhenDeleted", /* recordNotFound and inconsistent batch errors are
* caught
*/
"skipUpdatingIndexDocument" /* recordDoesNotMatch errors are caught.*/]
.forEach((failpoint) => {
// Check maxIdenticalKeys > numDocs > batch/snapshot size - all keys should be
// checked in one batch/snapshot.
onlyIdenticalKeys(11 /*numDocs*/,
10 /*batchSize*/,
5 /*snapshotSize*/,
defaultNumMaxIdenticalKeys,
collOpts,
failpoint);
// numDocs > maxIdenticalKeys > batch/snapshotsize - should only check up to
// numMaxIdenticalKeys.
onlyIdenticalKeys(20 /*numDocs*/,
5 /*batchSize*/,
6 /*snapshotSize*/,
7 /*numMaxIdenticalKeys*/,
collOpts,
failpoint);
// numDocs > maxIdenticalKeys > batch/snapshotsize - should only check up to
// numMaxIdenticalKeys.
onlyIdenticalKeys(20 /*numDocs*/,
5 /*batchSize*/,
6 /*snapshotSize*/,
7 /*numMaxIdenticalKeys*/,
collOpts,
failpoint);
// Simple tests with distinct keys before and after identical keys.
// Tests nIdenticalDocs < numMaxIdenticalKeys, batchSize < snapshotSize.
simpleIdenticalKeysInMiddleOfColl(11 /*nIdenticalDocs*/,
1 /*batchSize*/,
2 /*snapshotSize*/,
defaultNumMaxIdenticalKeys,
collOpts,
failpoint);
// Tests nIdenticalDocs > numMaxIdenticalKeys, batchSize == snapshotSize.
simpleIdenticalKeysInMiddleOfColl(20 /*nIdenticalDocs*/,
5 /*batchSize*/,
5 /*snapshotSize*/,
6 /*numMaxIdenticalKeys*/,
collOpts,
failpoint);
// Tests nIdenticalDocs > numMaxIdenticalKeys, batchSize > snapshotSize.
simpleIdenticalKeysInMiddleOfColl(20 /*nIdenticalDocs*/,
5 /*batchSize*/,
2 /*snapshotSize*/,
6 /*numMaxIdenticalKeys*/,
collOpts,
failpoint);
// Simple tests with distinct keys before and after identical keys.
// Tests nIdenticalDocs < numMaxIdenticalKeys, batchSize < snapshotSize.
simpleIdenticalKeysInMiddleOfColl(11 /*nIdenticalDocs*/,
1 /*batchSize*/,
2 /*snapshotSize*/,
defaultNumMaxIdenticalKeys,
collOpts,
failpoint);
// Tests nIdenticalDocs > numMaxIdenticalKeys, batchSize == snapshotSize.
simpleIdenticalKeysInMiddleOfColl(20 /*nIdenticalDocs*/,
5 /*batchSize*/,
5 /*snapshotSize*/,
6 /*numMaxIdenticalKeys*/,
collOpts,
failpoint);
// Tests nIdenticalDocs > numMaxIdenticalKeys, batchSize > snapshotSize.
simpleIdenticalKeysInMiddleOfColl(20 /*nIdenticalDocs*/,
5 /*batchSize*/,
2 /*snapshotSize*/,
6 /*numMaxIdenticalKeys*/,
collOpts,
failpoint);
// Identical keys at the end of the batch/snapshot size result in batch/snapshot
// limit getting ignored.
identicalKeysAtEndOfBatch(collOpts, failpoint);
// Identical keys at the end of the batch/snapshot size result in batch/snapshot
// limit getting ignored.
identicalKeysAtEndOfBatch(collOpts, failpoint);
// Batch/snapshot size >= nDocs, numMaxIdenticalKeys is ignored.
allKeysInOneBatch(collOpts, failpoint);
// Batch/snapshot size >= nDocs, numMaxIdenticalKeys is ignored.
allKeysInOneBatch(collOpts, failpoint);
// Testing that nConsecutiveIdenticalIndexKeysSeenAtEnd is reset when encountering a
// new distinct key.
nConsecutiveIdenticalIndexKeysSeenAtEndIsReset(collOpts, failpoint);
});
// Testing that nConsecutiveIdenticalIndexKeysSeenAtEnd is reset when encountering a
// new distinct key.
nConsecutiveIdenticalIndexKeysSeenAtEndIsReset(collOpts, failpoint);
});
hashingExtraIdenticalIndexKeysOnPrimary(collOpts);
hashingExtraIdenticalIndexKeysOnSecondary(collOpts);
hashingExtraIdenticalIndexKeysOnSecondaryMiddleOfBatch(collOpts);
identicalKeysChangedBeforeHashing(collOpts);
extraIdenticalIndexKeysOnSecondaryBeyondMax(collOpts);
hashingExtraIdenticalIndexKeysOnPrimary(collOpts);
hashingExtraIdenticalIndexKeysOnSecondary(collOpts);
hashingExtraIdenticalIndexKeysOnSecondaryMiddleOfBatch(collOpts);
identicalKeysChangedBeforeHashing(collOpts);
extraIdenticalIndexKeysOnSecondaryBeyondMax(collOpts);
// TODO SERVER-93406: Uncomment this test.
// extraDistinctIndexKeysOnSecondaryBeyondMax(collOpts);
});
// TODO SERVER-93406: Uncomment this test.
// extraDistinctIndexKeysOnSecondaryBeyondMax(collOpts);
});
replSet.stopSet(undefined /* signal */,
false /* forRestart */,

View File

@ -630,90 +630,87 @@ function runMainTests(
// Test with integer index entries (1, 2, 3, etc.), single character string entries ("1",
// "2", "3", etc.), and long string entries ("1aaaaaaaaaa")
[null,
"",
"aaaaaaaaaa"]
.forEach((docSuffix) => {
// Test with docs < batch size
runMainTests(10,
defaultMaxDocsPerBatch,
defaultSnapshotSize,
false /*skipLookupForExtraKeys*/,
docSuffix);
[null, "", "aaaaaaaaaa"].forEach((docSuffix) => {
// Test with docs < batch size
runMainTests(10,
defaultMaxDocsPerBatch,
defaultSnapshotSize,
false /*skipLookupForExtraKeys*/,
docSuffix);
// Test with docs > batch size.
runMainTests(1000,
defaultMaxDocsPerBatch,
defaultSnapshotSize,
false /*skipLookupForExtraKeys*/,
docSuffix);
// Test with docs > batch size.
runMainTests(1000,
defaultMaxDocsPerBatch,
defaultSnapshotSize,
false /*skipLookupForExtraKeys*/,
docSuffix);
// Test with snapshot size < batch size
runMainTests(1000,
99 /* batchSize */,
19 /* snapshotSize */,
false /*skipLookupForExtraKeys*/,
docSuffix);
// Test with snapshot size < batch size
runMainTests(1000,
99 /* batchSize */,
19 /* snapshotSize */,
false /*skipLookupForExtraKeys*/,
docSuffix);
// Pass in start/end parameters with full range.
// Pass in start/end parameters with full range.
runMainTests(10,
defaultMaxDocsPerBatch,
defaultSnapshotSize,
false /*skipLookupForExtraKeys*/,
docSuffix,
0,
9);
// Test a specific range.
runMainTests(10,
defaultMaxDocsPerBatch,
defaultSnapshotSize,
false /*skipLookupForExtraKeys*/,
docSuffix,
2,
8);
// Start < first doc (a: 0)
runMainTests(10,
defaultMaxDocsPerBatch,
defaultSnapshotSize,
false /*skipLookupForExtraKeys*/,
docSuffix,
-1,
8);
// End > last doc (a: 9)
if (docSuffix) {
runMainTests(10,
defaultMaxDocsPerBatch,
defaultSnapshotSize,
false /*skipLookupForExtraKeys*/,
docSuffix,
0,
9);
// Test a specific range.
"3",
"9z");
} else {
runMainTests(10,
defaultMaxDocsPerBatch,
defaultSnapshotSize,
false /*skipLookupForExtraKeys*/,
docSuffix,
2,
8);
// Start < first doc (a: 0)
runMainTests(10,
defaultMaxDocsPerBatch,
defaultSnapshotSize,
false /*skipLookupForExtraKeys*/,
docSuffix,
-1,
8);
// End > last doc (a: 9)
if (docSuffix) {
runMainTests(10,
defaultMaxDocsPerBatch,
defaultSnapshotSize,
false /*skipLookupForExtraKeys*/,
docSuffix,
"3",
"9z");
} else {
runMainTests(10,
defaultMaxDocsPerBatch,
defaultSnapshotSize,
false /*skipLookupForExtraKeys*/,
docSuffix,
3,
10);
}
3,
10);
}
// Test only start or end parameter passed in.
runMainTests(10,
defaultMaxDocsPerBatch,
defaultSnapshotSize,
false /*skipLookupForExtraKeys*/,
docSuffix,
4,
null /*end*/);
runMainTests(10,
defaultMaxDocsPerBatch,
defaultSnapshotSize,
false /*skipLookupForExtraKeys*/,
docSuffix,
null /*start*/,
7);
});
// Test only start or end parameter passed in.
runMainTests(10,
defaultMaxDocsPerBatch,
defaultSnapshotSize,
false /*skipLookupForExtraKeys*/,
docSuffix,
4,
null /*end*/);
runMainTests(10,
defaultMaxDocsPerBatch,
defaultSnapshotSize,
false /*skipLookupForExtraKeys*/,
docSuffix,
null /*start*/,
7);
});
// Test with start/end parameters and multiple batches/snapshots
// Test with specific range in the middle of the index and snapshotSize < batchSize.

View File

@ -524,27 +524,25 @@ function indexDropAfterFirstBatch(docSuffix, collOpts) {
checkHealthLog(secondaryHealthLog, logQueries.allErrorsOrWarningsQuery, 0);
}
[{},
{clusteredIndex: {key: {_id: 1}, unique: true}}]
.forEach(collOpts => {
// Test with integer index entries (1, 2, 3, etc.), single character string entries ("1",
// "2", "3", etc.), and long string entries ("1aaaaaaaaaa")
[null, "", "aaaaaaaaaa"].forEach((docSuffix) => {
indexNotFoundBeforeDbCheck(docSuffix, collOpts);
indexNotFoundDuringHashing(docSuffix, collOpts);
indexNotFoundDuringReverseLookup(docSuffix, collOpts);
collNotFoundBeforeDbCheck(docSuffix, collOpts);
collNotFoundDuringHashing(docSuffix, collOpts);
collNotFoundDuringReverseLookup(docSuffix, collOpts);
allIndexKeysNotFoundDuringReverseLookup(10, docSuffix, collOpts);
dbCheckDuringIndexBuild(docSuffix, collOpts);
indexDropAfterFirstBatch(docSuffix, collOpts);
});
keysChangedBeforeHashing(collOpts);
keyNotFoundDuringReverseLookup(10, collOpts);
[{}, {clusteredIndex: {key: {_id: 1}, unique: true}}].forEach(collOpts => {
// Test with integer index entries (1, 2, 3, etc.), single character string entries ("1",
// "2", "3", etc.), and long string entries ("1aaaaaaaaaa")
[null, "", "aaaaaaaaaa"].forEach((docSuffix) => {
indexNotFoundBeforeDbCheck(docSuffix, collOpts);
indexNotFoundDuringHashing(docSuffix, collOpts);
indexNotFoundDuringReverseLookup(docSuffix, collOpts);
collNotFoundBeforeDbCheck(docSuffix, collOpts);
collNotFoundDuringHashing(docSuffix, collOpts);
collNotFoundDuringReverseLookup(docSuffix, collOpts);
allIndexKeysNotFoundDuringReverseLookup(10, docSuffix, collOpts);
dbCheckDuringIndexBuild(docSuffix, collOpts);
indexDropAfterFirstBatch(docSuffix, collOpts);
});
keysChangedBeforeHashing(collOpts);
keyNotFoundDuringReverseLookup(10, collOpts);
});
replSet.stopSet(undefined /* signal */,
false /* forRestart */,
{skipCheckDBHashes: true, skipValidation: true});

View File

@ -98,15 +98,13 @@ function runTest(validateMode, writeConcern) {
rst.stopSet();
}
["dataConsistencyAndMissingIndexKeysCheck",
"extraIndexKeysCheck"]
.forEach((failpointName) => {
runTest(failpointName, {
w: 'majority',
wtimeout: 100,
});
runTest(failpointName, {
w: 3,
wtimeout: 100,
});
["dataConsistencyAndMissingIndexKeysCheck", "extraIndexKeysCheck"].forEach((failpointName) => {
runTest(failpointName, {
w: 'majority',
wtimeout: 100,
});
runTest(failpointName, {
w: 3,
wtimeout: 100,
});
});

View File

@ -243,14 +243,12 @@ function testSecondaryOnly(collOpts) {
checkHealthLog(secondary.getDB("local").system.healthlog, errQuery, 1);
}
[{},
{clusteredIndex: {key: {_id: 1}, unique: true}}]
.forEach(collOpts => {
testMultipleMissingKeys(collOpts);
testMultipleDocsOneInconsistency(collOpts);
testNoInconsistencies(collOpts);
testPrimaryOnly(collOpts);
testSecondaryOnly(collOpts);
});
[{}, {clusteredIndex: {key: {_id: 1}, unique: true}}].forEach(collOpts => {
testMultipleMissingKeys(collOpts);
testMultipleDocsOneInconsistency(collOpts);
testNoInconsistencies(collOpts);
testPrimaryOnly(collOpts);
testSecondaryOnly(collOpts);
});
replSet.stopSet();

View File

@ -153,12 +153,9 @@ function indexDropAfterFirstBatch() {
// Test with integer index entries (1, 2, 3, etc.), single character string entries ("1",
// "2", "3", etc.), and long string entries ("1aaaaaaaaaa")
[null,
"",
"aaaaaaaaaa"]
.forEach((docSuffix) => {
dbCheckDuringIndexBuild(docSuffix);
});
[null, "", "aaaaaaaaaa"].forEach((docSuffix) => {
dbCheckDuringIndexBuild(docSuffix);
});
indexDropAfterFirstBatch();

View File

@ -120,10 +120,8 @@ function runTestWithCollOpts(collOpts) {
runTest(101, 201, 0 /* numExpectedErrorsPrimary */, 0 /* numExpectedErrorsSecondary */);
}
[{},
{clusteredIndex: {key: {_id: 1}, unique: true}}]
.forEach(collOpts => {
runTestWithCollOpts(collOpts);
});
[{}, {clusteredIndex: {key: {_id: 1}, unique: true}}].forEach(collOpts => {
runTestWithCollOpts(collOpts);
});
rst.stopSet();

View File

@ -2,8 +2,7 @@
* Test that stepdown during collection cloning and oplog fetching does not interrupt initial sync.
*/
import {waitForCurOpByFailPoint} from "jstests/libs/curop_helpers.js";
import {kDefaultWaitForFailPointTimeout} from "jstests/libs/fail_point_util.js";
import {configureFailPoint} from "jstests/libs/fail_point_util.js";
import {configureFailPoint, kDefaultWaitForFailPointTimeout} from "jstests/libs/fail_point_util.js";
import {ReplSetTest} from "jstests/libs/replsettest.js";
const testName = "initialSyncDuringStepDown";

View File

@ -697,7 +697,9 @@ const tokenDB = tokenConn.getDB(kDbName);
// Test dbCheck command.
// This should fail since dbCheck is not supporting using a security token.
{ assert.commandFailedWithCode(tokenDB.runCommand({dbCheck: kCollName}), ErrorCodes.Unauthorized); }
{
assert.commandFailedWithCode(tokenDB.runCommand({dbCheck: kCollName}), ErrorCodes.Unauthorized);
}
primary._setSecurityToken(undefined);

View File

@ -303,8 +303,8 @@ export var AnalyzeShardKeyUtil = {
0,
metrics);
} else {
assert.eq(metrics.sampleSize.update + metrics.sampleSize.delete +
metrics.sampleSize.findAndModify,
assert.eq(metrics.sampleSize.update +
metrics.sampleSize.delete +metrics.sampleSize.findAndModify,
metrics.sampleSize.total,
metrics.sampleSize);

View File

@ -97,18 +97,14 @@ function runUpdateTestRetryStatementsSeparately(db, coll, makeSessionOptionsFunc
assert.commandWorked(coll.insert([{_id: 1, x: 0}, {_id: 2, x: 0}]));
const [initialRes] = runCommandsWithSessionOpts(db,
[
{
update: kCollName,
updates: [
{q: {_id: 1}, u: {$inc: {x: 1}}},
{q: {_id: 2}, u: {$inc: {x: 1}}}
],
stmtIds: [stmtId1, stmtId2]
}
],
initialSessionOpts);
const [initialRes] = runCommandsWithSessionOpts(
db,
[{
update: kCollName,
updates: [{q: {_id: 1}, u: {$inc: {x: 1}}}, {q: {_id: 2}, u: {$inc: {x: 1}}}],
stmtIds: [stmtId1, stmtId2]
}],
initialSessionOpts);
const [retryRes1, retryRes2] = runCommandsWithSessionOpts(
db,
[
@ -207,18 +203,14 @@ function runUpdateTestRetryWithAdditionalStatement(db, coll, makeSessionOptionsF
db,
[{update: kCollName, updates: [{q: {_id: 1}, u: {$inc: {x: 1}}}], stmtIds: [stmtId1]}],
initialSessionOpts);
const [retryRes] = runCommandsWithSessionOpts(db,
[
{
update: kCollName,
updates: [
{q: {_id: 1}, u: {$inc: {x: 1}}},
{q: {_id: 2}, u: {$inc: {x: 1}}}
],
stmtIds: [stmtId1, stmtId2]
}
],
retrySessionOpts);
const [retryRes] = runCommandsWithSessionOpts(
db,
[{
update: kCollName,
updates: [{q: {_id: 1}, u: {$inc: {x: 1}}}, {q: {_id: 2}, u: {$inc: {x: 1}}}],
stmtIds: [stmtId1, stmtId2]
}],
retrySessionOpts);
assert.eq(initialRes.nModified, 1);
assert(!initialRes.hasOwnProperty("retriedStmtIds"));

View File

@ -499,11 +499,9 @@ const st = new ShardingTest({mongos: 1, shards: 2});
cmdResponse, [ErrorCodes.SnapshotUnavailable, ErrorCodes.StaleChunkHistory]);
}
['find',
'aggregate']
.forEach(command => {
runTest(command);
});
['find', 'aggregate'].forEach(command => {
runTest(command);
});
}
st.stop();

View File

@ -10,8 +10,8 @@
import {ShardingTest} from "jstests/libs/shardingtest.js";
// Checking UUID and index consistency involves talking to a shard node, which in this
// test is shutdown.
//  Checking UUID and index consistency involves talking to a shard node, which in this
//  test is shutdown.
TestData.skipCheckingUUIDsConsistentAcrossCluster = true;
TestData.skipCheckingIndexesConsistentAcrossCluster = true;
TestData.skipCheckOrphans = true;

View File

@ -17,8 +17,7 @@
* - The read will fail with SnapshotTooOld, mongos should retry and succeed.
* - Assert the read succeeded and returned the updated (post-updateTS) document.
*/
import {kDefaultWaitForFailPointTimeout} from "jstests/libs/fail_point_util.js";
import {configureFailPoint} from "jstests/libs/fail_point_util.js";
import {configureFailPoint, kDefaultWaitForFailPointTimeout} from "jstests/libs/fail_point_util.js";
import {funWithArgs} from "jstests/libs/parallel_shell_helpers.js";
import {ShardingTest} from "jstests/libs/shardingtest.js";

View File

@ -6,7 +6,6 @@
*/
import {FeatureFlagUtil} from "jstests/libs/feature_flag_util.js";
import {ShardTargetingTest} from "jstests/libs/shard_targeting_util.js";
import {ShardingTest} from "jstests/libs/shardingtest.js";
const st = new ShardingTest({shards: 2, mongos: 1});

View File

@ -61,24 +61,22 @@ for (let id = 0; id < nDocs; ++id) {
assert.commandWorked(mongosColl.update(documentKey, {$set: {updatedCount: 1}}));
}
[changeStreamSingleColl,
changeStreamWholeDb]
.forEach(function(changeStream) {
jsTestLog(`Testing updateLookup on namespace ${changeStream._ns}`);
for (let id = 0; id < nDocs; ++id) {
assert.soon(() => changeStream.hasNext());
let next = changeStream.next();
assert.eq(next.operationType, "insert");
assert.eq(next.documentKey, Object.merge(shardKeyFromId(id), {_id: id}));
[changeStreamSingleColl, changeStreamWholeDb].forEach(function(changeStream) {
jsTestLog(`Testing updateLookup on namespace ${changeStream._ns}`);
for (let id = 0; id < nDocs; ++id) {
assert.soon(() => changeStream.hasNext());
let next = changeStream.next();
assert.eq(next.operationType, "insert");
assert.eq(next.documentKey, Object.merge(shardKeyFromId(id), {_id: id}));
assert.soon(() => changeStream.hasNext());
next = changeStream.next();
assert.eq(next.operationType, "update");
assert.eq(next.documentKey, Object.merge(shardKeyFromId(id), {_id: id}));
assert.docEq(Object.merge(shardKeyFromId(id), {_id: id, updatedCount: 1}),
next.fullDocument);
}
});
assert.soon(() => changeStream.hasNext());
next = changeStream.next();
assert.eq(next.operationType, "update");
assert.eq(next.documentKey, Object.merge(shardKeyFromId(id), {_id: id}));
assert.docEq(Object.merge(shardKeyFromId(id), {_id: id, updatedCount: 1}),
next.fullDocument);
}
});
// Test that the change stream can still see the updated post image, even if a chunk is
// migrated.

View File

@ -78,12 +78,10 @@ function testEpochChangeDuringAgg({mergeSpec, failpoint, failpointData}) {
// Use a failpoint to make the query feeding into the aggregate hang while we drop the
// collection.
[st.rs0.getPrimary(),
st.rs1.getPrimary()]
.forEach((mongod) => {
assert.commandWorked(mongod.adminCommand(
{configureFailPoint: failpoint, mode: "alwaysOn", data: failpointData || {}}));
});
[st.rs0.getPrimary(), st.rs1.getPrimary()].forEach((mongod) => {
assert.commandWorked(mongod.adminCommand(
{configureFailPoint: failpoint, mode: "alwaysOn", data: failpointData || {}}));
});
let parallelShellJoiner;
try {

View File

@ -107,18 +107,15 @@ function assertWouldChangeOwningShardUpdateResult(res, expectedUpdatedDoc) {
//
// Test behaviours common to update and upsert.
[false,
true]
.forEach(function(isUpsert) {
// Full shard key in query matches the update document.
assertUpdateWorked({x: 4, y: 3, z: 3}, {x: 4, y: 3, z: 3, a: 0}, isUpsert, 0);
assertUpdateWorked({x: 4, _id: 0, z: 3, y: 3}, {x: 4, y: 3, z: 3, a: 0}, isUpsert, 0);
[false, true].forEach(function(isUpsert) {
// Full shard key in query matches the update document.
assertUpdateWorked({x: 4, y: 3, z: 3}, {x: 4, y: 3, z: 3, a: 0}, isUpsert, 0);
assertUpdateWorked({x: 4, _id: 0, z: 3, y: 3}, {x: 4, y: 3, z: 3, a: 0}, isUpsert, 0);
// Case when upsert needs to insert a new document and the new document should belong in the
// same shard as the targeted shard. For non-upserts, it will be a no-op.
assertUpdateWorkedWithNoMatchingDoc(
{x: 4, y: 0, z: 0}, {x: 1, z: 3, y: 110, a: 90}, isUpsert);
});
// Case when upsert needs to insert a new document and the new document should belong in the
// same shard as the targeted shard. For non-upserts, it will be a no-op.
assertUpdateWorkedWithNoMatchingDoc({x: 4, y: 0, z: 0}, {x: 1, z: 3, y: 110, a: 90}, isUpsert);
});
//
// Test behaviours specific to non-upsert updates.

View File

@ -32,10 +32,10 @@ function merge(x, y) {
}
function runInsertScenarios(injectCodeField, extractCode, message) {
for (const testCase of [
[{}, false, "Not rewritten by default."],
[{allowRewriteStateChange: false}, false, "Explicitly disallowing rewrites."],
[{allowRewriteStateChange: true}, true, "Explicitly allowing rewrites."],
for (const testCase
of [[{}, false, "Not rewritten by default."],
[{allowRewriteStateChange: false}, false, "Explicitly disallowing rewrites."],
[{allowRewriteStateChange: true}, true, "Explicitly allowing rewrites."],
]) {
const [allowConfigFields, rewriteAllowed, desc] = testCase;
const summary = message + ": " + desc;

View File

@ -1529,8 +1529,7 @@ export var fc = (function() {
} else {
rangeSizeArrayIntValue.data[1] += 1;
}
(0,
UnsafeUniformArrayIntDistributionInternal_1.unsafeUniformArrayIntDistributionInternal)(
(0, UnsafeUniformArrayIntDistributionInternal_1.unsafeUniformArrayIntDistributionInternal)(
sharedData, rangeSizeArrayIntValue.data, rng);
return sharedData[0] * 0x100000000 + sharedData[1] + from;
}

View File

@ -4969,136 +4969,138 @@ const plotEmbeddings = [
* "fullplot" and "title" has no ties.
*/
export function getMovieData() {
const data = [
{
"_id": 0,
"title": "It's a Mad, Mad, Mad, Mad World",
"genres": ["Action", "Adventure", "Comedy"],
"plot_embedding": plotEmbeddings[0],
"fullplot":
"After a long prison sentence Smiler Grogan is heading at high speed to a California park where he hid $350,000 from a job 15 years previously. He accidentally careens over a cliff in view of four cars whose occupants go down to help. The dying Grogan gives details of where the money is buried and when the witnesses fail to agree on sharing the cash, a crazy chase develops across the state."
},
{
"_id": 1,
"title": "Battle for the Planet of the Apes",
"genres": ["Action", "Sci-Fi"],
"plot_embedding": plotEmbeddings[1],
"fullplot":
"After conquering the oppressive humans in \"Conquest for the Planet of the Apes\", Caesar must now keep the peace among the humans and apes. Gorilla General Aldo views things differently, and tries to cause an ape civil war. In the meantime, other human survivors learn of the ape city, and decide they want to take back civilization for themselves, thus setting the stage of warring ape factions and humans."
},
{
"_id": 2,
"title": "King Kong Lives",
"genres": ["Action", "Adventure", "Horror"],
"plot_embedding": plotEmbeddings[2],
"fullplot":
"A giant ape King Kong, which was shot and fell off the World Trade Center tower, appears to be alive, but is in coma for 10 years and desperately needs a blood transfusion in order to have an artificial heart implanted. Suddenly, in the rainforest, another gigantic ape is found - this time a female. She is brought to the USA, and the heart is successfully implanted. But then King Kong, having sensed the female ape, breaks loose."
},
{
"_id": 3,
"title": "Rise of the Planet of the Apes",
"genres": ["Action", "Drama", "Sci-Fi"],
"plot_embedding": plotEmbeddings[3],
"fullplot":
"At the story's heart is Caesar (Andy Serkis), a chimpanzee who gains human-like intelligence and emotions from an experimental drug. Raised like a child by the drug's creator, Will Rodman (James Franco) and a primatologist Caroline Aranha (Freida Pinto), Caesar ultimately finds himself taken from the humans he loves and imprisoned in an ape sanctuary in San Bruno. Seeking justice for his fellow inmates, Caesar gives the fellow apes the same drug that he inherited. He then assembles a simian army and escapes the sanctuary - putting man and ape on a collision course that could change the planet forever."
},
{
"_id": 4,
"title": "King Kong",
"genres": ["Adventure", "Fantasy", "Horror"],
"plot_embedding": plotEmbeddings[4],
"fullplot":
"An expedition of the \"Petrox\" company, is exploring in search of petrol. A strange island where they arrive is the home of a giant ape, King Kong, that is captured by the expedition in order to make money exhibiting it to the world. When in the U.S. the huge gorilla becomes restless, trying to return home..."
},
{
"_id": 5,
"title": "George of the Jungle",
"genres": ["Action", "Adventure", "Comedy"],
"plot_embedding": plotEmbeddings[5],
"fullplot":
"Baby George got into a plane crash in a jungle, stayed alive and was adopted by a wise ape. Ursula Stanhope, US noble woman is saved from death on safari by grown-up George, and he takes her to jungle to live with him. He slowly learns a rules of human relationships, while Ursula's lover Lyle is looking for her and the one who took her. After they are found, Ursula takes George to the USA."
},
{
"_id": 6,
"title": "Tarzan the Ape Man",
"genres": ["Action", "Adventure", "Romance"],
"plot_embedding": plotEmbeddings[6],
"fullplot":
"James Parker and Harry Holt are on an expedition in Africa in search of the elephant burial grounds that will provide enough ivory to make them rich. Parker's beautiful young daughter Jane arrives unexpectedly to join them. Harry is obviously attracted to Jane and he does his best to help protect her from all the dangers that they experience in the jungle. Jane is terrified when Tarzan and his ape friends first abduct her, but when she returns to her father's expedition she has second thoughts about leaving Tarzan. After the expedition is captured by a tribe of violent dwarfs, Jane sends Cheetah to bring Tarzan to rescue them..."
},
{
"_id": 7,
"title": "Abraham Lincoln: Vampire Hunter",
"genres": ["Action", "Fantasy", "Horror"],
"plot_embedding": plotEmbeddings[7],
"fullplot":
"At the age of 9, Abraham Lincoln witnesses his mother being killed by a vampire, Jack Barts. Some 10 years later, he unsuccessfully tries to eliminate Barts but in the process makes the acquaintance of Henry Sturgess who teaches him how to fight and what is required to kill a vampire. The quid pro quo is that Abe will kill only those vampires that Henry directs him to. Abe relocates to Springfield where he gets a job as a store clerk while he studies the law and kills vampires by night. He also meets and eventually marries the pretty Mary Todd. Many years later as President of the United States, he comes to realize that vampires are fighting with the Confederate forces. As a result he mounts his own campaign to defeat them."
},
{
"_id": 8,
"title": "The Son of Kong",
"genres": ["Adventure", "Comedy", "Fantasy"],
"plot_embedding": plotEmbeddings[8],
"fullplot":
"After the disastrous results of his last expedition, Carl Denham leaves New York aboard a ship to escape all the trouble. After a mutiny, he and a few companions are left behind on Skull island, where they meet a smaller relative of King Kong and make friends with him."
},
{
"_id": 9,
"title": "Planet of the Apes",
"genres": ["Action", "Adventure", "Sci-Fi"],
"plot_embedding": plotEmbeddings[9],
"fullplot":
"It is the year 2029: Astronaut Leo Davidson boards a pod cruiser on a Space Station for a \"routine\" reconnaissance mission. But an abrupt detour through a space time wormhole lands him on a strange planet where talking apes rule over the human race. With the help of a sympathetic chimpanzee activist named Ari and a small band of human rebels, Leo leads the effort to evade the advancing Gorilla Army led by General Thade and his most trusted warrior Attar. Now the race is on to reach a sacred temple within the planet's Forbidden Zone to discover the shocking secrets of mankind's past - and the key to its future."
},
{
"_id": 10,
"title": "Dawn of the Planet of the Apes",
"genres": ["Action", "Drama", "Sci-Fi"],
"plot_embedding": plotEmbeddings[10],
"fullplot":
"A growing nation of genetically evolved apes led by Caesar is threatened by a band of human survivors of the devastating virus unleashed a decade earlier. They reach a fragile peace, but it proves short-lived, as both sides are brought to the brink of a war that will determine who will emerge as Earth's dominant species."
},
{
"_id": 11,
"title": "Kung Fu Panda",
"genres": ["Animation", "Action", "Adventure"],
"plot_embedding": plotEmbeddings[11],
"fullplot":
"It's the story about a lazy, irreverent slacker panda, named Po, who is the biggest fan of Kung Fu around...which doesn't exactly come in handy while working every day in his family's noodle shop. Unexpectedly chosen to fulfill an ancient prophecy, Po's dreams become reality when he joins the world of Kung Fu and studies alongside his idols, the legendary Furious Five -- Tigress, Crane, Mantis, Viper and Monkey -- under the leadership of their guru, Master Shifu. But before they know it, the vengeful and treacherous snow leopard Tai Lung is headed their way, and it's up to Po to defend everyone from the oncoming threat. Can he turn his dreams of becoming a Kung Fu master into reality? Po puts his heart - and his girth - into the task, and the unlikely hero ultimately finds that his greatest weaknesses turn out to be his greatest strengths."
},
{
"_id": 12,
"title": "Hatari!",
"genres": ["Action", "Adventure", "Drama"],
"plot_embedding": plotEmbeddings[12],
"fullplot":
"John Wayne and his ensemble cast cavort over the African landscape filling orders from zoos for wild animals. Bruce Cabot plays \"the Indian\", a womanizing sharpshooter who is gored by a rhino in the opening scenes of the film. This becomes a running theme through the movie; their bad luck in catching rhinos, and provides the climactic ending chase. While Bruce is in the hospital, Elsa Martinelli shows up as a woman photographer from a Swiss zoo, and John wants to send her packing. She strongarms the Duke into letting her stay by promising that her zoo will buy most of their animals this season if she's allowed to go along on the hunts and take photos. Hardy Kruger, Gerard Blain, Michelle Girardon and Valentin de Vargas round out the group. They traipse over the African landscape capturing animals; Elsa also has a running gag where she collects baby elephants as the movie goes along. In the end she's acquired three of them."
},
{
"_id": 13,
"title": "Journey to the Center of the Earth",
"genres": ["Action", "Adventure", "Family"],
"plot_embedding": plotEmbeddings[13],
"fullplot":
"Professor Trevor Anderson receives his teenager nephew Sean Anderson. He will spend ten days with his uncle while his mother, Elizabeth, prepares to move to Canada. She gives a box to Trevor that belonged to his missing brother, Max, and Trevor finds a book with references to the last journey of his brother. He decides to follow the steps of Max with Sean and they travel to Iceland, where they meet the guide Hannah èsgeirsson. While climbing a mountain, there is a thunderstorm and they protect themselves in a cave. However, a lightening collapses the entrance and the trio is trapped in the cave. They seek an exit and falls in a hole, discovering a lost world in the center of the Earth."
},
{
"_id": 14,
"title": "Beauty and the Beast",
"genres": ["Fantasy", "Romance"],
"plot_embedding": plotEmbeddings[14],
"fullplot":
"An unexpected romance blooms after the the youngest daughter of a merchant who has fallen on hard times offers herself to the mysterious beast to which her father has become indebted."
},
{
"_id": 15,
"title": "Titanic",
"genres": ["Action", "Drama", "History"],
"plot_embedding": plotEmbeddings[15],
"fullplot":
"The plot focuses on the romances of two couples upon the doomed ship's maiden voyage. Isabella Paradine (Catherine Zeta-Jones) is a wealthy woman mourning the loss of her aunt, who reignites a romance with former flame Wynn Park (Peter Gallagher). Meanwhile, a charming ne'er-do-well named Jamie Perse (Mike Doyle) steals a ticket for the ship, and falls for a sweet innocent Irish girl on board. But their romance is threatened by the villainous Simon Doonan (Tim Curry), who has discovered about the ticket and makes Jamie his unwilling accomplice, as well as having sinister plans for the girl."
}
];
const
data =
[
{
"_id": 0,
"title": "It's a Mad, Mad, Mad, Mad World",
"genres": ["Action", "Adventure", "Comedy"],
"plot_embedding": plotEmbeddings[0],
"fullplot":
"After a long prison sentence Smiler Grogan is heading at high speed to a California park where he hid $350,000 from a job 15 years previously. He accidentally careens over a cliff in view of four cars whose occupants go down to help. The dying Grogan gives details of where the money is buried and when the witnesses fail to agree on sharing the cash, a crazy chase develops across the state."
},
{
"_id": 1,
"title": "Battle for the Planet of the Apes",
"genres": ["Action", "Sci-Fi"],
"plot_embedding": plotEmbeddings[1],
"fullplot":
"After conquering the oppressive humans in \"Conquest for the Planet of the Apes\", Caesar must now keep the peace among the humans and apes. Gorilla General Aldo views things differently, and tries to cause an ape civil war. In the meantime, other human survivors learn of the ape city, and decide they want to take back civilization for themselves, thus setting the stage of warring ape factions and humans."
},
{
"_id": 2,
"title": "King Kong Lives",
"genres": ["Action", "Adventure", "Horror"],
"plot_embedding": plotEmbeddings[2],
"fullplot":
"A giant ape King Kong, which was shot and fell off the World Trade Center tower, appears to be alive, but is in coma for 10 years and desperately needs a blood transfusion in order to have an artificial heart implanted. Suddenly, in the rainforest, another gigantic ape is found - this time a female. She is brought to the USA, and the heart is successfully implanted. But then King Kong, having sensed the female ape, breaks loose."
},
{
"_id": 3,
"title": "Rise of the Planet of the Apes",
"genres": ["Action", "Drama", "Sci-Fi"],
"plot_embedding": plotEmbeddings[3],
"fullplot":
"At the story's heart is Caesar (Andy Serkis), a chimpanzee who gains human-like intelligence and emotions from an experimental drug. Raised like a child by the drug's creator, Will Rodman (James Franco) and a primatologist Caroline Aranha (Freida Pinto), Caesar ultimately finds himself taken from the humans he loves and imprisoned in an ape sanctuary in San Bruno. Seeking justice for his fellow inmates, Caesar gives the fellow apes the same drug that he inherited. He then assembles a simian army and escapes the sanctuary - putting man and ape on a collision course that could change the planet forever."
},
{
"_id": 4,
"title": "King Kong",
"genres": ["Adventure", "Fantasy", "Horror"],
"plot_embedding": plotEmbeddings[4],
"fullplot":
"An expedition of the \"Petrox\" company, is exploring in search of petrol. A strange island where they arrive is the home of a giant ape, King Kong, that is captured by the expedition in order to make money exhibiting it to the world. When in the U.S. the huge gorilla becomes restless, trying to return home..."
},
{
"_id": 5,
"title": "George of the Jungle",
"genres": ["Action", "Adventure", "Comedy"],
"plot_embedding": plotEmbeddings[5],
"fullplot":
"Baby George got into a plane crash in a jungle, stayed alive and was adopted by a wise ape. Ursula Stanhope, US noble woman is saved from death on safari by grown-up George, and he takes her to jungle to live with him. He slowly learns a rules of human relationships, while Ursula's lover Lyle is looking for her and the one who took her. After they are found, Ursula takes George to the USA."
},
{
"_id": 6,
"title": "Tarzan the Ape Man",
"genres": ["Action", "Adventure", "Romance"],
"plot_embedding": plotEmbeddings[6],
"fullplot":
"James Parker and Harry Holt are on an expedition in Africa in search of the elephant burial grounds that will provide enough ivory to make them rich. Parker's beautiful young daughter Jane arrives unexpectedly to join them. Harry is obviously attracted to Jane and he does his best to help protect her from all the dangers that they experience in the jungle. Jane is terrified when Tarzan and his ape friends first abduct her, but when she returns to her father's expedition she has second thoughts about leaving Tarzan. After the expedition is captured by a tribe of violent dwarfs, Jane sends Cheetah to bring Tarzan to rescue them..."
},
{
"_id": 7,
"title": "Abraham Lincoln: Vampire Hunter",
"genres": ["Action", "Fantasy", "Horror"],
"plot_embedding": plotEmbeddings[7],
"fullplot":
"At the age of 9, Abraham Lincoln witnesses his mother being killed by a vampire, Jack Barts. Some 10 years later, he unsuccessfully tries to eliminate Barts but in the process makes the acquaintance of Henry Sturgess who teaches him how to fight and what is required to kill a vampire. The quid pro quo is that Abe will kill only those vampires that Henry directs him to. Abe relocates to Springfield where he gets a job as a store clerk while he studies the law and kills vampires by night. He also meets and eventually marries the pretty Mary Todd. Many years later as President of the United States, he comes to realize that vampires are fighting with the Confederate forces. As a result he mounts his own campaign to defeat them."
},
{
"_id": 8,
"title": "The Son of Kong",
"genres": ["Adventure", "Comedy", "Fantasy"],
"plot_embedding": plotEmbeddings[8],
"fullplot":
"After the disastrous results of his last expedition, Carl Denham leaves New York aboard a ship to escape all the trouble. After a mutiny, he and a few companions are left behind on Skull island, where they meet a smaller relative of King Kong and make friends with him."
},
{
"_id": 9,
"title": "Planet of the Apes",
"genres": ["Action", "Adventure", "Sci-Fi"],
"plot_embedding": plotEmbeddings[9],
"fullplot":
"It is the year 2029: Astronaut Leo Davidson boards a pod cruiser on a Space Station for a \"routine\" reconnaissance mission. But an abrupt detour through a space time wormhole lands him on a strange planet where talking apes rule over the human race. With the help of a sympathetic chimpanzee activist named Ari and a small band of human rebels, Leo leads the effort to evade the advancing Gorilla Army led by General Thade and his most trusted warrior Attar. Now the race is on to reach a sacred temple within the planet's Forbidden Zone to discover the shocking secrets of mankind's past - and the key to its future."
},
{
"_id": 10,
"title": "Dawn of the Planet of the Apes",
"genres": ["Action", "Drama", "Sci-Fi"],
"plot_embedding": plotEmbeddings[10],
"fullplot":
"A growing nation of genetically evolved apes led by Caesar is threatened by a band of human survivors of the devastating virus unleashed a decade earlier. They reach a fragile peace, but it proves short-lived, as both sides are brought to the brink of a war that will determine who will emerge as Earth's dominant species."
},
{
"_id": 11,
"title": "Kung Fu Panda",
"genres": ["Animation", "Action", "Adventure"],
"plot_embedding": plotEmbeddings[11],
"fullplot":
"It's the story about a lazy, irreverent slacker panda, named Po, who is the biggest fan of Kung Fu around...which doesn't exactly come in handy while working every day in his family's noodle shop. Unexpectedly chosen to fulfill an ancient prophecy, Po's dreams become reality when he joins the world of Kung Fu and studies alongside his idols, the legendary Furious Five -- Tigress, Crane, Mantis, Viper and Monkey -- under the leadership of their guru, Master Shifu. But before they know it, the vengeful and treacherous snow leopard Tai Lung is headed their way, and it's up to Po to defend everyone from the oncoming threat. Can he turn his dreams of becoming a Kung Fu master into reality? Po puts his heart - and his girth - into the task, and the unlikely hero ultimately finds that his greatest weaknesses turn out to be his greatest strengths."
},
{
"_id": 12,
"title": "Hatari!",
"genres": ["Action", "Adventure", "Drama"],
"plot_embedding": plotEmbeddings[12],
"fullplot":
"John Wayne and his ensemble cast cavort over the African landscape filling orders from zoos for wild animals. Bruce Cabot plays \"the Indian\", a womanizing sharpshooter who is gored by a rhino in the opening scenes of the film. This becomes a running theme through the movie; their bad luck in catching rhinos, and provides the climactic ending chase. While Bruce is in the hospital, Elsa Martinelli shows up as a woman photographer from a Swiss zoo, and John wants to send her packing. She strongarms the Duke into letting her stay by promising that her zoo will buy most of their animals this season if she's allowed to go along on the hunts and take photos. Hardy Kruger, Gerard Blain, Michelle Girardon and Valentin de Vargas round out the group. They traipse over the African landscape capturing animals; Elsa also has a running gag where she collects baby elephants as the movie goes along. In the end she's acquired three of them."
},
{
"_id": 13,
"title": "Journey to the Center of the Earth",
"genres": ["Action", "Adventure", "Family"],
"plot_embedding": plotEmbeddings[13],
"fullplot":
"Professor Trevor Anderson receives his teenager nephew Sean Anderson. He will spend ten days with his uncle while his mother, Elizabeth, prepares to move to Canada. She gives a box to Trevor that belonged to his missing brother, Max, and Trevor finds a book with references to the last journey of his brother. He decides to follow the steps of Max with Sean and they travel to Iceland, where they meet the guide Hannah èsgeirsson. While climbing a mountain, there is a thunderstorm and they protect themselves in a cave. However, a lightening collapses the entrance and the trio is trapped in the cave. They seek an exit and falls in a hole, discovering a lost world in the center of the Earth."
},
{
"_id": 14,
"title": "Beauty and the Beast",
"genres": ["Fantasy", "Romance"],
"plot_embedding": plotEmbeddings[14],
"fullplot":
"An unexpected romance blooms after the the youngest daughter of a merchant who has fallen on hard times offers herself to the mysterious beast to which her father has become indebted."
},
{
"_id": 15,
"title": "Titanic",
"genres": ["Action", "Drama", "History"],
"plot_embedding": plotEmbeddings[15],
"fullplot":
"The plot focuses on the romances of two couples upon the doomed ship's maiden voyage. Isabella Paradine (Catherine Zeta-Jones) is a wealthy woman mourning the loss of her aunt, who reignites a romance with former flame Wynn Park (Peter Gallagher). Meanwhile, a charming ne'er-do-well named Jamie Perse (Mike Doyle) steals a ticket for the ship, and falls for a sweet innocent Irish girl on board. But their romance is threatened by the villainous Simon Doonan (Tim Curry), who has discovered about the ticket and makes Jamie his unwilling accomplice, as well as having sinister plans for the girl."
}
];
return data;
}

View File

@ -32,7 +32,9 @@ function assertResultsExpectedFuzzyTest() {
}
// Trival success case, empty arrays must be equal.
{ assertDocArrExpectedFuzzy([], []); }
{
assertDocArrExpectedFuzzy([], []);
}
// Test that tolerance percentages within range [0, 1] are accepted.
{

View File

@ -6,6 +6,7 @@
*/
import "jstests/libs/query/sbe_assert_error_override.js";
import {FeatureFlagUtil} from "jstests/libs/feature_flag_util.js";
import {checkSbeRestrictedOrFullyEnabled} from "jstests/libs/query/sbe_util.js";
import {getUUIDFromListCollections} from "jstests/libs/uuid_util.js";

View File

@ -175,14 +175,14 @@ public:
inline ~clonable_ptr() = default;
/*! Moves a value, by pointer. Functions like `std::unique_ptr`. */
inline clonable_ptr(clonable_ptr&&) noexcept(noexcept(CloneFactory{
std::declval<CloneFactory>()}) && noexcept(UniquePtr<T>{
std::declval<UniquePtr<T>>()})) = default;
inline clonable_ptr(clonable_ptr&&) noexcept(
noexcept(CloneFactory{std::declval<CloneFactory>()}) &&
noexcept(UniquePtr<T>{std::declval<UniquePtr<T>>()})) = default;
/*! Moves a value, by pointer. Functions like `std::unique_ptr`. */
inline clonable_ptr& operator=(clonable_ptr&&) & noexcept(
noexcept(std::declval<CloneFactory>() = std::declval<CloneFactory>()) && noexcept(
std::declval<UniquePtr<T>>() = std::declval<UniquePtr<T>>())) = default;
noexcept(std::declval<CloneFactory>() = std::declval<CloneFactory>()) &&
noexcept(std::declval<UniquePtr<T>>() = std::declval<UniquePtr<T>>())) = default;
/*!
* Constructs a pointer referring to a new copy of an original value. The old object owned by

View File

@ -247,10 +247,14 @@ namespace SyntaxTests {
template <typename Clonable>
void construction() {
// Test default construction
{ mongo::clonable_ptr<Clonable>{}; }
{
mongo::clonable_ptr<Clonable>{};
}
// Test construction from a nullptr
{ mongo::clonable_ptr<Clonable>{nullptr}; }
{
mongo::clonable_ptr<Clonable>{nullptr};
}
// Test construction from a Clonable pointer.
{
@ -259,7 +263,9 @@ void construction() {
}
// Test move construction.
{ std::ignore = mongo::clonable_ptr<Clonable>{mongo::clonable_ptr<Clonable>{}}; }
{
std::ignore = mongo::clonable_ptr<Clonable>{mongo::clonable_ptr<Clonable>{}};
}
// Test copy construction.
{
@ -281,7 +287,9 @@ void construction() {
}
// Test unique pointer construction
{ mongo::clonable_ptr<Clonable>{std::make_unique<Clonable>()}; }
{
mongo::clonable_ptr<Clonable>{std::make_unique<Clonable>()};
}
// Test unique pointer construction (conversion)
{
@ -291,7 +299,9 @@ void construction() {
}
// Test non-conversion pointer construction
{ static_assert(!std::is_convertible<Clonable*, mongo::clonable_ptr<Clonable>>::value); }
{
static_assert(!std::is_convertible<Clonable*, mongo::clonable_ptr<Clonable>>::value);
}
// Test conversion unique pointer construction
{
@ -310,7 +320,9 @@ void augmentedConstruction() {
}
// Test Clone Factory construction
{ mongo::clonable_ptr<Clonable, CloneFactory>{Clonable::getCloningFunction()}; }
{
mongo::clonable_ptr<Clonable, CloneFactory>{Clonable::getCloningFunction()};
}
// TODO: Revist this when MSVC's enable-if and deletion on ctors works.
#ifndef _MSC_VER
@ -322,7 +334,9 @@ void augmentedConstruction() {
#endif
// Test construction from a nullptr with factory
{ mongo::clonable_ptr<Clonable, CloneFactory>{nullptr, Clonable::getCloningFunction()}; }
{
mongo::clonable_ptr<Clonable, CloneFactory>{nullptr, Clonable::getCloningFunction()};
}
// TODO: Revist this when MSVC's enable-if and deletion on ctors works.
#ifndef _MSC_VER

View File

@ -73,9 +73,9 @@ protected:
template <typename T>
static constexpr bool isContiguousContainerOfByteLike = //
stdx::is_detected_v<SizeOp, T>&& //
stdx::is_detected_v<DataOp, T>&& //
isByte<stdx::detected_t<ValueTypeOp, T>>;
stdx::is_detected_v<SizeOp, T> && //
stdx::is_detected_v<DataOp, T> && //
isByte<stdx::detected_t<ValueTypeOp, T>>;
public:
using byte_type = char;

View File

@ -36,7 +36,7 @@
namespace mongo {
struct ZeroInitTag_t {
ZeroInitTag_t(){};
ZeroInitTag_t() {};
};
const ZeroInitTag_t kZeroInitTag;

View File

@ -180,11 +180,9 @@ TEST(UUIDTest, toAndFromBSON) {
ASSERT_EQUALS(uuidBSON.woCompare(uuidBSON2), 0);
// UUIDs cannot be constructed from invalid BSON elements
auto bson2 = BSON("uuid"
<< "sam");
auto bson2 = BSON("uuid" << "sam");
ASSERT_EQUALS(ErrorCodes::InvalidUUID, UUID::parse(bson2.getField("uuid")));
auto bson3 = BSON("uuid"
<< "dddddddd-eeee-4fff-aaaa-bbbbbbbbbbbb");
auto bson3 = BSON("uuid" << "dddddddd-eeee-4fff-aaaa-bbbbbbbbbbbb");
ASSERT_EQUALS(ErrorCodes::InvalidUUID, UUID::parse(bson3.getField("uuid")));
auto bson4 = BSON("uuid" << 14);
ASSERT_EQUALS(ErrorCodes::InvalidUUID, UUID::parse(bson4.getField("uuid")));

View File

@ -80,10 +80,9 @@ BSONObj buildSampleObj(uint64_t i) {
return BSON(GENOID << "name"
<< "Wile E. Coyote"
<< "age" << pseudoRandomAge(i) << "i" << static_cast<int>(i) << "address"
<< BSON("street"
<< "433 W 43rd St"
<< "zip_code" << pseudoRandomZipCode(i) << "city"
<< "New York")
<< BSON("street" << "433 W 43rd St"
<< "zip_code" << pseudoRandomZipCode(i) << "city"
<< "New York")
<< "random" << pseudoRandom7Digits(i) << "phone_no" << pseudoRandomPhoneNo(i)
<< "long_string" << pseudoRandomLongStr(i));
}

View File

@ -655,9 +655,8 @@ TEST(Looping, Cpp17StructuredBindings) {
TEST(BSONObj, getFieldsWithEmbeddedNull) {
// Test that getField() returns an eoo element when the field name contains an embedded null.
// This should never happen, but we want to make sure we handle it correctly.
BSONObj obj = BSON(""
<< "foo"_sd
<< "bar" << 9 << "baz" << 4.5);
BSONObj obj = BSON("" << "foo"_sd
<< "bar" << 9 << "baz" << 4.5);
ASSERT_TRUE(obj.getField("\0"_sd).eoo());
ASSERT_TRUE(obj.getField("ba\0r"_sd).eoo());
ASSERT_TRUE(obj.getField("baz\0"_sd).eoo());

View File

@ -418,8 +418,7 @@ TEST(checkAndScrubInvalidUTF8, SimpleCodeWScope) {
// The invalid code is in the BSONObj of the CodeWScope, not the codeStr.
std::string validCode2 = "var x;";
BSONObj invalidCodeObj1 = BSON("x"
<< "\xf8\x80\x80\x80\x80");
BSONObj invalidCodeObj1 = BSON("x" << "\xf8\x80\x80\x80\x80");
BSONObj invalidCodeWScopeWithEmptyField2 =
makeBSONCodeWScopeObject("", validCode2, invalidCodeObj1);
@ -431,8 +430,7 @@ TEST(checkAndScrubInvalidUTF8, SimpleCodeWScope) {
// The invalid code is both in the codeStr and BSONObj of the CodeWScope.
std::string invalidCode2 = "var x; print('\xc3\x28');";
BSONObj invalidCodeObj2 = BSON("x"
<< "\xde\xa0\x80");
BSONObj invalidCodeObj2 = BSON("x" << "\xde\xa0\x80");
BSONObj invalidCodeWScopeWithEmptyField3 =
makeBSONCodeWScopeObject("", invalidCode2, invalidCodeObj2);
scrubAndAssertUTF8Valid(invalidCodeWScopeWithEmptyField3);
@ -528,13 +526,11 @@ TEST(checkAndScrubInvalidUTF8, SimpleArrays) {
TEST(checkAndScrubInvalidUTF8, DoesNotScrubNestedValidUTF8) {
// Tests that there isn't scrubbing of nested valid UTF-8.
// {a: "😊"}
BSONObj oneNest = BSON("a"
<< "😊");
BSONObj oneNest = BSON("a" << "😊");
unchangedBSONInput(oneNest);
// {c: {'rewind': "こんにちは"}}
BSONObj twoNest = BSON("c" << BSON("rewind"
<< "こんにちは"));
BSONObj twoNest = BSON("c" << BSON("rewind" << "こんにちは"));
unchangedBSONInput(twoNest);
// Test valid BSONCode.
@ -559,16 +555,11 @@ TEST(checkAndScrubInvalidUTF8, DoesNotScrubNestedValidUTF8) {
}
// Used for NestedInvalidUTF8[...] tests, declared globally because of the mixedBag# tests.
BSONObj oneNestInvalid = BSON("a"
<< "\xc2");
BSONObj oneNestFieldNameInvalid = BSON("\xde\xa0\x80"
<< "talk talk");
BSONObj twoNestInvalid1 = BSON("c" << BSON("\x80"
<< "\xff\x80\x80\x80\x80\x80\x80\x80"));
BSONObj twoNestInvalid2 = BSON("\xc3\x28" << BSON("\xf0\x9d\xdc\x80 "
<< "B2B"));
BSONObj invalidNestedCode = BSON("code" << BSON("code1"
<< "(function(){\xe2\x28\xa1})());"));
BSONObj oneNestInvalid = BSON("a" << "\xc2");
BSONObj oneNestFieldNameInvalid = BSON("\xde\xa0\x80" << "talk talk");
BSONObj twoNestInvalid1 = BSON("c" << BSON("\x80" << "\xff\x80\x80\x80\x80\x80\x80\x80"));
BSONObj twoNestInvalid2 = BSON("\xc3\x28" << BSON("\xf0\x9d\xdc\x80 " << "B2B"));
BSONObj invalidNestedCode = BSON("code" << BSON("code1" << "(function(){\xe2\x28\xa1})());"));
std::string invalidCode1 = "(\xc2 function(){print(x);})();";
BSONObj validCodeObj1 = BSON("x" << 1);
BSONObj invalidCodeWScope1 = makeBSONCodeWScopeObject("codeWScope1", invalidCode1, validCodeObj1);
@ -577,14 +568,12 @@ BSONObj invalidCodeObj1 = makeBSONCodeObject("codeSnippet1", "(function(){\xe2\x
BSONObj invalidCodeObj2 = makeBSONCodeObject("codeSnippet2", "var x = \xde\xa0\x80;");
std::string validCode1 = "var y;";
BSONObj invalidCodeObj3 = BSON("y"
<< "\xe0");
BSONObj invalidCodeObj3 = BSON("y" << "\xe0");
BSONObj invalidCodeWScope2 = makeBSONCodeWScopeObject("codeWScope2", validCode1, invalidCodeObj3);
// The invalid code is both in the codeStr and BSONObj of the CodeWScope.
std::string invalidCode2 = "var x; print('\xc0\x80');";
BSONObj invalidCodeObj4 = BSON("x"
<< "\xe0\x80\x80");
BSONObj invalidCodeObj4 = BSON("x" << "\xe0\x80\x80");
BSONObj invalidCodeWScope3 = makeBSONCodeWScopeObject("codeWScope3", invalidCode2, invalidCodeObj4);
TEST(checkAndScrubInvalidUTF8, SimpleNestedInvalidUTF8) {
@ -690,8 +679,7 @@ TEST(checkAndScrubInvalidUTF8, NestedInvalidMixedBag) {
// {c: {"\x80": "\xff\x80\x80\x80\x80\x80\x80\x80"}},
// {"codeWScope3": BSONCodeWScope{"var x; print('\xc0\x80');", (x:\xe0\x80\x80")}}
// ]}
auto validStringObj = BSON("fiona"
<< "apple");
auto validStringObj = BSON("fiona" << "apple");
BSONObj mixedBag4 = makeBSONArrayObject<BSONObj>("mixedBag4",
{
intObj,

View File

@ -198,9 +198,8 @@ TEST(BSONValidate, Fuzz) {
BSONObj original =
BSON("one" << 3 << "two" << 5 << "three" << BSONObj() << "four"
<< BSON("five" << BSON("six" << 11)) << "seven"
<< BSON_ARRAY("a"
<< "bb"
<< "ccc" << 5)
<< BSON_ARRAY("a" << "bb"
<< "ccc" << 5)
<< "eight" << BSONDBRef("rrr", OID("01234567890123456789aaaa")) << "_id"
<< OID("deadbeefdeadbeefdeadbeef") << "nine"
<< BSONBinData("\x69\xb7", 2, BinDataGeneral) << "ten"
@ -251,10 +250,9 @@ TEST(BSONValidateExtended, MD5Size) {
}
TEST(BSONValidateExtended, BSONArrayIndexes) {
BSONObj arr = BSON("0"
<< "a"
<< "1"
<< "b");
BSONObj arr = BSON("0" << "a"
<< "1"
<< "b");
BSONObj x1 = BSON("arr" << BSONArray(arr));
ASSERT_OK(validateBSON(x1.objdata(), x1.objsize(), mongo::BSONValidateModeEnum::kExtended));
ASSERT_OK(validateBSON(x1.objdata(), x1.objsize(), mongo::BSONValidateModeEnum::kFull));
@ -268,77 +266,72 @@ TEST(BSONValidateExtended, BSONArrayIndexes) {
status = validateBSON(x1.objdata(), x1.objsize(), mongo::BSONValidateModeEnum::kFull);
ASSERT_EQ(status, ErrorCodes::NonConformantBSON);
arr = BSON("1"
<< "a"
<< "2"
<< "b");
arr = BSON("1" << "a"
<< "2"
<< "b");
x1 = BSON("nonSequentialArray" << BSONArray(arr));
status = validateBSON(x1.objdata(), x1.objsize(), mongo::BSONValidateModeEnum::kExtended);
ASSERT_EQ(status, ErrorCodes::NonConformantBSON);
status = validateBSON(x1.objdata(), x1.objsize(), mongo::BSONValidateModeEnum::kFull);
ASSERT_EQ(status, ErrorCodes::NonConformantBSON);
x1 = BSON("nestedArraysAndObjects" << BSONArray(BSON("0"
<< "a"
<< "1"
<< BSONArray(BSON("0"
<< "a"
<< "2"
<< "b"))
<< "2"
<< "b")));
x1 = BSON("nestedArraysAndObjects" << BSONArray(BSON("0" << "a"
<< "1"
<< BSONArray(BSON("0" << "a"
<< "2"
<< "b"))
<< "2"
<< "b")));
status = validateBSON(x1.objdata(), x1.objsize(), mongo::BSONValidateModeEnum::kExtended);
ASSERT_EQ(status, ErrorCodes::NonConformantBSON);
status = validateBSON(x1.objdata(), x1.objsize(), mongo::BSONValidateModeEnum::kFull);
ASSERT_EQ(status, ErrorCodes::NonConformantBSON);
x1 = BSON("longArray" << BSONArray(BSON("0"
<< "a"
<< "1"
<< "b"
<< "2"
<< "c"
<< "3"
<< "d"
<< "4"
<< "e"
<< "5"
<< "f"
<< "6"
<< "g"
<< "7"
<< "h"
<< "8"
<< "i"
<< "9"
<< "j"
<< "10"
<< "k")));
x1 = BSON("longArray" << BSONArray(BSON("0" << "a"
<< "1"
<< "b"
<< "2"
<< "c"
<< "3"
<< "d"
<< "4"
<< "e"
<< "5"
<< "f"
<< "6"
<< "g"
<< "7"
<< "h"
<< "8"
<< "i"
<< "9"
<< "j"
<< "10"
<< "k")));
ASSERT_OK(validateBSON(x1.objdata(), x1.objsize(), mongo::BSONValidateModeEnum::kExtended));
ASSERT_OK(validateBSON(x1.objdata(), x1.objsize(), mongo::BSONValidateModeEnum::kFull));
x1 = BSON("longNonSequentialArray" << BSONArray(BSON("0"
<< "a"
<< "1"
<< "b"
<< "2"
<< "c"
<< "3"
<< "d"
<< "4"
<< "e"
<< "5"
<< "f"
<< "6"
<< "g"
<< "7"
<< "h"
<< "8"
<< "i"
<< "9"
<< "j"
<< "11"
<< "k")));
x1 = BSON("longNonSequentialArray" << BSONArray(BSON("0" << "a"
<< "1"
<< "b"
<< "2"
<< "c"
<< "3"
<< "d"
<< "4"
<< "e"
<< "5"
<< "f"
<< "6"
<< "g"
<< "7"
<< "h"
<< "8"
<< "i"
<< "9"
<< "j"
<< "11"
<< "k")));
status = validateBSON(x1.objdata(), x1.objsize(), mongo::BSONValidateModeEnum::kExtended);
ASSERT_EQ(status, ErrorCodes::NonConformantBSON);
status = validateBSON(x1.objdata(), x1.objsize(), mongo::BSONValidateModeEnum::kFull);
@ -346,10 +339,9 @@ TEST(BSONValidateExtended, BSONArrayIndexes) {
x1 = BSON("validNestedArraysAndObjects"
<< BSON("arr" << BSONArray(BSON("0" << BSON("2" << 1 << "1" << 0 << "3"
<< BSONArray(BSON("0"
<< "a"
<< "1"
<< "b"))
<< BSONArray(BSON("0" << "a"
<< "1"
<< "b"))
<< "4"
<< "b")))));
ASSERT_OK(validateBSON(x1.objdata(), x1.objsize(), mongo::BSONValidateModeEnum::kExtended));
@ -357,10 +349,9 @@ TEST(BSONValidateExtended, BSONArrayIndexes) {
x1 = BSON("invalidNestedArraysAndObjects"
<< BSON("arr" << BSONArray(BSON("0" << BSON("2" << 1 << "1" << 0 << "1"
<< BSONArray(BSON("0"
<< "a"
<< "2"
<< "b"))
<< BSONArray(BSON("0" << "a"
<< "2"
<< "b"))
<< "1"
<< "b")))));
status = validateBSON(x1.objdata(), x1.objsize(), mongo::BSONValidateModeEnum::kExtended);
@ -370,56 +361,48 @@ TEST(BSONValidateExtended, BSONArrayIndexes) {
}
TEST(BSONValidateExtended, BSONUTF8) {
auto x1 = BSON("ValidString"
<< "\x00"
<< "ValidString2"
<< "str");
auto x1 = BSON("ValidString" << "\x00"
<< "ValidString2"
<< "str");
ASSERT_OK(validateBSON(x1.objdata(), x1.objsize(), mongo::BSONValidateModeEnum::kExtended));
ASSERT_OK(validateBSON(x1.objdata(), x1.objsize(), mongo::BSONValidateModeEnum::kFull));
// Invalid UTF-8 - 10000000; leading bit cannot be set for single byte UTF-8.
x1 = BSON("InvalidOneByteString"
<< "\x80");
x1 = BSON("InvalidOneByteString" << "\x80");
auto status = validateBSON(x1.objdata(), x1.objsize(), mongo::BSONValidateModeEnum::kExtended);
ASSERT_OK(status);
status = validateBSON(x1.objdata(), x1.objsize(), mongo::BSONValidateModeEnum::kFull);
ASSERT_EQ(status, ErrorCodes::NonConformantBSON);
x1 = BSON("ValidTwoByteString"
<< "\x40\x40");
x1 = BSON("ValidTwoByteString" << "\x40\x40");
ASSERT_OK(validateBSON(x1.objdata(), x1.objsize(), mongo::BSONValidateModeEnum::kExtended));
ASSERT_OK(validateBSON(x1.objdata(), x1.objsize(), mongo::BSONValidateModeEnum::kFull));
// Invalid UTF-8 - 11011111 11001111; second bit of second byte cannot be set.
x1 = BSON("InvalidTwoByteString"
<< "\xDF\xCF");
x1 = BSON("InvalidTwoByteString" << "\xDF\xCF");
status = validateBSON(x1.objdata(), x1.objsize(), mongo::BSONValidateModeEnum::kExtended);
ASSERT_OK(status);
status = validateBSON(x1.objdata(), x1.objsize(), mongo::BSONValidateModeEnum::kFull);
ASSERT_EQ(status, ErrorCodes::NonConformantBSON);
x1 = BSON("ValidThreeByteString"
<< "\x40\x40\x40");
x1 = BSON("ValidThreeByteString" << "\x40\x40\x40");
ASSERT_OK(validateBSON(x1.objdata(), x1.objsize(), mongo::BSONValidateModeEnum::kExtended));
ASSERT_OK(validateBSON(x1.objdata(), x1.objsize(), mongo::BSONValidateModeEnum::kFull));
// Invalid UTF-8 - 11101111 10111111 11111111 - second bit of third byte cannot be set.
x1 = BSON("InvalidThreeByteString"
<< "\xEF\xBF\xFF");
x1 = BSON("InvalidThreeByteString" << "\xEF\xBF\xFF");
status = validateBSON(x1.objdata(), x1.objsize(), mongo::BSONValidateModeEnum::kExtended);
ASSERT_OK(status);
status = validateBSON(x1.objdata(), x1.objsize(), mongo::BSONValidateModeEnum::kFull);
ASSERT_EQ(status, ErrorCodes::NonConformantBSON);
x1 = BSON("ValidFourByteString"
<< "\x40\x40\x40\x40");
x1 = BSON("ValidFourByteString" << "\x40\x40\x40\x40");
ASSERT_OK(validateBSON(x1.objdata(), x1.objsize(), mongo::BSONValidateModeEnum::kExtended));
ASSERT_OK(validateBSON(x1.objdata(), x1.objsize(), mongo::BSONValidateModeEnum::kFull));
// Invalid UTF-8 - 11110000 10011000 10011010 11111111 - second bit of fourth byte cannot be
// set.
x1 = BSON("InvalidFourByteString"
<< "\xF0\x98\x9A\xFF");
x1 = BSON("InvalidFourByteString" << "\xF0\x98\x9A\xFF");
status = validateBSON(x1.objdata(), x1.objsize(), mongo::BSONValidateModeEnum::kExtended);
ASSERT_OK(status);
status = validateBSON(x1.objdata(), x1.objsize(), mongo::BSONValidateModeEnum::kFull);
@ -563,9 +546,7 @@ TEST(BSONValidateFast, ErrorIsInId) {
TEST(BSONValidateFast, NonTopLevelId) {
BufBuilder bb;
BSONObjBuilder ob(bb);
ob.append("not_id1",
BSON("_id"
<< "not the real _id"));
ob.append("not_id1", BSON("_id" << "not the real _id"));
appendInvalidStringElement("not_id2", &bb);
const BSONObj x = ob.done();
const Status status = validateBSON(x);
@ -581,9 +562,7 @@ TEST(BSONValidateFast, UnterminatedStringErrorInNestedObjectWithId) {
ob.append("x", 2.0);
appendInvalidStringElement("invalid", &bb);
const BSONObj nestedInvalid = ob.done();
const BSONObj x = BSON("_id" << 1 << "nested"
<< BSON_ARRAY("a"
<< "b" << nestedInvalid));
const BSONObj x = BSON("_id" << 1 << "nested" << BSON_ARRAY("a" << "b" << nestedInvalid));
const Status status = validateBSON(x);
ASSERT_NOT_OK(status);
ASSERT_EQUALS(status.reason(),
@ -597,8 +576,7 @@ TEST(BSONValidateFast, UnterminatedStringErrorInNestedObjectWithoutId) {
ob.append("x", 2.0);
appendInvalidStringElement("invalid", &bb);
const BSONObj nestedInvalid = ob.done();
const BSONObj x = BSON("nested" << BSON_ARRAY("a"
<< "b" << nestedInvalid));
const BSONObj x = BSON("nested" << BSON_ARRAY("a" << "b" << nestedInvalid));
const Status status = validateBSON(x);
ASSERT_NOT_OK(status);
ASSERT_EQUALS(status.reason(),
@ -613,9 +591,7 @@ TEST(BSONValidateFast, InvalidObjectWithInvalidSizeInNestedObjectWithId) {
// Minimum size to pass validation is 5 bytes.
appendObjectNameAndSize("invalid", &bb, 4);
const BSONObj nestedInvalid = ob.done();
const BSONObj x = BSON("_id" << 1 << "nested"
<< BSON_ARRAY("a"
<< "b" << nestedInvalid));
const BSONObj x = BSON("_id" << 1 << "nested" << BSON_ARRAY("a" << "b" << nestedInvalid));
const Status status = validateBSON(x);
ASSERT_NOT_OK(status);
ASSERT_EQUALS(status.reason(),
@ -629,9 +605,7 @@ TEST(BSONValidateFast, InvalidObjectWithZeroSizeInNestedObjectWithId) {
ob.append("x", 2.0);
appendObjectNameAndSize("invalid", &bb, 0);
const BSONObj nestedInvalid = ob.done();
const BSONObj x = BSON("_id" << 1 << "nested"
<< BSON_ARRAY("a"
<< "b" << nestedInvalid));
const BSONObj x = BSON("_id" << 1 << "nested" << BSON_ARRAY("a" << "b" << nestedInvalid));
const Status status = validateBSON(x);
ASSERT_NOT_OK(status);
ASSERT_EQUALS(status.reason(),
@ -645,9 +619,7 @@ TEST(BSONValidateFast, InvalidObjectWithNegativeSizeInNestedObjectWithId) {
ob.append("x", 2.0);
appendObjectNameAndSize("invalid", &bb, -999);
const BSONObj nestedInvalid = ob.done();
const BSONObj x = BSON("_id" << 1 << "nested"
<< BSON_ARRAY("a"
<< "b" << nestedInvalid));
const BSONObj x = BSON("_id" << 1 << "nested" << BSON_ARRAY("a" << "b" << nestedInvalid));
const Status status = validateBSON(x);
ASSERT_NOT_OK(status);
ASSERT_EQUALS(status.reason(),
@ -1046,9 +1018,7 @@ TEST(BSONValidateExtended, UnknownBinDataType) {
TEST(BSONValidateColumn, BSONColumnInBSON) {
BSONColumnBuilder cb;
cb.append(BSON("a"
<< "deadbeef")
.getField("a"));
cb.append(BSON("a" << "deadbeef").getField("a"));
cb.append(BSON("a" << 1).getField("a"));
cb.append(BSON("a" << 2).getField("a"));
cb.append(BSON("a" << 1).getField("a"));
@ -1074,9 +1044,7 @@ TEST(BSONValidateColumn, BSONColumnInBSON) {
TEST(BSONValidateColumn, BSONColumnInBSONRespectsVersion) {
BSONColumnBuilder cb;
cb.append(BSON("a"
<< "deadbeef")
.getField("a"));
cb.append(BSON("a" << "deadbeef").getField("a"));
cb.append(BSON("a" << 1).getField("a"));
cb.append(BSON("a" << 2).getField("a"));
cb.append(BSON("a" << 1).getField("a"));
@ -1114,9 +1082,7 @@ TEST(BSONValidateColumn, BSONColumnInBSONRespectsVersion) {
TEST(BSONValidateColumn, BSONColumnMissingEOO) {
BSONColumnBuilder cb;
cb.append(BSON("a"
<< "deadbeef")
.getField("a"));
cb.append(BSON("a" << "deadbeef").getField("a"));
BSONBinData columnData = cb.finalize();
ASSERT_OK(validateBSONColumn((char*)columnData.data, columnData.length));
@ -1131,9 +1097,7 @@ TEST(BSONValidateColumn, BSONColumnMissingEOO) {
TEST(BSONValidateColumn, BSONColumnFieldnameNotEmpty) {
BSONColumnBuilder cb;
cb.append(BSON("a"
<< "deadbeef")
.getField("a"));
cb.append(BSON("a" << "deadbeef").getField("a"));
BSONBinData columnData = cb.finalize();
ASSERT_OK(validateBSONColumn((char*)columnData.data, columnData.length));
@ -1149,9 +1113,7 @@ TEST(BSONValidateColumn, BSONColumnFieldnameNotEmpty) {
TEST(BSONValidateColumn, BSONColumnNoOverflowMissingAllEOOInColumn) {
BSONColumnBuilder cb;
cb.append(BSON("a"
<< "deadbeef")
.getField("a"));
cb.append(BSON("a" << "deadbeef").getField("a"));
BSONBinData columnData = cb.finalize();
for (int i = 0; i < columnData.length; ++i)
if (((char*)columnData.data)[i] == 0)
@ -1163,9 +1125,7 @@ TEST(BSONValidateColumn, BSONColumnNoOverflowMissingAllEOOInColumn) {
TEST(BSONValidateColumn, BSONColumnTrailingGarbage) {
BSONColumnBuilder cb;
cb.append(BSON("a"
<< "deadbeef")
.getField("a"));
cb.append(BSON("a" << "deadbeef").getField("a"));
BSONBinData columnData = cb.finalize();
ASSERT_OK(validateBSONColumn((char*)columnData.data, columnData.length));
char badData[4096];
@ -1178,9 +1138,7 @@ TEST(BSONValidateColumn, BSONColumnTrailingGarbage) {
TEST(BSONValidateColumn, BSONColumnNoOverflowBadContent) {
BSONColumnBuilder cb;
cb.append(BSON("a"
<< "deadbeef")
.getField("a"));
cb.append(BSON("a" << "deadbeef").getField("a"));
BSONBinData columnData = cb.finalize();
ASSERT_OK(validateBSONColumn((char*)columnData.data, columnData.length));
@ -1194,8 +1152,7 @@ TEST(BSONValidateColumn, BSONColumnNoOverflowBadContent) {
TEST(BSONValidateColumn, BSONColumnNoOverflowMissingFieldname) {
BSONColumnBuilder cb;
cb.append(BSON("a"
<< "deadbeef"));
cb.append(BSON("a" << "deadbeef"));
BSONBinData columnData = cb.finalize();
ASSERT_OK(validateBSONColumn((char*)columnData.data, columnData.length));
@ -1205,8 +1162,7 @@ TEST(BSONValidateColumn, BSONColumnNoOverflowMissingFieldname) {
TEST(BSONValidateColumn, BSONColumnNoOverflowBadFieldname) {
BSONColumnBuilder cb;
cb.append(BSON("a"
<< "deadbeef"));
cb.append(BSON("a" << "deadbeef"));
BSONBinData columnData = cb.finalize();
ASSERT_OK(validateBSONColumn((char*)columnData.data, columnData.length));
@ -1219,9 +1175,7 @@ TEST(BSONValidateColumn, BSONColumnNoOverflowBadFieldname) {
TEST(BSONValidateColumn, BSONColumnNoOverflowBadLiteral) {
BSONColumnBuilder cb;
cb.append(BSON("a"
<< "deadbeef")
.getField("a"));
cb.append(BSON("a" << "deadbeef").getField("a"));
BSONBinData columnData = cb.finalize();
ASSERT_OK(validateBSONColumn((char*)columnData.data, columnData.length));
@ -1235,30 +1189,21 @@ TEST(BSONValidateColumn, BSONColumnNoOverflowBadLiteral) {
TEST(BSONValidateColumn, BSONColumnInterleavedObjectPasses) {
BSONColumnBuilder cb;
cb.append(BSON("a"
<< "deadbeef")
.getField("a"));
BSONObj subObj1 = BSON("b"
<< "inside");
cb.append(BSON("a" << "deadbeef").getField("a"));
BSONObj subObj1 = BSON("b" << "inside");
cb.append(subObj1);
BSONObj subObj2 = BSON("b"
<< "outside");
BSONObj subObj2 = BSON("b" << "outside");
cb.append(subObj2);
BSONObj subObj3 = BSON("b"
<< "gone");
BSONObj subObj3 = BSON("b" << "gone");
cb.append(subObj3);
cb.append(BSON("c"
<< "foobar")
.getField("c"));
cb.append(BSON("c" << "foobar").getField("c"));
BSONBinData columnData = cb.finalize();
ASSERT_OK(validateBSONColumn((char*)columnData.data, columnData.length));
}
TEST(BSONValidateColumn, BSONColumnInterleavedArrayPasses) {
BSONColumnBuilder cb;
cb.append(BSON("a"
<< "deadbeef")
.getField("a"));
cb.append(BSON("a" << "deadbeef").getField("a"));
BSONArrayBuilder array;
for (int i = 0; i < 10; i++) {
@ -1266,26 +1211,19 @@ TEST(BSONValidateColumn, BSONColumnInterleavedArrayPasses) {
}
array.done();
cb.append(array.arr());
cb.append(BSON("c"
<< "foobar")
.getField("c"));
cb.append(BSON("c" << "foobar").getField("c"));
BSONBinData columnData = cb.finalize();
ASSERT_OK(validateBSONColumn((char*)columnData.data, columnData.length));
}
TEST(BSONValidateColumn, BSONColumnInterleavedNestedObjectPasses) {
BSONColumnBuilder cb;
cb.append(BSON("a"
<< "deadbeef")
.getField("a"));
BSONObj subObj1 = BSON("d"
<< "inside");
cb.append(BSON("a" << "deadbeef").getField("a"));
BSONObj subObj1 = BSON("d" << "inside");
BSONObj subObj2 = BSON("c" << subObj1);
BSONObj subObj3 = BSON("b" << subObj2);
cb.append(subObj3);
cb.append(BSON("c"
<< "foobar")
.getField("c"));
cb.append(BSON("c" << "foobar").getField("c"));
BSONBinData columnData = cb.finalize();
ASSERT_OK(validateBSONColumn((char*)columnData.data, columnData.length));
}
@ -1294,9 +1232,7 @@ TEST(BSONValidateColumn, BSONColumnInterleavedEmptyObjectPasses) {
BSONColumnBuilder cb;
BSONObj subObj1;
cb.append(subObj1);
cb.append(BSON("c"
<< "foobar")
.getField("c"));
cb.append(BSON("c" << "foobar").getField("c"));
BSONBinData columnData = cb.finalize();
ASSERT_OK(validateBSONColumn((char*)columnData.data, columnData.length));
}

View File

@ -298,10 +298,7 @@ TEST(BSONElement, IsNaN) {
ASSERT_FALSE(BSON("" << Decimal128{"9223372036854775808.5"}).firstElement().isNaN());
ASSERT_FALSE(BSON("" << Decimal128{"-9223372036854775809.99"}).firstElement().isNaN());
ASSERT_FALSE(BSON("" << 12345LL).firstElement().isNaN());
ASSERT_FALSE(BSON(""
<< "foo")
.firstElement()
.isNaN());
ASSERT_FALSE(BSON("" << "foo").firstElement().isNaN());
}
TEST(BSONElementIntegerParseTest, ParseIntegerElementToNonNegativeLongRejectsNegative) {
@ -332,14 +329,12 @@ TEST(BSONElementIntegerParseTest, ParseIntegerElementToLongRejectsTooLargeNegati
}
TEST(BSONElementIntegerParseTest, ParseIntegerElementToNonNegativeLongRejectsString) {
BSONObj query = BSON(""
<< "1");
BSONObj query = BSON("" << "1");
ASSERT_NOT_OK(query.firstElement().parseIntegerElementToNonNegativeLong());
}
TEST(BSONElementIntegerParseTest, ParseIntegerElementToLongRejectsString) {
BSONObj query = BSON(""
<< "1");
BSONObj query = BSON("" << "1");
ASSERT_NOT_OK(query.firstElement().parseIntegerElementToLong());
}

View File

@ -566,7 +566,7 @@ public:
*/
template <typename Map>
requires std::is_convertible_v<decltype(std::declval<Map>().begin()->first), StringData>
Derived& append(StringData fieldName, const Map& map) {
Derived& append(StringData fieldName, const Map& map) {
typename std::remove_reference<Derived>::type bob;
for (auto&& [k, v] : map) {
bob.append(k, v);

View File

@ -200,10 +200,9 @@ TEST(BSONObjBuilderTest, ResumeBuilding) {
}
auto obj = BSONObj(b.buf());
ASSERT_BSONOBJ_EQ(obj,
BSON("a"
<< "b"
<< "c"
<< "d"));
BSON("a" << "b"
<< "c"
<< "d"));
}
TEST(BSONObjBuilderTest, ResumeBuildingWithNesting) {
@ -211,9 +210,7 @@ TEST(BSONObjBuilderTest, ResumeBuildingWithNesting) {
// build a trivial object.
{
BSONObjBuilder firstBuilder(b);
firstBuilder.append("ll",
BSON("f" << BSON("cc"
<< "dd")));
firstBuilder.append("ll", BSON("f" << BSON("cc" << "dd")));
}
// add a complex field
{
@ -221,10 +218,7 @@ TEST(BSONObjBuilderTest, ResumeBuildingWithNesting) {
secondBuilder.append("a", BSON("c" << 3));
}
auto obj = BSONObj(b.buf());
ASSERT_BSONOBJ_EQ(obj,
BSON("ll" << BSON("f" << BSON("cc"
<< "dd"))
<< "a" << BSON("c" << 3)));
ASSERT_BSONOBJ_EQ(obj, BSON("ll" << BSON("f" << BSON("cc" << "dd")) << "a" << BSON("c" << 3)));
}
TEST(BSONObjBuilderTest, ResetToEmptyResultsInEmptyObj) {

View File

@ -159,7 +159,7 @@ concept Materializer = requires(T& t,
{
T::compare(
typename T::Element(), typename T::Element(), (const StringDataComparator*)nullptr)
} -> std::same_as<int>;
} -> std::same_as<int>;
};
/**

View File

@ -4169,8 +4169,7 @@ TEST_F(BSONColumnTest, ArrayUncompressed) {
}
TEST_F(BSONColumnTest, ArrayEqual) {
auto elemObj = createElementArray(BSON_ARRAY("a"
<< "b"));
auto elemObj = createElementArray(BSON_ARRAY("a" << "b"));
std::vector<BSONElement> elems = {elemObj, elemObj};
BufBuilder expected;
@ -8629,9 +8628,8 @@ TEST_F(BSONColumnTest, AppendMinKeyInSubObjAfterMerge) {
BufBuilder expected;
appendInterleavedStart(expected,
BSON("root" << BSON("a"
<< "asd"
<< "0" << 1)));
BSON("root" << BSON("a" << "asd"
<< "0" << 1)));
appendSimple8bControl(expected, 0b1000, 0b0000);
appendSimple8bBlocks64(expected,
{
@ -8754,9 +8752,8 @@ TEST_F(BSONColumnTest, DecompressMinKeyInSubObjAfterMerge) {
BufBuilder expected;
appendInterleavedStart(expected,
BSON("root" << BSON("a"
<< "asd"
<< "0" << 1)));
BSON("root" << BSON("a" << "asd"
<< "0" << 1)));
appendSimple8bControl(expected, 0b1000, 0b0000);
appendSimple8bBlocks64(expected,
{

View File

@ -373,8 +373,7 @@ inline size_t visitAll(const char* buffer,
uint64_t& prevNonRLE,
const Visit& visit,
const VisitMissing& visitMissing) {
return visitAll<T>(
buffer, size, prevNonRLE, visit, [&visit]() { visit(0); }, visitMissing);
return visitAll<T>(buffer, size, prevNonRLE, visit, [&visit]() { visit(0); }, visitMissing);
}
/**

View File

@ -44,9 +44,8 @@ namespace mongo {
* Concept for writing 64bit simple8b blocks via a callback.
*/
template <class F>
concept Simple8bBlockWriter = requires(F&& f) {
std::invoke(std::forward<F>(f), std::declval<uint64_t>());
};
concept Simple8bBlockWriter =
requires(F&& f) { std::invoke(std::forward<F>(f), std::declval<uint64_t>()); };
/**
* Simple8bBuilder compresses a series of integers into chains of 64 bit Simple8b blocks.

View File

@ -53,9 +53,9 @@ TEST_F(UglyBSONFixture, DuplicateFields) {
ON_BLOCK_EXIT([] { OpMsgBuilder::disableDupeFieldCheck_forTest.store(false); });
assertCommandFailsOnServer(DatabaseName::kAdmin,
BSON("insert"
<< "test"
<< "documents" << BSONArray() << "documents" << BSONArray()),
BSON("insert" << "test"
<< "documents" << BSONArray() << "documents"
<< BSONArray()),
ErrorCodes::IDLDuplicateField);
}

View File

@ -53,21 +53,18 @@ TEST(BsonCheck, CheckHasOnlyOnEmptyObject) {
TEST(BsonCheck, CheckHasOnlyLegalFields) {
ASSERT_OK(bsonCheckOnlyHasFields("",
BSON("aField"
<< "value"
<< "thirdField" << 1 << "anotherField" << 2),
BSON("aField" << "value"
<< "thirdField" << 1 << "anotherField" << 2),
legals));
ASSERT_OK(bsonCheckOnlyHasFields("",
BSON("aField"
<< "value"
<< "thirdField" << 1),
BSON("aField" << "value"
<< "thirdField" << 1),
legals));
ASSERT_EQUALS(ErrorCodes::BadValue,
bsonCheckOnlyHasFields("",
BSON("aField"
<< "value"
<< "illegal" << 4 << "thirdField" << 1),
BSON("aField" << "value"
<< "illegal" << 4 << "thirdField" << 1),
legals));
}

View File

@ -404,7 +404,8 @@ public:
}
template <int...>
requires(!std::is_same_v<int64_t, long long>) void appendNum(int64_t j) {
requires(!std::is_same_v<int64_t, long long>)
void appendNum(int64_t j) {
appendNumImpl(j);
}

View File

@ -121,11 +121,10 @@ public:
pushResponse(BSON("ok" << 1));
// Call clientAuthenticate()
return BSON("mechanism"
<< "MONGODB-X509"
<< "db"
<< "$external"
<< "user" << _username);
return BSON("mechanism" << "MONGODB-X509"
<< "db"
<< "$external"
<< "user" << _username);
}

View File

@ -319,8 +319,7 @@ TEST_F(DBClientCursorTest, DBClientCursorHandlesOpMsgExhaustCorrectly) {
// Create and set a terminal 'getMore' response. The 'moreToCome' flag is not set, since this is
// the last message of the stream.
auto terminalDoc = BSON("_id"
<< "terminal");
auto terminalDoc = BSON("_id" << "terminal");
auto getMoreTerminalResponseMsg = mockGetMoreResponse(nss, 0, {terminalDoc});
conn.setRecvResponse(getMoreTerminalResponseMsg);
@ -404,8 +403,7 @@ TEST_F(DBClientCursorTest, DBClientCursorResendsGetMoreIfMoreToComeFlagIsOmitted
ASSERT_BSONOBJ_EQ(docObj(4), cursor.next());
// Exhaust the cursor with a terminal 'getMore' response.
auto terminalDoc = BSON("_id"
<< "terminal");
auto terminalDoc = BSON("_id" << "terminal");
auto terminalGetMoreResponseMsg = mockGetMoreResponse(nss, 0, {terminalDoc});
conn.setRecvResponse(terminalGetMoreResponseMsg);

View File

@ -87,8 +87,7 @@ public:
OpMsgRequest pingRequest() {
OpMsgRequest request;
request.body = BSON("msg"
<< "ping");
request.body = BSON("msg" << "ping");
return request;
}

View File

@ -594,10 +594,9 @@ protected:
oldConfig.findMemberByHostAndPort(HostAndPort(host));
membersBuilder.append(BSON("_id" << member->getId().getData() << "host" << host
<< "tags"
<< BSON("dc"
<< "ny"
<< "p"
<< "1")));
<< BSON("dc" << "ny"
<< "p"
<< "1")));
_replSet->getNode(host)->insert(IdentityNS, BSON(HostField(host)));
}
@ -610,12 +609,11 @@ protected:
oldConfig.findMemberByHostAndPort(HostAndPort(host));
membersBuilder.append(BSON("_id" << member->getId().getData() << "host" << host
<< "tags"
<< BSON("dc"
<< "sf"
<< "s"
<< "1"
<< "group"
<< "1")));
<< BSON("dc" << "sf"
<< "s"
<< "1"
<< "group"
<< "1")));
_replSet->getNode(host)->insert(IdentityNS, BSON(HostField(host)));
}
@ -626,12 +624,11 @@ protected:
oldConfig.findMemberByHostAndPort(HostAndPort(host));
membersBuilder.append(BSON("_id" << member->getId().getData() << "host" << host
<< "tags"
<< BSON("dc"
<< "ma"
<< "s"
<< "2"
<< "group"
<< "1")));
<< BSON("dc" << "ma"
<< "s"
<< "2"
<< "group"
<< "1")));
_replSet->getNode(host)->insert(IdentityNS, BSON(HostField(host)));
}
@ -642,10 +639,9 @@ protected:
oldConfig.findMemberByHostAndPort(HostAndPort(host));
membersBuilder.append(BSON("_id" << member->getId().getData() << "host" << host
<< "tags"
<< BSON("dc"
<< "eu"
<< "s"
<< "3")));
<< BSON("dc" << "eu"
<< "s"
<< "3")));
_replSet->getNode(host)->insert(IdentityNS, BSON(HostField(host)));
}
@ -656,10 +652,9 @@ protected:
oldConfig.findMemberByHostAndPort(HostAndPort(host));
membersBuilder.append(BSON("_id" << member->getId().getData() << "host" << host
<< "tags"
<< BSON("dc"
<< "jp"
<< "s"
<< "4")));
<< BSON("dc" << "jp"
<< "s"
<< "4")));
_replSet->getNode(host)->insert(IdentityNS, BSON(HostField(host)));
}

Some files were not shown because too many files have changed in this diff Show More