Skip to content

Commit 92e7f35

Browse files
author
dalyd
committed
Merge branch 'develop'
2 parents bd8901a + 404e3ea commit 92e7f35

6 files changed

+761
-78
lines changed

testcases/pipelines.js

-15
Original file line numberDiff line numberDiff line change
@@ -1018,21 +1018,6 @@ generateTestCase({
10181018
]
10191019
});
10201020

1021-
generateTestCase({
1022-
name: "Out",
1023-
post: function outCleanup(sourceCollection) {
1024-
var outCollName = sourceCollection.getName() + "_tmp_out";
1025-
var outCollection = sourceCollection.getDB()[outCollName];
1026-
var backingCollName = sourceCollection.getName() + "_backing";
1027-
var backingCollection = sourceCollection.getDB()[backingCollName];
1028-
sourceCollection.drop();
1029-
outCollection.drop();
1030-
backingCollection.drop();
1031-
},
1032-
pipeline: [{$out: "#B_COLL_tmp_out"}],
1033-
addSkipStage: false
1034-
});
1035-
10361021
generateTestCase({
10371022
name: "Project",
10381023
docGenerator: function simpleProjectionDocGenerator(i) {

testcases/all_paths_index.js renamed to testcases/wildcard_index_insert.js

+22-60
Original file line numberDiff line numberDiff line change
@@ -2,69 +2,28 @@ if ((typeof tests === "undefined" ? "undefined" : typeof(tests)) != "object") {
22
tests = [];
33
}
44

5-
/*
6-
* Inserts value at the location specified by path (using dot notation) in object.
7-
* If there's a common non-object field name this function overwrites the previous values.
8-
*/
9-
function setDottedFieldToValue(object, path, value) {
10-
if (typeof path === "string") {
11-
var fields = path.split(".");
12-
if (fields.length == 1) {
13-
object[path] = value;
14-
} else {
15-
if (typeof(object[fields[0]]) !== "object") {
16-
object[fields[0]] = {};
17-
}
18-
setDottedFieldToValue(
19-
object[fields[0]], path.slice(fields[0].length + 1, path.length), value);
20-
}
21-
}
22-
return object;
23-
}
24-
255
/**
26-
* Creates test cases and adds them to the global testing array. By default,
27-
* each test case
28-
* specification produces several test cases:
6+
* Creates test cases and adds them to the global testing array.
297
*
308
* @param {Object} options - Options describing the test case.
319
* @param {String} options.type - The name of the type of test case. It is
3210
* prepended to the test name.
3311
* @param {String} options.name - The name of the test case.
34-
* `${type}.AllPathsIndex.` is prepended.
12+
* `${type}.WildCardIndex.` is prepended.
3513
* @param {Object[]} options.ops - The operations to perform in benchRun.
3614
* @param {function} options.pre - A function that sets up for the test case.
3715
* @param {String[]} {options.tags=[]} - Additional tags describing this test.
38-
* The "all_paths", "indexed", and ">=4.1.3" tags are added automatically.
16+
* The "wildcard", "indexed", and ">=4.1.3" tags are added automatically.
3917
*/
4018
function addTest(options) {
4119
tests.push({
42-
name: options.type + ".AllPathsIndex." + options.name,
43-
tags: ["all_paths", "indexed", ">=4.1.3"].concat(options.tags),
20+
name: options.type + ".WildCardIndex." + options.name,
21+
tags: ["wildcard_write", "indexed", ">=4.1.3"].concat(options.tags),
4422
pre: options.pre,
4523
ops: options.ops
4624
});
4725
}
4826

49-
function getNFieldNames(n) {
50-
var fieldNames = [];
51-
for (var i = 0; i < n; i++) {
52-
fieldNames.push("field-" + i);
53-
}
54-
return fieldNames;
55-
}
56-
57-
/*
58-
* Arbitrary field names.
59-
*/
60-
var FIELD_NAMES = getNFieldNames(200);
61-
62-
/*
63-
* Constant used as a parameter for test cases.
64-
*/
65-
var INDEX_FOR_QUERIES = 3111;
66-
var NUMBER_FOR_RANGE = 16;
67-
6827
/*
6928
* Adds n fields (from fieldNamesArray with offset offset) and assigns values from values.
7029
*/
@@ -179,9 +138,9 @@ function getDocGeneratorForDeeplyNestedFields(fieldNameArr, documentDepth, nFiel
179138
function getSetupFunctionForTargetedIndex(fieldsToIndex) {
180139
return function(collection) {
181140
collection.drop();
182-
// Instead of creating an allPaths index, creating a normal index for each top-level
141+
// Instead of creating a wildcard index, creating a normal index for each top-level
183142
// field used. This way, the same number of index entries are created, regardless of
184-
// whether we use an allPaths index, or a targeted index.
143+
// whether we use an wildcard index, or a targeted index.
185144
for (var i = 0; i < fieldsToIndex.length; i++) {
186145
var fieldName = fieldsToIndex[i];
187146
assert.commandWorked(collection.createIndex(
@@ -194,24 +153,22 @@ function getSetupFunctionForTargetedIndex(fieldsToIndex) {
194153
* Returns a function, which when called, will drop the given collection and create a $** index on
195154
* 'fieldsToIndex'. If 'fieldsToIndex' is empty, it will create a $** index on all fields.
196155
*/
197-
function getSetupFunctionWithAllPathsIndex(fieldsToIndex) {
156+
function getSetupFunctionWithWildCardIndex(projectionFields) {
198157
return function(collection) {
199158
collection.drop();
200159
var proj = {};
201-
for (var i = 0; i < fieldsToIndex.length; i++) {
202-
proj[fieldsToIndex[i]] = 1;
160+
for (var i = 0; i < projectionFields.length; i++) {
161+
proj[projectionFields[i]] = 1;
203162
}
204163
var indexOptions = undefined;
205-
if (fieldsToIndex.length > 0) {
164+
if (projectionFields.length > 0) {
206165
indexOptions = {wildcardProjection: proj};
207166
}
208167
assert.commandWorked(collection.createIndex({"$**": 1}, indexOptions));
209168
};
210169
}
211170

212-
var kInsertTags = ["insert"];
213-
214-
// TODO: SERVER-36214 make read-path tests which include compound & range queries.
171+
var kInsertTags = ["wildcard_insert"];
215172

216173
/*
217174
* Make a test that inserts doc.
@@ -235,24 +192,29 @@ function makeInsertTestForDocType(name, pre, documentGenerator, additionalTags)
235192
}
236193

237194
makeInsertTestForDocType("MultipleFieldsAllExcluded",
238-
getSetupFunctionWithAllPathsIndex(["nonexistent"]),
195+
getSetupFunctionWithWildCardIndex(["nonexistent"]),
239196
getDocGeneratorForTopLevelFields(getNFieldNames(16)),
240197
["regression"]);
241198
makeInsertTestForDocType("AllDiffFields",
242-
getSetupFunctionWithAllPathsIndex([]),
199+
getSetupFunctionWithWildCardIndex([]),
243200
getDocGeneratorForUniqueLeaves(getNFieldNames(200)),
244201
["regression"]);
202+
var NUMBER_FOR_RANGE = 16;
245203
makeInsertTestForDocType("DeeplyNested",
246-
getSetupFunctionWithAllPathsIndex([]),
204+
getSetupFunctionWithWildCardIndex([]),
247205
getDocGeneratorForDeeplyNestedFields(
248206
getNFieldNames(200), NUMBER_FOR_RANGE, NUMBER_FOR_RANGE - 1),
249207
["regression"]);
250208

251209
// Comparison tests which use a standard index.
252210

253211
function makeComparisonWriteTest(name, fieldsToIndex, documentGenerator) {
254-
makeInsertTestForDocType(name + ".AllPathsIndex",
255-
getSetupFunctionWithAllPathsIndex(fieldsToIndex),
212+
makeInsertTestForDocType(name + ".WildCardIndex",
213+
getSetupFunctionWithWildCardIndex(fieldsToIndex),
214+
documentGenerator,
215+
["core"]);
216+
makeInsertTestForDocType(name + ".WildCardIndexNoProjection",
217+
getSetupFunctionWithWildCardIndex([]),
256218
documentGenerator,
257219
["core"]);
258220
makeInsertTestForDocType(name + ".StandardIndex",

0 commit comments

Comments
 (0)