Commit Graph

1191 Commits

Author SHA1 Message Date
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 9f854a43f7 PHPC-1681 Support parsing $uuid as extended JSON representation for subtype 4 binary (#1208)
* Update to latest version of libmongoc

* Support parse error tests for binary types

* Sync bson-corpus spec tests for binary
2021-03-26 10:04:18 +01:00
Andreas Braun ddfe1c3321 Fix running auth tests (#1206)
* Fix running auth tests

* Fix flaky tests on replica sets

* Remove arbiters from replica set config

This was done for auth due to a bug fixed in 3.7.7, but the change was not reverted (see https://github.com/mongodb-labs/drivers-evergreen-tools/pull/38).

* Harden test against non-deterministic return order
2021-03-25 10:25:42 +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 ed31cba5cb PHPC-1739 Move from travis-ci to GitHub Actions (#1199)
* Add GitHub Action workflow for tests

* Add workflow to check formatting

* Remove travis-ci config

* Fix clang-format error

* Add shared json extension for tests

* Hide output for xfail tests

* Use mongo-orchestration configs from drivers-evergreen-tools

* Drop obsolete test scripts

This drops the legacy VM environment and remnants of the travis-ci config

* Remove obsolete server_id config

* Add note about MONGO_ORCHESTRATION_URI to contribution docs

* Restore previous XFAIL behaviour

This did not have the expected effect of preventing diff output for tests that expect failures, so it can be reverted.

* Make SSL certificate path configurable for tests

Since mongo-orchestration will always bring its own certificates, we need to set the correct SSL certificate directory for our tests. This is skipped on GitHub Actions as we don't test SSL builds there (yet). If SSL_DIR was not set, tests requiring SSL will be skipped.

* Fix code review nits
2021-02-23 14:49:54 +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
Andreas Braun 9c51b70e60 Merge branch 'v1.9'
* v1.9:
  Fix build failures with clang 12 (#1193)
  PHPC-1748 Fix wrong return value of Cursor::key when iterator is not valid (#1192)
2021-01-26 07:55:36 +01:00
Andreas Braun 24eb9bc37a PHPC-1748 Fix wrong return value of Cursor::key when iterator is not valid (#1192)
* PHPC-1748 Fix wrong return value of Cursor::key when iterator is not valid

* Inline single-use iterator handlers
2021-01-25 12:44:03 +01:00
Andreas Braun 032af9a8ef PHPC-1529: Reset libmongocrypt key vault client after forking (#1189)
* PHPC-1529: Reset libmongocrypt key vault client after forking

* Run ping command instead of find

* Update wrong comment

* Only run tests when libmongocrypt is present

* Add mongocryptd.pid to gitignore

* Fix test failures due to missing mongocryptd
2021-01-20 19:30:39 +01:00
Andreas Braun 9da82d3425 Merge branch 'v1.9'
* v1.9:
  PHPC-1713: Ensure Cursor::current returns null on invalid positions (#1186)
2021-01-13 11:00:09 +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 70a097e5a1 PHPC-1713: Ensure Cursor::current returns null on invalid positions (#1186)
* Ensure Cursor::current returns null on invalid positions

* Addressed code review feedback
2020-12-22 14:37:19 +01: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 a0be179a70 PHPC-1691: Provide Iterator implementation for cursors 2020-10-29 19:38:14 +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 9fc51c842b PHPC-1698: fix prep_tagsets leak for ReadPreference::__set_state (#1167) 2020-10-12 12:52:19 +02:00
Jeremy Mikola ec3471a9bc Merge branch 'v1.8' 2020-09-16 12:01:13 -04:00
Jeremy Mikola 1d70e1a3f5 PHPC-1683: Collect WCE error labels in libmongoc bulk write replies
Also adds additional type and error checking to phongo_exception_append_error_labels.
2020-09-16 11:59:54 -04:00
Andreas Braun a42ece59cc PHPC-1167: Avoid dangling session pointer in bulk writes (#1156) 2020-07-31 14:13:51 +02:00
Jeremy Mikola b1b4122e85 Fix titles of Server session pinning tests 2020-07-29 16:44:07 -04: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 c81330c077 Remove trailing space in generated comments 2020-07-23 11:36:09 -04:00
Jeremy Mikola 96f97f8d43 PHPC-1653: Resync BSON corpus spec tests
Syncs tests with mongodb/specifications@1713439515. Includes tests for PHPC-1655 and PHPC-1652.

Adds logic to canonicalize $numberDouble values, which allows previously skipped tests to pass. This was noticed because SPEC-1537 changed the description of these tests and they were no loner skipped by convert-bson-corpus-tests.php.
2020-07-23 11:36:09 -04:00
Jeremy Mikola 2073946849 Bump libmongoc to 1.17.0-rc0
Test change to use session with command to ensure it is pooled
2020-07-15 11:59:44 -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 7fcf858878 Account for additional output during cleanup 2020-06-30 10:48:15 +02:00
Andreas Braun a520c00959 PHPC-1629: Check if write concern is valid during construction and unserialization 2020-05-29 14:47:24 +02:00
Andreas Braun a449493052 Fix error message for maxStaleness with primary read preference 2020-05-27 12:35:04 +02:00
Andreas Braun 5027842983 PHPC-1571: Support server hedged reads via read preference 2020-05-27 12:35:04 +02:00
Jeremy Mikola 354bcc9441 PHPC-1598: Fix get_gc handlers for classes with get_properties
The ReadConcern, ReadPreference, WriteConcern, and BSON classes have no properties beyond pointers to libmongoc/libbson structs; however, all of these classes use get_properties to report fields for var_export (PHPC-850, PHPC-460).

The standard get_gc handler defers to get_properties to collect other zvals for GC inspection. This is problematic for the aforementioned get_properties handlers, since a HashTable of zvals intended for debugging will be returned and those properties will already be freed by our free_object handler (via FREE_HASHTABLE).

Having each class define its own get_gc handler is the first step to fixing this issue. The BSON classes already defined their own get_gc handlers, but erroneously returned the internally cached properties directly.

The second step to fixing this issue is ensuring that get_gc delegates to zend_std_get_properties, as is done in various PHP core extensions. Doing so ensures that we do not leak other zvals that may be assigned as public properties by the application (covered by the second regression test), since zend_std_get_properties will return those for GC inspection.
2020-05-19 18:14:53 -04:00
Andreas Braun a039b7a77f Use getenv over $_ENV 2020-05-19 20:21:51 +02:00
Andreas Braun 5e750a86b2 PHPC-1533: Add first OCSP test 2020-05-19 20:21:51 +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
Andreas Braun 0fa7df90f4 Fix wrong exception when using external auth source 2020-04-29 12:55:53 +02:00
Andreas Braun cc5d7697b7 PHPC-1591: Add tests for allowed cases when authSource is given but username is not 2020-04-22 12:39:34 +02:00
Andreas Braun 36cf304f68 PHPC-1561: Allow hinting for delete 2020-03-30 17:36:33 +02:00
Andreas Braun 6217d4879c Fix update spec test for server-side error 2020-03-30 17:36:33 +02:00
Andreas Braun 6d5263ce4d Fix tests for new tls option incompatibilities 2020-03-30 17:36:33 +02:00
Andreas Braun 9618edff2a PHPC-1060: Run Atlas connectivity tests on Evergreen 2020-03-25 13:19:33 +01:00
Andreas Braun bf7b7f6cec PHPC-1525: Deprecate oplogReplay query option 2020-03-24 12:34:25 +01:00
Andreas Braun 895fcf4bbc PHPC-1494: Add driver option to pass additional handshake data 2020-03-20 14:26:38 +01:00