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

« back to all changes in this revision

Viewing changes to jstests/apply_ops2.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
//Test applyops upsert flag SERVER-7452
 
2
 
 
3
var t = db.apply_ops2;
 
4
t.drop();
 
5
 
 
6
assert.eq(0, t.find().count(), "test collection not empty");
 
7
 
 
8
t.insert({_id:1, x:"init"});
 
9
 
 
10
//alwaysUpsert = true
 
11
print("Testing applyOps with alwaysUpsert = true");
 
12
 
 
13
var res = db.runCommand({ applyOps: [
 
14
    {
 
15
        op: "u",
 
16
        ns: t.getFullName(),
 
17
        o2 : { _id: 1 },
 
18
        o: { $set: { x: "upsert=true existing" }}
 
19
    },
 
20
    {
 
21
        op: "u",
 
22
        ns: t.getFullName(),
 
23
        o2: { _id: 2 },
 
24
        o: { $set : { x: "upsert=true non-existing" }}
 
25
    }], alwaysUpsert: true });
 
26
 
 
27
assert.eq(true, res.results[0], "upsert = true, existing doc update failed");
 
28
assert.eq(true, res.results[1], "upsert = true, nonexisting doc not upserted");
 
29
assert.eq(2, t.find().count(), "2 docs expected after upsert");
 
30
 
 
31
//alwaysUpsert = false
 
32
print("Testing applyOps with alwaysUpsert = false");
 
33
 
 
34
res = db.runCommand({ applyOps: [
 
35
    {
 
36
        op: "u",
 
37
        ns: t.getFullName(),
 
38
        o2: { _id: 1 },
 
39
        o: { $set : { x: "upsert=false existing" }}
 
40
    },
 
41
    {
 
42
        op: "u",
 
43
        ns: t.getFullName(),
 
44
        o2: { _id: 3 },
 
45
        o: { $set: { x: "upsert=false non-existing" }}
 
46
    }], alwaysUpsert: false });
 
47
 
 
48
assert.eq(true, res.results[0], "upsert = false, existing doc update failed");
 
49
assert.eq(false, res.results[1], "upsert = false, nonexisting doc upserted");
 
50
assert.eq(2, t.find().count(), "2 docs expected after upsert failure");
 
51
 
 
52
//alwaysUpsert not specified, should default to true
 
53
print("Testing applyOps with default alwaysUpsert");
 
54
 
 
55
res = db.runCommand({ applyOps: [
 
56
    {
 
57
        op: "u",
 
58
        ns: t.getFullName(),
 
59
        o2: { _id: 1 },
 
60
        o: { $set: { x: "upsert=default existing" }}
 
61
    },
 
62
    {
 
63
        op: "u",
 
64
        ns: t.getFullName(),
 
65
        o2: { _id: 4 },
 
66
        o: { $set: { x: "upsert=defaults non-existing" }}
 
67
    }]});
 
68
 
 
69
assert.eq(true, res.results[0], "default upsert, existing doc update failed");
 
70
assert.eq(true, res.results[1], "default upsert, nonexisting doc not upserted");
 
71
assert.eq(3, t.find().count(), "2 docs expected after upsert failure");