diff --git a/tests/include/.gitignore b/tests/include/.gitignore index 7d9ced9c2..eb56f03c9 100644 --- a/tests/include/.gitignore +++ b/tests/include/.gitignore @@ -3,3 +3,8 @@ guzzle/ # byproduct of logging/monolog tests monolog2/ monolog3/ +# byproduct of running drupal tests +drupal_6_bootstrap.inc +drupal_6_common.inc +drupal_7_bootstrap.inc +drupal_7_common.inc diff --git a/tests/include/drupal.php b/tests/include/drupal.php new file mode 100644 index 000000000..97a0dcfa8 --- /dev/null +++ b/tests/include/drupal.php @@ -0,0 +1,69 @@ + [ + 'bootstrap.inc' => '14e7070e475e020775255db84f3d3a73999418aa8b6ac51299eb34078690413b5e7aef4003c89f2538d3966b460e2dbf', + 'common.inc' => 'b84b1e7c61cf8d28ded9c6c8b20abc52bc2962bf15ab9f08a2daa90b1c09694501a85a912a8d0e9ede842655be4c446d'], + '7' => [ + 'bootstrap.inc' => '673244b6d19dd2de6b5048f3412d62f1baf24593245175034d59f0dac305c936b0e67a1a91ba57614d17154cd82e0db5', + 'common.inc' => 'f0b758b53f6819bc133b22987c180f947f5055d1225bf14ab2768e84a64c83283e507fcf82e6c3499e3eaf51e65340d0'] + ]; + $file_prefix = 'drupal_' . $version . '_'; + $drupal_source = 'https://raw.githubusercontent.com/drupal/drupal/'; + + if (6 == $version) { + // fd9d1859fce12f359a587e038212d30c2bd738e6 is snapshot in time of 6.x after 6.37 but before 6.38 + $drupal_commit_sha = 'fd9d1859fce12f359a587e038212d30c2bd738e6'; + } elseif (7 == $version) { + // 728503753272f746bb988ffb30d5327f8f2df4b2 is 7.92 + $drupal_commit_sha = '728503753272f746bb988ffb30d5327f8f2df4b2'; + } else { + /* Unsupported version */ + return false; + } + + foreach ($files as $f) { + $src_file_path = $drupal_source . $drupal_commit_sha . '/includes/' . $f; + $dest_file_path = $pwd . '/' . $file_prefix . $f; + if (!file_exists($dest_file_path)) { + copy($src_file_path, $dest_file_path); + } + } + + foreach ($files as $f) { + $file_path = $pwd . '/' . $file_prefix . $f; + if (!file_exists($file_path)) { + return false; + } + $got_checksum = hash_file('sha384', $file_path); + $want_checksum = $checksums[$version][$f]; + if ($got_checksum != $want_checksum) { + return false; + } + } + + return true; +} diff --git a/tests/integration/external/drupal6/skipif.inc b/tests/integration/external/drupal6/skipif.inc new file mode 100644 index 000000000..56940a205 --- /dev/null +++ b/tests/integration/external/drupal6/skipif.inc @@ -0,0 +1,15 @@ +")) { + die("skip: PHP > 7.4.0 not supported\n"); +} + +require_once(realpath(dirname(__FILE__)) . '/../../../include/drupal.php'); + +if (!download_drupal(6)) { + die("warn: drupal6 installation required\n"); +} diff --git a/tests/integration/external/drupal6/test_basic.php b/tests/integration/external/drupal6/test_basic.php new file mode 100644 index 000000000..e0b9c45d6 --- /dev/null +++ b/tests/integration/external/drupal6/test_basic.php @@ -0,0 +1,51 @@ +data; + diff --git a/tests/integration/external/drupal6/test_cat_and_synthetics_disabled.php b/tests/integration/external/drupal6/test_cat_and_synthetics_disabled.php new file mode 100644 index 000000000..b3ce9faa8 --- /dev/null +++ b/tests/integration/external/drupal6/test_cat_and_synthetics_disabled.php @@ -0,0 +1,76 @@ +data; diff --git a/tests/integration/external/drupal6/test_cat_disabled.php b/tests/integration/external/drupal6/test_cat_disabled.php new file mode 100644 index 000000000..de021cd01 --- /dev/null +++ b/tests/integration/external/drupal6/test_cat_disabled.php @@ -0,0 +1,55 @@ +data; diff --git a/tests/integration/external/drupal6/test_cross_process_empty_headers.php b/tests/integration/external/drupal6/test_cross_process_empty_headers.php new file mode 100644 index 000000000..d686ee49d --- /dev/null +++ b/tests/integration/external/drupal6/test_cross_process_empty_headers.php @@ -0,0 +1,59 @@ +data; diff --git a/tests/integration/external/drupal6/test_cross_process_existing_header.php b/tests/integration/external/drupal6/test_cross_process_existing_header.php new file mode 100644 index 000000000..7bc4b6e64 --- /dev/null +++ b/tests/integration/external/drupal6/test_cross_process_existing_header.php @@ -0,0 +1,59 @@ + "windsurfing")); +echo $rv->data; diff --git a/tests/integration/external/drupal6/test_cross_process_no_headers.php b/tests/integration/external/drupal6/test_cross_process_no_headers.php new file mode 100644 index 000000000..9cec8a27d --- /dev/null +++ b/tests/integration/external/drupal6/test_cross_process_no_headers.php @@ -0,0 +1,59 @@ +data; diff --git a/tests/integration/external/drupal6/test_dt_empty_headers.php b/tests/integration/external/drupal6/test_dt_empty_headers.php new file mode 100644 index 000000000..1a5309a73 --- /dev/null +++ b/tests/integration/external/drupal6/test_dt_empty_headers.php @@ -0,0 +1,63 @@ +data; diff --git a/tests/integration/external/drupal6/test_dt_existing_headers.php b/tests/integration/external/drupal6/test_dt_existing_headers.php new file mode 100644 index 000000000..d7f12d461 --- /dev/null +++ b/tests/integration/external/drupal6/test_dt_existing_headers.php @@ -0,0 +1,65 @@ + "windsurfing")); +echo $rv->data; +$rv = drupal_http_request($url, array(CUSTOMER_HEADER => "windsurfing")); +echo $rv->data; diff --git a/tests/integration/external/drupal6/test_dt_newrelic_header_disabled.php b/tests/integration/external/drupal6/test_dt_newrelic_header_disabled.php new file mode 100644 index 000000000..4781c96fa --- /dev/null +++ b/tests/integration/external/drupal6/test_dt_newrelic_header_disabled.php @@ -0,0 +1,61 @@ +data; diff --git a/tests/integration/external/drupal6/test_dt_no_headers.php b/tests/integration/external/drupal6/test_dt_no_headers.php new file mode 100644 index 000000000..b41e8d662 --- /dev/null +++ b/tests/integration/external/drupal6/test_dt_no_headers.php @@ -0,0 +1,62 @@ +data; diff --git a/tests/integration/external/drupal6/test_multiple_calls.php b/tests/integration/external/drupal6/test_multiple_calls.php new file mode 100644 index 000000000..581c83ea0 --- /dev/null +++ b/tests/integration/external/drupal6/test_multiple_calls.php @@ -0,0 +1,56 @@ +data."\n"; +$rv = drupal_http_request($url, array()); +echo $rv->data."\n"; +$rv = drupal_http_request($url, array('X-Foo' => 'bar'), 'GET', NULL, 2, 2); +echo $rv->data."\n"; diff --git a/tests/integration/external/drupal6/test_span_externals.php b/tests/integration/external/drupal6/test_span_externals.php new file mode 100644 index 000000000..09b2a9871 --- /dev/null +++ b/tests/integration/external/drupal6/test_span_externals.php @@ -0,0 +1,103 @@ +data; diff --git a/tests/integration/external/drupal6/test_synthetics_disabled.php b/tests/integration/external/drupal6/test_synthetics_disabled.php new file mode 100644 index 000000000..d69230a2e --- /dev/null +++ b/tests/integration/external/drupal6/test_synthetics_disabled.php @@ -0,0 +1,78 @@ +data; diff --git a/tests/integration/external/drupal6/test_synthetics_with_cat_disabled.php b/tests/integration/external/drupal6/test_synthetics_with_cat_disabled.php new file mode 100644 index 000000000..5d5b6843f --- /dev/null +++ b/tests/integration/external/drupal6/test_synthetics_with_cat_disabled.php @@ -0,0 +1,78 @@ +data; diff --git a/tests/integration/external/drupal6/test_synthetics_with_dt.php b/tests/integration/external/drupal6/test_synthetics_with_dt.php new file mode 100644 index 000000000..6af782360 --- /dev/null +++ b/tests/integration/external/drupal6/test_synthetics_with_dt.php @@ -0,0 +1,84 @@ +data; diff --git a/tests/integration/external/drupal7/skipif.inc b/tests/integration/external/drupal7/skipif.inc new file mode 100644 index 000000000..41d425401 --- /dev/null +++ b/tests/integration/external/drupal7/skipif.inc @@ -0,0 +1,15 @@ +=")) { + die("skip: PHP >= 8.2 not supported\n"); +} + +require_once(realpath(dirname(__FILE__)) . '/../../../include/drupal.php'); + +if (!download_drupal(7)) { + die("warn: drupal7 installation required\n"); +} diff --git a/tests/integration/external/drupal7/test_bad_params_integer_headers.php b/tests/integration/external/drupal7/test_bad_params_integer_headers.php new file mode 100644 index 000000000..b717584c4 --- /dev/null +++ b/tests/integration/external/drupal7/test_bad_params_integer_headers.php @@ -0,0 +1,50 @@ + 22)); diff --git a/tests/integration/external/drupal7/test_bad_params_integer_options.php b/tests/integration/external/drupal7/test_bad_params_integer_options.php new file mode 100644 index 000000000..63cd65175 --- /dev/null +++ b/tests/integration/external/drupal7/test_bad_params_integer_options.php @@ -0,0 +1,45 @@ + NULL)); diff --git a/tests/integration/external/drupal7/test_bad_params_null_options.php b/tests/integration/external/drupal7/test_bad_params_null_options.php new file mode 100644 index 000000000..8d582967e --- /dev/null +++ b/tests/integration/external/drupal7/test_bad_params_null_options.php @@ -0,0 +1,49 @@ +error, "url is number"); +$rv = drupal_http_request(false); +tap_equal('missing schema', $rv->error, "url is false"); diff --git a/tests/integration/external/drupal7/test_basic.php b/tests/integration/external/drupal7/test_basic.php new file mode 100644 index 000000000..2f9ff08e4 --- /dev/null +++ b/tests/integration/external/drupal7/test_basic.php @@ -0,0 +1,50 @@ +data; diff --git a/tests/integration/external/drupal7/test_cat_and_synthetics_disabled.php b/tests/integration/external/drupal7/test_cat_and_synthetics_disabled.php new file mode 100644 index 000000000..32b5e9510 --- /dev/null +++ b/tests/integration/external/drupal7/test_cat_and_synthetics_disabled.php @@ -0,0 +1,76 @@ +data; diff --git a/tests/integration/external/drupal7/test_cat_disabled.php b/tests/integration/external/drupal7/test_cat_disabled.php new file mode 100644 index 000000000..3dae42b91 --- /dev/null +++ b/tests/integration/external/drupal7/test_cat_disabled.php @@ -0,0 +1,59 @@ +data; diff --git a/tests/integration/external/drupal7/test_cross_process_empty_headers.php b/tests/integration/external/drupal7/test_cross_process_empty_headers.php new file mode 100644 index 000000000..bbbb3e5ee --- /dev/null +++ b/tests/integration/external/drupal7/test_cross_process_empty_headers.php @@ -0,0 +1,59 @@ + array())); +echo $rv->data; diff --git a/tests/integration/external/drupal7/test_cross_process_empty_options.php b/tests/integration/external/drupal7/test_cross_process_empty_options.php new file mode 100644 index 000000000..cdb2f7a9d --- /dev/null +++ b/tests/integration/external/drupal7/test_cross_process_empty_options.php @@ -0,0 +1,59 @@ +data; diff --git a/tests/integration/external/drupal7/test_cross_process_existing_header.php b/tests/integration/external/drupal7/test_cross_process_existing_header.php new file mode 100644 index 000000000..b0741979d --- /dev/null +++ b/tests/integration/external/drupal7/test_cross_process_existing_header.php @@ -0,0 +1,63 @@ + array('kiteboarding' => 'windsurfing'))); +echo $rv->data; diff --git a/tests/integration/external/drupal7/test_cross_process_no_options.php b/tests/integration/external/drupal7/test_cross_process_no_options.php new file mode 100644 index 000000000..9d658c44a --- /dev/null +++ b/tests/integration/external/drupal7/test_cross_process_no_options.php @@ -0,0 +1,59 @@ +data; diff --git a/tests/integration/external/drupal7/test_dt_empty_headers.php b/tests/integration/external/drupal7/test_dt_empty_headers.php new file mode 100644 index 000000000..1bb2b0dd4 --- /dev/null +++ b/tests/integration/external/drupal7/test_dt_empty_headers.php @@ -0,0 +1,63 @@ + array())); +echo $rv->data; diff --git a/tests/integration/external/drupal7/test_dt_existing_headers.php b/tests/integration/external/drupal7/test_dt_existing_headers.php new file mode 100644 index 000000000..538a66c7a --- /dev/null +++ b/tests/integration/external/drupal7/test_dt_existing_headers.php @@ -0,0 +1,64 @@ + array("kiteboarding" => "windsurfing"))); +echo $rv->data; +$rv = drupal_http_request($url, array('headers' => array(CUSTOMER_HEADER => "windsurfing"))); +echo $rv->data; diff --git a/tests/integration/external/drupal7/test_dt_newrelic_header_disabled.php b/tests/integration/external/drupal7/test_dt_newrelic_header_disabled.php new file mode 100644 index 000000000..d3ee2219f --- /dev/null +++ b/tests/integration/external/drupal7/test_dt_newrelic_header_disabled.php @@ -0,0 +1,61 @@ +data; diff --git a/tests/integration/external/drupal7/test_dt_no_headers.php b/tests/integration/external/drupal7/test_dt_no_headers.php new file mode 100644 index 000000000..9f60bf427 --- /dev/null +++ b/tests/integration/external/drupal7/test_dt_no_headers.php @@ -0,0 +1,62 @@ +data; diff --git a/tests/integration/external/drupal7/test_multiple_calls.php b/tests/integration/external/drupal7/test_multiple_calls.php new file mode 100644 index 000000000..9279a8801 --- /dev/null +++ b/tests/integration/external/drupal7/test_multiple_calls.php @@ -0,0 +1,53 @@ +data."\n"; +$rv = drupal_http_request($url, array()); +echo $rv->data."\n"; diff --git a/tests/integration/external/drupal7/test_spans_post.php b/tests/integration/external/drupal7/test_spans_post.php new file mode 100644 index 000000000..7c84f5f6b --- /dev/null +++ b/tests/integration/external/drupal7/test_spans_post.php @@ -0,0 +1,103 @@ + 'POST')); diff --git a/tests/integration/external/drupal7/test_spans_post_clm.php b/tests/integration/external/drupal7/test_spans_post_clm.php new file mode 100644 index 000000000..bb56c9ee7 --- /dev/null +++ b/tests/integration/external/drupal7/test_spans_post_clm.php @@ -0,0 +1,103 @@ += 7.0 needed for CLM\n"); +} +*/ + +/*EXPECT_SPAN_EVENTS +[ + "?? agent run id", + { + "reservoir_size": 10000, + "events_seen": 3 + }, + [ + [ + { + "traceId": "??", + "duration": "??", + "transactionId": "??", + "name": "OtherTransaction\/php__FILE__", + "guid": "??", + "type": "Span", + "category": "generic", + "priority": "??", + "sampled": true, + "nr.entryPoint": true, + "timestamp": "??", + "transaction.name": "OtherTransaction\/php__FILE__" + }, + {}, + {} + ], + [ + { + "type": "Span", + "traceId": "??", + "transactionId": "??", + "sampled": true, + "priority": "??", + "name": "Custom\/drupal_http_request", + "guid": "??", + "timestamp": "??", + "duration": "??", + "category": "generic", + "parentId": "??" + }, + {}, + { + "code.lineno": 797, + "code.filepath": "/.*\/drupal_7_common.inc/", + "code.function": "drupal_http_request" + } + ], + [ + { + "traceId": "??", + "duration": "??", + "transactionId": "??", + "name": "External\/127.0.0.1\/all", + "guid": "??", + "type": "Span", + "category": "http", + "priority": "??", + "sampled": true, + "timestamp": "??", + "parentId": "??", + "span.kind": "client", + "component": "Drupal" + }, + {}, + { + "http.url": "??", + "http.method": "POST", + "http.statusCode": 200 + } + ] + ] +] +*/ + +require_once(realpath(dirname(__FILE__)) . '/../../../include/drupal_7_bootstrap.inc'); +require_once(realpath(dirname(__FILE__)) . '/../../../include/drupal_7_common.inc'); +require_once(realpath(dirname(__FILE__)) . '/../../../include/config.php'); + +$url = "http://" . make_tracing_url(realpath(dirname(__FILE__)) . '/../../../include/tracing_endpoint.php'); +$rv = drupal_http_request($url, array('method' => 'POST')); diff --git a/tests/integration/external/drupal7/test_spans_post_clm_off.php b/tests/integration/external/drupal7/test_spans_post_clm_off.php new file mode 100644 index 000000000..9ab4accb1 --- /dev/null +++ b/tests/integration/external/drupal7/test_spans_post_clm_off.php @@ -0,0 +1,96 @@ + 'POST')); diff --git a/tests/integration/external/drupal7/test_spans_sets_external_span_correctly.php b/tests/integration/external/drupal7/test_spans_sets_external_span_correctly.php new file mode 100644 index 000000000..4c319f229 --- /dev/null +++ b/tests/integration/external/drupal7/test_spans_sets_external_span_correctly.php @@ -0,0 +1,103 @@ + array("kiteboarding" => "windsurfing"))); diff --git a/tests/integration/external/drupal7/test_spans_sets_external_span_correctly_clm_off.php b/tests/integration/external/drupal7/test_spans_sets_external_span_correctly_clm_off.php new file mode 100644 index 000000000..70dca905a --- /dev/null +++ b/tests/integration/external/drupal7/test_spans_sets_external_span_correctly_clm_off.php @@ -0,0 +1,96 @@ + array("kiteboarding" => "windsurfing"))); diff --git a/tests/integration/external/drupal7/test_synthetics.php b/tests/integration/external/drupal7/test_synthetics.php new file mode 100644 index 000000000..a0312e00d --- /dev/null +++ b/tests/integration/external/drupal7/test_synthetics.php @@ -0,0 +1,79 @@ +data; diff --git a/tests/integration/external/drupal7/test_synthetics_disabled.php b/tests/integration/external/drupal7/test_synthetics_disabled.php new file mode 100644 index 000000000..bdc4ff73a --- /dev/null +++ b/tests/integration/external/drupal7/test_synthetics_disabled.php @@ -0,0 +1,82 @@ +data; diff --git a/tests/integration/external/drupal7/test_synthetics_with_cat_disabled.php b/tests/integration/external/drupal7/test_synthetics_with_cat_disabled.php new file mode 100644 index 000000000..8a27df9cb --- /dev/null +++ b/tests/integration/external/drupal7/test_synthetics_with_cat_disabled.php @@ -0,0 +1,77 @@ +data; diff --git a/tests/integration/external/drupal7/test_synthetics_with_dt.php b/tests/integration/external/drupal7/test_synthetics_with_dt.php new file mode 100644 index 000000000..af960b29d --- /dev/null +++ b/tests/integration/external/drupal7/test_synthetics_with_dt.php @@ -0,0 +1,80 @@ +data;