Skip to content

Commit 44ee3a3

Browse files
committed
PHPC-450: failReceivedGetmore does not support getMore commands
The fail point used in this test does not yet support 3.2's getMore command, so this must be run on 3.0 (or earlier). See: SERVER-21831 This change also splits the test into query/command variants, corrects the title (which was apparently copied from cursor-getmore-004.phpt), and removes the use of data fixtures (small documents inserted within the test work just fine for its purposes).
1 parent dee9ff9 commit 44ee3a3

File tree

3 files changed

+70
-114
lines changed

3 files changed

+70
-114
lines changed

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/utils/tools.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -391,10 +391,8 @@ function fromJSON($var) {
391391
return $func($var);
392392
}
393393

394-
395-
396-
/* NOTE: Using this function will take down mongod ! */
394+
/* Note: this fail point may terminate the mongod process, so you may want to
395+
* use this in conjunction with a throwaway server. */
397396
function failGetMore(MongoDB\Driver\Manager $manager) {
398397
return configureFailPoint($manager, "failReceivedGetmore", "alwaysOn");
399398
}
400-

0 commit comments

Comments
 (0)