Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHPLIB-1541: Include specs repository as a submodule #1429

Merged
merged 18 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ $ composer update

In addition to installing project dependencies, Composer will check that the
required extension version is installed. Directions for installing the extension
may be found [here](https://php.net/manual/en/mongodb.installation.php). Composer will also install the submodule required for
running spec tests.
may be found [here](https://php.net/manual/en/mongodb.installation.php).
Composer will also install the submodule required for running spec tests.

Installation directions for Composer may be found in its
[Getting Started](https://getcomposer.org/doc/00-intro.md) guide.
Expand Down
31 changes: 21 additions & 10 deletions tests/UnifiedSpecTests/UnifiedSpecTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@
use PHPUnit\Framework\Warning;

use function array_flip;
use function basename;

Check failure on line 14 in tests/UnifiedSpecTests/UnifiedSpecTest.php

View workflow job for this annotation

GitHub Actions / phpcs

Type basename is not used in this file.
use function dirname;

Check failure on line 15 in tests/UnifiedSpecTests/UnifiedSpecTest.php

View workflow job for this annotation

GitHub Actions / phpcs

Type dirname is not used in this file.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note the phpcs warnings for basename and dirname.

use function glob;
use function preg_match;
use function sprintf;
use function str_starts_with;

/**
* Unified test format spec tests.
Expand All @@ -25,8 +24,11 @@
class UnifiedSpecTest extends FunctionalTestCase
{
/**
* Incomplete test groups are listed here. These are checked using a left-
* anchored regex. Note that regex placeholder can't be used.
* Incomplete test groups are listed here. Any data set that starts with a
* string listed in this index will be skipped with the message given as
* value.
*
* @var array<string, string>
*/
private static array $incompleteTestGroups = [
// Many load balancer tests use CMAP events and/or assertNumberConnectionsCheckedOut
Expand All @@ -37,8 +39,14 @@
// mongoc_cluster_stream_for_server does not retry handshakes (CDRIVER-4532, PHPLIB-1033, PHPLIB-1042)
'retryable-reads/retryable reads handshake failures' => 'Handshakes are not retried (CDRIVER-4532)',
'retryable-writes/retryable writes handshake failures' => 'Handshakes are not retried (CDRIVER-4532)',
// sort option for update operations is not supported (PHPLIB-1492)
'crud/BulkWrite replaceOne-sort' => 'Sort for replace operations is not supported (PHPLIB-1492)',
'crud/BulkWrite updateOne-sort' => 'Sort for update operations is not supported (PHPLIB-1492)',
'crud/replaceOne-sort' => 'Sort for replace operations is not supported (PHPLIB-1492)',
'crud/updateOne-sort' => 'Sort for update operations is not supported (PHPLIB-1492)',
];

/** @var array<string, string> */
private static array $incompleteTests = [
// Many load balancer tests use CMAP events and/or assertNumberConnectionsCheckedOut
'load-balancers/monitoring events include correct fields: poolClearedEvent events include serviceId' => 'PHPC does not implement CMAP',
Expand All @@ -64,12 +72,17 @@
* Any tests with duplicate names are skipped here. While test names should
* not be reused in spec tests, this offers a way to skip such tests until
* the name is changed.
*
* @var array<string, string>
*/
private static array $duplicateTests = ['crud/client bulkWrite partial results: partialResult is set when first operation fails during an unordered bulk write (summary)'];
private static array $duplicateTests = [];

/**
* Any tests that rely on session pinning (including targetedFailPoint) must
* be skipped since libmongoc does not pin on load-balanced toplogies. */
* be skipped since libmongoc does not pin on load-balanced toplogies.
*
* @var array<string, string>
*/
private static array $incompleteLoadBalancerTests = [
'transactions/mongos-recovery-token: commitTransaction explicit retries include recoveryToken' => 'libmongoc omits recoveryToken for load-balanced topology (CDRIVER-4718)',
'transactions/pin-mongos: multiple commits' => 'libmongoc does not pin for load-balanced topology',
Expand Down Expand Up @@ -101,7 +114,7 @@
}

foreach (self::$incompleteTestGroups as $testGroup => $reason) {
if (preg_match(sprintf('#^%s#', $testGroup), $this->dataDescription())) {
if (str_starts_with($this->dataDescription(), $testGroup)) {
$this->markTestIncomplete($reason);
}
}
Expand Down Expand Up @@ -371,15 +384,13 @@
yield from self::provideTests('index-management/tests', 'index-management');
}

private static function provideTests(string $directory, ?string $group = null): Generator
private static function provideTests(string $directory, string $testGroup): Generator
{
$pattern = self::$testDir . '/' . $directory . '/*.json';

$duplicateTests = array_flip(self::$duplicateTests);

foreach (glob($pattern) as $filename) {
$testGroup = $group ?? dirname(basename($filename));

foreach (UnifiedTestCase::fromFile($filename) as $name => $test) {
$testKey = $testGroup . '/' . $name;

Expand Down
2 changes: 1 addition & 1 deletion tests/specifications
Submodule specifications updated 24 files
+2 −0 source/client-side-encryption/client-side-encryption.md
+106 −0 source/client-side-encryption/tests/README.md
+3 −0 source/client-side-operations-timeout/tests/README.md
+3 −2 source/command-logging-and-monitoring/tests/monitoring/unacknowledged-client-bulkWrite.json
+2 −1 source/command-logging-and-monitoring/tests/monitoring/unacknowledged-client-bulkWrite.yml
+89 −19 source/crud/bulk-write.md
+47 −1 source/crud/crud.md
+46 −2 source/crud/tests/README.md
+239 −0 source/crud/tests/unified/bulkWrite-replaceOne-sort.json
+94 −0 source/crud/tests/unified/bulkWrite-replaceOne-sort.yml
+255 −0 source/crud/tests/unified/bulkWrite-updateOne-sort.json
+94 −0 source/crud/tests/unified/bulkWrite-updateOne-sort.yml
+58 −0 source/crud/tests/unified/client-bulkWrite-errors.json
+29 −0 source/crud/tests/unified/client-bulkWrite-errors.yml
+1 −1 source/crud/tests/unified/client-bulkWrite-partialResults.json
+1 −1 source/crud/tests/unified/client-bulkWrite-partialResults.yml
+162 −0 source/crud/tests/unified/client-bulkWrite-replaceOne-sort.json
+76 −0 source/crud/tests/unified/client-bulkWrite-replaceOne-sort.yml
+166 −0 source/crud/tests/unified/client-bulkWrite-updateOne-sort.json
+76 −0 source/crud/tests/unified/client-bulkWrite-updateOne-sort.yml
+232 −0 source/crud/tests/unified/replaceOne-sort.json
+94 −0 source/crud/tests/unified/replaceOne-sort.yml
+240 −0 source/crud/tests/unified/updateOne-sort.json
+96 −0 source/crud/tests/unified/updateOne-sort.yml
Loading