Skip to content

Commit 5aa8f0c

Browse files
committed
PHPLIB-1240: Respect useMultipleMongoses:true for non-serverless LB topologies
1 parent ffc2d69 commit 5aa8f0c

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

tests/SpecTests/RetryableWritesSpecTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,15 @@ class RetryableWritesSpecTest extends FunctionalTestCase
3434
*/
3535
public function testRetryableWrites(stdClass $test, ?array $runOn, array $data): void
3636
{
37-
$useMultipleMongoses = isset($test->useMultipleMongoses) && $test->useMultipleMongoses && $this->isMongos();
38-
3937
if (isset($runOn)) {
4038
$this->checkServerRequirements($runOn);
4139
}
4240

41+
// Serverless uses a load balancer fronting a single proxy (PHPLIB-757)
42+
$useMultipleMongoses = $this->isMongos() || ($this->isLoadBalanced() && ! $this->isServerless())
43+
? ($test->useMultipleMongoses ?? false)
44+
: false;
45+
4346
$context = Context::fromRetryableWrites($test, $this->getDatabaseName(), $this->getCollectionName(), $useMultipleMongoses);
4447
$this->setContext($context);
4548

tests/SpecTests/TransactionsSpecTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,6 @@ private function runTransactionTest(stdClass $test, ?array $runOn, array $data,
143143
$this->markTestIncomplete(self::$incompleteTests[$this->dataDescription()]);
144144
}
145145

146-
$useMultipleMongoses = isset($test->useMultipleMongoses) && $test->useMultipleMongoses && $this->isMongos();
147-
148146
if (isset($runOn)) {
149147
$this->checkServerRequirements($runOn);
150148
}
@@ -156,6 +154,11 @@ private function runTransactionTest(stdClass $test, ?array $runOn, array $data,
156154
$databaseName ??= $this->getDatabaseName();
157155
$collectionName ??= $this->getCollectionName();
158156

157+
// Serverless uses a load balancer fronting a single proxy (PHPLIB-757)
158+
$useMultipleMongoses = $this->isMongos() || ($this->isLoadBalanced() && ! $this->isServerless())
159+
? ($test->useMultipleMongoses ?? false)
160+
: false;
161+
159162
$context = Context::fromTransactions($test, $databaseName, $collectionName, $useMultipleMongoses);
160163
$this->setContext($context);
161164

0 commit comments

Comments
 (0)