Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongo-php-library
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sinan
mongo-php-library
Commits
e98829b6
Unverified
Commit
e98829b6
authored
Aug 05, 2019
by
Andreas Braun
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #657
parents
261b6059
f9452d80
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
91 additions
and
4 deletions
+91
-4
cluster.json
mongo-orchestration/sharded_clusters/cluster.json
+7
-0
cluster_replset.json
mongo-orchestration/sharded_clusters/cluster_replset.json
+7
-0
FunctionalTestCase.php
tests/FunctionalTestCase.php
+62
-0
WatchFunctionalTest.php
tests/Operation/WatchFunctionalTest.php
+4
-0
RetryableWritesSpecTest.php
tests/SpecTests/RetryableWritesSpecTest.php
+6
-2
TransactionsSpecTest.php
tests/SpecTests/TransactionsSpecTest.php
+5
-2
No files found.
mongo-orchestration/sharded_clusters/cluster.json
View file @
e98829b6
...
...
@@ -74,6 +74,13 @@
"logappend"
:
true
,
"port"
:
4300
,
"bind_ip_all"
:
true
},
{
"logpath"
:
"/tmp/SHARDED/ROUTER/4301/mongod.log"
,
"ipv6"
:
true
,
"logappend"
:
true
,
"port"
:
4301
,
"bind_ip_all"
:
true
}
]
}
mongo-orchestration/sharded_clusters/cluster_replset.json
View file @
e98829b6
...
...
@@ -98,6 +98,13 @@
"logappend"
:
true
,
"port"
:
4430
,
"bind_ip_all"
:
true
},
{
"logpath"
:
"/tmp/SHARDED-RS/ROUTER/4431/mongod.log"
,
"ipv6"
:
true
,
"logappend"
:
true
,
"port"
:
4431
,
"bind_ip_all"
:
true
}
]
}
tests/FunctionalTestCase.php
View file @
e98829b6
...
...
@@ -38,6 +38,68 @@ abstract class FunctionalTestCase extends TestCase
parent
::
tearDown
();
}
public
static
function
getUri
(
$allowMultipleMongoses
=
false
)
{
$uri
=
parent
::
getUri
();
if
(
$allowMultipleMongoses
)
{
return
$uri
;
}
$urlParts
=
parse_url
(
$uri
);
if
(
$urlParts
===
false
)
{
return
$uri
;
}
// Only modify URIs using the mongodb scheme
if
(
$urlParts
[
'scheme'
]
!==
'mongodb'
)
{
return
$uri
;
}
$hosts
=
explode
(
','
,
$urlParts
[
'host'
]);
$numHosts
=
count
(
$hosts
);
if
(
$numHosts
===
1
)
{
return
$uri
;
}
$manager
=
new
Manager
(
$uri
);
if
(
$manager
->
selectServer
(
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
))
->
getType
()
!==
Server
::
TYPE_MONGOS
)
{
return
$uri
;
}
// Re-append port to last host
if
(
isset
(
$urlParts
[
'port'
]))
{
$hosts
[
$numHosts
-
1
]
.=
':'
.
$urlParts
[
'port'
];
}
$parts
=
[
'mongodb://'
];
if
(
isset
(
$urlParts
[
'user'
],
$urlParts
[
'pass'
]))
{
$parts
+=
[
$urlParts
[
'user'
],
':'
,
$urlParts
[
'pass'
],
'@'
,
];
}
$parts
[]
=
$hosts
[
0
];
if
(
isset
(
$urlParts
[
'path'
]))
{
$parts
[]
=
$urlParts
[
'path'
];
}
if
(
isset
(
$urlParts
[
'query'
]))
{
$parts
+=
[
'?'
,
$urlParts
[
'path'
]
];
}
return
implode
(
''
,
$parts
);
}
protected
function
assertCollectionCount
(
$namespace
,
$count
)
{
list
(
$databaseName
,
$collectionName
)
=
explode
(
'.'
,
$namespace
,
2
);
...
...
tests/Operation/WatchFunctionalTest.php
View file @
e98829b6
...
...
@@ -55,14 +55,17 @@ class WatchFunctionalTest extends FunctionalTestCase
$this
->
insertDocument
([
'x'
=>
2
]);
$changeStream
->
next
();
$this
->
assertTrue
(
$changeStream
->
valid
());
$this
->
assertSameDocument
(
$changeStream
->
current
()
->
_id
,
$changeStream
->
getResumeToken
());
$changeStream
->
next
();
$this
->
assertTrue
(
$changeStream
->
valid
());
$this
->
assertSameDocument
(
$changeStream
->
current
()
->
_id
,
$changeStream
->
getResumeToken
());
$this
->
insertDocument
([
'x'
=>
3
]);
$changeStream
->
next
();
$this
->
assertTrue
(
$changeStream
->
valid
());
$this
->
assertSameDocument
(
$changeStream
->
current
()
->
_id
,
$changeStream
->
getResumeToken
());
}
...
...
@@ -116,6 +119,7 @@ class WatchFunctionalTest extends FunctionalTestCase
$postBatchResumeToken
=
$this
->
getPostBatchResumeTokenFromReply
(
$events
[
0
][
'succeeded'
]
->
getReply
());
$changeStream
->
next
();
$this
->
assertTrue
(
$changeStream
->
valid
());
$this
->
assertSameDocument
(
$changeStream
->
current
()
->
_id
,
$changeStream
->
getResumeToken
());
$changeStream
->
next
();
...
...
tests/SpecTests/RetryableWritesSpecTest.php
View file @
e98829b6
...
...
@@ -3,6 +3,7 @@
namespace
MongoDB\Tests\SpecTests
;
use
LogicException
;
use
MongoDB\Driver\Manager
;
use
stdClass
;
/**
...
...
@@ -22,9 +23,12 @@ class RetryableWritesSpecTest extends FunctionalTestCase
*/
public
function
testRetryableWrites
(
stdClass
$test
,
array
$runOn
=
null
,
array
$data
)
{
// TODO: Revise this once a test environment with multiple mongos nodes is available (see: PHPLIB-430)
if
(
$this
->
isShardedCluster
()
&&
!
$this
->
isShardedClusterUsingReplicasets
())
{
$this
->
markTestSkipped
(
'Transaction numbers are only allowed on a replica set member or mongos (PHPC-1415)'
);
}
if
(
isset
(
$test
->
useMultipleMongoses
)
&&
$test
->
useMultipleMongoses
&&
$this
->
isShardedCluster
())
{
$this
->
ma
rkTestSkipped
(
'"useMultipleMongoses" is not supported'
);
$this
->
ma
nager
=
new
Manager
(
static
::
getUri
(
true
)
);
}
if
(
isset
(
$runOn
))
{
...
...
tests/SpecTests/TransactionsSpecTest.php
View file @
e98829b6
...
...
@@ -123,9 +123,12 @@ class TransactionsSpecTest extends FunctionalTestCase
$this
->
markTestIncomplete
(
self
::
$incompleteTests
[
$this
->
dataDescription
()]);
}
// TODO: Revise this once a test environment with multiple mongos nodes is available (see: PHPLIB-430)
if
(
$this
->
isShardedCluster
())
{
$this
->
markTestSkipped
(
'PHP MongoDB driver 1.6.0alpha2 does not support running multi-document transactions on sharded clusters'
);
}
if
(
isset
(
$test
->
useMultipleMongoses
)
&&
$test
->
useMultipleMongoses
&&
$this
->
isShardedCluster
())
{
$this
->
ma
rkTestIncomplete
(
'"useMultipleMongoses" is not supported'
);
$this
->
ma
nager
=
new
Manager
(
static
::
getUri
(
true
)
);
}
if
(
isset
(
$runOn
))
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment