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

Merge pull request #657

parents 261b6059 f9452d80
...@@ -74,6 +74,13 @@ ...@@ -74,6 +74,13 @@
"logappend": true, "logappend": true,
"port": 4300, "port": 4300,
"bind_ip_all": true "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 @@ ...@@ -98,6 +98,13 @@
"logappend": true, "logappend": true,
"port": 4430, "port": 4430,
"bind_ip_all": true "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 ...@@ -38,6 +38,68 @@ abstract class FunctionalTestCase extends TestCase
parent::tearDown(); 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) protected function assertCollectionCount($namespace, $count)
{ {
list($databaseName, $collectionName) = explode('.', $namespace, 2); list($databaseName, $collectionName) = explode('.', $namespace, 2);
......
...@@ -55,14 +55,17 @@ class WatchFunctionalTest extends FunctionalTestCase ...@@ -55,14 +55,17 @@ class WatchFunctionalTest extends FunctionalTestCase
$this->insertDocument(['x' => 2]); $this->insertDocument(['x' => 2]);
$changeStream->next(); $changeStream->next();
$this->assertTrue($changeStream->valid());
$this->assertSameDocument($changeStream->current()->_id, $changeStream->getResumeToken()); $this->assertSameDocument($changeStream->current()->_id, $changeStream->getResumeToken());
$changeStream->next(); $changeStream->next();
$this->assertTrue($changeStream->valid());
$this->assertSameDocument($changeStream->current()->_id, $changeStream->getResumeToken()); $this->assertSameDocument($changeStream->current()->_id, $changeStream->getResumeToken());
$this->insertDocument(['x' => 3]); $this->insertDocument(['x' => 3]);
$changeStream->next(); $changeStream->next();
$this->assertTrue($changeStream->valid());
$this->assertSameDocument($changeStream->current()->_id, $changeStream->getResumeToken()); $this->assertSameDocument($changeStream->current()->_id, $changeStream->getResumeToken());
} }
...@@ -116,6 +119,7 @@ class WatchFunctionalTest extends FunctionalTestCase ...@@ -116,6 +119,7 @@ class WatchFunctionalTest extends FunctionalTestCase
$postBatchResumeToken = $this->getPostBatchResumeTokenFromReply($events[0]['succeeded']->getReply()); $postBatchResumeToken = $this->getPostBatchResumeTokenFromReply($events[0]['succeeded']->getReply());
$changeStream->next(); $changeStream->next();
$this->assertTrue($changeStream->valid());
$this->assertSameDocument($changeStream->current()->_id, $changeStream->getResumeToken()); $this->assertSameDocument($changeStream->current()->_id, $changeStream->getResumeToken());
$changeStream->next(); $changeStream->next();
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace MongoDB\Tests\SpecTests; namespace MongoDB\Tests\SpecTests;
use LogicException; use LogicException;
use MongoDB\Driver\Manager;
use stdClass; use stdClass;
/** /**
...@@ -22,9 +23,12 @@ class RetryableWritesSpecTest extends FunctionalTestCase ...@@ -22,9 +23,12 @@ class RetryableWritesSpecTest extends FunctionalTestCase
*/ */
public function testRetryableWrites(stdClass $test, array $runOn = null, array $data) 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()) { if (isset($test->useMultipleMongoses) && $test->useMultipleMongoses && $this->isShardedCluster()) {
$this->markTestSkipped('"useMultipleMongoses" is not supported'); $this->manager = new Manager(static::getUri(true));
} }
if (isset($runOn)) { if (isset($runOn)) {
......
...@@ -123,9 +123,12 @@ class TransactionsSpecTest extends FunctionalTestCase ...@@ -123,9 +123,12 @@ class TransactionsSpecTest extends FunctionalTestCase
$this->markTestIncomplete(self::$incompleteTests[$this->dataDescription()]); $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()) { if (isset($test->useMultipleMongoses) && $test->useMultipleMongoses && $this->isShardedCluster()) {
$this->markTestIncomplete('"useMultipleMongoses" is not supported'); $this->manager = new Manager(static::getUri(true));
} }
if (isset($runOn)) { 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