Skip to content

Commit 018f216

Browse files
committed
Merge pull request #156
2 parents 8e882a2 + b64561b commit 018f216

16 files changed

+661
-280
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ env:
1717
before_install:
1818
- sudo pip install cpp-coveralls
1919
- sudo pip install ${MONGODB_ORCHESTRATION_REPO}
20-
- sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
21-
- echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
20+
- sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
21+
- echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
2222
- sudo apt-get update
2323
- sudo apt-get install -y mongodb-org
2424
- sudo apt-get install gdb valgrind

scripts/presets/replicaset-30.json

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
{
2+
"id": "REPLICASET_30",
3+
"name": "mongod",
4+
"members": [
5+
{
6+
"procParams": {
7+
"dbpath": "/tmp/REPLICASET/3100/",
8+
"ipv6": true,
9+
"logappend": true,
10+
"logpath": "/tmp/REPLICASET/3100/mongod.log",
11+
"nohttpinterface": true,
12+
"journal": true,
13+
"noprealloc": true,
14+
"nssize": 1,
15+
"port": 3100,
16+
"smallfiles": true,
17+
"setParameter": {"enableTestCommands": 1}
18+
},
19+
"rsParams": {
20+
"priority": 99,
21+
"tags": {
22+
"ordinal": "one",
23+
"dc": "pa"
24+
}
25+
},
26+
"server_id": "RS-30-one"
27+
},
28+
{
29+
"procParams": {
30+
"dbpath": "/tmp/REPLICASET/3101/",
31+
"ipv6": true,
32+
"logappend": true,
33+
"logpath": "/tmp/REPLICASET/3101/mongod.log",
34+
"nohttpinterface": true,
35+
"journal": true,
36+
"noprealloc": true,
37+
"nssize": 1,
38+
"port": 3101,
39+
"smallfiles": true,
40+
"setParameter": {"enableTestCommands": 1}
41+
},
42+
"rsParams": {
43+
"priority": 1.1,
44+
"tags": {
45+
"ordinal": "two",
46+
"dc": "nyc"
47+
}
48+
},
49+
"server_id": "RS-30-two"
50+
},
51+
{
52+
"procParams": {
53+
"dbpath": "/tmp/REPLICASET/3102/",
54+
"ipv6": true,
55+
"logappend": true,
56+
"logpath": "/tmp/REPLICASET/3002/mongod.log",
57+
"nohttpinterface": true,
58+
"journal": true,
59+
"noprealloc": true,
60+
"nssize": 1,
61+
"port": 3102,
62+
"smallfiles": true,
63+
"setParameter": {"enableTestCommands": 1}
64+
},
65+
"rsParams": {
66+
"arbiterOnly": true
67+
68+
},
69+
"server_id": "RS-30-arbiter"
70+
}
71+
],
72+
"version": "30-release"
73+
}
74+

scripts/start-servers.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ function lap() {
2929
],
3030
"replicasets" => [
3131
"scripts/presets/replicaset.json",
32+
"scripts/presets/replicaset-30.json",
3233
],
3334
];
3435

tests/cursor/cursor-destruct-001.phpt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,16 @@ function getNumOpenCursors(MongoDB\Driver\Manager $manager)
1010
{
1111
$cursor = $manager->executeCommand(DATABASE_NAME, new MongoDB\Driver\Command(array('serverStatus' => 1)));
1212
$result = current($cursor->toArray());
13-
return $result->cursors->totalOpen;
13+
14+
if (isset($result->metrics->cursor->open->total)) {
15+
return $result->metrics->cursor->open->total;
16+
}
17+
18+
if (isset($result->cursors->totalOpen)) {
19+
return $result->cursors->totalOpen;
20+
}
21+
22+
throw new RuntimeException('Could not find number of open cursors in serverStatus');
1423
}
1524

1625
$manager = new MongoDB\Driver\Manager(STANDALONE);

tests/cursor/cursor-getmore-005.phpt

Lines changed: 17 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,34 @@
11
--TEST--
2-
MongoDB\Driver\Cursor command result iteration with batchSize requiring getmore with non-full batches
2+
MongoDB\Driver\Cursor query result iteration with getmore failure
33
--SKIPIF--
44
<?php require __DIR__ . "/" ."../utils/basic-skipif.inc"; ?>
5-
<?php START("THROWAWAY"); CLEANUP(THROWAWAY); LOAD(THROWAWAY); ?>
5+
<?php START("THROWAWAY", ["version" => "30-release"]); CLEANUP(THROWAWAY); ?>
66
--FILE--
77
<?php
88
require_once __DIR__ . "/../utils/basic.inc";
99

1010
$manager = new MongoDB\Driver\Manager(THROWAWAY);
1111

12-
$query = new MongoDB\Driver\Query(array(), array(
13-
'projection' => array('_id' => 0, 'username' => 1),
14-
'sort' => array('username' => 1),
15-
));
12+
$bulkWrite = new MongoDB\Driver\BulkWrite;
1613

14+
for ($i = 0; $i < 5; $i++) {
15+
$bulkWrite->insert(array('_id' => $i));
16+
}
17+
18+
$writeResult = $manager->executeBulkWrite(NS, $bulkWrite);
19+
printf("Inserted: %d\n", $writeResult->getInsertedCount());
20+
21+
$query = new MongoDB\Driver\Query([], ['batchSize' => 2]);
1722
$cursor = $manager->executeQuery(NS, $query);
1823

1924
failGetMore($manager);
25+
2026
throws(function() use ($cursor) {
21-
foreach ($cursor as $document) {
22-
echo $document->username . "\n";
27+
foreach ($cursor as $i => $document) {
28+
printf("%d => {_id: %d}\n", $i, $document->_id);
2329
}
2430
}, "MongoDB\Driver\Exception\ConnectionException");
2531

26-
2732
?>
2833
===DONE===
2934
<?php DELETE("THROWAWAY"); ?>
@@ -32,106 +37,8 @@ throws(function() use ($cursor) {
3237
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
3338
<?php DELETE("THROWAWAY"); ?>
3439
--EXPECT--
35-
aaliyah.kertzmann
36-
aaron89
37-
abbott.alden
38-
abbott.flo
39-
abby76
40-
abernathy.adrienne
41-
abernathy.audrey
42-
abner.kreiger
43-
aboehm
44-
abshire.icie
45-
abshire.jazlyn
46-
adams.delta
47-
adolph20
48-
adonis.schamberger
49-
agleason
50-
ahartmann
51-
ahettinger
52-
akreiger
53-
al.cormier
54-
al97
55-
albin95
56-
alda.murray
57-
alden.blanda
58-
alessandra76
59-
alex73
60-
alexa01
61-
alfred.ritchie
62-
alia07
63-
alia72
64-
alize.hegmann
65-
allie48
66-
alta.sawayn
67-
alvena.pacocha
68-
alvis22
69-
alycia48
70-
amalia84
71-
amely01
72-
amos.corkery
73-
amos78
74-
anahi95
75-
anais.feest
76-
anais58
77-
andreanne.steuber
78-
angela.dickinson
79-
angelina.bartoletti
80-
angelina31
81-
aniyah.franecki
82-
annalise40
83-
antoinette.gaylord
84-
antoinette.weissnat
85-
aoberbrunner
86-
apacocha
87-
apollich
88-
ara92
89-
arch44
90-
arely.ryan
91-
armstrong.clara
92-
armstrong.gordon
93-
arnold.kiehn
94-
arvel.hilll
95-
asatterfield
96-
aschuppe
97-
ashlynn71
98-
ashlynn85
99-
ashton.o'kon
100-
austen03
101-
austen47
102-
austin67
103-
awintheiser
104-
awyman
105-
ayana.brakus
106-
bailey.mertz
107-
bailey.sarina
108-
balistreri.donald
109-
barrett.prohaska
110-
bartell.susie
111-
bashirian.lina
112-
bayer.ova
113-
baylee.maggio
114-
bbernier
115-
bblick
116-
beahan.oleta
117-
beatty.layne
118-
beatty.myrtis
119-
beau49
120-
beaulah.mann
121-
bechtelar.nadia
122-
becker.theron
123-
beer.mossie
124-
beer.roselyn
125-
benedict.johnson
126-
berge.enoch
127-
bergnaum.roberto
128-
bernardo.mccullough
129-
bernardo52
130-
bernhard.margaretta
131-
bernie.morissette
132-
bethel20
133-
betty09
134-
bins.aliyah
135-
bins.laisha
40+
Inserted: 5
41+
0 => {_id: 0}
42+
1 => {_id: 1}
13643
OK: Got MongoDB\Driver\Exception\ConnectionException
13744
===DONE===

tests/cursor/cursor-getmore-006.phpt

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
--TEST--
2+
MongoDB\Driver\Cursor command result iteration with getmore failure
3+
--SKIPIF--
4+
<?php require __DIR__ . "/" ."../utils/basic-skipif.inc"; ?>
5+
<?php START("THROWAWAY", ["version" => "30-release"]); CLEANUP(THROWAWAY); ?>
6+
--FILE--
7+
<?php
8+
require_once __DIR__ . "/../utils/basic.inc";
9+
10+
$manager = new MongoDB\Driver\Manager(THROWAWAY);
11+
12+
$bulkWrite = new MongoDB\Driver\BulkWrite;
13+
14+
for ($i = 0; $i < 5; $i++) {
15+
$bulkWrite->insert(array('_id' => $i));
16+
}
17+
18+
$writeResult = $manager->executeBulkWrite(NS, $bulkWrite);
19+
printf("Inserted: %d\n", $writeResult->getInsertedCount());
20+
21+
$command = new MongoDB\Driver\Command([
22+
'aggregate' => COLLECTION_NAME,
23+
'pipeline' => [
24+
['$match' => new stdClass],
25+
],
26+
'cursor' => ['batchSize' => 2],
27+
]);
28+
29+
$cursor = $manager->executeCommand(DATABASE_NAME, $command);
30+
31+
failGetMore($manager);
32+
33+
throws(function() use ($cursor) {
34+
foreach ($cursor as $i => $document) {
35+
printf("%d => {_id: %d}\n", $i, $document->_id);
36+
}
37+
}, "MongoDB\Driver\Exception\ConnectionException");
38+
39+
?>
40+
===DONE===
41+
<?php DELETE("THROWAWAY"); ?>
42+
<?php exit(0); ?>
43+
--CLEAN--
44+
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
45+
<?php DELETE("THROWAWAY"); ?>
46+
--EXPECT--
47+
Inserted: 5
48+
0 => {_id: 0}
49+
1 => {_id: 1}
50+
OK: Got MongoDB\Driver\Exception\ConnectionException
51+
===DONE===

tests/manager/manager-executeQuery-001.phpt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
--TEST--
2-
MongoDB\Driver\Manager::executeQuery() one document
2+
MongoDB\Driver\Manager::executeQuery() one document (OP_QUERY)
33
--SKIPIF--
4-
<?php require __DIR__ . "/../utils/basic-skipif.inc"; CLEANUP(STANDALONE) ?>
4+
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5+
<?php NEEDS("STANDALONE_30"); CLEANUP(STANDALONE_30); ?>
56
--FILE--
67
<?php
78
require_once __DIR__ . "/../utils/basic.inc";
89

9-
$manager = new MongoDB\Driver\Manager(STANDALONE);
10+
$manager = new MongoDB\Driver\Manager(STANDALONE_30);
1011

1112
// load fixtures for test
1213
$bulk = new MongoDB\Driver\BulkWrite();
@@ -52,15 +53,15 @@ object(MongoDB\Driver\Cursor)#%d (%d) {
5253
["has_fields"]=>
5354
bool(true)
5455
["query"]=>
55-
object(stdClass)#%d (1) {
56+
object(stdClass)#%d (%d) {
5657
["$query"]=>
5758
object(stdClass)#%d (%d) {
5859
["x"]=>
5960
int(3)
6061
}
6162
}
6263
["fields"]=>
63-
object(stdClass)#%d (1) {
64+
object(stdClass)#%d (%d) {
6465
["y"]=>
6566
int(1)
6667
}

0 commit comments

Comments
 (0)