Commit Graph

258 Commits

Author SHA1 Message Date
Andreas Braun
43b5499e01 PHPC-2156: Work around crypt_shared log output (#1403) 2023-02-02 10:41:13 +01:00
Jeremy Mikola
542d1d3007 Cross-reference prose tests in session test descriptions (#1393)
* Remove redundant params in create_test_manager() calls

* Use disableClientPersistence in session test requiring different clients
2022-12-22 03:21:45 -05:00
Andreas Braun
5f3503c01c PHPC-2165: Expose server error replies in BulkWriteResult (#1385) 2022-12-06 08:18:16 +01:00
Jeremy Mikola
6a7a2ba546 Bump to libmongoc to 1.24-dev (#1388)
* Update expected output for libmongoc 1.24-dev

See mongodb/mongo-c-driver@40a64c2ffd

* Require C99 when compiling
2022-11-30 03:06:12 -05:00
Jeremy Mikola
51f0dd5399 PHPC-2143: Build Windows DLLs with GitHub Actions (#1380)
* Fix APM and CSFLE tests for Windows CI

* Add Windows to GitHub CI and build DLLs for releases

* Add --enable-debug-pack configure opt to generate PDB files

* Reminder to check for Windows build artifacts before publishing releases

* Revise advice on publicizing releases
2022-11-21 10:09:46 -05:00
Jeremy Mikola
dadb93fb34 Merge branch 'v1.14'
v1.14 pointed to libmongoc 1.14.2, which was released some time after the submodule target in the master branch (a dev commit before libmongoc 1.23.0). To resolve this conflict, the libmongoc submodule has been bumped to 1.23.0.

Note: a libmongoc 1.23.1 tag also exists, but that bump can be done in a subsequent PHPC ticket related to the libmongoc changes therein.

This also adds a section to CONTRIBUTING.md to provide guidance on resolving submodule merge conflicts.
2022-10-20 21:44:20 +08:00
Jeremy Mikola
0a23d0a94b PHPC-2157: Upgrade libmongoc to 1.22.2 (#1374) 2022-10-20 13:21:56 +02:00
Andreas Braun
4fd0fa96a6 PHPC-2141: Emit deprecation notice for WriteResult getters with unacknowledged writes (#1367) 2022-10-05 16:15:38 +02:00
Jeremy Mikola
f0421fa1fe PHPC-2103: Report loaded crypt_shared version in phpinfo() (#1351)
* Match error message variations between libmongoc 1.23+ and older

This typo was corrected in mongodb/mongo-c-driver@1d7229f0e9 and will appear in the 1.23.0 release.

* PHPC-2103: Report loaded crypt_shared version in phpinfo()

* PHPC-2132: Fix pattern for matching phpinfo() values
2022-09-14 17:28:13 -04:00
Andreas Braun
6887226d34 PHPC-1709: Add typing information to arginfo (#1337)
* Add missing macros for declaring arguments

* Add macros to define disabled constructor and __wakeup

* Define arginfo via stubs for BSON classes

* Declare tentative return types in interfaces

* Add correct return type for __set_state methods

* Generate class entries for BSON classes

* Declare Binary class constants in stub file

* Use stubs in exception classes

* Add stubs for monitoring classes

* Fix wrong JsonSerializable class in BSON stubs

* Disable declaration-after-statement

This is necessary to let the generated arginfo files compile

* Use stubs for driver classes

* Fix deprecation messages in tests

* Add missing macro

* Fix tests relying on value injection

* Parse parameters in disabled constructor/wakup function

* Add note about arginfo files to contribution docs

* Add GitHub action to check generated arginfo files

* PHPC-2115: Use DateTimeInterface in UTCDateTime constructor signature

* Don't install mongodb extension in GitHub actions workflows

* Change indentation in stub files

* Use individual #if conditions for each stub method

* Make disabled constructor/wakeup methods static

* Fix bulkWrite parameter name

* Use %d to match property count in tests

* Ensure all classes with disabled serialisation declare __wakeup
2022-08-03 08:42:07 +02:00
Jeremy Mikola
03fcb6b9ef PHPC-2099: crypt_shared testing (#1333)
* Use non-breaking space in OS axis labels

* Revise titles and Manager construction in autoEncryption tests

* Define CSFLE_KEY_VAULT_NS and CSFLE_LOCAL_KEY constants

The value for CSFLE_KEY_VAULT_NS is based on the example from PHPLIB-826. This was not required but helps makes all tests consistent and will make it easier if we need to add functionality to a helper to drop the key vault collection before a test.

Using CSFLE_LOCAL_KEY allows removal of a duplicated string literal in various CSFLE tests. Although the new constant wasn't required for all tests (empty strings worked fine to satisfy option validation), using a constant helps ensure consistency across the test suite.

Also use create_test_manager() in more places when basic.inc is included. The remaining instances of direct Manager construction should only be in tests where basic.inc isn't used.
2022-06-22 13:37:56 -04:00
Jeremy Mikola
6b8f5c20a6 PHPC-2097: Enable ClientEncryption constructor 2022-05-31 18:59:22 -04:00
Jeremy Mikola
2063c2099f Revise error messages for autoEncryption and ClientEncryption options 2022-05-31 18:59:22 -04:00
Jeremy Mikola
66fc49354d PHPC-2096: Implement Manager::getEncryptedFieldsMap()
PHPLIB will need to access the encryptedFieldsMap autoEncryption option.
2022-05-31 18:59:22 -04:00
Jeremy Mikola
52f014bc8f PHPC-2085: autoEncryption options for queryable encryption 2022-05-31 18:59:22 -04:00
Jeremy Mikola
93efe0aeb6 PHPC-2073: Remove references to pre-3.6 servers (#1305)
* Remove pre-3.6 server versions from Evergreen matrix

* Remove skipped tests for pre-3.6 servers

* Remove old mongo-orchestration configs and Evergreen tasks

* Remove flaky replica set tests

These tests assume a particular replica set member is always the primary, so tag assertions may fail if a different member is elected. The server-getTags-002.phpt test has more flexible assertions for replica set tags, so we can safely remove these tests.
2022-03-01 20:30:00 -05:00
Jeremy Mikola
2db00e0e24 PHPC-2064: Call skip_if_not_clean after other skip functions
"nocache" output from skip_if_not_clean may cause "skip" output from other functions to be ignored. Changing the order so that skip_if_not_clean is always called last will fix this in most cases (excluding tests that call skip_if_not_clean multiple times).
2022-02-10 13:20:52 -05:00
Jeremy Mikola
f681a0bd2f PHPC-2047: Update load balancer testing config (#1300)
* PHPC-2047: 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.

* Add missing live server checks in tests
2022-02-03 14:49:19 -05:00
Jeremy Mikola
31dcb61f91 PHPC-1950: Update authMechanism URI option tests
Now that URI option validation is consistent between connection strings and array options, we can remove the previous test for authSource without credentials.
2022-01-05 13:10:45 -05:00
Jeremy Mikola
f74a60982a PHPC-1900: Test srvServiceName URI option 2022-01-05 13:10:45 -05:00
Jeremy Mikola
963d720237 PHPC-1908: Test srvMaxHosts URI option 2022-01-05 13:10:45 -05:00
Jeremy Mikola
c67ed67e49 PHPC-2020: Test loadBalanced URI option validation 2022-01-05 13:10:45 -05:00
Jeremy Mikola
ab44b0cbeb PHPC-1647: Use mongoc_client_new_from_uri_with_error
This allows PHPC to defer entirely to libmongoc for cross-option URI validation

Bump libmongoc to 1.21-dev

Build changes are ported from upstream CMake changes (see: CDRIVER-4249)
2022-01-05 13:10:45 -05:00
Jeremy Mikola
da0f73a677 PHPC-1912: CSFLE 1.0 KMIP Support (#1280)
* PHPC-2009: Support tlsOptions encryption option

This also adds some missing option validation tests for the autoEncryption driver option and Manager::createClientEncryption().

* PHPC-2010: Type validation for autoEncryption.extraOptions
2021-12-13 20:10:07 -05:00
Jeremy Mikola
0e45605fa2 PHPC-1937: Manager::selectServer() defaults to primary read preference (#1267)
* Use .invalid TLD for invalid host in tests

See: https://datatracker.ietf.org/doc/html/rfc2606

* PHPC-1937: Manager::selectServer() defaults to primary read preference
2021-10-26 13:07:21 -04:00
Jeremy Mikola
ae74c7a1cd PHPC-1752: Fix tests for load balanced topologies
Skip tests expecting gossiped $clusterTime on first command. This may be a bug in libmongoc, per CDRIVER-4174.

Make exception assertion in TLS tests more flexible. Expect parent ConnectionException to accomodate load balanced clients, which do not use server selection. Both exception messages will include a common prefix from libmongoc.

Do not assert exception message for failed TLS connection. While the message will typically include "TLS handshake failed", that is not guaranteed.

Make ping response assertions in TLS tests more flexible. Sharded clusters and replica sets may return additional fields in the ping response (e.g. cluster time). These tests were originally written to expect a standalone response.

Allow unset RTT (-1) for load balanced client.

Note SRV caveat for is_replica_set test function.

Allow load balancers for tests that require sharded clusters. Load balancers should always proxy a mongos, so existing skip functions that check for mongos can now allow a load balancer. If there is some incompatibility specific to LBs, we can address that later with a LB-specific skip function.

Require mongos for pinning tests. Pinning does not apply to load balanced clients, since there is only one connection.
2021-10-15 13:44:32 -04:00
Andreas Braun
b27fa4d019 PHPC-1965 Re-enable PHP 8.1 build on GH Actions (#1258)
* Re-enable PHP 8.1 build on GH Actions

* Work around different error wording in PHP 8.1

* Limit failing tests to PHP < 8.1

* Add tests for PHPC-1839 for PHP >= 8.1
2021-09-07 08:18:08 +02:00
Jeremy Mikola
88dcfcea50 PHPC-1538: authSource in URI string no longer requires credentials (#1248)
Bump libmongoc 1.19.0 to pull in changes from CDRIVER-3502.

Unfortunately, the restriction is still in place for authSource in the URI options array (pending PHPC-1950).
2021-08-16 18:10:25 -04:00
Jeremy Mikola
ac4935338a PHPC-1761: Snapshot Reads (#1243)
* Bump libmongoc to 1.19-dev

* PHPC-1890: Constant for ReadConcern snapshot level

* Move Manager::startSession() error test and delete obsolete test

The deleted error test was redundant. It was originally created in ca4c52eb1c to work around changes in PHP 8, but 60febd0f28 subsequently reintroduced a portable version of the test case.

Also adds missing SKIPIF to startSession test.

* PHPC-1889: Session snapshot option

* PHPC-1875: Session with snapshot=true cannot perform writes

* PHPC-1876: Session with snapshot=true requires MongoDB 5.0+
2021-08-04 19:11:33 -04:00
Jeremy Mikola
8c0722224a PHPC-1762: CRUD spec prose tests for WriteError and WriteConcernError.errInfo (#1229)
* PHPC-1762: CRUD spec prose tests for WriteError and WriteConcernError errInfo

Note: the prose test for WriteConcernError.info was originally in PHPLIB but was inadvertently removed in mongodb/mongo-php-library@a9e29770ea (mongodb/mongo-php-library#820).

* Require 5.0+ server for versioned API test

* Add links to prose tests
2021-06-24 10:23:28 -04:00
Andreas Braun
a612c370f6 PHPC-1756: Remove oppressive terminology from source code (#1221)
* Use latest version of libmongoc

* Remove deprecated terminology for primary

* Remove deprecated terminology for secondary

* Fix clang-format

* Remove check for legacy field

* Fix missing space in error expectation

* Harden test expectation around primary checks
2021-06-22 19:30:56 +02:00
Andreas Braun
135fe453bb PHPC-1848: Add 5.0 to the server testing matrix (#1222)
* Add 5.0 to the test matrix

* Use different query operator to trigger error

5.0 throws a different error for top-level fields with dollars, so we're using an unknown operator instead.

* Introduce edge-versions axis to test against latest stable
2021-05-27 10:33:42 +02:00
Jeremy Mikola
324182a8e6 PHPC-1804: Manager::addSubscriber and removeSubscriber (#1213)
* Use zend_exception_ce instead of zend_exception_get_default()

zend_exception_get_default() has been deprecated since PHP 7.0. See: php/php-src@f9e9d3a437

* Check retval from php_phongo_set_monitoring_callbacks

This ensures that php_phongo_client_register is never called in the event this method fails (however unlikely).

* Index subscriber HashTable by numeric object handles

This also updates add/removeSubscriber to use the new argument parsing macros from deead9687e.

* PHPC-1804: Manager::addSubscriber and removeSubscriber

Implements per-client event subscribers. Moves existing APM code to a new phongo_apm.c module and adds logic to coordinate dispatching between global and per-client subscribers.
2021-04-09 08:55:44 -04:00
Andreas Braun
deead9687e PHPC-1716 Allow configuring server API version in manager (#1204)
* Introduce MongoDB\Driver\ServerApi

* Accept serverApi driver option

* Introduce create_test_manager factory to create manager

A centralised entry point is required to inject the API_VERSION env variable later.

* Add build variant to test with requireApiVersion=true

* Fix wrong configuration for auth variable

This changed when migrating from our own scripts to drivers-evergreen-tools and was not updated properly, causing all tests to run with auth disabled.

* Declare ZEND_PARSE_PARAMETERS_NONE macro

This macro is missing on PHP < 7.3

* Remove duplicated API param storage

* Add missing semicolons

* Add ZEND_PARSE_PARAMETERS_NON_EX macro

* Extract error handling functionality to separate macros

* Throw if internal mongoc_server_api_t is already initialised

* Use imported namespaces in tools file

* Fix type info for reflection

* Use American English spelling

* Only use typed serialize signature on PHP 8+

* Update PHONGO_PARSE_PARAMETERS_NONE macro for PHP < 7.3

* Remove usage of ZEND_STRL within zend_hash_str_add

This causes compile failures on PHP < 7.3 that I have yet to understand.

* Fix errors in new PHONGO_PARSE_PARAMETERS macros
2021-03-26 15:43:48 +01:00
Andreas Braun
37408e1ccf Merge branch 'v1.9'
* v1.9:
  PHPC-1739 Move from travis-ci to GitHub Actions (#1199)
  PHPC-1774 Fix truncation of PHP_VERSION constant in handshake metadata (#1202)
  PHPC-1775 Use correct size for strncpy in when initialising DBPointer (#1203)
2021-02-23 14:52:15 +01:00
Andreas Braun
ef28066d84 PHPC-1774 Fix truncation of PHP_VERSION constant in handshake metadata (#1202)
* PHPC-1774 Fix truncation of PHP_VERSION constant in handshake metadata

* Work around libmongoc issue that concatenates platform without whitespace
2021-02-23 13:50:26 +01:00
Jeremy Mikola
5e2f7b5461 PHPC-1645: Allow disabling of libmongoc client persistence (#1187)
* Replace client pointers on object structs with Manager references

* Request-scoped Manager registry for APM events

* Ensure Manager is registered regardless of persistent client

* Reset request-scoped clients when forking

* Test for freeing Manager during RSHUTDOWN via subscriber reference

Co-authored-by: Andreas Braun <git@alcaeus.org>
2021-01-12 08:27:32 -05:00
Andreas Braun
d70efb6ea6 PHPC-1700: Fix memory leak when read preference is invalid (#1179)
* PHPC-1700: Fix memory leak in prep_tagsets

* PHPC-1701: Add regression test for memory leak in prep_authmechanisms
2020-11-25 10:39:38 +01:00
Andreas Braun
60febd0f28 PHPC-1699: Ensure all argument parsing errors throw InvalidArgumentException (#1173)
Co-authored-by: Jeremy Mikola <jmikola@gmail.com>
2020-10-28 08:20:32 +01:00
Jeremy Mikola
ca4c52eb1c PHPC-1692: Test suite fixes for PHP 8 2020-10-13 15:24:02 +02:00
Jeremy Mikola
5ec48480db Use aggregate with $out in executeReadWriteCommand tests
MongoDB 4.0.x (and possibly earlier) happens to require an $out stage for aggregate if a writeConcern option would be used. While this test doesn't use a write concern, it could inherit one from MONGODB_URI.

As for findAndModify, that is only considered a write command (does not accept a readConcern option).
2020-07-29 16:44:07 -04:00
Jeremy Mikola
b8bd32f8f3 Use executeCommand for create in txn pinning tests
The previous inconsistency was likely the result of copypasta (especially where executeReadCommand was used). There is no issue with using executeCommand here since an explicit write concern is provided (nothing will be inherited).
2020-07-29 16:44:07 -04:00
Jeremy Mikola
bc73a1c50b PHPC-169: Test read and write concern inheritance 2020-07-29 16:44:07 -04:00
Jeremy Mikola
36d3e70982 PHPC-1648: Validate directConnection in URI options array 2020-07-08 13:55:30 -04:00
Andreas Braun
d1883adca5 Merge branch 'v1.7' into v1.8
* v1.7:
  PHPC-1639: Manager::executeCommand should not inherit read preference
2020-07-02 10:20:17 +02:00
Andreas Braun
b0ba3afda9 PHPC-1639: Manager::executeCommand should not inherit read preference 2020-07-02 09:18:35 +02:00
Andreas Braun
2d59e0e0d8 PHPC-1533: Consolidate URI option tests 2020-05-19 20:21:51 +02:00
Andreas Braun
607b91cefd PHPC-1533: Handle OCSP URI options 2020-05-19 20:21:50 +02:00
Jeremy Mikola
2e8fa8b7f3 PHPC-1554: Tests for directConnection URI option 2020-05-13 14:10:49 -04:00
Jeremy Mikola
9ae06e236e Skip known/expected test failures in AppVeyor 2020-05-11 17:43:08 -04:00