Skip to content

Commit

Permalink
PHPLIB-1240: Respect useMultipleMongoses:true for non-serverless LB t…
Browse files Browse the repository at this point in the history
…opologies
  • Loading branch information
jmikola committed Sep 21, 2023
1 parent ffc2d69 commit 5aa8f0c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions tests/SpecTests/RetryableWritesSpecTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,15 @@ class RetryableWritesSpecTest extends FunctionalTestCase
*/
public function testRetryableWrites(stdClass $test, ?array $runOn, array $data): void
{
$useMultipleMongoses = isset($test->useMultipleMongoses) && $test->useMultipleMongoses && $this->isMongos();

if (isset($runOn)) {
$this->checkServerRequirements($runOn);
}

// Serverless uses a load balancer fronting a single proxy (PHPLIB-757)
$useMultipleMongoses = $this->isMongos() || ($this->isLoadBalanced() && ! $this->isServerless())
? ($test->useMultipleMongoses ?? false)
: false;

$context = Context::fromRetryableWrites($test, $this->getDatabaseName(), $this->getCollectionName(), $useMultipleMongoses);
$this->setContext($context);

Expand Down
7 changes: 5 additions & 2 deletions tests/SpecTests/TransactionsSpecTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,6 @@ private function runTransactionTest(stdClass $test, ?array $runOn, array $data,
$this->markTestIncomplete(self::$incompleteTests[$this->dataDescription()]);
}

$useMultipleMongoses = isset($test->useMultipleMongoses) && $test->useMultipleMongoses && $this->isMongos();

if (isset($runOn)) {
$this->checkServerRequirements($runOn);
}
Expand All @@ -156,6 +154,11 @@ private function runTransactionTest(stdClass $test, ?array $runOn, array $data,
$databaseName ??= $this->getDatabaseName();
$collectionName ??= $this->getCollectionName();

// Serverless uses a load balancer fronting a single proxy (PHPLIB-757)
$useMultipleMongoses = $this->isMongos() || ($this->isLoadBalanced() && ! $this->isServerless())
? ($test->useMultipleMongoses ?? false)
: false;

$context = Context::fromTransactions($test, $databaseName, $collectionName, $useMultipleMongoses);
$this->setContext($context);

Expand Down

0 comments on commit 5aa8f0c

Please sign in to comment.