diff --git a/tests/SpecTests/RetryableWritesSpecTest.php b/tests/SpecTests/RetryableWritesSpecTest.php index b85eb1c27..7752942e5 100644 --- a/tests/SpecTests/RetryableWritesSpecTest.php +++ b/tests/SpecTests/RetryableWritesSpecTest.php @@ -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); diff --git a/tests/SpecTests/TransactionsSpecTest.php b/tests/SpecTests/TransactionsSpecTest.php index 226ece4ae..fb89efad3 100644 --- a/tests/SpecTests/TransactionsSpecTest.php +++ b/tests/SpecTests/TransactionsSpecTest.php @@ -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); } @@ -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);