~ubuntu-branches/ubuntu/utopic/mongodb/utopic

« back to all changes in this revision

Viewing changes to jstests/core/find1.js

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-07-03 09:23:46 UTC
  • mfrom: (1.3.10) (44.1.14 sid)
  • Revision ID: package-import@ubuntu.com-20140703092346-c5bvt46wnzougyly
Tags: 1:2.6.3-0ubuntu1
* New upstream stable release:
  - Dropped patches, included upstream:
    + 0003-All-platforms-but-Windows-find-hash-in-std-tr1.patch
    + 0008-Use-system-libstemmer.patch
    + 0011-Use-a-signed-char-to-store-BSONType-enumerations.patch
    + 0001-SERVER-12064-Atomic-operations-for-gcc-non-Intel-arc.patch
    + 0002-SERVER-12065-Support-ARM-and-AArch64-builds.patch
  - d/p/*: Refreshed/rebased remaining patches.
  - Use system provided libyaml-cpp:
    + d/control: Add libyaml-cpp-dev to BD's.
    + d/rules: Enable --with-system-yaml option.
    + d/p/fix-yaml-detection.patch: Fix detection of libyaml-cpp library.
  - d/mongodb-server.mongodb.upstart: Sync changes from upstream.
  - d/control,mongodb-dev.*: Drop mongodb-dev package; it has no reverse
    dependencies and upstream no longer install header files.
  - d/NEWS: Point users to upstream upgrade documentation for upgrades
    from 2.4 to 2.6.
* Merge from Debian unstable.
* d/control: BD on libv8-3.14-dev to ensure that transitioning to new v8
  versions is a explicit action due to changes in behaviour in >= 3.25
  (LP: #1295723).
* d/mongodb-server.prerm: Dropped debug echo call from maintainer script
  (LP: #1294455).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
t = db.find1;
 
2
t.drop();
 
3
 
 
4
lookAtDocumentMetrics = false;
 
5
 
 
6
// QUERY MIGRATION
 
7
// New system is still not connected to server status
 
8
if ( db.serverStatus().metrics ) {
 
9
    // var ss = db.serverStatus();
 
10
    // lookAtDocumentMetrics = ss.metrics.document != null && ss.metrics.queryExecutor.scanned != null;
 
11
}
 
12
 
 
13
print( "lookAtDocumentMetrics: " + lookAtDocumentMetrics );
 
14
 
 
15
if ( lookAtDocumentMetrics ) {
 
16
    // ignore mongos
 
17
    nscannedStart = db.serverStatus().metrics.queryExecutor.scanned
 
18
}
 
19
 
 
20
 
 
21
t.save( { a : 1 , b : "hi" } );
 
22
t.save( { a : 2 , b : "hi" } );
 
23
 
 
24
/* very basic test of $snapshot just that we get some result */
 
25
// we are assumign here that snapshot uses the id index; maybe one day it doesn't if so this would need to change then
 
26
assert( t.find({$query:{},$snapshot:1})[0].a == 1 , "$snapshot simple test 1" );
 
27
var q = t.findOne();
 
28
q.c = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
 
29
t.save(q); // will move a:1 object to after a:2 in the file 
 
30
assert( t.find({$query:{},$snapshot:1})[0].a == 1 , "$snapshot simple test 2" );
 
31
 
 
32
assert( t.findOne( { a : 1 } ).b != null , "A" );
 
33
assert( t.findOne( { a : 1 } , { a : 1 } ).b == null , "B");
 
34
 
 
35
assert( t.find( { a : 1 } )[0].b != null , "C" );
 
36
assert( t.find( { a : 1 } , { a : 1 } )[0].b == null , "D" );
 
37
assert( t.find( { a : 1 } , { a : 1 } ).sort( { a : 1 } )[0].b == null , "D" );
 
38
 
 
39
id = t.findOne()._id;
 
40
 
 
41
assert( t.findOne( id ) , "E" );
 
42
assert( t.findOne( id ).a , "F" );
 
43
assert( t.findOne( id ).b , "G" );
 
44
 
 
45
assert( t.findOne( id , { a : 1 } ).a , "H" );
 
46
assert( ! t.findOne( id , { a : 1 } ).b , "I" );
 
47
 
 
48
assert(t.validate().valid,"not valid");
 
49
 
 
50
if ( lookAtDocumentMetrics ) {
 
51
    // ignore mongos
 
52
    nscannedEnd = db.serverStatus().metrics.queryExecutor.scanned
 
53
    assert.lte( nscannedStart + 16, nscannedEnd );
 
54
}