Unverified Commit e98829b6 authored by Andreas Braun's avatar Andreas Braun

Merge pull request #657

parents 261b6059 f9452d80
......@@ -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
}
]
}
......@@ -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
}
]
}
......@@ -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);
......
......@@ -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();
......
......@@ -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->markTestSkipped('"useMultipleMongoses" is not supported');
$this->manager = new Manager(static::getUri(true));
}
if (isset($runOn)) {
......
......@@ -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->markTestIncomplete('"useMultipleMongoses" is not supported');
$this->manager = new Manager(static::getUri(true));
}
if (isset($runOn)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment