Skip to content

Commit

Permalink
Add Drupal 7 integration (#35)
Browse files Browse the repository at this point in the history
* Integration for drupal 7

(currently only manually tested)

* Add drupal 7 files

* Tests to cover drupal 7 integration

* Trace drupal error handler

* Lint

* Fix tag class casing

* Skip test ext/sockets/tests/socket_create_listen-nobind.phpt on PHP 5.4..7.3 (#1275)

* Disabled on versions: `5.4 --> 7.3`.
* [Broken CI build example](https://app.circleci.com/pipelines/github/DataDog/dd-trace-php/6016/workflows/dd24ea85-1ec4-47ea-9311-080a66d045a5/jobs/497177)

This test runs succesfully only if a socket CANNOT be created on port 80 in the environment where the test is executed. With recent changes to CircleCI is now possible to create a socket on port 80. As a proof of it, ssh-ing into a CircleCI runner:

```
$ TEST_PHP_EXECUTABLE=$(which php) php run-tests.php --show-out --show-diff ext/sockets/tests/socket_create_listen-nobind.phpt
...
001+ resource(4) of type (Socket)   <<<< dumping the returned socket [here](https://github.com/php/php-src/blob/53ea910d1760c87b6110a461f13ebe0e244c9914/ext/sockets/tests/socket_create_listen-nobind.phpt#L17), it is supposed to return `false` instead.
...
```

The reason why this test is not failing on PHP 7.4+ if because it is skipped by this [extra check](https://github.com/php/php-src/blob/9db3eda2cbaa01529d807b2326be13e7b0e5e496/ext/sockets/tests/socket_create_listen-nobind.phpt#L16-L18).

As a confirmation, running the previous test on a 7.4 runner would result in:

```
$ TEST_PHP_EXECUTABLE=$(which php) php run-tests.php --show-out --show-diff ext/sockets/tests/socket_create_listen-nobind.phpt
...
SKIP Test if socket_create_listen() returns false, when it cannot bind to the port. [ext/sockets/tests/socket_create_listen-nobind.phpt] reason: Test cannot be run in environment that will allow binding to port 80 (azure)
...
```

* Sync xfail_tests for 7.4 & 8.0 with upstream

* Add to drupal traced functions

drupal_cron_run, drupal_http_request, module_invoke, module_invoke_all

Co-authored-by: Luca Abbati <[email protected]>
  • Loading branch information
t2t2 and labbati authored Aug 4, 2021
1 parent 75e2186 commit 8f5a6f3
Show file tree
Hide file tree
Showing 1,171 changed files with 339,308 additions and 36 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file - [read more

## [Unreleased]
### Added
- Drupal 8 and 9 support.
- Drupal 7, 8 and 9 support.

## [0.30.1-beta-sfx4]

Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,8 @@ test_web_wordpress_48:
$(call run_tests,tests/Integrations/WordPress/V4_8)
test_web_wordpress_55:
$(call run_tests,tests/Integrations/WordPress/V5_5)
test_web_drupal_7:
$(call run_tests,tests/Integrations/Drupal/V7)
test_web_drupal_89:
$(COMPOSER) --working-dir=tests/Frameworks/Drupal/Version_8_9 update
$(call run_tests,tests/Integrations/Drupal/V8_9)
Expand Down
1 change: 1 addition & 0 deletions dockerfiles/ci/xfail_tests/5.4.list
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ ext/simplexml/tests/SimpleXMLElement_addAttribute_basic.phpt
ext/simplexml/tests/bug66084_0.phpt
ext/simplexml/tests/simplexml_load_file.phpt
ext/sockets/tests/socket_connect_params.phpt
ext/sockets/tests/socket_create_listen-nobind.phpt
ext/sockets/tests/socket_create_pair.phpt
ext/spl/tests/SplDoublylinkedlist_offsetunset_first.phpt
ext/spl/tests/SplDoublylinkedlist_offsetunset_last.phpt
Expand Down
1 change: 1 addition & 0 deletions dockerfiles/ci/xfail_tests/5.5.list
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ ext/simplexml/tests/bug66084_0.phpt
ext/simplexml/tests/bug69491.phpt
ext/simplexml/tests/simplexml_load_file.phpt
ext/sockets/tests/socket_connect_params.phpt
ext/sockets/tests/socket_create_listen-nobind.phpt
ext/sockets/tests/socket_create_pair.phpt
ext/spl/tests/SplDoublylinkedlist_offsetunset_first.phpt
ext/spl/tests/SplDoublylinkedlist_offsetunset_last.phpt
Expand Down
1 change: 1 addition & 0 deletions dockerfiles/ci/xfail_tests/5.6.list
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ ext/simplexml/tests/bug66084_0.phpt
ext/simplexml/tests/bug69491.phpt
ext/simplexml/tests/simplexml_load_file.phpt
ext/sockets/tests/socket_connect_params.phpt
ext/sockets/tests/socket_create_listen-nobind.phpt
ext/sockets/tests/socket_create_pair.phpt
ext/spl/tests/SplDoublylinkedlist_offsetunset_first.phpt
ext/spl/tests/SplDoublylinkedlist_offsetunset_last.phpt
Expand Down
1 change: 1 addition & 0 deletions dockerfiles/ci/xfail_tests/7.0.list
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ ext/simplexml/tests/bug72971.phpt
ext/simplexml/tests/bug72971_2.phpt
ext/simplexml/tests/simplexml_load_file.phpt
ext/sockets/tests/socket_connect_params.phpt
ext/sockets/tests/socket_create_listen-nobind.phpt
ext/sockets/tests/socket_create_pair.phpt
ext/spl/tests/ArrayObject_clone_other_std_props.phpt
ext/spl/tests/ArrayObject_dump_during_sort.phpt
Expand Down
1 change: 1 addition & 0 deletions dockerfiles/ci/xfail_tests/7.1.list
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ ext/simplexml/tests/bug72971.phpt
ext/simplexml/tests/bug72971_2.phpt
ext/simplexml/tests/simplexml_load_file.phpt
ext/sockets/tests/socket_connect_params.phpt
ext/sockets/tests/socket_create_listen-nobind.phpt
ext/sockets/tests/socket_create_pair.phpt
ext/spl/tests/ArrayObject_clone_other_std_props.phpt
ext/spl/tests/ArrayObject_dump_during_sort.phpt
Expand Down
1 change: 1 addition & 0 deletions dockerfiles/ci/xfail_tests/7.2.list
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ ext/simplexml/tests/bug72971.phpt
ext/simplexml/tests/bug72971_2.phpt
ext/simplexml/tests/simplexml_load_file.phpt
ext/sockets/tests/socket_connect_params.phpt
ext/sockets/tests/socket_create_listen-nobind.phpt
ext/sockets/tests/socket_create_pair.phpt
ext/sodium/tests/utils.phpt
ext/spl/tests/ArrayObject_clone_other_std_props.phpt
Expand Down
1 change: 1 addition & 0 deletions dockerfiles/ci/xfail_tests/7.3.list
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ ext/simplexml/tests/bug72971.phpt
ext/simplexml/tests/bug72971_2.phpt
ext/simplexml/tests/simplexml_load_file.phpt
ext/sockets/tests/socket_connect_params.phpt
ext/sockets/tests/socket_create_listen-nobind.phpt
ext/sockets/tests/socket_create_pair.phpt
ext/sodium/tests/utils.phpt
ext/spl/tests/ArrayObject_clone_other_std_props.phpt
Expand Down
5 changes: 5 additions & 0 deletions dockerfiles/ci/xfail_tests/7.4.list
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Zend/tests/bug79778.phpt
Zend/tests/bug79862.phpt
Zend/tests/bug80037.phpt
Zend/tests/bug80194.phpt
Zend/tests/bug81104.phpt
Zend/tests/class_alias_020.phpt
Zend/tests/class_name_as_scalar.phpt
Zend/tests/closure_058.phpt
Expand All @@ -80,6 +81,7 @@ Zend/tests/list_keyed_conversions.phpt
Zend/tests/modify_isref_value_return.phpt
Zend/tests/multibyte/multibyte_encoding_004.phpt
Zend/tests/object_array_cast.phpt
Zend/tests/object_gc_in_shutdown.phpt
Zend/tests/objects_019.phpt
Zend/tests/objects_032.phpt
Zend/tests/offset_array.phpt
Expand Down Expand Up @@ -203,6 +205,8 @@ ext/openssl/tests/tlsv1.0_wrapper.phpt
ext/openssl/tests/tlsv1.1_wrapper.phpt
ext/openssl/tests/tlsv1.2_wrapper.phpt
ext/openssl/tests/tlsv1.3_wrapper.phpt
ext/pcntl/tests/pcntl_unshare_01.phpt
ext/pcntl/tests/pcntl_unshare_03.phpt
ext/pdo_sqlite/tests/pdo_sqlite_lastinsertid.phpt
ext/phar/tests/031.phpt
ext/phar/tests/032.phpt
Expand Down Expand Up @@ -385,6 +389,7 @@ ext/standard/tests/serialize/serialize_globals_var_refs.phpt
ext/standard/tests/serialize/sleep_uninitialized_typed_prop.phpt
ext/standard/tests/serialize/typed_property_refs.phpt
ext/standard/tests/streams/bug78902.phpt
ext/standard/tests/streams/proc_open_bug69900.phpt
ext/standard/tests/streams/stream_context_tcp_nodelay_fopen.phpt
ext/standard/tests/strings/implode1.phpt
ext/zip/tests/bug38943.phpt
Expand Down
7 changes: 7 additions & 0 deletions dockerfiles/ci/xfail_tests/8.0.list
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ Zend/tests/bug79778.phpt
Zend/tests/bug79862.phpt
Zend/tests/bug80037.phpt
Zend/tests/bug80194.phpt
Zend/tests/bug81076.phpt
Zend/tests/bug81104.phpt
Zend/tests/class_alias_020.phpt
Zend/tests/class_name_as_scalar.phpt
Zend/tests/closure_058.phpt
Expand Down Expand Up @@ -96,6 +98,7 @@ Zend/tests/multibyte/multibyte_encoding_004.phpt
Zend/tests/named_params/attributes.phpt
Zend/tests/nullsafe_operator/019.phpt
Zend/tests/object_array_cast.phpt
Zend/tests/object_gc_in_shutdown.phpt
Zend/tests/objects_019.phpt
Zend/tests/objects_032.phpt
Zend/tests/offset_array.phpt
Expand Down Expand Up @@ -245,6 +248,9 @@ ext/openssl/tests/tlsv1.0_wrapper.phpt
ext/openssl/tests/tlsv1.1_wrapper.phpt
ext/openssl/tests/tlsv1.2_wrapper.phpt
ext/openssl/tests/tlsv1.3_wrapper.phpt
ext/pcntl/tests/pcntl_unshare_01.phpt
ext/pcntl/tests/pcntl_unshare_02.phpt
ext/pcntl/tests/pcntl_unshare_03.phpt
ext/pdo_sqlite/tests/pdo_sqlite_lastinsertid.phpt
ext/phar/tests/031.phpt
ext/phar/tests/032.phpt
Expand Down Expand Up @@ -446,6 +452,7 @@ ext/standard/tests/serialize/typed_property_refs.phpt
ext/standard/tests/serialize/typed_property_ref_overwrite.phpt
ext/standard/tests/serialize/typed_property_ref_overwrite2.phpt
ext/standard/tests/streams/bug78902.phpt
ext/standard/tests/streams/proc_open_bug69900.phpt
ext/standard/tests/streams/stream_context_tcp_nodelay_fopen.phpt
ext/standard/tests/strings/implode1.phpt
ext/standard/tests/strings/sprintf_variation54.phpt
Expand Down
115 changes: 84 additions & 31 deletions dockerfiles/ci/xfail_tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,62 @@

This file explains why we decided to disable specific PHP language tests. Investigations for tests disabled before this file was created are not present.

---

# Categories of tests

## Object/resource ID skips

The following tests are marked as skipped due to the test relying on a hard-coded resource or object ID. All of these IDs change when the PHP tracer is enabled due to the objects/resources created in the `ddtrace.request_init_hook`.

- `ext/sockets/tests/socket_create_pair.phpt`
- `ext/zip/tests/bug38943.phpt`
- `ext/zip/tests/bug38943_2.phpt`
- `Zend/tests/bug80194.phpt`

## Random port selection

Many tests choose a random port to start up a service. Many of these tests have been updated to not used a random port in more recent PHP versions, but we skip these tests in older versions of PHP because they often choose a port that is already in use in CI.

- `ext/sockets/tests/socket_connect_params.phpt` ([Fixed](https://github.com/php/php-src/commit/3e9dac2) in PHP 7.4)

## Fail even with no tracer installed

The following tests fail even when the tracer is not installed.

- `ext/mcrypt/tests/bug67707.phpt` (PHP 7.1 only)
- `ext/mcrypt/tests/bug72535.phpt` (PHP 7.1 only)
- `ext/standard/tests/streams/stream_context_tcp_nodelay_fopen.phpt` (PHP 7.1+)

## Deep call stacks (PHP 5)

On PHP 5, certain tests can have intermittently deep call stacks that are deep enough to trigger the warning: `ddtrace has detected a call stack depth of 512`.

- `Zend/tests/bug54268.phpt`

---

# Specific tests

## `Zend/tests/object_gc_in_shutdown.phpt`, `Zend/tests/bug81104.phpt`

Tests memory limits, which we exceed due to tracer being loaded.

## `ext/pcntl/tests/pcntl_unshare_01.phpt`

Disabled on versions: `7.4` (it wasn't there on [7.3-](https://github.com/php/php-src/tree/PHP-7.3/ext/pcntl/tests)).

Links to sample broken executions: [7.4](https://app.circleci.com/pipelines/github/DataDog/dd-trace-php/5532/workflows/2d26f68b-fb78-46f1-b846-c9e0f1c5cefc/jobs/377363).

_Investigation_

`unshare` requires processes [not to be threaded](https://man7.org/linux/man-pages/man2/unshare.2.html) to use the flag `CLONE_NEWUSER`. In our case the background sender is started in a thread and causes the `CLONE_NEWUSER` to be flagged as an error.
Disabling the creation of the background sender thread the test passes (with a delay of 5 seconds).

## `ext/pcntl/tests/pcntl_unshare_03.phpt`

See `ext/pcntl/tests/pcntl_unshare_01.phpt`.

## `ext/openssl/tests/bug54992.phpt`

Disabled on versions: `5.4`, `5.5`.
Expand All @@ -16,7 +72,6 @@ It was [skipped before](https://github.com/php/php-src/blob/bcd100d812b525c982cf

Building again the container without `pcntl` enabled AND not even building the tracer, the test still fails. Possibly the reason is that we need an ssh server listening internally on [port 64321](https://github.com/php/php-src/blob/bcd100d812b525c982cf75d6c6dabe839f61634a/ext/openssl/tests/bug54992.phpt#L13). Configuring the openssh server to run even this last test is neyond the scope of our language tests.


## `ext/ftp/tests`

Disabled on versions: `5.4`, `5.5`.
Expand Down Expand Up @@ -55,46 +110,44 @@ bool(false)

This test was flaky until it was [fixed in PHP 7.2](https://github.com/php/php-src/commit/f4474e5).

---

# Categories of tests

## Object/resource ID skips

The following tests are marked as skipped due to the test relying on a hard-coded resource or object ID. All of these IDs change when the PHP tracer is enabled due to the objects/resources created in the `ddtrace.request_init_hook`.

- `ext/sockets/tests/socket_create_pair.phpt`
- `ext/zip/tests/bug38943.phpt`
- `ext/zip/tests/bug38943_2.phpt`
- `Zend/tests/bug80194.phpt`
## `ext/standard/tests/streams/proc_open_bug69900.phpt`

## Random port selection
* Disabled on versions: `7.0+`.
* [Broken CI build example](https://app.circleci.com/pipelines/github/DataDog/dd-trace-php/5558/workflows/0f25c071-6f6c-4d83-b075-536f6a63369e/jobs/382667)
* This test has [a long history of being flaky in CI](https://github.com/php/php-src/commits/master/ext/standard/tests/streams/proc_open_bug69900.phpt).

Many tests choose a random port to start up a service. Many of these tests have been updated to not used a random port in more recent PHP versions, but we skip these tests in older versions of PHP because they often choose a port that is already in use in CI.

- `ext/sockets/tests/socket_connect_params.phpt` ([Fixed](https://github.com/php/php-src/commit/3e9dac2) in PHP 7.4)
## `sapi/cli/tests/017.phpt`

## Fail even with no tracer installed
Disabled on versions: `5.4`, `5.5`, `5.6`.

The following tests fail even when the tracer is not installed.
Links to sample broken executions: [5.5](https://app.circleci.com/pipelines/github/DataDog/dd-trace-php/5610/workflows/b7836d18-ba47-4315-9cd2-4c1749c0e984/jobs/393611), [5.6](https://app.circleci.com/pipelines/github/DataDog/dd-trace-php/5610/workflows/b7836d18-ba47-4315-9cd2-4c1749c0e984/jobs/393616).

- `ext/mcrypt/tests/bug67707.phpt` (PHP 7.1 only)
- `ext/mcrypt/tests/bug72535.phpt` (PHP 7.1 only)
- `ext/standard/tests/streams/stream_context_tcp_nodelay_fopen.phpt` (PHP 7.1+)
_Investigation_

## Deep call stacks (PHP 5)
The test fails on new buster containers because we copy on 5.x the `php-development.ini` that enables `log_errors = On`.
This causes this test to print an extra line (the logged error) and to fail. The failure happen without the tracer installed as well.

On PHP 5, certain tests can have intermittently deep call stacks that are deep enough to trigger the warning: `ddtrace has detected a call stack depth of 512`.
## `ext/sockets/tests/socket_create_listen-nobind.phpt`

- `Zend/tests/bug54268.phpt`
* Disabled on versions: `5.4 --> 7.3`.
* [Broken CI build example](https://app.circleci.com/pipelines/github/DataDog/dd-trace-php/6016/workflows/dd24ea85-1ec4-47ea-9311-080a66d045a5/jobs/497177)

## `sapi/cli/tests/017.phpt`
This test runs succesfully only if a socket CANNOT be created on port 80 in the environment where the test is executed. With recent changes to CircleCI is now possible to create a socket on port 80. As a proof of it, ssh-ing into a CircleCI runner:

Disabled on versions: `5.4`, `5.5`, `5.6`.
```
$ TEST_PHP_EXECUTABLE=$(which php) php run-tests.php --show-out --show-diff ext/sockets/tests/socket_create_listen-nobind.phpt
...
001+ resource(4) of type (Socket) <<<< dumping the returned socket [here](https://github.com/php/php-src/blob/53ea910d1760c87b6110a461f13ebe0e244c9914/ext/sockets/tests/socket_create_listen-nobind.phpt#L17), it is supposed to return `false` instead.
...
```

Links to sample broken executions: [5.5](https://app.circleci.com/pipelines/github/DataDog/dd-trace-php/5610/workflows/b7836d18-ba47-4315-9cd2-4c1749c0e984/jobs/393611), [5.6](https://app.circleci.com/pipelines/github/DataDog/dd-trace-php/5610/workflows/b7836d18-ba47-4315-9cd2-4c1749c0e984/jobs/393616).
The reason why this test is not failing on PHP 7.4+ if because it is skipped by this [extra check](https://github.com/php/php-src/blob/9db3eda2cbaa01529d807b2326be13e7b0e5e496/ext/sockets/tests/socket_create_listen-nobind.phpt#L16-L18).

_Investigation_
As a confirmation, running the previous test on a 7.4 runner would result in:

The test fails on new buster containers because we copy on 5.x the `php-development.ini` that enables `log_errors = On`.
This causes this test to print an extra line (the logged error) and to fail. The failure happen without the tracer installed as well.
```
$ TEST_PHP_EXECUTABLE=$(which php) php run-tests.php --show-out --show-diff ext/sockets/tests/socket_create_listen-nobind.phpt
...
SKIP Test if socket_create_listen() returns false, when it cannot bind to the port. [ext/sockets/tests/socket_create_listen-nobind.phpt] reason: Test cannot be run in environment that will allow binding to port 80 (azure)
...
```
Loading

0 comments on commit 8f5a6f3

Please sign in to comment.