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

« back to all changes in this revision

Viewing changes to jstests/collmod.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
// Basic js tests for the collMod command.
 
2
// Test setting the usePowerOf2Sizes flag, and modifying TTL indexes.
 
3
 
 
4
var coll = "collModTest";
 
5
var t = db.getCollection( coll );
 
6
t.drop();
 
7
 
 
8
db.createCollection( coll );
 
9
 
 
10
 
 
11
// Verify the new collection has userFlags set to 0
 
12
assert.eq( t.stats().userFlags , 0 , "fresh collection doesn't have userFlags = 0 ");
 
13
 
 
14
// Modify the collection with the usePowerOf2Sizes flag. Verify userFlags now = 1.
 
15
var res = db.runCommand( { "collMod" : coll,  "usePowerOf2Sizes" : true } );
 
16
printjson( res );
 
17
assert.eq( res.ok , 1 , "collMod failed" );
 
18
assert.eq( t.stats().userFlags , 1 , "modified collection should have userFlags = 1 ");
 
19
 
 
20
// Try to modify it with some unrecognized value
 
21
var res = db.runCommand( { "collMod" : coll,  "unrecognized" : true } );
 
22
printjson( res );
 
23
assert.eq( res.ok , 0 , "collMod shouldn't return ok with unrecognized value" );
 
24
 
 
25
// add a TTL index
 
26
t.ensureIndex( {a : 1}, { "expireAfterSeconds": 50 } )
 
27
assert.eq( 1, db.system.indexes.count( { key : {a:1}, expireAfterSeconds : 50 } ),
 
28
           "TTL index not added" );
 
29
 
 
30
// try to modify it with a bad key pattern
 
31
var res = db.runCommand( { "collMod" : coll,
 
32
                           "index" : { "keyPattern" : "bad" , "expireAfterSeconds" : 100 } } );
 
33
printjson( res );
 
34
assert.eq( 0 , res.ok , "mod shouldn't work with bad keypattern");
 
35
 
 
36
// try to modify it without expireAfterSeconds field
 
37
var res = db.runCommand( { "collMod" : coll,
 
38
                         "index" : { "keyPattern" : {a : 1} } } );
 
39
printjson( res );
 
40
assert.eq( 0 , res.ok , "TTL mod shouldn't work without expireAfterSeconds");
 
41
 
 
42
// try to modify it with a non-numeric expireAfterSeconds field
 
43
var res = db.runCommand( { "collMod" : coll,
 
44
                           "index" : { "keyPattern" : {a : 1}, "expireAfterSeconds" : "100" } } );
 
45
printjson( res );
 
46
assert.eq( 0 , res.ok , "TTL mod shouldn't work with non-numeric expireAfterSeconds");
 
47
 
 
48
// this time modifying should finally  work
 
49
var res = db.runCommand( { "collMod" : coll,
 
50
                           "index" : { "keyPattern" : {a : 1}, "expireAfterSeconds" : 100 } } );
 
51
printjson( res );
 
52
assert.eq( 1, db.system.indexes.count( { key : {a:1}, expireAfterSeconds : 100 } ),
 
53
           "TTL index not modified" );
 
54
 
 
55
// try to modify a faulty TTL index with a non-numeric expireAfterSeconds field
 
56
t.dropIndex( {a : 1 } );
 
57
t.ensureIndex( {a : 1} , { "expireAfterSeconds": "50" } )
 
58
var res = db.runCommand( { "collMod" : coll,
 
59
                           "index" : { "keyPattern" : {a : 1} , "expireAfterSeconds" : 100 } } );
 
60
printjson( res );
 
61
assert.eq( 0, res.ok, "shouldn't be able to modify faulty index spec" );
 
62
 
 
63
// try with new index, this time set both expireAfterSeconds and the usePowerOf2Sizes flag
 
64
t.dropIndex( {a : 1 } );
 
65
t.ensureIndex( {a : 1} , { "expireAfterSeconds": 50 } )
 
66
var res = db.runCommand( { "collMod" : coll ,
 
67
                           "usePowerOf2Sizes" : false,
 
68
                           "index" : { "keyPattern" : {a : 1} , "expireAfterSeconds" : 100 } } );
 
69
printjson( res );
 
70
assert.eq( 1, res.ok, "should be able to modify both userFlags and expireAfterSeconds" );
 
71
assert.eq( t.stats().userFlags , 0 , "userflags should be 0 now");
 
72
assert.eq( 1, db.system.indexes.count( { key : {a:1}, expireAfterSeconds : 100 } ),
 
73
           "TTL index should be 100 now" );
 
74