Skip to content

Commit

Permalink
Merge branch 'oapi' into ads/oapi-jit-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zsistla authored Sep 6, 2023
2 parents 153fea0 + 7b142fc commit fc68e7c
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 11 deletions.
16 changes: 9 additions & 7 deletions agent/lib_phpunit.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,8 @@ NR_PHP_WRAPPER(nr_phpunit_instrument_testresult_endtest) {
}

/*
* PHPUnit 6+ started passing "tests skipped due to dependency failures"
* to the endTest method -- however, we already catch these tests in
* PHPUnit passes "tests skipped due to dependency failures"
* to the endTest method. For PHPUnit 5.x, we already catch these tests in
* our nr_phpunit_instrument_testresult_adderror wrapper. This check
* ensures these skipped tests aren't double counted by bailing if
* a test's status isn't set.
Expand All @@ -490,8 +490,13 @@ NR_PHP_WRAPPER(nr_phpunit_instrument_testresult_endtest) {
duration = nr_php_arg_get(2, NR_EXECUTE_ORIG_ARGS TSRMLS_CC);
if (!nr_php_is_zval_valid_double(duration)) {
nrl_verbosedebug(NRL_INSTRUMENT, "%s: invalid test duration", __func__);
NR_PHP_WRAPPER_CALL;
goto end;
/*
* When PHPUnit 6.x+ passes "tests skipped due to dependency failures"
* to the endTest method the second argument - $time - has the value of 0.
* However Zend Engine does not correctly set the type for this argument
* in this case and therefore we need to fix the type of duration here:
*/
ZVAL_DOUBLE(duration, 0.0);
}

NR_PHP_WRAPPER_CALL;
Expand Down Expand Up @@ -689,7 +694,4 @@ void nr_phpunit_enable(TSRMLS_D) {
nr_php_wrap_user_function(
NR_PSTR("PHPUnit_Framework_TestResult::addError"),
nr_phpunit_instrument_testresult_adderror TSRMLS_CC);
nr_php_wrap_user_function(
NR_PSTR("PHPUnit\\Framework\\TestResult::addError"),
nr_phpunit_instrument_testresult_adderror TSRMLS_CC);
}
7 changes: 3 additions & 4 deletions agent/php_execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,11 +488,10 @@ static nr_library_table_t libraries[] = {

/*
* The first path is for Composer installs, the second is for
* /usr/local/bin. While BaseTestRunner isn't the very first file to load,
* it contains the test status constants and loads before tests can run.
* /usr/local/bin.
*/
{"PHPUnit", "phpunit/src/runner/basetestrunner.php", nr_phpunit_enable},
{"PHPUnit", "phpunit/runner/basetestrunner.php", nr_phpunit_enable},
{"PHPUnit", "phpunit/src/framework/test.php", nr_phpunit_enable},
{"PHPUnit", "phpunit/framework/test.php", nr_phpunit_enable},

{"Predis", "predis/src/client.php", nr_predis_enable},
{"Predis", "predis/client.php", nr_predis_enable},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
/*SKIPIF
<?php
require("skipif.inc");
if (version_compare(PHP_VERSION, "8.0", ">=")) {
die("skip: PHP >= 8.0 not supported\n");
}
*/

/*EXPECT_METRICS
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

/*DESCRIPTION
Test that adding cross process headers doesn't blow up if the second parameter
is bogus.
*/

// force the framework to avoid requiring the drupal detection file
/*INI
newrelic.framework = drupal
newrelic.distributed_tracing_enabled=0
*/

/*SKIPIF
<?php
require("skipif.inc");
if (version_compare(PHP_VERSION, "8.0", "<")) {
die("skip: PHP < 8.0 not supported\n");
}
*/

/*EXPECT_METRICS
[
"?? agent run id",
"?? timeframe start",
"?? timeframe stop",
[
[{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]],
[{"name": "Supportability/Logging/Metrics/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]],
[{"name":"Errors/OtherTransaction/php__FILE__"}, [1, 0, 0, 0, 0, 0]],
[{"name":"Errors/all"}, [1, 0, 0, 0, 0, 0]],
[{"name":"Errors/allOther"}, [1, 0, 0, 0, 0, 0]],
[{"name":"OtherTransaction/all"}, [1, "??", "??", "??", "??", "??"]],
[{"name":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]],
[{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]],
[{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]],
[{"name":"Supportability/framework/Drupal/forced"}, [1, 0, 0, 0, 0, 0]]
]
]
*/

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://" . $EXTERNAL_HOST;

drupal_http_request($url, array("headers" => 22));
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
/*SKIPIF
<?php
require("skipif.inc");
if (version_compare(PHP_VERSION, "8.0", ">=")) {
die("skip: PHP >= 8.0 not supported\n");
}
*/

/*EXPECT_METRICS
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

/*DESCRIPTION
Test that adding cross process headers doesn't blow up if the second parameter
is bogus.
*/

// force the framework to avoid requiring the drupal detection file
/*INI
newrelic.framework = drupal
newrelic.distributed_tracing_enabled=0
*/

/*SKIPIF
<?php
require("skipif.inc");
if (version_compare(PHP_VERSION, "8.0", "<")) {
die("skip: PHP < 8.0 not supported\n");
}
*/

/*EXPECT_METRICS
[
"?? agent run id",
"?? timeframe start",
"?? timeframe stop",
[
[{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]],
[{"name": "Supportability/Logging/Metrics/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]],
[{"name":"Errors/OtherTransaction/php__FILE__"}, [1, 0, 0, 0, 0, 0]],
[{"name":"Errors/all"}, [1, 0, 0, 0, 0, 0]],
[{"name":"Errors/allOther"}, [1, 0, 0, 0, 0, 0]],
[{"name":"OtherTransaction/all"}, [1, "??", "??", "??", "??", "??"]],
[{"name":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]],
[{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]],
[{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]],
[{"name":"Supportability/framework/Drupal/forced"}, [1, 0, 0, 0, 0, 0]]
]
]
*/

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://" . $EXTERNAL_HOST;

drupal_http_request($url, array("headers" => NULL));

0 comments on commit fc68e7c

Please sign in to comment.