Skip to content

Commit f54147c

Browse files
authored
PHPLIB-783, PHPLIB-784: Update load balancer testing config and CSFLE tests (#887)
* PHPLIB-783: Update load balancer testing config Upstream changes in drivers-evergreen-tools now require passing LOAD_BALANCER to run-orchestration.sh. Additionally, service ID mocking is no longer required as of server version 5.1. Load balancer testing requires PHPC 1.13.x for CDRIVER-4207 * Remove PHP memory limit for Evergreen * PHPLIB-784: Replace example.com in CSFLE prose tests * Skip collMod test on sharded clusters due to inconsistent result reporting
1 parent 93ccf29 commit f54147c

File tree

4 files changed

+19
-27
lines changed

4 files changed

+19
-27
lines changed

.evergreen/config.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ functions:
175175
params:
176176
script: |
177177
${PREPARE_SHELL}
178-
MONGODB_VERSION=${VERSION} ORCHESTRATION_FILE=${ORCHESTRATION_FILE} TOPOLOGY=${TOPOLOGY} AUTH=${AUTH} SSL=${SSL} STORAGE_ENGINE=${STORAGE_ENGINE} REQUIRE_API_VERSION=${REQUIRE_API_VERSION} sh ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh
178+
MONGODB_VERSION=${VERSION} ORCHESTRATION_FILE=${ORCHESTRATION_FILE} TOPOLOGY=${TOPOLOGY} AUTH=${AUTH} SSL=${SSL} STORAGE_ENGINE=${STORAGE_ENGINE} LOAD_BALANCER=${LOAD_BALANCER} REQUIRE_API_VERSION=${REQUIRE_API_VERSION} sh ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh
179179
# run-orchestration generates expansion file with the MONGODB_URI for the cluster
180180
- command: expansions.update
181181
params:
@@ -505,13 +505,12 @@ tasks:
505505
- func: "bootstrap mongo-orchestration"
506506
vars:
507507
TOPOLOGY: "sharded_cluster"
508+
LOAD_BALANCER: "true"
508509
SSL: "yes"
509510
- func: "start load balancer"
510511
- func: "start kms servers"
511512
- func: "run tests"
512513
vars:
513-
# Testing with HAProxy requires service ID mocking
514-
MOCK_SERVICE_ID: 1
515514
# Note: loadBalanced=true should already be appended to SINGLE_MONGOS_LB_URI
516515
MONGODB_URI: "${SINGLE_MONGOS_LB_URI}"
517516
SSL: "yes"
@@ -767,7 +766,9 @@ buildvariants:
767766
- .serverless
768767

769768
- matrix_name: "test-loadBalanced"
770-
matrix_spec: { "versions": ["5.0", "latest"], "php-edge-versions": "latest-stable", "driver-versions": "latest-stable" }
769+
# TODO: Add "5.2" server version alongside "latest" following its GA release
770+
# TODO: Revert driver-version to latest-stable after PHPC 1.13.0 is released (for CDRIVER-4207)
771+
matrix_spec: { "versions": "latest", "php-edge-versions": "latest-stable", "driver-versions": "latest-dev" }
771772
display_name: "Load balanced - ${versions}"
772773
run_on: debian92-test
773774
tasks:

phpunit.evergreen.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
<php>
1414
<ini name="error_reporting" value="-1"/>
15+
<ini name="memory_limit" value="-1"/>
1516
<env name="MONGODB_URI" value="mongodb://127.0.0.1:27017/?serverSelectionTimeoutMS=100"/>
1617
<env name="MONGODB_DATABASE" value="phplib_test"/>
1718
</php>

tests/Operation/ModifyCollectionFunctionalTest.php

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
use MongoDB\Operation\CreateIndexes;
66
use MongoDB\Operation\ModifyCollection;
77

8-
use function array_key_exists;
9-
108
class ModifyCollectionFunctionalTest extends FunctionalTestCase
119
{
1210
/**
@@ -16,6 +14,10 @@ class ModifyCollectionFunctionalTest extends FunctionalTestCase
1614
*/
1715
public function testCollMod(): void
1816
{
17+
if ($this->isShardedCluster()) {
18+
$this->markTestSkipped('Sharded clusters may report result inconsistently');
19+
}
20+
1921
$this->createCollection();
2022

2123
$indexes = [['key' => ['lastAccess' => 1], 'expireAfterSeconds' => 3]];
@@ -30,19 +32,7 @@ public function testCollMod(): void
3032
);
3133
$result = $modifyCollection->execute($this->getPrimaryServer());
3234

33-
if (array_key_exists('raw', $result)) {
34-
/* Sharded environment, where we only assert if a shard had a successful update. For
35-
* non-primary shards that don't have chunks for the collection, the result contains a
36-
* "ns does not exist" error. */
37-
foreach ($result['raw'] as $shard) {
38-
if (array_key_exists('ok', $shard) && $shard['ok'] == 1) {
39-
$this->assertSame(3, $shard['expireAfterSeconds_old']);
40-
$this->assertSame(1000, $shard['expireAfterSeconds_new']);
41-
}
42-
}
43-
} else {
44-
$this->assertSame(3, $result['expireAfterSeconds_old']);
45-
$this->assertSame(1000, $result['expireAfterSeconds_new']);
46-
}
35+
$this->assertSame(3, $result['expireAfterSeconds_old']);
36+
$this->assertSame(1000, $result['expireAfterSeconds_new']);
4737
}
4838
}

tests/SpecTests/ClientSideEncryptionSpecTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -665,8 +665,8 @@ public function testCustomEndpoint(Closure $test): void
665665
$clientEncryptionInvalid = $client->createClientEncryption([
666666
'keyVaultNamespace' => 'keyvault.datakeys',
667667
'kmsProviders' => [
668-
'azure' => Context::getAzureCredentials() + ['identityPlatformEndpoint' => 'example.com:443'],
669-
'gcp' => Context::getGCPCredentials() + ['endpoint' => 'example.com:443'],
668+
'azure' => Context::getAzureCredentials() + ['identityPlatformEndpoint' => 'doesnotexist.invalid:443'],
669+
'gcp' => Context::getGCPCredentials() + ['endpoint' => 'doesnotexist.invalid:443'],
670670
'kmip' => ['endpoint' => 'doesnotexist.local:5698'],
671671
],
672672
'tlsOptions' => [
@@ -732,8 +732,8 @@ static function (self $test, ClientEncryption $clientEncryption, ClientEncryptio
732732
yield 'Test 6' => [
733733
static function (self $test, ClientEncryption $clientEncryption, ClientEncryption $clientEncryptionInvalid) use ($awsMasterKey): void {
734734
$test->expectException(RuntimeException::class);
735-
$test->expectExceptionMessageMatches('#parse error#');
736-
$clientEncryption->createDataKey('aws', ['masterKey' => $awsMasterKey + ['endpoint' => 'example.com']]);
735+
$test->expectExceptionMessageMatches('#doesnotexist.invalid#');
736+
$clientEncryption->createDataKey('aws', ['masterKey' => $awsMasterKey + ['endpoint' => 'doesnotexist.invalid']]);
737737
},
738738
];
739739

@@ -744,7 +744,7 @@ static function (self $test, ClientEncryption $clientEncryption, ClientEncryptio
744744
$test->assertSame('test', $clientEncryption->decrypt($encrypted));
745745

746746
$test->expectException(RuntimeException::class);
747-
$test->expectExceptionMessageMatches('#parse error#');
747+
$test->expectExceptionMessageMatches('#doesnotexist.invalid#');
748748
$clientEncryptionInvalid->createDataKey('azure', ['masterKey' => $azureMasterKey]);
749749
},
750750
];
@@ -756,15 +756,15 @@ static function (self $test, ClientEncryption $clientEncryption, ClientEncryptio
756756
$test->assertSame('test', $clientEncryption->decrypt($encrypted));
757757

758758
$test->expectException(RuntimeException::class);
759-
$test->expectExceptionMessageMatches('#parse error#');
759+
$test->expectExceptionMessageMatches('#doesnotexist.invalid#');
760760
$clientEncryptionInvalid->createDataKey('gcp', ['masterKey' => $gcpMasterKey]);
761761
},
762762
];
763763

764764
yield 'Test 9' => [
765765
static function (self $test, ClientEncryption $clientEncryption, ClientEncryption $clientEncryptionInvalid) use ($gcpMasterKey): void {
766766
$masterKey = $gcpMasterKey;
767-
$masterKey['endpoint'] = 'example.com:443';
767+
$masterKey['endpoint'] = 'doesnotexist.invalid:443';
768768

769769
$test->expectException(RuntimeException::class);
770770
$test->expectExceptionMessageMatches('#Invalid KMS response#');

0 commit comments

Comments
 (0)