~evarlast/ubuntu/utopic/mongodb/upstart-workaround-debian-bug-718702

« back to all changes in this revision

Viewing changes to jstests/covered_index_simple_3.js

  • Committer: Package Import Robot
  • Author(s): James Page, James Page, Robie Basak
  • Date: 2013-05-29 17:44:42 UTC
  • mfrom: (44.1.7 sid)
  • Revision ID: package-import@ubuntu.com-20130529174442-z0a4qmoww4y0t458
Tags: 1:2.4.3-1ubuntu1
[ James Page ]
* Merge from Debian unstable, remaining changes:
  - Enable SSL support:
    + d/control: Add libssl-dev to BD's.
    + d/rules: Enabled --ssl option.
    + d/mongodb.conf: Add example SSL configuration options.
  - d/mongodb-server.mongodb.upstart: Add upstart configuration.
  - d/rules: Don't strip binaries during scons build for Ubuntu.
  - d/control: Add armhf to target archs.
  - d/p/SConscript.client.patch: fixup install of client libraries.
  - d/p/0010-install-libs-to-usr-lib-not-usr-lib64-Closes-588557.patch:
    Install libraries to lib not lib64.
* Dropped changes:
  - d/p/arm-support.patch: Included in Debian.
  - d/p/double-alignment.patch: Included in Debian.
  - d/rules,control: Debian also builds with avaliable system libraries
    now.
* Fix FTBFS due to gcc and boost upgrades in saucy:
  - d/p/0008-ignore-unused-local-typedefs.patch: Add -Wno-unused-typedefs
    to unbreak building with g++-4.8.
  - d/p/0009-boost-1.53.patch: Fixup signed/unsigned casting issue.

[ Robie Basak ]
* d/p/0011-Use-a-signed-char-to-store-BSONType-enumerations.patch: Fixup
  build failure on ARM due to missing signed'ness of char cast.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Simple covered index query test with a unique sparse index
 
2
 
 
3
var coll = db.getCollection("covered_simple_3")
 
4
coll.drop()
 
5
for (i=0;i<10;i++) {
 
6
    coll.insert({foo:i})
 
7
}
 
8
for (i=0;i<5;i++) {
 
9
    coll.insert({bar:i})
 
10
}
 
11
coll.insert({foo:"string"})
 
12
coll.insert({foo:{bar:1}})
 
13
coll.insert({foo:null})
 
14
coll.ensureIndex({foo:1}, {sparse:true, unique:true})
 
15
 
 
16
// Test equality with int value
 
17
var plan = coll.find({foo:1}, {foo:1, _id:0}).hint({foo:1}).explain()
 
18
assert.eq(true, plan.indexOnly, "simple.3.1 - indexOnly should be true on covered query")
 
19
assert.eq(0, plan.nscannedObjects, "simple.3.1 - nscannedObjects should be 0 for covered query")
 
20
 
 
21
// Test equality with string value
 
22
var plan = coll.find({foo:"string"}, {foo:1, _id:0}).hint({foo:1}).explain()
 
23
assert.eq(true, plan.indexOnly, "simple.3.2 - indexOnly should be true on covered query")
 
24
assert.eq(0, plan.nscannedObjects, "simple.3.2 - nscannedObjects should be 0 for covered query")
 
25
 
 
26
// Test equality with int value on a dotted field
 
27
var plan = coll.find({foo:{bar:1}}, {foo:1, _id:0}).hint({foo:1}).explain()
 
28
assert.eq(true, plan.indexOnly, "simple.3.3 - indexOnly should be true on covered query")
 
29
assert.eq(0, plan.nscannedObjects, "simple.3.3 - nscannedObjects should be 0 for covered query")
 
30
 
 
31
// Test no query
 
32
var plan = coll.find({}, {foo:1, _id:0}).hint({foo:1}).explain()
 
33
assert.eq(true, plan.indexOnly, "simple.3.4 - indexOnly should be true on covered query")
 
34
assert.eq(0, plan.nscannedObjects, "simple.3.4 - nscannedObjects should be 0 for covered query")
 
35
 
 
36
// Test range query
 
37
var plan = coll.find({foo:{$gt:2,$lt:6}}, {foo:1, _id:0}).hint({foo:1}).explain()
 
38
assert.eq(true, plan.indexOnly, "simple.3.5 - indexOnly should be true on covered query")
 
39
assert.eq(0, plan.nscannedObjects, "simple.3.5 - nscannedObjects should be 0 for covered query")
 
40
 
 
41
// Test in query
 
42
var plan = coll.find({foo:{$in:[5,8]}}, {foo:1, _id:0}).hint({foo:1}).explain()
 
43
assert.eq(true, plan.indexOnly, "simple.3.6 - indexOnly should be true on covered query")
 
44
assert.eq(0, plan.nscannedObjects, "simple.3.6 - nscannedObjects should be 0 for covered query")
 
45
 
 
46
// Test exists query
 
47
var plan = coll.find({foo:{$exists:true}}, {foo:1, _id:0}).hint({foo:1}).explain()
 
48
assert.eq(true, plan.indexOnly, "simple.3.7 - indexOnly should be true on covered query")
 
49
// this should be 0 but is not due to bug https://jira.mongodb.org/browse/SERVER-3187
 
50
assert.eq(13, plan.nscannedObjects, "simple.3.7 - nscannedObjects should be 0 for covered query")
 
51
 
 
52
// Test not in query
 
53
var plan = coll.find({foo:{$nin:[5,8]}}, {foo:1, _id:0}).hint({foo:1}).explain()
 
54
assert.eq(true, plan.indexOnly, "simple.3.8 - indexOnly should be true on covered query")
 
55
// this should be 0 but is not due to bug https://jira.mongodb.org/browse/SERVER-3187
 
56
assert.eq(13, plan.nscannedObjects, "simple.3.8 - nscannedObjects should be 0 for covered query")
 
57
 
 
58
print ('all tests pass')
 
 
b'\\ No newline at end of file'