Commit Graph

72 Commits

Author SHA1 Message Date
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
6ffcb1f1dd PHPC-2117: Test on PHP 8.2 (#1340)
* Test on PHP 8.2

* Fix tests relating to dynamic properties

* Fix tests failing due to different __set_state output

* Duplicate clone test without dynamic properties for PHP >= 8.2
2022-08-04 08:53:25 +02: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
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
4e69ea49f8 PHPC-2032: Concise debug output for ended sessions (#1295) 2022-01-20 11:26:09 -05:00
Jeremy Mikola
83521ad9f7 PHPC-2003: Implement Session::isDirty() (#1293) 2022-01-18 10:58:00 -05:00
Jeremy Mikola
a039df758b PHPC-2004: Use tentative return types for BSON interface toString methods (#1283)
This should avoid the BC break introduced in 6c82ec8b52. PHP 8.1 will automatically add return type info for Stringable, which means the ReturnTypeWillChange attribute should not be necessary on userland classes.
2021-12-14 11:12:36 -05:00
Jeremy Mikola
6c82ec8b52 PHPC-2004 and PHPC-2007: Specify __toString() return type and implement Stringable (#1274)
* PHPC-2004: Specify string return type in __toString() arginfos

Adding return type info to the interface methods is a small subtle BC break. Userland classes will also need to add return type info prior to PHP 8.1, where it is added automatically. However, to leave the interface methods untyped would invite an error because BSON classes cannot otherwise conform to Stringable, which has return type info.

Additionally, PHP 8.2 will start raising a warning when return type info is automatically applied, so a BC break in some form is inevitable.

* PHPC-2007: Explicitly implement Stringable for PHP 8+

* Fix code formatting

This was missed in fe99deb32a
2021-11-29 13:14:10 -05: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
Jeremy Mikola
e32f59bad8 PHPC-1875: Skip snapshot error test on sharded clusters (#1262)
skip_if_not_replica_set will be more portable once we start testing on load balancers, which will back sharded clusters.
2021-10-01 16:03:38 -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
Tanli Su
9890e619f4 PHPC-1474: Expose transaction information in debug info for session 2021-07-02 15:50:41 -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
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
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
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
Andreas Braun
57a9036782 PHPC-1442: Remove SKIPIF checks for PHP 5 2020-02-11 14:06:10 +01:00
Jeremy Mikola
d4f8583da2 Remove unused variable 2020-02-03 13:13:48 +01:00
Jeremy Mikola
1260d114bc PHPC-1274: Reset client after forking for executeBulkWrite 2020-02-03 13:13:48 +01:00
Jeremy Mikola
1c203bbc6e PHPC-1526 Exclude sharded RS env in session forking test 2020-01-21 16:50:09 -05:00
Jeremy Mikola
9ecb50a7e6 PHPC-1274: Reset client after forking for Cursor and Session
Check PID before creating/freeing a session or cursor to avoid interfering with resources owned by a parent process. Additionally, prohibit resetting a client multiple times to avoid cases where child resources may not be cleaned up.
2020-01-10 17:28:48 -05:00
Andreas Braun
c15d1315ba PHPC-1438: Expose session state 2019-12-06 11:36:35 +01:00
Andreas Braun
fef008ed20 PHPC-1439: Skip transaction tests on sharded clusters < 4.2 2019-11-06 14:16:08 +01:00
Andreas Braun
09f83fa251 PHPC-1439: Expose transaction options on session object 2019-11-05 07:37:23 +01:00
Andreas Braun
e0cc7e6798 PHPC-1391: Prohibit starting a transaction for maxWireVersion < 7
The exeption itself is caused by libmongoc not allowing transactions. This commit only adds tests to protect against regressions
2019-10-17 13:05:01 -04:00
Andreas Braun
cbca0685ca PHPC-1435: Assert against correct error message depending on PHP version 2019-09-02 16:19:33 +02:00
Andreas Braun
b0414d55c6 PHPC-1290: Improve checks for transaction support 2019-09-02 16:19:33 +02:00
Andreas Braun
d5e077928d PHPC-1435: Fix test checking invalid argument values 2019-08-29 10:44:57 -04:00
Andreas Braun
d750c7013c PHPC-1290: Run relevant tests on sharded clusters 2019-08-29 07:26:43 +02:00
Andreas Braun
969b0f827e PHPC-1290: Expose pinned server on session object 2019-08-28 20:10:46 +02:00
Andreas Braun
d03f36227e PHPC-1290: Adapt server selection logic to respect session pinning 2019-08-28 20:10:46 +02:00
Andreas Braun
804f383aea PHPC-1382: Allow applications to set maxTimeMS for commitTransaction 2019-08-21 19:30:29 +02:00
Jeremy Mikola
6481582b52 PHPC-1319: commitTransaction applies w:majority when retrying 2019-07-30 11:39:05 +08:00
Jeremy Mikola
66ab6c3ceb Merge branch 'v1.5' 2019-06-03 11:32:18 -04:00
Jeremy Mikola
ce2e43ea31 PHPC-1359: Prohibit startTransaction() on sharded clusters
In versions of the driver that do not support mongos pinning, we should prohibit starting a transaction on a sharded cluster (even if the server version might actually support transactions).
2019-06-03 10:30:43 -04:00
Jeremy Mikola
2104d6dff3 PHPC-1345: Revise fragile session ID assertion 2019-05-03 14:01:37 -04:00
Derick Rethans
87096da964 PHPC-1263: Update tests for PHP 7.3's output changes 2018-10-09 14:16:58 +01:00
Derick Rethans
0ec480fd65 Merge branch 'v1.5' 2018-08-30 11:49:22 +01:00
Derick Rethans
9778b84da7 PHPC-1263: Fix tests for PHP 7.3 output changes 2018-08-30 11:49:01 +01:00
Derick Rethans
f9c1d89d4f Merge branch 'v1.5' 2018-07-31 17:02:56 +01:00
Derick Rethans
9ade9abe9b PHPC-1227: Add more tests for disallowed per-op read/write concerns in transactions 2018-07-31 17:00:30 +01:00
Derick Rethans
d1ae6aeb34 Merge branch 'v1.5' 2018-07-30 10:37:45 +01:00
Derick Rethans
28449395e0 PHPC-1227: Add test for disallowed per-op read/write concerns in transactions 2018-07-27 17:53:22 +01:00
Derick Rethans
589590e67e Merge branch 'v1.5' 2018-07-24 09:52:57 +01:00
Derick Rethans
f10d16fad1 PHPC-1244: Use majority WC to drop/create collections for transaction tests 2018-07-23 17:49:45 +01:00
Jeremy Mikola
2c0e7299c8 Clean up SKIPIFs for additional session tests 2018-07-23 10:27:24 -04:00
Jeremy Mikola
0ad377c584 Merge branch 'v1.5' 2018-07-20 16:29:10 -04:00
Jeremy Mikola
4d15c14cae Clean up SKIPIFs for session tests 2018-07-20 12:00:51 -04:00
Derick Rethans
7212d65b16 Merge branch 'v1.5' 2018-07-20 16:40:02 +01:00