1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
|
--TEST--
Test for PHP-569: MongoClient: Checking permutations to trigger GLE.
--SKIPIF--
<?php $needs = "2.5.5"; $needsOp = "lt"; ?>
<?php require_once "tests/utils/standalone.inc";?>
--FILE--
<?php
require_once "tests/utils/server.inc";
MongoLog::setModule( MongoLog::IO );
MongoLog::setLevel( MongoLog::FINE );
set_error_handler('foo'); function foo($a, $b) { echo $b, "\n"; };
$m = new_mongo_standalone();
$m->selectDB(dbname())->test->remove();
$tests = array(
array(),
array( 'safe' => 0 ),
array( 'safe' => 1 ),
array( 'safe' => 2 ),
array( 'safe' => "majority" ),
array( 'w' => 0 ),
array( 'w' => 1 ),
array( 'w' => 2 ),
array( 'w' => "majority" ),
array( 'fsync' => 0 ),
array( 'fsync' => 1 ),
array( 'fsync' => 0, "w" => 1 ),
array( 'fsync' => 1, "w" => 0 ),
);
foreach ( $tests as $key => $test )
{
echo "\nRunning test $key, with options: ", json_encode( $test ), ":\n";
try
{
$m->selectDB(dbname())->test->insert( array( '_id' => $key ), $test );
}
catch ( Exception $e )
{
if (current($test) != "majority") {
/* 2.5.x maps majority=1 for standalone servers so doesn't raise an exception */
echo $e->getMessage(), "\n";
}
}
}
?>
--EXPECTF--
IO FINE: is_gle_op: yes
IO FINE: append_getlasterror
IO FINE: getting reply
IO FINE: getting cursor header
IO FINE: getting cursor body
Running test 0, with options: []:
IO FINE: is_gle_op: yes
IO FINE: append_getlasterror
IO FINE: getting reply
IO FINE: getting cursor header
IO FINE: getting cursor body
Running test 1, with options: {"safe":0}:
MongoCollection::insert(): The 'safe' option is deprecated, please use 'w' instead
IO FINE: is_gle_op: no
Running test 2, with options: {"safe":1}:
MongoCollection::insert(): The 'safe' option is deprecated, please use 'w' instead
IO FINE: is_gle_op: yes
IO FINE: append_getlasterror
IO FINE: getting reply
IO FINE: getting cursor header
IO FINE: getting cursor body
Running test 3, with options: {"safe":2}:
MongoCollection::insert(): The 'safe' option is deprecated, please use 'w' instead
IO FINE: is_gle_op: yes
IO FINE: append_getlasterror
IO FINE: append_getlasterror: added w=2
IO FINE: append_getlasterror: added wtimeout=10000 (from collection property)
IO FINE: getting reply
IO FINE: getting cursor header
IO FINE: getting cursor body
%s:%d:%s
Running test 4, with options: {"safe":"majority"}:
MongoCollection::insert(): The 'safe' option is deprecated, please use 'w' instead
IO FINE: is_gle_op: yes
IO FINE: append_getlasterror
IO FINE: append_getlasterror: added w='majority'
IO FINE: append_getlasterror: added wtimeout=10000 (from collection property)
IO FINE: getting reply
IO FINE: getting cursor header
IO FINE: getting cursor body
Running test 5, with options: {"w":0}:
IO FINE: is_gle_op: no
Running test 6, with options: {"w":1}:
IO FINE: is_gle_op: yes
IO FINE: append_getlasterror
IO FINE: getting reply
IO FINE: getting cursor header
IO FINE: getting cursor body
Running test 7, with options: {"w":2}:
IO FINE: is_gle_op: yes
IO FINE: append_getlasterror
IO FINE: append_getlasterror: added w=2
IO FINE: append_getlasterror: added wtimeout=10000 (from collection property)
IO FINE: getting reply
IO FINE: getting cursor header
IO FINE: getting cursor body
%s:%d:%s
Running test 8, with options: {"w":"majority"}:
IO FINE: is_gle_op: yes
IO FINE: append_getlasterror
IO FINE: append_getlasterror: added w='majority'
IO FINE: append_getlasterror: added wtimeout=10000 (from collection property)
IO FINE: getting reply
IO FINE: getting cursor header
IO FINE: getting cursor body
Running test 9, with options: {"fsync":0}:
IO FINE: is_gle_op: yes
IO FINE: append_getlasterror
IO FINE: getting reply
IO FINE: getting cursor header
IO FINE: getting cursor body
Running test 10, with options: {"fsync":1}:
IO FINE: is_gle_op: yes
IO FINE: append_getlasterror
IO FINE: append_getlasterror: added fsync=1
IO FINE: getting reply
IO FINE: getting cursor header
IO FINE: getting cursor body
Running test 11, with options: {"fsync":0,"w":1}:
IO FINE: is_gle_op: yes
IO FINE: append_getlasterror
IO FINE: getting reply
IO FINE: getting cursor header
IO FINE: getting cursor body
Running test 12, with options: {"fsync":1,"w":0}:
IO FINE: is_gle_op: yes
IO FINE: append_getlasterror
IO FINE: append_getlasterror: added fsync=1
IO FINE: getting reply
IO FINE: getting cursor header
IO FINE: getting cursor body
|