diff --git a/.github/workflows/code-coverage-baseline.yml b/.github/workflows/code-coverage-baseline.yml index ab5b213f8..199bdccac 100644 --- a/.github/workflows/code-coverage-baseline.yml +++ b/.github/workflows/code-coverage-baseline.yml @@ -69,7 +69,7 @@ jobs: matrix: platform: [gnu, musl] arch: [amd64] - php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3'] + php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] include: - codecov: 0 - platform: gnu @@ -147,7 +147,7 @@ jobs: matrix: platform: [gnu, musl] arch: [amd64] - php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3'] + php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] include: - codecov: 0 - platform: gnu diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index c715fe73b..48d046adf 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -16,7 +16,7 @@ jobs: # - https://gh.io/supported-runners-and-hardware-resources # - https://gh.io/using-larger-runners # Consider using larger runners for possible analysis time improvements. - runs-on: 'ubuntu-latest' + runs-on: 'ubuntu-22.04' timeout-minutes: 360 permissions: # required for all workflows diff --git a/.github/workflows/make-agent.yml b/.github/workflows/make-agent.yml index b29881676..6508fcaf3 100644 --- a/.github/workflows/make-agent.yml +++ b/.github/workflows/make-agent.yml @@ -32,7 +32,7 @@ jobs: strategy: matrix: platform: [gnu, musl] - php: ['8.0', '8.1', '8.2', '8.3'] + php: ['8.0', '8.1', '8.2', '8.3', '8.4'] steps: - name: Checkout Repo uses: actions/checkout@v4 diff --git a/.github/workflows/make-integration-tests.yml b/.github/workflows/make-integration-tests.yml index 800146f41..0b6660575 100644 --- a/.github/workflows/make-integration-tests.yml +++ b/.github/workflows/make-integration-tests.yml @@ -34,7 +34,7 @@ jobs: fail-fast: true matrix: platform: [gnu, musl] - php: ['8.0', '8.1', '8.2', '8.3'] + php: ['8.0', '8.1', '8.2', '8.3', '8.4'] steps: - name: Checkout integration tests uses: actions/checkout@v4 diff --git a/.github/workflows/security-scan.yml b/.github/workflows/security-scan.yml index 98e8039ba..a5bbd9cd9 100644 --- a/.github/workflows/security-scan.yml +++ b/.github/workflows/security-scan.yml @@ -45,4 +45,5 @@ jobs: if: ${{ github.event_name == 'schedule' }} uses: github/codeql-action/upload-sarif@v3 with: + checkout_path: ./php-agent sarif_file: trivy-results.sarif diff --git a/.github/workflows/test-agent.yml b/.github/workflows/test-agent.yml index 328be3a39..fff60dae5 100644 --- a/.github/workflows/test-agent.yml +++ b/.github/workflows/test-agent.yml @@ -97,7 +97,7 @@ jobs: matrix: platform: [gnu, musl] arch: [amd64, arm64] - php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3'] + php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] exclude: - arch: arm64 php: '7.2' @@ -203,7 +203,7 @@ jobs: matrix: platform: [gnu, musl] arch: [amd64, arm64] - php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3'] + php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] exclude: - arch: arm64 php: '7.2' diff --git a/VERSION b/VERSION index 72773deb8..7ef698131 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -11.4.0 +11.5.0 diff --git a/agent/config.m4 b/agent/config.m4 index 5806caac5..6671bcd54 100644 --- a/agent/config.m4 +++ b/agent/config.m4 @@ -232,13 +232,16 @@ if test "$PHP_NEWRELIC" = "yes"; then lib_guzzle4.c lib_guzzle6.c lib_guzzle_common.c \ lib_mongodb.c lib_phpunit.c lib_predis.c lib_zend_http.c \ lib_composer.c" - PHP_NEW_EXTENSION(newrelic, $FRAMEWORKS $LIBRARIES $NEWRELIC_AGENT, $ext_shared,, \\$(NEWRELIC_CFLAGS)) + PHP_NEW_EXTENSION(newrelic, $FRAMEWORKS $LIBRARIES $NEWRELIC_AGENT, $ext_shared,, $(NEWRELIC_CFLAGS)) PHP_SUBST(NEWRELIC_CFLAGS) dnl Define $(PHP_CONFIG) so we can call it when building tests. PHP_SUBST(PHP_CONFIG) + dnl Make sure we include the source directory in the include search path. + PHP_ADD_INCLUDE([$abs_srcdir], [1]) + dnl Include the Makefile.frag, which we use to handle build time dnl dependencies. PHP_ADD_MAKEFILE_FRAGMENT diff --git a/agent/fw_drupal8.c b/agent/fw_drupal8.c index 541cb8b87..32976c64a 100644 --- a/agent/fw_drupal8.c +++ b/agent/fw_drupal8.c @@ -9,6 +9,7 @@ #include "php_user_instrument.h" #include "php_execute.h" #include "php_wrapper.h" +#include "php_error.h" #include "fw_drupal_common.h" #include "fw_hooks.h" #include "fw_support.h" @@ -20,6 +21,62 @@ #define PHP_PACKAGE_NAME "drupal/core" +NR_PHP_WRAPPER(nr_drupal_exception) { + int priority = nr_php_error_get_priority(E_ERROR); + zval* event = NULL; + zval* exception = NULL; + + /* Warning avoidance */ + (void)wraprec; + + NR_PHP_WRAPPER_REQUIRE_FRAMEWORK(NR_FW_DRUPAL8); + + if (NR_SUCCESS != nr_txn_record_error_worthy(NRPRG(txn), priority)) { + NR_PHP_WRAPPER_CALL; + goto end; + } + + /* Get the event that was given. */ + event = nr_php_arg_get(1, NR_EXECUTE_ORIG_ARGS); + + /* Call the original function. */ + NR_PHP_WRAPPER_CALL; + + if (0 == nr_php_is_zval_valid_object(event)) { + nrl_verbosedebug(NRL_TXN, + "Drupal: ExceptionSubscriber::onException() does not " + "have an `event` parameter"); + goto end; + } + + /* + * Get the exception from the event. + */ + exception = nr_php_call(event, "getThrowable"); + if (!nr_php_is_zval_valid_object(exception)) { + // be abundantly cautious: free exception before attempting to re-assign + nr_php_zval_free(&exception); + exception = nr_php_call(event, "getException"); + } + + if (!nr_php_is_zval_valid_object(exception)) { + nrl_verbosedebug(NRL_TXN, "Drupal: getException() returned a non-object"); + goto end; + } + + if (NR_SUCCESS + != nr_php_error_record_exception(NRPRG(txn), exception, priority, true, + NULL, + &NRPRG(exception_filters))) { + nrl_verbosedebug(NRL_TXN, "Drupal: unable to record exception"); + } + +end: + nr_php_arg_release(&event); + nr_php_zval_free(&exception); +} +NR_PHP_WRAPPER_END + /* * Purpose : Convenience function to handle adding a callback to a method, * given a class entry and a method name. This will check the @@ -730,6 +787,26 @@ void nr_drupal8_enable(TSRMLS_D) { "er::getControllerFromDefinition"), nr_drupal8_name_the_wt TSRMLS_CC); + /* + * ExceptionSubscribers handle Drupal errors and exceptions before + * the agent has the opportunity to capture them. Instrument several + * of these ExceptionSubscriber function `onException` methods in order + * to capture Exceptions and Errors in Drupal 9.x+ + */ + // clang-format off + /* + * Log exceptions without further handling. + */ + nr_php_wrap_user_function(NR_PSTR("Drupal\\Core\\EventSubscriber\\ExceptionLoggingSubscriber::onException"), + nr_drupal_exception); + + /* + * Last-chance handler for exceptions: the final exception subscriber. + */ + nr_php_wrap_user_function(NR_PSTR("Drupal\\Core\\EventSubscriber\\FinalExceptionSubscriber::onException"), + nr_drupal_exception); + // clang-format on + /* * The drupal_modules config setting controls instrumentation of modules, * hooks, and views. diff --git a/agent/lib_aws_sdk_php.c b/agent/lib_aws_sdk_php.c index ad956ac1e..51ef17fda 100644 --- a/agent/lib_aws_sdk_php.c +++ b/agent/lib_aws_sdk_php.c @@ -22,49 +22,40 @@ * In a normal course of events, the following line will always work * zend_eval_string("Aws\\Sdk::VERSION;", &retval, "Get AWS Version") * By the time we have detected the existence of the aws-sdk-php and with - * default composer profject settings, it callable even from + * default composer project settings, it is callable even from * nr_aws_sdk_php_enable which will automatically load the class if it isn't - * loaded yet and then evaluate the string. However, in the rare case that files + * loaded yet and then evaluate the string. In the rare case that files * are not loaded via autoloader and/or have non-default composer classload - * settings, if the class is not found, PHP 8.2+ will generate a fatal - * unrecoverable uncatchable error error whenever it cannot find a class. While - * calling this from nr_aws_sdk_php_enable would have been great and would allow - * the sdk version value to be set only once, to avoid the very unlikely but not - * impossible fatal error, this will be called from the - * "Aws\\ClientResolver::_apply_user_agent" wrapper which GUARANTEES that - * aws/sdk exists and is already loaded. - * - * - * Additionally given that aws-sdk-php is currently detected from the - * AwsClient.php file, this method will always be called when a client is - * created unlike Sdk::construct which doesn't show with PHP 8.2+. - * - * Using Aws/Sdk::__construct for version is currently nonviable as it is - * unreliable as a version determiner. - * Having separate functionality to extract from Aws/Sdk::__construct - * is both not required and is redundant and causes additional overhead and - * so only one function is needed to extract version. - * - * Aws\\ClientResolver::_apply_user_agent a reliable function as it is - * always called on client initialization since it is key to populating - * the request headers, and it loads Sdk by default. - * - * Concerns about future/past proofing to the checking prioritized the following - * implementation vs using the eval method. + * settings, if the class is not found, PHP 8.2+ will generate an + * error whenever it cannot find a class which must be caught. Calling this + * from nr_aws_sdk_php_enable would allow the sdk version value to be set only + * once. To avoid the VERY unlikely but not impossible fatal error, we need to + * wrap the call in a try/catch block and make it a lambda so that we avoid + * fatal errors. */ void nr_lib_aws_sdk_php_handle_version() { - zval* zval_version = NULL; - zend_class_entry* class_entry = NULL; char* version = NULL; - - class_entry = nr_php_find_class("aws\\sdk"); - if (NULL != class_entry) { - zval_version = nr_php_get_class_constant(class_entry, "VERSION"); - - if (nr_php_is_zval_non_empty_string(zval_version)) { - version = Z_STRVAL_P(zval_version); + zval retval; + int result = FAILURE; + + result = zend_eval_string( + "(function() {" + " $nr_aws_sdk_version = '';" + " try {" + " $nr_aws_sdk_version = Aws\\Sdk::VERSION;" + " } catch (Throwable $e) {" + " }" + " return $nr_aws_sdk_version;" + "})();", + &retval, "Get nr_aws_sdk_version"); + + /* See if we got a non-empty/non-null string for version. */ + if (SUCCESS == result) { + if (nr_php_is_zval_non_empty_string(&retval)) { + version = Z_STRVAL(retval); } } + if (NRINI(vulnerability_management_package_detection_enabled)) { /* Add php package to transaction */ nr_txn_add_php_package(NRPRG(txn), PHP_PACKAGE_NAME, version); @@ -73,7 +64,7 @@ void nr_lib_aws_sdk_php_handle_version() { nr_txn_suggest_package_supportability_metric(NRPRG(txn), PHP_PACKAGE_NAME, version); - nr_php_zval_free(&zval_version); + zval_dtor(&retval); } void nr_lib_aws_sdk_php_add_supportability_service_metric( @@ -96,13 +87,6 @@ void nr_lib_aws_sdk_php_add_supportability_service_metric( nrm_force_add(NRPRG(txn) ? NRTXN(unscoped_metrics) : 0, buf, 0); } -NR_PHP_WRAPPER(nr_create_aws_sdk_version_metrics) { - (void)wraprec; - NR_PHP_WRAPPER_CALL; - nr_lib_aws_sdk_php_handle_version(); -} -NR_PHP_WRAPPER_END - /* * AwsClient::parseClass * This is called from the base AwsClient class for every client associated @@ -144,7 +128,7 @@ NR_PHP_WRAPPER_END * optimizable library. Small overhead incurred when encountering an autoload * file, but detects aws-sdk-php immediately before any sdk code executes * (changes needed for this are detailed in the original PR) - * 2. use a file that gets called later and only when AwsClient.php file file is + * 2. use a file that gets called later and only when AwsClient.php file is * called. It's called later and we'll miss some instrumentation, but if we're * only ever going to be interested in Client calls anyway, maybe that's ok? * Doesn't detect Sdk.php (optimized out) so when customers only use that or @@ -158,22 +142,24 @@ NR_PHP_WRAPPER_END * to wrap, this will add overhead to every hash map lookup. Currently * implemented option is 2, use the AwsClient.php as this is our main focus. * This means until a call to an Aws/AwsClient function, - * all calls including aws\sdk calls are ignored. Version detection will be - * tied to Aws/ClientResolver::_apply_user_agent which is ALWAYS called when - * dealing with aws clients. It will not be computed from - * Aws/Sdk::__constructor which would at best be duplicate info and worst would - * never be ignored until a client is called. + * all calls including aws\sdk calls are ignored. + * + * Version detection will be called directly from Aws\Sdk.php */ void nr_aws_sdk_php_enable() { - /* This will be used to extract the version. */ - nr_php_wrap_user_function(NR_PSTR("Aws\\ClientResolver::_apply_user_agent"), - nr_create_aws_sdk_version_metrics); - /* Called when initializing all other Clients */ - nr_php_wrap_user_function(NR_PSTR("Aws\\AwsClient::parseClass"), - nr_create_aws_service_metric); - + /* + * Set the UNKNOWN package first, so it doesn't overwrite what we find with + * nr_lib_aws_sdk_php_handle_version. + */ if (NRINI(vulnerability_management_package_detection_enabled)) { nr_txn_add_php_package(NRPRG(txn), PHP_PACKAGE_NAME, PHP_PACKAGE_VERSION_UNKNOWN); } + + /* Extract the version for aws-sdk 3+ */ + nr_lib_aws_sdk_php_handle_version(); + + /* Called when initializing all Clients */ + nr_php_wrap_user_function(NR_PSTR("Aws\\AwsClient::parseClass"), + nr_create_aws_service_metric); } diff --git a/agent/newrelic-install.sh b/agent/newrelic-install.sh index 9ef1e45fd..8ff9cd3ed 100755 --- a/agent/newrelic-install.sh +++ b/agent/newrelic-install.sh @@ -335,10 +335,10 @@ for pmv in "20170718" "20180731" "20190902"; do done fi # Currently supported versions: -# (8.0, 8.1, 8.2, 8.3) +# (8.0, 8.1, 8.2, 8.3, 8.4) # for x64 and aarch64 if [ ${arch} = x64 ] || [ ${arch} = aarch64 ]; then - for pmv in "20200930" "20210902" "20220829" "20230831"; do + for pmv in "20200930" "20210902" "20220829" "20230831" "20240924"; do check_file "${ilibdir}/agent/${arch}/newrelic-${pmv}.so" done fi @@ -542,6 +542,7 @@ add_to_path /usr/local/php-8.0/bin add_to_path /usr/local/php-8.1/bin add_to_path /usr/local/php-8.2/bin add_to_path /usr/local/php-8.3/bin +add_to_path /usr/local/php-8.4/bin add_to_path /opt/local/bin add_to_path /usr/php/bin @@ -553,6 +554,7 @@ add_to_path /usr/php-8.0/bin add_to_path /usr/php-8.1/bin add_to_path /usr/php-8.2/bin add_to_path /usr/php-8.3/bin +add_to_path /usr/php-8.4/bin add_to_path /usr/php/7.2/bin add_to_path /usr/php/7.3/bin @@ -561,6 +563,7 @@ add_to_path /usr/php/8.0/bin add_to_path /usr/php/8.1/bin add_to_path /usr/php/8.2/bin add_to_path /usr/php/8.3/bin +add_to_path /usr/php/8.4/bin add_to_path /opt/php/bin add_to_path /opt/zend/bin @@ -572,6 +575,7 @@ add_to_path /opt/php-8.0/bin add_to_path /opt/php-8.1/bin add_to_path /opt/php-8.2/bin add_to_path /opt/php-8.3/bin +add_to_path /opt/php-8.4/bin if [ -n "${NR_INSTALL_PATH}" ]; then oIFS="${IFS}" @@ -1052,7 +1056,11 @@ for this copy of PHP. We apologize for the inconvenience. 8.3.*) pi_php8="yes" - ;; + ;; + + 8.4.*) + pi_php8="yes" + ;; *) error "unsupported version '${pi_ver}' of PHP found at: @@ -1232,6 +1240,7 @@ does not exist. This particular instance of PHP will be skipped. 8.1.*) pi_modver="20210902" ;; 8.2.*) pi_modver="20220829" ;; 8.3.*) pi_modver="20230831" ;; + 8.4.*) pi_modver="20240924" ;; esac log "${pdir}: pi_modver=${pi_modver}" diff --git a/agent/php_includes.h b/agent/php_includes.h index 72c25a26a..da255fdbc 100644 --- a/agent/php_includes.h +++ b/agent/php_includes.h @@ -54,6 +54,7 @@ #define ZEND_8_1_X_API_NO 20210902 #define ZEND_8_2_X_API_NO 20220829 #define ZEND_8_3_X_API_NO 20230831 +#define ZEND_8_4_X_API_NO 20240924 #if ZEND_MODULE_API_NO >= ZEND_8_0_X_API_NO /* PHP8+ */ #include "Zend/zend_observer.h" diff --git a/agent/php_internal_instrument.c b/agent/php_internal_instrument.c index ce6c089ec..e37510e32 100644 --- a/agent/php_internal_instrument.c +++ b/agent/php_internal_instrument.c @@ -3840,9 +3840,37 @@ void nr_php_generate_internal_wrap_records(void) { NR_INTERNAL_WRAPREC("sqlite3::exec", sqlite3_exec, sqlite3, 0, 0) NR_INTERNAL_WRAPREC("pdo::__construct", pdo_construct, pdo_construct, 0, 0) +#if ZEND_MODULE_API_NO >= ZEND_8_4_X_API_NO + NR_INTERNAL_WRAPREC("pdo\\firebird::__construct", pdo_construct, pdo_construct, 0, 0) + NR_INTERNAL_WRAPREC("pdo\\mysql::__construct", pdo_construct, pdo_construct, 0, 0) + NR_INTERNAL_WRAPREC("pdo\\odbc::__construct", pdo_construct, pdo_construct, 0, 0) + NR_INTERNAL_WRAPREC("pdo\\pgsql::__construct", pdo_construct, pdo_construct, 0, 0) + NR_INTERNAL_WRAPREC("pdo\\sqlite::__construct", pdo_construct, pdo_construct, 0, 0) +#endif NR_INTERNAL_WRAPREC("pdo::query", pdo_query, pdo_query, 0, 0) +#if ZEND_MODULE_API_NO >= ZEND_8_4_X_API_NO + NR_INTERNAL_WRAPREC("pdo\\firebird::query", pdo_query, pdo_query, 0, 0) + NR_INTERNAL_WRAPREC("pdo\\mysql::query", pdo_query, pdo_query, 0, 0) + NR_INTERNAL_WRAPREC("pdo\\odbc::query", pdo_query, pdo_query, 0, 0) + NR_INTERNAL_WRAPREC("pdo\\pgsql::query", pdo_query, pdo_query, 0, 0) + NR_INTERNAL_WRAPREC("pdo\\sqlite::query", pdo_query, pdo_query, 0, 0) +#endif NR_INTERNAL_WRAPREC("pdo::exec", pdo_exec, pdo_exec, 0, 0) +#if ZEND_MODULE_API_NO >= ZEND_8_4_X_API_NO + NR_INTERNAL_WRAPREC("pdo\\firebird::exec", pdo_exec, pdo_exec, 0, 0) + NR_INTERNAL_WRAPREC("pdo\\mysql::exec", pdo_exec, pdo_exec, 0, 0) + NR_INTERNAL_WRAPREC("pdo\\odbc::exec", pdo_exec, pdo_exec, 0, 0) + NR_INTERNAL_WRAPREC("pdo\\pgsql::exec", pdo_exec, pdo_exec, 0, 0) + NR_INTERNAL_WRAPREC("pdo\\sqlite::exec", pdo_exec, pdo_exec, 0, 0) +#endif NR_INTERNAL_WRAPREC("pdo::prepare", pdo_prepare, pdo_prepare, 0, 0) +#if ZEND_MODULE_API_NO >= ZEND_8_4_X_API_NO + NR_INTERNAL_WRAPREC("pdo\\firebird::prepare", pdo_prepare, pdo_prepare, 0, 0) + NR_INTERNAL_WRAPREC("pdo\\mysql::prepare", pdo_prepare, pdo_prepare, 0, 0) + NR_INTERNAL_WRAPREC("pdo\\odbc::prepare", pdo_prepare, pdo_prepare, 0, 0) + NR_INTERNAL_WRAPREC("pdo\\pgsql::prepare", pdo_prepare, pdo_prepare, 0, 0) + NR_INTERNAL_WRAPREC("pdo\\sqlite::prepare", pdo_prepare, pdo_prepare, 0, 0) +#endif NR_INTERNAL_WRAPREC("pdostatement::execute", pdostmt_execute, pdostatement_execute, 0, 0) diff --git a/agent/tests/test_agent.c b/agent/tests/test_agent.c index 12d3437e4..53b3495ee 100644 --- a/agent/tests/test_agent.c +++ b/agent/tests/test_agent.c @@ -142,7 +142,11 @@ static void test_function_debug_name(TSRMLS_D) { func = nr_php_zval_to_function(closure TSRMLS_CC); name = nr_php_function_debug_name(func); +#if ZEND_MODULE_API_NO < ZEND_8_4_X_API_NO tlib_pass_if_str_equal("closure", "{closure} declared at -:1", name); +#else + tlib_pass_if_str_equal("closure", "{closure:-:1} declared at -:1", name); +#endif nr_php_zval_free(&closure); nr_free(name); diff --git a/axiom/nr_txn.c b/axiom/nr_txn.c index 774c44671..4e5c4c41e 100644 --- a/axiom/nr_txn.c +++ b/axiom/nr_txn.c @@ -2582,6 +2582,8 @@ nrobj_t* nr_txn_event_intrinsics(const nrtxn_t* txn) { params, txn->unscoped_metrics, "WebFrontend/QueueTime", "queueDuration"); nr_txn_add_metric_total_as_attribute(params, txn->unscoped_metrics, "External/all", "externalDuration"); + nr_txn_add_metric_count_as_attribute(params, txn->unscoped_metrics, + "External/all", "externalCallCount"); nr_txn_add_metric_total_as_attribute(params, txn->unscoped_metrics, "Datastore/all", "databaseDuration"); nr_txn_add_metric_count_as_attribute(params, txn->unscoped_metrics, diff --git a/axiom/nr_version.c b/axiom/nr_version.c index 5f09c86a7..6125e272e 100644 --- a/axiom/nr_version.c +++ b/axiom/nr_version.c @@ -23,7 +23,6 @@ /* * Current version naming scheme is gemstones * - * freesia 03Nov2022 (10.3) * goldenrod 12Dec2022 (10.4) * hydrangea 18Jan2023 (10.5) * impatiens 13Feb2023 (10.6) @@ -47,8 +46,9 @@ * amethyst 26Aug2024 (11.1) * bowenite 30Sep2024 (11.2) * corundum 21Oct2024 (11.3) + * diamond 09Dec2024 (11.4) */ -#define NR_CODENAME "diamond" +#define NR_CODENAME "emerald" const char* nr_version(void) { return NR_STR2(NR_VERSION); diff --git a/axiom/tests/test_cmd_txndata.c b/axiom/tests/test_cmd_txndata.c index fc9272e1c..1107d9a79 100644 --- a/axiom/tests/test_cmd_txndata.c +++ b/axiom/tests/test_cmd_txndata.c @@ -1094,6 +1094,7 @@ static void test_encode_txn_event(void) { "\"duration\":0.98700,\"totalTime\":0.98700,\"nr.apdexPerfZone\":" "\"F\"," "\"queueDuration\":3.00000,\"externalDuration\":2.00000," + "\"externalCallCount\":1," "\"databaseDuration\":2.00000," "\"databaseCallCount\":2," "\"error\":false}," diff --git a/axiom/tests/test_txn.c b/axiom/tests/test_txn.c index 9230a416a..279bbbbee 100644 --- a/axiom/tests/test_txn.c +++ b/axiom/tests/test_txn.c @@ -4056,6 +4056,7 @@ static void test_create_event(void) { "\"nr.apdexPerfZone\":\"F\"," "\"queueDuration\":3.00000," "\"externalDuration\":2.00000," + "\"externalCallCount\":1," "\"databaseDuration\":1.00000," "\"databaseCallCount\":1," "\"error\":false" @@ -4078,6 +4079,7 @@ static void test_create_event(void) { "\"totalTime\":0.98700," "\"queueDuration\":3.00000," "\"externalDuration\":2.00000," + "\"externalCallCount\":1," "\"databaseDuration\":1.00000," "\"databaseCallCount\":1," "\"error\":false" @@ -4103,6 +4105,7 @@ static void test_create_event(void) { "\"nr.apdexPerfZone\":\"F\"," "\"queueDuration\":3.00000," "\"externalDuration\":2.00000," + "\"externalCallCount\":1," "\"databaseDuration\":1.00000," "\"databaseCallCount\":1," "\"error\":false" @@ -4126,6 +4129,7 @@ static void test_create_event(void) { "\"nr.apdexPerfZone\":\"F\"," "\"queueDuration\":3.00000," "\"externalDuration\":2.00000," + "\"externalCallCount\":1," "\"databaseDuration\":1.00000," "\"databaseCallCount\":1," "\"error\":false" @@ -4148,6 +4152,7 @@ static void test_create_event(void) { "\"nr.apdexPerfZone\":\"F\"," "\"queueDuration\":3.00000," "\"externalDuration\":2.00000," + "\"externalCallCount\":1," "\"databaseDuration\":1.00000," "\"databaseCallCount\":1," "\"error\":false" diff --git a/daemon/go.mod b/daemon/go.mod index 5fb45e76e..5685974d5 100644 --- a/daemon/go.mod +++ b/daemon/go.mod @@ -1,18 +1,19 @@ module github.com/newrelic/newrelic-php-agent/daemon go 1.21 + toolchain go1.23.1 require ( github.com/golang/protobuf v1.5.3 github.com/google/flatbuffers v23.5.26+incompatible - golang.org/x/net v0.23.0 + golang.org/x/net v0.33.0 google.golang.org/grpc v1.61.0 google.golang.org/protobuf v1.33.0 ) require ( - golang.org/x/sys v0.18.0 // indirect - golang.org/x/text v0.14.0 // indirect + golang.org/x/sys v0.28.0 // indirect + golang.org/x/text v0.21.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 // indirect ) diff --git a/daemon/go.sum b/daemon/go.sum index f7f322d87..8ede3e252 100644 --- a/daemon/go.sum +++ b/daemon/go.sum @@ -6,12 +6,12 @@ github.com/google/flatbuffers v23.5.26+incompatible/go.mod h1:1AeVuKshWv4vARoZat github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= -golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= +golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 h1:Jyp0Hsi0bmHXG6k9eATXoYtjd6e2UzZ1SCn/wIupY14= google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17/go.mod h1:oQ5rr10WTTMvP4A36n8JpR1OrO1BEiV4f78CneXZxkA= diff --git a/docker-compose.yaml b/docker-compose.yaml index 21044c7c7..b99c89dc0 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -14,38 +14,26 @@ services: MYSQL_USER: admin MYSQL_PASSWORD: admin MYSQL_HOST: mysqldb - ports: - - "3306:3306" healthcheck: test: ["CMD", "mysql", "--user=admin", "--password=admin", "-e", "SELECT 1"] interval: 10s timeout: 10s retries: 3 start_period: 20s - container_name: mysqldb volumes: - var-run-mysqld:/var/run/mysqld redisdb: image: redis restart: always - ports: - - "6379:6379" - container_name: redisdb memcached: image: memcached:latest restart: always - ports: - - "11211:11211" - container_name: memcached postgres: image: postgres restart: always environment: POSTGRES_PASSWORD: root POSTGRES_USER: postgres - ports: - - "5432:5432" - container_name: postgres php: platform: ${PLATFORM:-} image: newrelic/nr-php-agent-builder:make-php-${PHP:-8.2}-${LIBC:-gnu}-${IMAGE_VERSION:-v1} @@ -106,7 +94,6 @@ services: working_dir: /usr/src/myapp stdin_open: true tty: true - container_name: agent-devenv profiles: ["dev"] volumes: diff --git a/docs/development.md b/docs/development.md index 11700cdee..ec42de64d 100644 --- a/docs/development.md +++ b/docs/development.md @@ -58,7 +58,7 @@ _(most operating systems package these with `-dev` or `-devel` suffixes)_ ### PHP -The PHP agent supports PHP versions `7.2`, `7.3`, `7.4`,`8.0`, `8.1`, '8.2', and `8.3`. +The PHP agent supports PHP versions `7.2`, `7.3`, `7.4`,`8.0`, `8.1`, `8.2`, `8.3` and `8.4`. ## Build the PHP Agent diff --git a/files/Dockerfile b/files/Dockerfile index 3081cf1ab..2f99740e3 100644 --- a/files/Dockerfile +++ b/files/Dockerfile @@ -9,7 +9,7 @@ ARG PHP_VER -FROM php:${PHP_VER:-8.3} +FROM php:${PHP_VER:-8.4} RUN docker-php-source extract @@ -89,7 +89,7 @@ COPY --from=composer ["/usr/bin/composer", "/usr/bin/composer"] # and 8.0 has problems with how the explanation for informational_schema # work (refer to bug https://bugs.mysql.com/bug.php?id=102536) so to run # the mysql tests a separate machine running mysql server 5.6 is required. -RUN docker-php-ext-install pdo pdo_mysql +RUN docker-php-ext-install pdo pdo_mysql pdo_pgsql # install redis extension required by test_redis: RUN \ @@ -142,16 +142,18 @@ ENV PHP_VER=${PHP_VER} ARG PS1 ENV PS1="New Relic > " -# QOL aliases -# `rebuild` - make clean + make agent + make tests -# `integ` - run all integration tests -RUN echo 'alias integ="/usr/src/myapp/bin/integration_runner -agent /usr/src/myapp/agent/.libs/newrelic.so"' >> ~/.bashrc \ - && echo 'alias rebuild="make -C agent clean && rm agent/Makefile && make && make tests"' >> ~/.bashrc - ARG USER=developer ARG UID=501 ARG GID=20 RUN useradd --uid ${UID} --gid ${GID} --shell /bin/bash --create-home ${USER} USER ${USER} +# QOL aliases +# `rebuild` - make clean + make agent + make tests +# `integ` - run all integration tests +RUN echo 'alias integ="/usr/src/myapp/bin/integration_runner -agent /usr/src/myapp/agent/.libs/newrelic.so"' >> ~/.bashrc \ + && echo 'alias rebuild="make -C agent clean && rm agent/Makefile && make && make tests"' >> ~/.bashrc WORKDIR /usr/src/myapp +# Avoid "fatal: detected dubious ownership in repository at '/usr/src/myapp/'" error +# when running git commands inside container with host volume mounted: +RUN git config --global --add safe.directory /usr/src/myapp/ CMD ["bash"] diff --git a/make/php_versions.mk b/make/php_versions.mk index e0a63e9b9..f28157f09 100644 --- a/make/php_versions.mk +++ b/make/php_versions.mk @@ -3,4 +3,4 @@ # SPDX-License-Identifier: Apache-2.0 # -PHP_VERSION_LIST=$${PHPS:-8.3 8.2 8.1 8.0 7.4 7.3 7.2} +PHP_VERSION_LIST=$${PHPS:-8.4 8.3 8.2 8.1 8.0 7.4 7.3 7.2} diff --git a/make/release.mk b/make/release.mk index 8eee97388..bb166f66e 100644 --- a/make/release.mk +++ b/make/release.mk @@ -163,6 +163,7 @@ release-$1-zts: Makefile agent | releases/$$(RELEASE_OS)/agent/$$(RELEASE_ARCH)/ endef +$(eval $(call RELEASE_AGENT_TARGET,8.4,20240924)) $(eval $(call RELEASE_AGENT_TARGET,8.3,20230831)) $(eval $(call RELEASE_AGENT_TARGET,8.2,20220829)) $(eval $(call RELEASE_AGENT_TARGET,8.1,20210902)) diff --git a/tests/include/config.php b/tests/include/config.php index 4cde7cfb2..399d15552 100644 --- a/tests/include/config.php +++ b/tests/include/config.php @@ -13,7 +13,7 @@ function isset_or($check, $alternate = NULL) $MYSQL_USER = isset_or('MYSQL_USER', 'root'); $MYSQL_PASSWD = isset_or('MYSQL_PASSWD', 'root'); -$MYSQL_DB = 'information_schema'; // TODO: MSL comment here. +$MYSQL_DB = isset_or('MYSQL_DB', 'information_schema'); $MYSQL_HOST = isset_or('MYSQL_HOST', 'localhost'); $MYSQL_PORT = isset_or('MYSQL_PORT', 3306); $MYSQL_SOCKET = isset_or('MYSQL_SOCKET', ''); @@ -75,6 +75,10 @@ function make_tracing_url($file) $PG_PORT = isset_or('PG_PORT', '5433'); $PG_CONNECTION = "host=$PG_HOST port=$PG_PORT user=$PG_USER password=$PG_PW connect_timeout=1"; +$PDO_PGSQL_DSN = 'pgsql:'; +$PDO_PGSQL_DSN .= 'host=' . $PG_HOST . ';'; +$PDO_PGSQL_DSN .= 'port=' . $PG_PORT . ';'; + // Header used to track whether or not our CAT instrumentation interferes with // other existing headers. define('CUSTOMER_HEADER', 'Customer-Header'); diff --git a/tests/include/guzzle.tar.bz2 b/tests/include/guzzle.tar.bz2 index 49e7b4ef2..a7ecfeb72 100644 Binary files a/tests/include/guzzle.tar.bz2 and b/tests/include/guzzle.tar.bz2 differ diff --git a/tests/include/monolog2.tar.bz2 b/tests/include/monolog2.tar.bz2 index 2b97f8938..a1c0578e4 100644 Binary files a/tests/include/monolog2.tar.bz2 and b/tests/include/monolog2.tar.bz2 differ diff --git a/tests/include/monolog3.tar.bz2 b/tests/include/monolog3.tar.bz2 index 2cce31210..783c067d6 100644 Binary files a/tests/include/monolog3.tar.bz2 and b/tests/include/monolog3.tar.bz2 differ diff --git a/tests/integration/api/error_group_callback/test_error_group_callback_error_web.php b/tests/integration/api/error_group_callback/test_error_group_callback_error_web.php index c4c02c418..3b82e16f9 100644 --- a/tests/integration/api/error_group_callback/test_error_group_callback_error_web.php +++ b/tests/integration/api/error_group_callback/test_error_group_callback_error_web.php @@ -8,6 +8,14 @@ Tests newrelic_set_error_group_callback() API for Web errors. */ +/*SKIPIF +=")) { + die("skip: newer test for PHPs 8.4+\n"); +} +*/ + + /*ENVIRONMENT REQUEST_METHOD=GET QUERY_STRING=foo=1&bar=2 diff --git a/tests/integration/api/error_group_callback/test_error_group_callback_error_web.php84.php b/tests/integration/api/error_group_callback/test_error_group_callback_error_web.php84.php new file mode 100644 index 000000000..e740c7613 --- /dev/null +++ b/tests/integration/api/error_group_callback/test_error_group_callback_error_web.php84.php @@ -0,0 +1,179 @@ + \/test_error_group_callback_error_web.php84.php\?foo=1&bar=2 +path => .*test_error_group_callback_error_web.php84.php +method => GET +status_code => 200 + +klass => E_USER_WARNING +message => I'M COVERED IN BEES +file => .*test_error_group_callback_error_web.php84.php +stack => \[" in trigger_error called at .*test_error_group_callback_error_web.php84.php \(.*\)"," in alpha called at .*test_error_group_callback_error_web.php84.php \(.*\)"\] +*/ + +/*EXPECT_METRICS +[ + "?? agent run id", + "?? timeframe start", + "?? timeframe stop", + [ + [{"name":"Apdex"}, [0, "??", "??", "??", "??", "??"]], + [{"name":"Apdex/Uri__FILE__"}, [0, "??", "??", "??", "??", "??"]], + [{"name":"DurationByCaller/Unknown/Unknown/Unknown/Unknown/all"}, [1, "??", "??", "??", "??", "??"]], + [{"name":"DurationByCaller/Unknown/Unknown/Unknown/Unknown/allWeb"}, [1, "??", "??", "??", "??", "??"]], + [{"name":"Errors/WebTransaction/Uri__FILE__"}, [1, "??", "??", "??", "??", "??"]], + [{"name":"Errors/all"}, [1, "??", "??", "??", "??", "??"]], + [{"name":"Errors/allWeb"}, [1, "??", "??", "??", "??", "??"]], + [{"name":"ErrorsByCaller/Unknown/Unknown/Unknown/Unknown/all"}, [1, "??", "??", "??", "??", "??"]], + [{"name":"ErrorsByCaller/Unknown/Unknown/Unknown/Unknown/allWeb"}, [1, "??", "??", "??", "??", "??"]], + [{"name":"HttpDispatcher"}, [1, "??", "??", "??", "??", "??"]], + [{"name":"Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name":"Supportability/Logging/Metrics/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name":"Supportability/api/set_error_group_callback"}, [1, 0, 0, 0, 0, 0]], + [{"name":"WebTransaction"}, [1, "??", "??", "??", "??", "??"]], + [{"name":"WebTransaction/Uri__FILE__"}, [1, "??", "??", "??", "??", "??"]], + [{"name":"WebTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], + [{"name":"WebTransactionTotalTime/Uri__FILE__"}, [1, "??", "??", "??", "??", "??"]], + [{"name":"Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]] + ] +] +*/ + + +/*EXPECT_ERROR_EVENTS +[ + "?? agent run id", + { + "reservoir_size": 100, + "events_seen": 1 + }, + [ + [ + { + "type": "TransactionError", + "timestamp": "??", + "error.class": "E_USER_WARNING", + "error.message": "I'M COVERED IN BEES", + "transactionName": "WebTransaction\/Uri__FILE__", + "duration": "??", + "nr.transactionGuid": "??", + "guid": "??", + "sampled": true, + "priority": "??", + "traceId": "??", + "spanId": "??" + }, + {}, + { + "response.headers.contentType": "application\/json", + "http.statusCode": 200, + "response.statusCode": 200, + "httpResponseCode": "200", + "request.uri": "__FILE__", + "error.group.name": "CUSTOM ERROR GROUP NAME", + "SERVER_NAME": "127.0.0.1", + "request.method": "GET", + "request.headers.host": "127.0.0.1" + } + ] + ] +] +*/ + +/*EXPECT_TRACED_ERRORS +[ + "?? agent run id", + [ + [ + "??", + "WebTransaction\/Uri__FILE__", + "I'M COVERED IN BEES", + "E_USER_WARNING", + { + "stack_trace": [ + " in trigger_error called at __FILE__ (??)", + " in alpha called at __FILE__ (??)" + ], + "agentAttributes": { + "response.headers.contentType": "application\/json", + "http.statusCode": 200, + "response.statusCode": 200, + "httpResponseCode": "200", + "request.uri": "__FILE__", + "error.group.name": "CUSTOM ERROR GROUP NAME", + "SERVER_NAME": "127.0.0.1", + "request.method": "GET", + "request.headers.host": "127.0.0.1" + }, + "intrinsics": { + "totalTime": "??", + "cpu_time": "??", + "cpu_user_time": "??", + "cpu_sys_time": "??", + "guid": "??", + "sampled": true, + "priority": "??", + "traceId": "??" + }, + "request_uri": "__FILE__" + }, + "?? transaction ID" + ] + ] +] +*/ + +require_once(realpath(dirname(__FILE__)) . '/../../../include/tap.php'); + +header('Content-Type: text/html'); +header('Content-Type: application/json'); + +function alpha() +{ + trigger_error("I'M COVERED IN BEES", E_USER_WARNING); +} + +$callback = function($txndata, $errdata) +{ + foreach($txndata as $tkey => $tdata) { + echo "$tkey => $tdata\n"; + }; + + echo "\n"; + + foreach($errdata as $ekey => $edata) { + echo "$ekey => $edata\n"; + }; + + $fingerprint = "CUSTOM ERROR GROUP NAME"; + return $fingerprint; +}; + +$result = newrelic_set_error_group_callback($callback); + +tap_assert($result, "callback registered"); + +alpha(); diff --git a/tests/integration/api/notice_error/test_good_4_args_error_handler.php b/tests/integration/api/notice_error/test_good_4_args_error_handler.php index 6562e4f7a..323bce533 100644 --- a/tests/integration/api/notice_error/test_good_4_args_error_handler.php +++ b/tests/integration/api/notice_error/test_good_4_args_error_handler.php @@ -142,8 +142,8 @@ */ function a() { - trigger_error("4 arg error", E_USER_ERROR); + trigger_error("4 arg error", E_USER_WARNING); } -set_error_handler('newrelic_notice_error', E_USER_ERROR); +set_error_handler('newrelic_notice_error', E_USER_WARNING); a(); diff --git a/tests/integration/api/notice_error/test_good_5_args_error_handler.php b/tests/integration/api/notice_error/test_good_5_args_error_handler.php index 17772271c..485b2f500 100644 --- a/tests/integration/api/notice_error/test_good_5_args_error_handler.php +++ b/tests/integration/api/notice_error/test_good_5_args_error_handler.php @@ -142,8 +142,8 @@ */ function a() { - trigger_error("5 arg error", E_USER_ERROR); + trigger_error("5 arg error", E_USER_WARNING); } -set_error_handler('newrelic_notice_error', E_USER_ERROR); +set_error_handler('newrelic_notice_error', E_USER_WARNING); a(); diff --git a/tests/integration/api/notice_error/test_prioritize_api.php b/tests/integration/api/notice_error/test_prioritize_api.php index 92c2f04ec..4bf0418f8 100644 --- a/tests/integration/api/notice_error/test_prioritize_api.php +++ b/tests/integration/api/notice_error/test_prioritize_api.php @@ -84,7 +84,7 @@ function gamma($password) function omega() { - trigger_error("ignore me", E_USER_ERROR); + trigger_error("ignore me", E_USER_WARNING); } gamma('my super secret password that New Relic cannot know'); diff --git a/tests/integration/api/notice_error/test_priority.php b/tests/integration/api/notice_error/test_priority.php index c33fdeb12..806c11f9e 100644 --- a/tests/integration/api/notice_error/test_priority.php +++ b/tests/integration/api/notice_error/test_priority.php @@ -16,7 +16,7 @@ "?? when", "OtherTransaction/php__FILE__", "highest priority", - "E_USER_ERROR", + "E_USER_WARNING", { "stack_trace": [ " in trigger_error called at __FILE__ (??)" @@ -42,7 +42,7 @@ { "type": "TransactionError", "timestamp": "??", - "error.class": "E_USER_ERROR", + "error.class": "E_USER_WARNING", "error.message": "highest priority", "transactionName": "OtherTransaction\/php__FILE__", "duration": "??", @@ -60,9 +60,7 @@ ] */ -/* - * Cause three errors to be noticed in order of decreasing priority. - */ -trigger_error ("highest priority", E_USER_ERROR); -trigger_error ("goldilox", E_USER_WARNING); trigger_error ("lowest priority", E_USER_NOTICE); +trigger_error ("goldilox", E_USER_DEPRECATED); +trigger_error ("highest priority", E_USER_WARNING); +trigger_error ("goldilox", E_USER_DEPRECATED); diff --git a/tests/integration/api/set_user_id/test_set_user_id_error.php b/tests/integration/api/set_user_id/test_set_user_id_error.php index 1632bbca9..dbf782bdb 100644 --- a/tests/integration/api/set_user_id/test_set_user_id_error.php +++ b/tests/integration/api/set_user_id/test_set_user_id_error.php @@ -44,7 +44,7 @@ "??", "OtherTransaction\/php__FILE__", "I'M COVERED IN BEES", - "E_USER_ERROR", + "E_USER_WARNING", { "stack_trace": [ " in trigger_error called at __FILE__ (??)", @@ -82,7 +82,7 @@ { "type": "TransactionError", "timestamp": "??", - "error.class": "E_USER_ERROR", + "error.class": "E_USER_WARNING", "error.message": "I'M COVERED IN BEES", "transactionName": "OtherTransaction\/php__FILE__", "duration": "??", @@ -106,7 +106,7 @@ function alpha() { - trigger_error("I'M COVERED IN BEES", E_USER_ERROR); + trigger_error("I'M COVERED IN BEES", E_USER_WARNING); }; $uuid = "0123456789abcdefghijlkmnopqrstuvwxyz"; diff --git a/tests/integration/attributes/test_transaction_closure_clm.php b/tests/integration/attributes/test_transaction_closure_clm.php index cb6759465..369c7cc49 100644 --- a/tests/integration/attributes/test_transaction_closure_clm.php +++ b/tests/integration/attributes/test_transaction_closure_clm.php @@ -14,6 +14,9 @@ class name, and lineno for closures. if (version_compare(PHP_VERSION, "7.0", "<")) { die("skip: CLM for PHP 5 not supported\n"); } +if (version_compare(PHP_VERSION, "8.4", ">=")) { + die("skip: newer test for PHP 8.4+\n"); +} */ /*INI @@ -94,7 +97,7 @@ class name, and lineno for closures. }, {}, { - "code.lineno": 151, + "code.lineno": 154, "code.filepath": "__FILE__", "code.function": "{closure}" } @@ -115,7 +118,7 @@ class name, and lineno for closures. }, {}, { - "code.lineno": 159, + "code.lineno": 162, "code.filepath": "__FILE__", "code.function": "{closure}" } @@ -136,7 +139,7 @@ class name, and lineno for closures. }, {}, { - "code.lineno": 159, + "code.lineno": 162, "code.filepath": "__FILE__", "code.function": "{closure}" } diff --git a/tests/integration/attributes/test_transaction_closure_clm.php84.php b/tests/integration/attributes/test_transaction_closure_clm.php84.php new file mode 100644 index 000000000..7a30585c4 --- /dev/null +++ b/tests/integration/attributes/test_transaction_closure_clm.php84.php @@ -0,0 +1,167 @@ +=")) { + die("skip: newer test for PHP 8.4+\n"); +} */ /*INI diff --git a/tests/integration/attributes/test_transaction_closure_clm_off.php84.php b/tests/integration/attributes/test_transaction_closure_clm_off.php84.php new file mode 100644 index 000000000..dda499cb6 --- /dev/null +++ b/tests/integration/attributes/test_transaction_closure_clm_off.php84.php @@ -0,0 +1,154 @@ +=")) { + die("skip: PHP >= 8.4.0 not supported\n"); +} */ /*INI diff --git a/tests/integration/errors/test_E_DEPRECATED_2.php84.php b/tests/integration/errors/test_E_DEPRECATED_2.php84.php new file mode 100644 index 000000000..afb0b9ca6 --- /dev/null +++ b/tests/integration/errors/test_E_DEPRECATED_2.php84.php @@ -0,0 +1,81 @@ +=")) { + die("skip: E_USER_ERROR deprecated in PHP 8.4\n"); +} +*/ + /*INI display_errors=1 log_errors=0 diff --git a/tests/integration/errors/test_uncaught_handled_exception_02.php b/tests/integration/errors/test_uncaught_handled_exception_02.php index 5fc475dca..059686adb 100644 --- a/tests/integration/errors/test_uncaught_handled_exception_02.php +++ b/tests/integration/errors/test_uncaught_handled_exception_02.php @@ -26,6 +26,9 @@ if (version_compare(PHP_VERSION, "8.0", "<")) { die("skip: PHP < 8.0.0 not supported\n"); } +if (version_compare(PHP_VERSION, "8.4", ">=")) { + die("skip: newer test for PHP 8.4+\n"); +} */ diff --git a/tests/integration/errors/test_uncaught_handled_exception_02.php84.php b/tests/integration/errors/test_uncaught_handled_exception_02.php84.php new file mode 100644 index 000000000..01a5df516 --- /dev/null +++ b/tests/integration/errors/test_uncaught_handled_exception_02.php84.php @@ -0,0 +1,169 @@ +query('select * from tables limit 1;'); + $result = $conn->query('select * from information_schema.tables limit 1;'); } test_slow_sql(); diff --git a/tests/integration/external/curl_exec/test_dt_simple.php b/tests/integration/external/curl_exec/test_dt_simple.php index 5574bcf38..b7009267a 100644 --- a/tests/integration/external/curl_exec/test_dt_simple.php +++ b/tests/integration/external/curl_exec/test_dt_simple.php @@ -28,6 +28,36 @@ /*EXPECT_RESPONSE_HEADERS */ +/*EXPECT_ANALYTICS_EVENTS +[ + "?? agent run id", + { + "reservoir_size": 50, + "events_seen": 1 + }, + [ + [ + { + "type": "Transaction", + "name": "OtherTransaction\/php__FILE__", + "timestamp": "??", + "duration": "??", + "totalTime": "??", + "externalDuration": "??", + "externalCallCount": 1, + "guid": "??", + "sampled": true, + "priority": "??", + "traceId": "??", + "error": false + }, + {}, + {} + ] + ] +] +*/ + /*EXPECT_TRACED_ERRORS null */ diff --git a/tests/integration/external/guzzle7/skipif.inc b/tests/integration/external/guzzle7/skipif.inc index 91ee13a0b..e8ede4887 100644 --- a/tests/integration/external/guzzle7/skipif.inc +++ b/tests/integration/external/guzzle7/skipif.inc @@ -6,8 +6,8 @@ require_once(realpath(dirname(__FILE__)) . '/../../../include/unpack_guzzle.php'); -if (version_compare(phpversion(), '7.2.5', '<')) { - die("skip: PHP >= 7.2.5 required\n"); +if (version_compare(phpversion(), '8.1', '<')) { + die("skip: PHP >= 8.1 required\n"); } /* diff --git a/tests/integration/external/guzzle7/test_spans_are_created_correctly.php b/tests/integration/external/guzzle7/test_spans_are_created_correctly.php index 87388da64..4ec83c617 100644 --- a/tests/integration/external/guzzle7/test_spans_are_created_correctly.php +++ b/tests/integration/external/guzzle7/test_spans_are_created_correctly.php @@ -19,6 +19,35 @@ newrelic.transaction_tracer.detail = 0 */ +/*EXPECT_ANALYTICS_EVENTS +[ + "?? agent run id", + { + "reservoir_size": 50, + "events_seen": 1 + }, + [ + [ + { + "type": "Transaction", + "name": "OtherTransaction\/php__FILE__", + "timestamp": "??", + "duration": "??", + "totalTime": "??", + "externalDuration": "??", + "externalCallCount": 1, + "guid": "??", + "sampled": true, + "priority": "??", + "traceId": "??", + "error": false + }, + {}, + {} + ] + ] +] +*/ /*EXPECT_SPAN_EVENTS_LIKE [ diff --git a/tests/integration/external/guzzle7/test_uncaught_bad_response_exception_sync.php b/tests/integration/external/guzzle7/test_uncaught_bad_response_exception_sync.php index 88e2acdaf..98172f8ef 100644 --- a/tests/integration/external/guzzle7/test_uncaught_bad_response_exception_sync.php +++ b/tests/integration/external/guzzle7/test_uncaught_bad_response_exception_sync.php @@ -81,6 +81,39 @@ ] */ +/*EXPECT_ANALYTICS_EVENTS +[ + "?? agent run id", + { + "reservoir_size": 50, + "events_seen": 1 + }, + [ + [ + { + "type": "Transaction", + "name": "OtherTransaction\/php__FILE__", + "timestamp": "??", + "duration": "??", + "totalTime": "??", + "externalDuration": "??", + "externalCallCount": 1, + "guid": "??", + "sampled": true, + "priority": "??", + "traceId": "??", + "error": true + }, + {}, + { + "errorType": "GuzzleHttp\\Exception\\BadResponseException", + "errorMessage": "Uncaught exception 'GuzzleHttp\\Exception\\BadResponseException' with message 'ClientException' in __FILE__:??" + } + ] + ] +] +*/ + /*EXPECT_TRACED_ERRORS [ "?? agent run id", diff --git a/tests/integration/jit/function/test_span_events_are_created_upon_caught_error.php b/tests/integration/jit/function/test_span_events_are_created_upon_caught_error.php index bca70be7e..0c113528a 100644 --- a/tests/integration/jit/function/test_span_events_are_created_upon_caught_error.php +++ b/tests/integration/jit/function/test_span_events_are_created_upon_caught_error.php @@ -15,6 +15,9 @@ =")) { + die("skip: newer test for PHP 8.4+\n"); +} */ diff --git a/tests/integration/jit/function/test_span_events_are_created_upon_caught_error.php84.php b/tests/integration/jit/function/test_span_events_are_created_upon_caught_error.php84.php new file mode 100644 index 000000000..f5ef9e41e --- /dev/null +++ b/tests/integration/jit/function/test_span_events_are_created_upon_caught_error.php84.php @@ -0,0 +1,196 @@ + 'FakeDB', + ) +); +a(); diff --git a/tests/integration/jit/function/test_span_events_are_created_upon_uncaught_error.php b/tests/integration/jit/function/test_span_events_are_created_upon_uncaught_error.php index c3f064b6d..cc1fc14b3 100644 --- a/tests/integration/jit/function/test_span_events_are_created_upon_uncaught_error.php +++ b/tests/integration/jit/function/test_span_events_are_created_upon_uncaught_error.php @@ -13,6 +13,9 @@ =")) { + die("skip: newer test for PHPs 8.4+\n"); +} + +*/ + +/*INI +newrelic.distributed_tracing_enabled=1 +newrelic.transaction_tracer.threshold = 0 +newrelic.span_events_enabled=1 +newrelic.cross_application_tracer.enabled = false +display_errors=1 +log_errors=0 +error_reporting = E_ALL +opcache.enable=1 +opcache.enable_cli=1 +opcache.file_update_protection=0 +opcache.jit_buffer_size=32M +opcache.jit=function +*/ + +/*PHPMODULES +zend_extension=opcache.so +*/ + +/*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": "Datastore\/statement\/FakeDB\/other\/other", + "guid": "??", + "timestamp": "??", + "duration": "??", + "category": "datastore", + "parentId": "??", + "span.kind": "client", + "component": "FakeDB" + }, + {}, + { + "db.instance": "unknown", + "peer.hostname": "unknown", + "peer.address": "unknown:unknown" + } + ], + [ + { + "type": "Span", + "traceId": "??", + "transactionId": "??", + "sampled": true, + "priority": "??", + "name": "Custom\/a", + "guid": "??", + "timestamp": "??", + "duration": "??", + "category": "generic", + "parentId": "??" + }, + {}, + { + "error.message": "foo", + "error.class": "E_USER_ERROR", + "code.lineno": "??", + "code.filepath": "__FILE__", + "code.function": "??" + } + ] + ] +] +*/ + +/*EXPECT_REGEX +^\s*(PHP )?Fatal error:\s*foo in .*? on line [0-9]+\s*$ +*/ + +function a() +{ + time_nanosleep(0, 100000000); + trigger_error('foo', E_USER_ERROR); +} + +newrelic_record_datastore_segment( + function () { + time_nanosleep(0, 100000000); + }, array( + 'product' => 'FakeDB', + ) +); +a(); + +echo 'this should never be printed'; diff --git a/tests/integration/jit/function/test_span_events_are_created_upon_uncaught_handled_exception.php b/tests/integration/jit/function/test_span_events_are_created_upon_uncaught_handled_exception.php index 2381e2045..7624a2a4b 100644 --- a/tests/integration/jit/function/test_span_events_are_created_upon_uncaught_handled_exception.php +++ b/tests/integration/jit/function/test_span_events_are_created_upon_uncaught_handled_exception.php @@ -15,6 +15,9 @@ =")) { + die("skip: newer test for PHP 8.4+\n"); +} */ diff --git a/tests/integration/jit/function/test_span_events_are_created_upon_uncaught_handled_exception.php84.php b/tests/integration/jit/function/test_span_events_are_created_upon_uncaught_handled_exception.php84.php new file mode 100644 index 000000000..28099b17c --- /dev/null +++ b/tests/integration/jit/function/test_span_events_are_created_upon_uncaught_handled_exception.php84.php @@ -0,0 +1,200 @@ + 'FakeDB', + ) +); +a(); + +echo 'this should never be printed'; diff --git a/tests/integration/jit/tracing/test_span_events_are_created_upon_caught_error.php b/tests/integration/jit/tracing/test_span_events_are_created_upon_caught_error.php index ebde4a26b..74e03bf46 100644 --- a/tests/integration/jit/tracing/test_span_events_are_created_upon_caught_error.php +++ b/tests/integration/jit/tracing/test_span_events_are_created_upon_caught_error.php @@ -15,6 +15,9 @@ =")) { + die("skip: newer test for PHP 8.4+\n"); +} */ diff --git a/tests/integration/jit/tracing/test_span_events_are_created_upon_caught_error.php84.php b/tests/integration/jit/tracing/test_span_events_are_created_upon_caught_error.php84.php new file mode 100644 index 000000000..eeb18dc14 --- /dev/null +++ b/tests/integration/jit/tracing/test_span_events_are_created_upon_caught_error.php84.php @@ -0,0 +1,195 @@ + 'FakeDB', + ) +); +a(); diff --git a/tests/integration/jit/tracing/test_span_events_are_created_upon_uncaught_error.php b/tests/integration/jit/tracing/test_span_events_are_created_upon_uncaught_error.php index ee1a578ae..51f8b899a 100644 --- a/tests/integration/jit/tracing/test_span_events_are_created_upon_uncaught_error.php +++ b/tests/integration/jit/tracing/test_span_events_are_created_upon_uncaught_error.php @@ -13,6 +13,9 @@ =")) { + die("skip: newer test for PHPs 8.4+\n"); +} */ diff --git a/tests/integration/jit/tracing/test_span_events_are_created_upon_uncaught_error.php84.php b/tests/integration/jit/tracing/test_span_events_are_created_upon_uncaught_error.php84.php new file mode 100644 index 000000000..54660f8a3 --- /dev/null +++ b/tests/integration/jit/tracing/test_span_events_are_created_upon_uncaught_error.php84.php @@ -0,0 +1,135 @@ + 'FakeDB', + ) +); +a(); diff --git a/tests/integration/jit/tracing/test_span_events_are_created_upon_uncaught_handled_exception.php b/tests/integration/jit/tracing/test_span_events_are_created_upon_uncaught_handled_exception.php index 395b1231f..7444c28e7 100644 --- a/tests/integration/jit/tracing/test_span_events_are_created_upon_uncaught_handled_exception.php +++ b/tests/integration/jit/tracing/test_span_events_are_created_upon_uncaught_handled_exception.php @@ -15,6 +15,9 @@ =")) { + die("skip: newer test for PHP 8.4+\n"); +} */ diff --git a/tests/integration/jit/tracing/test_span_events_are_created_upon_uncaught_handled_exception.php84.php b/tests/integration/jit/tracing/test_span_events_are_created_upon_uncaught_handled_exception.php84.php new file mode 100644 index 000000000..922a0c5a7 --- /dev/null +++ b/tests/integration/jit/tracing/test_span_events_are_created_upon_uncaught_handled_exception.php84.php @@ -0,0 +1,197 @@ + 'FakeDB', + ) +); +a(); + +echo 'this should never be printed'; diff --git a/tests/integration/opcache/disabled/test_span_events_are_created_upon_caught_error.php b/tests/integration/opcache/disabled/test_span_events_are_created_upon_caught_error.php index d61b7fea0..ce62bfc12 100644 --- a/tests/integration/opcache/disabled/test_span_events_are_created_upon_caught_error.php +++ b/tests/integration/opcache/disabled/test_span_events_are_created_upon_caught_error.php @@ -15,6 +15,9 @@ =")) { + die("skip: newer test for PHP 8.4+\n"); +} */ diff --git a/tests/integration/opcache/disabled/test_span_events_are_created_upon_caught_error.php84.php b/tests/integration/opcache/disabled/test_span_events_are_created_upon_caught_error.php84.php new file mode 100644 index 000000000..86c24a776 --- /dev/null +++ b/tests/integration/opcache/disabled/test_span_events_are_created_upon_caught_error.php84.php @@ -0,0 +1,193 @@ + 'FakeDB', + ) +); +a(); diff --git a/tests/integration/opcache/disabled/test_span_events_are_created_upon_uncaught_error.php b/tests/integration/opcache/disabled/test_span_events_are_created_upon_uncaught_error.php index bc42257cc..49320f19b 100644 --- a/tests/integration/opcache/disabled/test_span_events_are_created_upon_uncaught_error.php +++ b/tests/integration/opcache/disabled/test_span_events_are_created_upon_uncaught_error.php @@ -13,6 +13,9 @@ =")) { + die("skip: newer test for PHPs 8.4+\n"); +} */ diff --git a/tests/integration/opcache/disabled/test_span_events_are_created_upon_uncaught_error.php84.php b/tests/integration/opcache/disabled/test_span_events_are_created_upon_uncaught_error.php84.php new file mode 100644 index 000000000..35014d54f --- /dev/null +++ b/tests/integration/opcache/disabled/test_span_events_are_created_upon_uncaught_error.php84.php @@ -0,0 +1,132 @@ + 'FakeDB', + ) +); +a(); diff --git a/tests/integration/opcache/disabled/test_span_events_are_created_upon_uncaught_handled_exception.php b/tests/integration/opcache/disabled/test_span_events_are_created_upon_uncaught_handled_exception.php index d45a094b8..76dd4fe41 100644 --- a/tests/integration/opcache/disabled/test_span_events_are_created_upon_uncaught_handled_exception.php +++ b/tests/integration/opcache/disabled/test_span_events_are_created_upon_uncaught_handled_exception.php @@ -17,6 +17,9 @@ if (version_compare(PHP_VERSION, "8.0", "<")) { die("skip: PHP < 7.0.0 not supported\n"); } +if (version_compare(PHP_VERSION, "8.4", ">=")) { + die("skip: newer test for PHP 8.4+\n"); +} require('skipif.inc'); diff --git a/tests/integration/opcache/disabled/test_span_events_are_created_upon_uncaught_handled_exception.php84.php b/tests/integration/opcache/disabled/test_span_events_are_created_upon_uncaught_handled_exception.php84.php new file mode 100644 index 000000000..e4be687b9 --- /dev/null +++ b/tests/integration/opcache/disabled/test_span_events_are_created_upon_uncaught_handled_exception.php84.php @@ -0,0 +1,197 @@ + 'FakeDB', + ) +); +a(); + +echo 'this should never be printed'; diff --git a/tests/integration/pdo/mysql/base-class/test_instance_reporting_port.php b/tests/integration/pdo/mysql/base-class/test_instance_reporting_port.php new file mode 100644 index 000000000..0742b5461 --- /dev/null +++ b/tests/integration/pdo/mysql/base-class/test_instance_reporting_port.php @@ -0,0 +1,157 @@ +", + "?? SQL id", + "DROP TABLE ENV[DATASTORE_COLLECTION];", + "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/drop", + 1, + "?? total time", + "?? min time", + "?? max time", + { + "backtrace": [ + "/ in PDO::exec called at .*\/", + " in test_instance_reporting called at __FILE__ (??)" + ], + "host": "ENV[MYSQL_HOST]", + "port_path_or_id": "ENV[MYSQL_PORT]", + "database_name": "ENV[MYSQL_DB]" + } + ], + [ + "OtherTransaction/php__FILE__", + "", + "?? SQL id", + "CREATE TABLE ENV[DATASTORE_COLLECTION] (id INT, description VARCHAR(?));", + "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/create", + 1, + "?? total time", + "?? min time", + "?? max time", + { + "backtrace": [ + "/ in PDO::exec called at .*\/", + " in test_instance_reporting called at __FILE__ (??)" + ], + "host": "ENV[MYSQL_HOST]", + "port_path_or_id": "ENV[MYSQL_PORT]", + "database_name": "ENV[MYSQL_DB]" + } + ] + ] +] +*/ + +/*EXPECT_SPAN_EVENTS_LIKE +[ + [ + { + "category": "datastore", + "type": "Span", + "guid": "??", + "traceId": "??", + "transactionId": "??", + "name": "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/create", + "timestamp": "??", + "duration": "??", + "priority": "??", + "sampled": true, + "parentId": "??", + "span.kind": "client", + "component": "ENV[DATASTORE_PRODUCT]" + }, + {}, + { + "peer.hostname": "ENV[MYSQL_HOST]", + "peer.address": "ENV[MYSQL_HOST]:ENV[MYSQL_PORT]", + "db.instance": "ENV[MYSQL_DB]", + "db.statement": "CREATE TABLE ENV[DATASTORE_COLLECTION] (id INT, description VARCHAR(?));" + } + ], + [ + { + "category": "datastore", + "type": "Span", + "guid": "??", + "traceId": "??", + "transactionId": "??", + "name": "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/drop", + "timestamp": "??", + "duration": "??", + "priority": "??", + "sampled": true, + "parentId": "??", + "span.kind": "client", + "component": "ENV[DATASTORE_PRODUCT]" + }, + {}, + { + "peer.hostname": "ENV[MYSQL_HOST]", + "peer.address": "ENV[MYSQL_HOST]:ENV[MYSQL_PORT]", + "db.instance": "ENV[MYSQL_DB]", + "db.statement": "DROP TABLE ENV[DATASTORE_COLLECTION];" + } + ] +] +*/ + +require_once(realpath (dirname ( __FILE__ )) . '/../../test_instance_reporting.inc'); +require_once(realpath (dirname ( __FILE__ )) . '/../../../../include/config.php'); + +test_instance_reporting(new PDO($PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD), 0); diff --git a/tests/integration/pdo/mysql/base-class/test_instance_reporting_socket.php b/tests/integration/pdo/mysql/base-class/test_instance_reporting_socket.php new file mode 100644 index 000000000..95177d7c7 --- /dev/null +++ b/tests/integration/pdo/mysql/base-class/test_instance_reporting_socket.php @@ -0,0 +1,160 @@ +", + "?? SQL id", + "DROP TABLE ENV[DATASTORE_COLLECTION];", + "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/drop", + 1, + "?? total time", + "?? min time", + "?? max time", + { + "backtrace": [ + "/ in PDO::exec called at .*\/", + " in test_instance_reporting called at __FILE__ (??)" + ], + "host": "__HOST__", + "port_path_or_id": "ENV[MYSQL_SOCKET]", + "database_name": "ENV[MYSQL_DB]" + } + ], + [ + "OtherTransaction/php__FILE__", + "", + "?? SQL id", + "CREATE TABLE ENV[DATASTORE_COLLECTION] (id INT, description VARCHAR(?));", + "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/create", + 1, + "?? total time", + "?? min time", + "?? max time", + { + "backtrace": [ + "/ in PDO::exec called at .*\/", + " in test_instance_reporting called at __FILE__ (??)" + ], + "host": "__HOST__", + "port_path_or_id": "ENV[MYSQL_SOCKET]", + "database_name": "ENV[MYSQL_DB]" + } + ] + ] +] +*/ + +/*EXPECT_SPAN_EVENTS_LIKE +[ + [ + { + "category": "datastore", + "type": "Span", + "guid": "??", + "traceId": "??", + "transactionId": "??", + "name": "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/create", + "timestamp": "??", + "duration": "??", + "priority": "??", + "sampled": true, + "parentId": "??", + "span.kind": "client", + "component": "ENV[DATASTORE_PRODUCT]" + }, + {}, + { + "peer.hostname": "__HOST__", + "peer.address": "__HOST__:ENV[MYSQL_SOCKET]", + "db.instance": "ENV[MYSQL_DB]", + "db.statement": "CREATE TABLE ENV[DATASTORE_COLLECTION] (id INT, description VARCHAR(?));" + } + ], + [ + { + "category": "datastore", + "type": "Span", + "guid": "??", + "traceId": "??", + "transactionId": "??", + "name": "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/drop", + "timestamp": "??", + "duration": "??", + "priority": "??", + "sampled": true, + "parentId": "??", + "span.kind": "client", + "component": "ENV[DATASTORE_PRODUCT]" + }, + {}, + { + "peer.hostname": "__HOST__", + "peer.address": "__HOST__:ENV[MYSQL_SOCKET]", + "db.instance": "ENV[MYSQL_DB]", + "db.statement": "DROP TABLE ENV[DATASTORE_COLLECTION];" + } + ] +] +*/ + +require_once(realpath (dirname ( __FILE__ )) . '/../../test_instance_reporting.inc'); +require_once(realpath (dirname ( __FILE__ )) . '/../../../../include/config.php'); + +$DSN = 'mysql:'; +$DSN .= 'unix_socket=' . $MYSQL_SOCKET . ';'; +$DSN .= 'dbname=' . $MYSQL_DB . ';'; + +test_instance_reporting(new PDO($DSN, $MYSQL_USER, $MYSQL_PASSWD), 0); diff --git a/tests/integration/pdo/mysql/base-class/test_prepared_stmt_basic.php b/tests/integration/pdo/mysql/base-class/test_prepared_stmt_basic.php new file mode 100644 index 000000000..93e54a033 --- /dev/null +++ b/tests/integration/pdo/mysql/base-class/test_prepared_stmt_basic.php @@ -0,0 +1,110 @@ +", + "?? SQL id", + "select * from information_schema.tables limit ?;", + "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/select", + 1, + "?? total time", + "?? min time", + "?? max time", + { + "backtrace": [ + "/ in PDOStatement::execute called at .*\/", + " in test_prepared_stmt called at __FILE__ (??)" + ], + "explain_plan": "??" + } + ] + ] +] +*/ + +// peer.address is unknown:unknown because instance_reporting is disabled +/*EXPECT_SPAN_EVENTS_LIKE +[ + [ + { + "category": "datastore", + "type": "Span", + "guid": "??", + "traceId": "??", + "transactionId": "??", + "name": "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/select", + "timestamp": "??", + "duration": "??", + "priority": "??", + "sampled": true, + "parentId": "??", + "span.kind": "client", + "component": "ENV[DATASTORE_PRODUCT]" + }, + {}, + { + "peer.address": "unknown:unknown", + "db.statement": "select * from information_schema.tables limit ?;" + } + ] +] +*/ + +require_once(realpath (dirname ( __FILE__ )) . '/../../test_prepared_stmt_basic.inc'); +require_once(realpath (dirname ( __FILE__ )) . '/../../../../include/config.php'); + +$query = 'select * from information_schema.tables limit 1;'; +test_prepared_stmt(new PDO($PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD), $query); diff --git a/tests/integration/pdo/mysql/base-class/test_prepared_stmt_bind_value.php b/tests/integration/pdo/mysql/base-class/test_prepared_stmt_bind_value.php new file mode 100644 index 000000000..34868e9ec --- /dev/null +++ b/tests/integration/pdo/mysql/base-class/test_prepared_stmt_bind_value.php @@ -0,0 +1,111 @@ +", + "?? SQL id", + "select * from information_schema.tables where table_name = ? limit ?;", + "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/select", + 1, + "?? total time", + "?? min time", + "?? max time", + { + "backtrace": [ + "/ in PDOStatement::execute called at .*\/", + " in test_prepared_stmt called at __FILE__ (??)" + ], + "explain_plan": "??" + } + ] + ] +] +*/ + +// peer.address is unknown:unknown because instance_reporting is disabled +/*EXPECT_SPAN_EVENTS_LIKE +[ + [ + { + "category": "datastore", + "type": "Span", + "guid": "??", + "traceId": "??", + "transactionId": "??", + "name": "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/select", + "timestamp": "??", + "duration": "??", + "priority": "??", + "sampled": true, + "parentId": "??", + "span.kind": "client", + "component": "ENV[DATASTORE_PRODUCT]" + }, + {}, + { + "peer.address": "unknown:unknown", + "db.statement": "select * from information_schema.tables where table_name = ? limit ?;" + } + ] +] +*/ + +require_once(realpath (dirname ( __FILE__ )) . '/../../test_prepared_stmt_bind_value.inc'); +require_once(realpath (dirname ( __FILE__ )) . '/../../../../include/config.php'); + +$query = 'select * from information_schema.tables where table_name = ? limit 1;'; +test_prepared_stmt(new PDO($PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD), $query); diff --git a/tests/integration/pdo/mysql/base-class/test_query_1_arg.php b/tests/integration/pdo/mysql/base-class/test_query_1_arg.php new file mode 100644 index 000000000..65a1da4fa --- /dev/null +++ b/tests/integration/pdo/mysql/base-class/test_query_1_arg.php @@ -0,0 +1,52 @@ +", + "?? SQL id", + "DROP TABLE ENV[DATASTORE_COLLECTION];", + "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/drop", + 1, + "?? total time", + "?? min time", + "?? max time", + { + "backtrace": [ + "/ in PDO::exec called at .*\/", + " in test_instance_reporting called at __FILE__ (??)" + ], + "host": "ENV[MYSQL_HOST]", + "port_path_or_id": "ENV[MYSQL_PORT]", + "database_name": "ENV[MYSQL_DB]" + } + ], + [ + "OtherTransaction/php__FILE__", + "", + "?? SQL id", + "CREATE TABLE ENV[DATASTORE_COLLECTION] (id INT, description VARCHAR(?));", + "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/create", + 1, + "?? total time", + "?? min time", + "?? max time", + { + "backtrace": [ + "/ in PDO::exec called at .*\/", + " in test_instance_reporting called at __FILE__ (??)" + ], + "host": "ENV[MYSQL_HOST]", + "port_path_or_id": "ENV[MYSQL_PORT]", + "database_name": "ENV[MYSQL_DB]" + } + ] + ] +] +*/ + +/*EXPECT_SPAN_EVENTS_LIKE +[ + [ + { + "category": "datastore", + "type": "Span", + "guid": "??", + "traceId": "??", + "transactionId": "??", + "name": "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/create", + "timestamp": "??", + "duration": "??", + "priority": "??", + "sampled": true, + "parentId": "??", + "span.kind": "client", + "component": "ENV[DATASTORE_PRODUCT]" + }, + {}, + { + "peer.hostname": "ENV[MYSQL_HOST]", + "peer.address": "ENV[MYSQL_HOST]:ENV[MYSQL_PORT]", + "db.instance": "ENV[MYSQL_DB]", + "db.statement": "CREATE TABLE ENV[DATASTORE_COLLECTION] (id INT, description VARCHAR(?));" + } + ], + [ + { + "category": "datastore", + "type": "Span", + "guid": "??", + "traceId": "??", + "transactionId": "??", + "name": "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/drop", + "timestamp": "??", + "duration": "??", + "priority": "??", + "sampled": true, + "parentId": "??", + "span.kind": "client", + "component": "ENV[DATASTORE_PRODUCT]" + }, + {}, + { + "peer.hostname": "ENV[MYSQL_HOST]", + "peer.address": "ENV[MYSQL_HOST]:ENV[MYSQL_PORT]", + "db.instance": "ENV[MYSQL_DB]", + "db.statement": "DROP TABLE ENV[DATASTORE_COLLECTION];" + } + ] +] +*/ + +require_once(realpath (dirname ( __FILE__ )) . '/../../test_instance_reporting.inc'); +require_once(realpath (dirname ( __FILE__ )) . '/../../../../include/config.php'); + +test_instance_reporting(new Pdo\Mysql($PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD), 0); diff --git a/tests/integration/pdo/mysql/constructor/test_instance_reporting_socket.php b/tests/integration/pdo/mysql/constructor/test_instance_reporting_socket.php new file mode 100644 index 000000000..073bceb80 --- /dev/null +++ b/tests/integration/pdo/mysql/constructor/test_instance_reporting_socket.php @@ -0,0 +1,161 @@ +", + "?? SQL id", + "DROP TABLE ENV[DATASTORE_COLLECTION];", + "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/drop", + 1, + "?? total time", + "?? min time", + "?? max time", + { + "backtrace": [ + "/ in PDO::exec called at .*\/", + " in test_instance_reporting called at __FILE__ (??)" + ], + "host": "__HOST__", + "port_path_or_id": "ENV[MYSQL_SOCKET]", + "database_name": "ENV[MYSQL_DB]" + } + ], + [ + "OtherTransaction/php__FILE__", + "", + "?? SQL id", + "CREATE TABLE ENV[DATASTORE_COLLECTION] (id INT, description VARCHAR(?));", + "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/create", + 1, + "?? total time", + "?? min time", + "?? max time", + { + "backtrace": [ + "/ in PDO::exec called at .*\/", + " in test_instance_reporting called at __FILE__ (??)" + ], + "host": "__HOST__", + "port_path_or_id": "ENV[MYSQL_SOCKET]", + "database_name": "ENV[MYSQL_DB]" + } + ] + ] +] +*/ + +/*EXPECT_SPAN_EVENTS_LIKE +[ + [ + { + "category": "datastore", + "type": "Span", + "guid": "??", + "traceId": "??", + "transactionId": "??", + "name": "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/create", + "timestamp": "??", + "duration": "??", + "priority": "??", + "sampled": true, + "parentId": "??", + "span.kind": "client", + "component": "ENV[DATASTORE_PRODUCT]" + }, + {}, + { + "peer.hostname": "__HOST__", + "peer.address": "__HOST__:ENV[MYSQL_SOCKET]", + "db.instance": "ENV[MYSQL_DB]", + "db.statement": "CREATE TABLE ENV[DATASTORE_COLLECTION] (id INT, description VARCHAR(?));" + } + ], + [ + { + "category": "datastore", + "type": "Span", + "guid": "??", + "traceId": "??", + "transactionId": "??", + "name": "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/drop", + "timestamp": "??", + "duration": "??", + "priority": "??", + "sampled": true, + "parentId": "??", + "span.kind": "client", + "component": "ENV[DATASTORE_PRODUCT]" + }, + {}, + { + "peer.hostname": "__HOST__", + "peer.address": "__HOST__:ENV[MYSQL_SOCKET]", + "db.instance": "ENV[MYSQL_DB]", + "db.statement": "DROP TABLE ENV[DATASTORE_COLLECTION];" + } + ] +] +*/ + +require_once(realpath (dirname ( __FILE__ )) . '/../../test_instance_reporting.inc'); +require_once(realpath (dirname ( __FILE__ )) . '/../../../../include/config.php'); + +$DSN = 'mysql:'; +$DSN .= 'unix_socket=' . $MYSQL_SOCKET . ';'; +$DSN .= 'dbname=' . $MYSQL_DB . ';'; + +test_instance_reporting(new Pdo\Mysql($DSN, $MYSQL_USER, $MYSQL_PASSWD), 0); diff --git a/tests/integration/pdo/mysql/constructor/test_prepared_stmt_basic.php b/tests/integration/pdo/mysql/constructor/test_prepared_stmt_basic.php new file mode 100644 index 000000000..695dab225 --- /dev/null +++ b/tests/integration/pdo/mysql/constructor/test_prepared_stmt_basic.php @@ -0,0 +1,111 @@ +", + "?? SQL id", + "select * from information_schema.tables limit ?;", + "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/select", + 1, + "?? total time", + "?? min time", + "?? max time", + { + "backtrace": [ + "/ in PDOStatement::execute called at .*\/", + " in test_prepared_stmt called at __FILE__ (??)" + ], + "explain_plan": "??" + } + ] + ] +] +*/ + +// peer.address is unknown:unknown because instance_reporting is disabled +/*EXPECT_SPAN_EVENTS_LIKE +[ + [ + { + "category": "datastore", + "type": "Span", + "guid": "??", + "traceId": "??", + "transactionId": "??", + "name": "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/select", + "timestamp": "??", + "duration": "??", + "priority": "??", + "sampled": true, + "parentId": "??", + "span.kind": "client", + "component": "ENV[DATASTORE_PRODUCT]" + }, + {}, + { + "peer.address": "unknown:unknown", + "db.statement": "select * from information_schema.tables limit ?;" + } + ] +] +*/ + +require_once(realpath (dirname ( __FILE__ )) . '/../../test_prepared_stmt_basic.inc'); +require_once(realpath (dirname ( __FILE__ )) . '/../../../../include/config.php'); + +$query = 'select * from information_schema.tables limit 1;'; +test_prepared_stmt(new Pdo\Mysql($PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD), $query); diff --git a/tests/integration/pdo/mysql/constructor/test_prepared_stmt_bind_value.php b/tests/integration/pdo/mysql/constructor/test_prepared_stmt_bind_value.php new file mode 100644 index 000000000..214533332 --- /dev/null +++ b/tests/integration/pdo/mysql/constructor/test_prepared_stmt_bind_value.php @@ -0,0 +1,112 @@ +", + "?? SQL id", + "select * from information_schema.tables where table_name = ? limit ?;", + "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/select", + 1, + "?? total time", + "?? min time", + "?? max time", + { + "backtrace": [ + "/ in PDOStatement::execute called at .*\/", + " in test_prepared_stmt called at __FILE__ (??)" + ], + "explain_plan": "??" + } + ] + ] +] +*/ + +// peer.address is unknown:unknown because instance_reporting is disabled +/*EXPECT_SPAN_EVENTS_LIKE +[ + [ + { + "category": "datastore", + "type": "Span", + "guid": "??", + "traceId": "??", + "transactionId": "??", + "name": "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/select", + "timestamp": "??", + "duration": "??", + "priority": "??", + "sampled": true, + "parentId": "??", + "span.kind": "client", + "component": "ENV[DATASTORE_PRODUCT]" + }, + {}, + { + "peer.address": "unknown:unknown", + "db.statement": "select * from information_schema.tables where table_name = ? limit ?;" + } + ] +] +*/ + +require_once(realpath (dirname ( __FILE__ )) . '/../../test_prepared_stmt_bind_value.inc'); +require_once(realpath (dirname ( __FILE__ )) . '/../../../../include/config.php'); + +$query = 'select * from information_schema.tables where table_name = ? limit 1;'; +test_prepared_stmt(new Pdo\Mysql($PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD), $query); diff --git a/tests/integration/pdo/mysql/constructor/test_query_1_arg.php b/tests/integration/pdo/mysql/constructor/test_query_1_arg.php new file mode 100644 index 000000000..63d641e70 --- /dev/null +++ b/tests/integration/pdo/mysql/constructor/test_query_1_arg.php @@ -0,0 +1,53 @@ +", + "?? SQL id", + "DROP TABLE ENV[DATASTORE_COLLECTION];", + "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/drop", + 1, + "?? total time", + "?? min time", + "?? max time", + { + "backtrace": [ + "/ in PDO::exec called at .*\/", + " in test_instance_reporting called at __FILE__ (??)" + ], + "host": "ENV[MYSQL_HOST]", + "port_path_or_id": "ENV[MYSQL_PORT]", + "database_name": "ENV[MYSQL_DB]" + } + ], + [ + "OtherTransaction/php__FILE__", + "", + "?? SQL id", + "CREATE TABLE ENV[DATASTORE_COLLECTION] (id INT, description VARCHAR(?));", + "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/create", + 1, + "?? total time", + "?? min time", + "?? max time", + { + "backtrace": [ + "/ in PDO::exec called at .*\/", + " in test_instance_reporting called at __FILE__ (??)" + ], + "host": "ENV[MYSQL_HOST]", + "port_path_or_id": "ENV[MYSQL_PORT]", + "database_name": "ENV[MYSQL_DB]" + } + ] + ] +] +*/ + +/*EXPECT_SPAN_EVENTS_LIKE +[ + [ + { + "category": "datastore", + "type": "Span", + "guid": "??", + "traceId": "??", + "transactionId": "??", + "name": "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/create", + "timestamp": "??", + "duration": "??", + "priority": "??", + "sampled": true, + "parentId": "??", + "span.kind": "client", + "component": "ENV[DATASTORE_PRODUCT]" + }, + {}, + { + "peer.hostname": "ENV[MYSQL_HOST]", + "peer.address": "ENV[MYSQL_HOST]:ENV[MYSQL_PORT]", + "db.instance": "ENV[MYSQL_DB]", + "db.statement": "CREATE TABLE ENV[DATASTORE_COLLECTION] (id INT, description VARCHAR(?));" + } + ], + [ + { + "category": "datastore", + "type": "Span", + "guid": "??", + "traceId": "??", + "transactionId": "??", + "name": "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/drop", + "timestamp": "??", + "duration": "??", + "priority": "??", + "sampled": true, + "parentId": "??", + "span.kind": "client", + "component": "ENV[DATASTORE_PRODUCT]" + }, + {}, + { + "peer.hostname": "ENV[MYSQL_HOST]", + "peer.address": "ENV[MYSQL_HOST]:ENV[MYSQL_PORT]", + "db.instance": "ENV[MYSQL_DB]", + "db.statement": "DROP TABLE ENV[DATASTORE_COLLECTION];" + } + ] +] +*/ + +require_once(realpath (dirname ( __FILE__ )) . '/../../test_instance_reporting.inc'); +require_once(realpath (dirname ( __FILE__ )) . '/../../../../include/config.php'); + +test_instance_reporting(PDO::connect($PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD), 0); diff --git a/tests/integration/pdo/mysql/factory/test_instance_reporting_socket.php b/tests/integration/pdo/mysql/factory/test_instance_reporting_socket.php new file mode 100644 index 000000000..796d108db --- /dev/null +++ b/tests/integration/pdo/mysql/factory/test_instance_reporting_socket.php @@ -0,0 +1,161 @@ +", + "?? SQL id", + "DROP TABLE ENV[DATASTORE_COLLECTION];", + "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/drop", + 1, + "?? total time", + "?? min time", + "?? max time", + { + "backtrace": [ + "/ in PDO::exec called at .*\/", + " in test_instance_reporting called at __FILE__ (??)" + ], + "host": "__HOST__", + "port_path_or_id": "ENV[MYSQL_SOCKET]", + "database_name": "ENV[MYSQL_DB]" + } + ], + [ + "OtherTransaction/php__FILE__", + "", + "?? SQL id", + "CREATE TABLE ENV[DATASTORE_COLLECTION] (id INT, description VARCHAR(?));", + "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/create", + 1, + "?? total time", + "?? min time", + "?? max time", + { + "backtrace": [ + "/ in PDO::exec called at .*\/", + " in test_instance_reporting called at __FILE__ (??)" + ], + "host": "__HOST__", + "port_path_or_id": "ENV[MYSQL_SOCKET]", + "database_name": "ENV[MYSQL_DB]" + } + ] + ] +] +*/ + +/*EXPECT_SPAN_EVENTS_LIKE +[ + [ + { + "category": "datastore", + "type": "Span", + "guid": "??", + "traceId": "??", + "transactionId": "??", + "name": "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/create", + "timestamp": "??", + "duration": "??", + "priority": "??", + "sampled": true, + "parentId": "??", + "span.kind": "client", + "component": "ENV[DATASTORE_PRODUCT]" + }, + {}, + { + "peer.hostname": "__HOST__", + "peer.address": "__HOST__:ENV[MYSQL_SOCKET]", + "db.instance": "ENV[MYSQL_DB]", + "db.statement": "CREATE TABLE ENV[DATASTORE_COLLECTION] (id INT, description VARCHAR(?));" + } + ], + [ + { + "category": "datastore", + "type": "Span", + "guid": "??", + "traceId": "??", + "transactionId": "??", + "name": "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/drop", + "timestamp": "??", + "duration": "??", + "priority": "??", + "sampled": true, + "parentId": "??", + "span.kind": "client", + "component": "ENV[DATASTORE_PRODUCT]" + }, + {}, + { + "peer.hostname": "__HOST__", + "peer.address": "__HOST__:ENV[MYSQL_SOCKET]", + "db.instance": "ENV[MYSQL_DB]", + "db.statement": "DROP TABLE ENV[DATASTORE_COLLECTION];" + } + ] +] +*/ + +require_once(realpath (dirname ( __FILE__ )) . '/../../test_instance_reporting.inc'); +require_once(realpath (dirname ( __FILE__ )) . '/../../../../include/config.php'); + +$DSN = 'mysql:'; +$DSN .= 'unix_socket=' . $MYSQL_SOCKET . ';'; +$DSN .= 'dbname=' . $MYSQL_DB . ';'; + +test_instance_reporting(PDO::connect($DSN, $MYSQL_USER, $MYSQL_PASSWD), 0); diff --git a/tests/integration/pdo/mysql/factory/test_prepared_stmt_basic.php b/tests/integration/pdo/mysql/factory/test_prepared_stmt_basic.php new file mode 100644 index 000000000..6488f0ffe --- /dev/null +++ b/tests/integration/pdo/mysql/factory/test_prepared_stmt_basic.php @@ -0,0 +1,111 @@ +", + "?? SQL id", + "select * from information_schema.tables limit ?;", + "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/select", + 1, + "?? total time", + "?? min time", + "?? max time", + { + "backtrace": [ + "/ in PDOStatement::execute called at .*\/", + " in test_prepared_stmt called at __FILE__ (??)" + ], + "explain_plan": "??" + } + ] + ] +] +*/ + +// peer.address is unknown:unknown because instance_reporting is disabled +/*EXPECT_SPAN_EVENTS_LIKE +[ + [ + { + "category": "datastore", + "type": "Span", + "guid": "??", + "traceId": "??", + "transactionId": "??", + "name": "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/select", + "timestamp": "??", + "duration": "??", + "priority": "??", + "sampled": true, + "parentId": "??", + "span.kind": "client", + "component": "ENV[DATASTORE_PRODUCT]" + }, + {}, + { + "peer.address": "unknown:unknown", + "db.statement": "select * from information_schema.tables limit ?;" + } + ] +] +*/ + +require_once(realpath (dirname ( __FILE__ )) . '/../../test_prepared_stmt_basic.inc'); +require_once(realpath (dirname ( __FILE__ )) . '/../../../../include/config.php'); + +$query = 'select * from information_schema.tables limit 1;'; +test_prepared_stmt(PDO::connect($PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD), $query); diff --git a/tests/integration/pdo/mysql/factory/test_prepared_stmt_bind_value.php b/tests/integration/pdo/mysql/factory/test_prepared_stmt_bind_value.php new file mode 100644 index 000000000..e1cae652e --- /dev/null +++ b/tests/integration/pdo/mysql/factory/test_prepared_stmt_bind_value.php @@ -0,0 +1,112 @@ +", + "?? SQL id", + "select * from information_schema.tables where table_name = ? limit ?;", + "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/select", + 1, + "?? total time", + "?? min time", + "?? max time", + { + "backtrace": [ + "/ in PDOStatement::execute called at .*\/", + " in test_prepared_stmt called at __FILE__ (??)" + ], + "explain_plan": "??" + } + ] + ] +] +*/ + +// peer.address is unknown:unknown because instance_reporting is disabled +/*EXPECT_SPAN_EVENTS_LIKE +[ + [ + { + "category": "datastore", + "type": "Span", + "guid": "??", + "traceId": "??", + "transactionId": "??", + "name": "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/select", + "timestamp": "??", + "duration": "??", + "priority": "??", + "sampled": true, + "parentId": "??", + "span.kind": "client", + "component": "ENV[DATASTORE_PRODUCT]" + }, + {}, + { + "peer.address": "unknown:unknown", + "db.statement": "select * from information_schema.tables where table_name = ? limit ?;" + } + ] +] +*/ + +require_once(realpath (dirname ( __FILE__ )) . '/../../test_prepared_stmt_bind_value.inc'); +require_once(realpath (dirname ( __FILE__ )) . '/../../../../include/config.php'); + +$query = 'select * from information_schema.tables where table_name = ? limit 1;'; +test_prepared_stmt(PDO::connect($PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD), $query); diff --git a/tests/integration/pdo/mysql/factory/test_query_1_arg.php b/tests/integration/pdo/mysql/factory/test_query_1_arg.php new file mode 100644 index 000000000..b15999e0b --- /dev/null +++ b/tests/integration/pdo/mysql/factory/test_query_1_arg.php @@ -0,0 +1,53 @@ +", + "?? SQL id", + "DROP TABLE ENV[DATASTORE_COLLECTION];", + "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/drop", + 1, + "?? total time", + "?? min time", + "?? max time", + { + "backtrace": [ + "/ in PDO::exec called at .*\/", + " in test_instance_reporting called at __FILE__ (??)" + ], + "host": "ENV[PG_HOST]", + "port_path_or_id": "ENV[PG_PORT]", + "database_name": "postgres" + } + ], + [ + "OtherTransaction/php__FILE__", + "", + "?? SQL id", + "CREATE TABLE ENV[DATASTORE_COLLECTION] (id INT, description VARCHAR(?));", + "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/create", + 1, + "?? total time", + "?? min time", + "?? max time", + { + "backtrace": [ + "/ in PDO::exec called at .*\/", + " in test_instance_reporting called at __FILE__ (??)" + ], + "host": "ENV[PG_HOST]", + "port_path_or_id": "ENV[PG_PORT]", + "database_name": "postgres" + } + ] + ] +] +*/ + +/*EXPECT_SPAN_EVENTS_LIKE +[ + [ + { + "category": "datastore", + "type": "Span", + "guid": "??", + "traceId": "??", + "transactionId": "??", + "name": "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/create", + "timestamp": "??", + "duration": "??", + "priority": "??", + "sampled": true, + "parentId": "??", + "span.kind": "client", + "component": "ENV[DATASTORE_PRODUCT]" + }, + {}, + { + "peer.hostname": "ENV[PG_HOST]", + "peer.address": "ENV[PG_HOST]:ENV[PG_PORT]", + "db.instance": "postgres", + "db.statement": "CREATE TABLE ENV[DATASTORE_COLLECTION] (id INT, description VARCHAR(?));" + } + ], + [ + { + "category": "datastore", + "type": "Span", + "guid": "??", + "traceId": "??", + "transactionId": "??", + "name": "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/drop", + "timestamp": "??", + "duration": "??", + "priority": "??", + "sampled": true, + "parentId": "??", + "span.kind": "client", + "component": "ENV[DATASTORE_PRODUCT]" + }, + {}, + { + "peer.hostname": "ENV[PG_HOST]", + "peer.address": "ENV[PG_HOST]:ENV[PG_PORT]", + "db.instance": "postgres", + "db.statement": "DROP TABLE ENV[DATASTORE_COLLECTION];" + } + ] +] +*/ + +require_once(realpath (dirname ( __FILE__ )) . '/../../test_instance_reporting.inc'); +require_once(realpath (dirname ( __FILE__ )) . '/../../../../include/config.php'); + +test_instance_reporting(new PDO($PDO_PGSQL_DSN, $PG_USER, $PG_PW), 0); diff --git a/tests/integration/pdo/pgsql/base-class/test_prepared_stmt_basic.php b/tests/integration/pdo/pgsql/base-class/test_prepared_stmt_basic.php new file mode 100644 index 000000000..9c7960080 --- /dev/null +++ b/tests/integration/pdo/pgsql/base-class/test_prepared_stmt_basic.php @@ -0,0 +1,106 @@ +", + "?? SQL id", + "select * from information_schema.tables limit ?;", + "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/select", + 1, + "?? total time", + "?? min time", + "?? max time", + { + "backtrace": [ + "/ in PDOStatement::execute called at .*\/", + " in test_prepared_stmt called at __FILE__ (??)" + ] + } + ] + ] +] +*/ + +// peer.address is unknown:unknown because instance_reporting is disabled +/*EXPECT_SPAN_EVENTS_LIKE +[ + [ + { + "category": "datastore", + "type": "Span", + "guid": "??", + "traceId": "??", + "transactionId": "??", + "name": "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/select", + "timestamp": "??", + "duration": "??", + "priority": "??", + "sampled": true, + "parentId": "??", + "span.kind": "client", + "component": "ENV[DATASTORE_PRODUCT]" + }, + {}, + { + "peer.address": "unknown:unknown", + "db.statement": "select * from information_schema.tables limit ?;" + } + ] +] +*/ + +require_once(realpath (dirname ( __FILE__ )) . '/../../test_prepared_stmt_basic.inc'); +require_once(realpath (dirname ( __FILE__ )) . '/../../../../include/config.php'); + +$query = 'select * from information_schema.tables limit 1;'; +test_prepared_stmt(new PDO($PDO_PGSQL_DSN, $PG_USER, $PG_PW), $query); diff --git a/tests/integration/pdo/pgsql/base-class/test_prepared_stmt_bind_value.php b/tests/integration/pdo/pgsql/base-class/test_prepared_stmt_bind_value.php new file mode 100644 index 000000000..56737cafb --- /dev/null +++ b/tests/integration/pdo/pgsql/base-class/test_prepared_stmt_bind_value.php @@ -0,0 +1,107 @@ +", + "?? SQL id", + "select * from information_schema.tables where table_name = ? limit ?;", + "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/select", + 1, + "?? total time", + "?? min time", + "?? max time", + { + "backtrace": [ + "/ in PDOStatement::execute called at .*\/", + " in test_prepared_stmt called at __FILE__ (??)" + ] + } + ] + ] +] +*/ + +// peer.address is unknown:unknown because instance_reporting is disabled +/*EXPECT_SPAN_EVENTS_LIKE +[ + [ + { + "category": "datastore", + "type": "Span", + "guid": "??", + "traceId": "??", + "transactionId": "??", + "name": "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/select", + "timestamp": "??", + "duration": "??", + "priority": "??", + "sampled": true, + "parentId": "??", + "span.kind": "client", + "component": "ENV[DATASTORE_PRODUCT]" + }, + {}, + { + "peer.address": "unknown:unknown", + "db.statement": "select * from information_schema.tables where table_name = ? limit ?;" + } + ] +] +*/ + +require_once(realpath (dirname ( __FILE__ )) . '/../../test_prepared_stmt_bind_value.inc'); +require_once(realpath (dirname ( __FILE__ )) . '/../../../../include/config.php'); + +$query = 'select * from information_schema.tables where table_name = ? limit 1;'; +test_prepared_stmt(new PDO($PDO_PGSQL_DSN, $PG_USER, $PG_PW), $query); diff --git a/tests/integration/pdo/pgsql/base-class/test_query_1_arg.php b/tests/integration/pdo/pgsql/base-class/test_query_1_arg.php new file mode 100644 index 000000000..48e212208 --- /dev/null +++ b/tests/integration/pdo/pgsql/base-class/test_query_1_arg.php @@ -0,0 +1,55 @@ +", + "?? SQL id", + "DROP TABLE ENV[DATASTORE_COLLECTION];", + "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/drop", + 1, + "?? total time", + "?? min time", + "?? max time", + { + "backtrace": [ + "/ in PDO::exec called at .*\/", + " in test_instance_reporting called at __FILE__ (??)" + ], + "host": "ENV[PG_HOST]", + "port_path_or_id": "ENV[PG_PORT]", + "database_name": "postgres" + } + ], + [ + "OtherTransaction/php__FILE__", + "", + "?? SQL id", + "CREATE TABLE ENV[DATASTORE_COLLECTION] (id INT, description VARCHAR(?));", + "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/create", + 1, + "?? total time", + "?? min time", + "?? max time", + { + "backtrace": [ + "/ in PDO::exec called at .*\/", + " in test_instance_reporting called at __FILE__ (??)" + ], + "host": "ENV[PG_HOST]", + "port_path_or_id": "ENV[PG_PORT]", + "database_name": "postgres" + } + ] + ] +] +*/ + +/*EXPECT_SPAN_EVENTS_LIKE +[ + [ + { + "category": "datastore", + "type": "Span", + "guid": "??", + "traceId": "??", + "transactionId": "??", + "name": "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/create", + "timestamp": "??", + "duration": "??", + "priority": "??", + "sampled": true, + "parentId": "??", + "span.kind": "client", + "component": "ENV[DATASTORE_PRODUCT]" + }, + {}, + { + "peer.hostname": "ENV[PG_HOST]", + "peer.address": "ENV[PG_HOST]:ENV[PG_PORT]", + "db.instance": "postgres", + "db.statement": "CREATE TABLE ENV[DATASTORE_COLLECTION] (id INT, description VARCHAR(?));" + } + ], + [ + { + "category": "datastore", + "type": "Span", + "guid": "??", + "traceId": "??", + "transactionId": "??", + "name": "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/drop", + "timestamp": "??", + "duration": "??", + "priority": "??", + "sampled": true, + "parentId": "??", + "span.kind": "client", + "component": "ENV[DATASTORE_PRODUCT]" + }, + {}, + { + "peer.hostname": "ENV[PG_HOST]", + "peer.address": "ENV[PG_HOST]:ENV[PG_PORT]", + "db.instance": "postgres", + "db.statement": "DROP TABLE ENV[DATASTORE_COLLECTION];" + } + ] +] +*/ + +require_once(realpath (dirname ( __FILE__ )) . '/../../test_instance_reporting.inc'); +require_once(realpath (dirname ( __FILE__ )) . '/../../../../include/config.php'); + +test_instance_reporting(new Pdo\Pgsql($PDO_PGSQL_DSN, $PG_USER, $PG_PW), 0); diff --git a/tests/integration/pdo/pgsql/constructor/test_prepared_stmt_basic.php b/tests/integration/pdo/pgsql/constructor/test_prepared_stmt_basic.php new file mode 100644 index 000000000..131ab0935 --- /dev/null +++ b/tests/integration/pdo/pgsql/constructor/test_prepared_stmt_basic.php @@ -0,0 +1,107 @@ +", + "?? SQL id", + "select * from information_schema.tables limit ?;", + "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/select", + 1, + "?? total time", + "?? min time", + "?? max time", + { + "backtrace": [ + "/ in PDOStatement::execute called at .*\/", + " in test_prepared_stmt called at __FILE__ (??)" + ] + } + ] + ] +] +*/ + +// peer.address is unknown:unknown because instance_reporting is disabled +/*EXPECT_SPAN_EVENTS_LIKE +[ + [ + { + "category": "datastore", + "type": "Span", + "guid": "??", + "traceId": "??", + "transactionId": "??", + "name": "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/select", + "timestamp": "??", + "duration": "??", + "priority": "??", + "sampled": true, + "parentId": "??", + "span.kind": "client", + "component": "ENV[DATASTORE_PRODUCT]" + }, + {}, + { + "peer.address": "unknown:unknown", + "db.statement": "select * from information_schema.tables limit ?;" + } + ] +] +*/ + +require_once(realpath (dirname ( __FILE__ )) . '/../../test_prepared_stmt_basic.inc'); +require_once(realpath (dirname ( __FILE__ )) . '/../../../../include/config.php'); + +$query = 'select * from information_schema.tables limit 1;'; +test_prepared_stmt(new Pdo\Pgsql($PDO_PGSQL_DSN, $PG_USER, $PG_PW), $query); diff --git a/tests/integration/pdo/pgsql/constructor/test_prepared_stmt_bind_value.php b/tests/integration/pdo/pgsql/constructor/test_prepared_stmt_bind_value.php new file mode 100644 index 000000000..c954060f8 --- /dev/null +++ b/tests/integration/pdo/pgsql/constructor/test_prepared_stmt_bind_value.php @@ -0,0 +1,108 @@ +", + "?? SQL id", + "select * from information_schema.tables where table_name = ? limit ?;", + "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/select", + 1, + "?? total time", + "?? min time", + "?? max time", + { + "backtrace": [ + "/ in PDOStatement::execute called at .*\/", + " in test_prepared_stmt called at __FILE__ (??)" + ] + } + ] + ] +] +*/ + +// peer.address is unknown:unknown because instance_reporting is disabled +/*EXPECT_SPAN_EVENTS_LIKE +[ + [ + { + "category": "datastore", + "type": "Span", + "guid": "??", + "traceId": "??", + "transactionId": "??", + "name": "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/select", + "timestamp": "??", + "duration": "??", + "priority": "??", + "sampled": true, + "parentId": "??", + "span.kind": "client", + "component": "ENV[DATASTORE_PRODUCT]" + }, + {}, + { + "peer.address": "unknown:unknown", + "db.statement": "select * from information_schema.tables where table_name = ? limit ?;" + } + ] +] +*/ + +require_once(realpath (dirname ( __FILE__ )) . '/../../test_prepared_stmt_bind_value.inc'); +require_once(realpath (dirname ( __FILE__ )) . '/../../../../include/config.php'); + +$query = 'select * from information_schema.tables where table_name = ? limit 1;'; +test_prepared_stmt(new Pdo\Pgsql($PDO_PGSQL_DSN, $PG_USER, $PG_PW), $query); diff --git a/tests/integration/pdo/pgsql/constructor/test_query_1_arg.php b/tests/integration/pdo/pgsql/constructor/test_query_1_arg.php new file mode 100644 index 000000000..c3cc9381d --- /dev/null +++ b/tests/integration/pdo/pgsql/constructor/test_query_1_arg.php @@ -0,0 +1,52 @@ +", + "?? SQL id", + "DROP TABLE ENV[DATASTORE_COLLECTION];", + "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/drop", + 1, + "?? total time", + "?? min time", + "?? max time", + { + "backtrace": [ + "/ in PDO::exec called at .*\/", + " in test_instance_reporting called at __FILE__ (??)" + ], + "host": "ENV[PG_HOST]", + "port_path_or_id": "ENV[PG_PORT]", + "database_name": "postgres" + } + ], + [ + "OtherTransaction/php__FILE__", + "", + "?? SQL id", + "CREATE TABLE ENV[DATASTORE_COLLECTION] (id INT, description VARCHAR(?));", + "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/create", + 1, + "?? total time", + "?? min time", + "?? max time", + { + "backtrace": [ + "/ in PDO::exec called at .*\/", + " in test_instance_reporting called at __FILE__ (??)" + ], + "host": "ENV[PG_HOST]", + "port_path_or_id": "ENV[PG_PORT]", + "database_name": "postgres" + } + ] + ] +] +*/ + +/*EXPECT_SPAN_EVENTS_LIKE +[ + [ + { + "category": "datastore", + "type": "Span", + "guid": "??", + "traceId": "??", + "transactionId": "??", + "name": "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/create", + "timestamp": "??", + "duration": "??", + "priority": "??", + "sampled": true, + "parentId": "??", + "span.kind": "client", + "component": "ENV[DATASTORE_PRODUCT]" + }, + {}, + { + "peer.hostname": "ENV[PG_HOST]", + "peer.address": "ENV[PG_HOST]:ENV[PG_PORT]", + "db.instance": "postgres", + "db.statement": "CREATE TABLE ENV[DATASTORE_COLLECTION] (id INT, description VARCHAR(?));" + } + ], + [ + { + "category": "datastore", + "type": "Span", + "guid": "??", + "traceId": "??", + "transactionId": "??", + "name": "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/drop", + "timestamp": "??", + "duration": "??", + "priority": "??", + "sampled": true, + "parentId": "??", + "span.kind": "client", + "component": "ENV[DATASTORE_PRODUCT]" + }, + {}, + { + "peer.hostname": "ENV[PG_HOST]", + "peer.address": "ENV[PG_HOST]:ENV[PG_PORT]", + "db.instance": "postgres", + "db.statement": "DROP TABLE ENV[DATASTORE_COLLECTION];" + } + ] +] +*/ + +require_once(realpath (dirname ( __FILE__ )) . '/../../test_instance_reporting.inc'); +require_once(realpath (dirname ( __FILE__ )) . '/../../../../include/config.php'); + +test_instance_reporting(PDO::connect($PDO_PGSQL_DSN, $PG_USER, $PG_PW), 0); diff --git a/tests/integration/pdo/pgsql/factory/test_prepared_stmt_basic.php b/tests/integration/pdo/pgsql/factory/test_prepared_stmt_basic.php new file mode 100644 index 000000000..58841fbf7 --- /dev/null +++ b/tests/integration/pdo/pgsql/factory/test_prepared_stmt_basic.php @@ -0,0 +1,107 @@ +", + "?? SQL id", + "select * from information_schema.tables limit ?;", + "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/select", + 1, + "?? total time", + "?? min time", + "?? max time", + { + "backtrace": [ + "/ in PDOStatement::execute called at .*\/", + " in test_prepared_stmt called at __FILE__ (??)" + ] + } + ] + ] +] +*/ + +// peer.address is unknown:unknown because instance_reporting is disabled +/*EXPECT_SPAN_EVENTS_LIKE +[ + [ + { + "category": "datastore", + "type": "Span", + "guid": "??", + "traceId": "??", + "transactionId": "??", + "name": "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/select", + "timestamp": "??", + "duration": "??", + "priority": "??", + "sampled": true, + "parentId": "??", + "span.kind": "client", + "component": "ENV[DATASTORE_PRODUCT]" + }, + {}, + { + "peer.address": "unknown:unknown", + "db.statement": "select * from information_schema.tables limit ?;" + } + ] +] +*/ + +require_once(realpath (dirname ( __FILE__ )) . '/../../test_prepared_stmt_basic.inc'); +require_once(realpath (dirname ( __FILE__ )) . '/../../../../include/config.php'); + +$query = 'select * from information_schema.tables limit 1;'; +test_prepared_stmt(PDO::connect($PDO_PGSQL_DSN, $PG_USER, $PG_PW), $query); diff --git a/tests/integration/pdo/pgsql/factory/test_prepared_stmt_bind_value.php b/tests/integration/pdo/pgsql/factory/test_prepared_stmt_bind_value.php new file mode 100644 index 000000000..7ccfa9e9f --- /dev/null +++ b/tests/integration/pdo/pgsql/factory/test_prepared_stmt_bind_value.php @@ -0,0 +1,108 @@ +", + "?? SQL id", + "select * from information_schema.tables where table_name = ? limit ?;", + "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/select", + 1, + "?? total time", + "?? min time", + "?? max time", + { + "backtrace": [ + "/ in PDOStatement::execute called at .*\/", + " in test_prepared_stmt called at __FILE__ (??)" + ] + } + ] + ] +] +*/ + +// peer.address is unknown:unknown because instance_reporting is disabled +/*EXPECT_SPAN_EVENTS_LIKE +[ + [ + { + "category": "datastore", + "type": "Span", + "guid": "??", + "traceId": "??", + "transactionId": "??", + "name": "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/select", + "timestamp": "??", + "duration": "??", + "priority": "??", + "sampled": true, + "parentId": "??", + "span.kind": "client", + "component": "ENV[DATASTORE_PRODUCT]" + }, + {}, + { + "peer.address": "unknown:unknown", + "db.statement": "select * from information_schema.tables where table_name = ? limit ?;" + } + ] +] +*/ + +require_once(realpath (dirname ( __FILE__ )) . '/../../test_prepared_stmt_bind_value.inc'); +require_once(realpath (dirname ( __FILE__ )) . '/../../../../include/config.php'); + +$query = 'select * from information_schema.tables where table_name = ? limit 1;'; +test_prepared_stmt(PDO::connect($PDO_PGSQL_DSN, $PG_USER, $PG_PW), $query); diff --git a/tests/integration/pdo/pgsql/factory/test_query_1_arg.php b/tests/integration/pdo/pgsql/factory/test_query_1_arg.php new file mode 100644 index 000000000..1f47b55b7 --- /dev/null +++ b/tests/integration/pdo/pgsql/factory/test_query_1_arg.php @@ -0,0 +1,52 @@ += 8.4\n"); +} + diff --git a/tests/integration/pdo/skipif_pgsql.inc b/tests/integration/pdo/skipif_pgsql.inc new file mode 100644 index 000000000..92caf44be --- /dev/null +++ b/tests/integration/pdo/skipif_pgsql.inc @@ -0,0 +1,37 @@ +getMessage() . "\n"); +} diff --git a/tests/integration/pdo/sqlite/base-class/test_prepared_stmt_basic.php b/tests/integration/pdo/sqlite/base-class/test_prepared_stmt_basic.php new file mode 100644 index 000000000..ddf000ce8 --- /dev/null +++ b/tests/integration/pdo/sqlite/base-class/test_prepared_stmt_basic.php @@ -0,0 +1,106 @@ +", + "?? SQL id", + "select * from ENV[DATASTORE_COLLECTION] limit ?;", + "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/select", + 1, + "?? total time", + "?? min time", + "?? max time", + { + "backtrace": [ + "/ in PDOStatement::execute called at .*\/", + " in test_prepared_stmt called at __FILE__ (??)" + ] + } + ] + ] +] +*/ + +// peer.address is unknown:unknown because instance_reporting is disabled +/*EXPECT_SPAN_EVENTS_LIKE +[ + [ + { + "category": "datastore", + "type": "Span", + "guid": "??", + "traceId": "??", + "transactionId": "??", + "name": "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/select", + "timestamp": "??", + "duration": "??", + "priority": "??", + "sampled": true, + "parentId": "??", + "span.kind": "client", + "component": "ENV[DATASTORE_PRODUCT]" + }, + {}, + { + "peer.address": "unknown:unknown", + "db.statement": "select * from ENV[DATASTORE_COLLECTION] limit ?;" + } + ] +] +*/ + +require_once(realpath (dirname ( __FILE__ )) . '/../../test_prepared_stmt_basic.inc'); +require_once(realpath (dirname ( __FILE__ )) . '/../../../../include/config.php'); + +$query = 'select * from sqlite_master limit 1;'; +test_prepared_stmt(new PDO('sqlite::memory:'), $query); diff --git a/tests/integration/pdo/sqlite/base-class/test_prepared_stmt_bind_value.php b/tests/integration/pdo/sqlite/base-class/test_prepared_stmt_bind_value.php new file mode 100644 index 000000000..a26e0802f --- /dev/null +++ b/tests/integration/pdo/sqlite/base-class/test_prepared_stmt_bind_value.php @@ -0,0 +1,107 @@ +", + "?? SQL id", + "select * from ENV[DATASTORE_COLLECTION] where tbl_name = ? limit ?;", + "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/select", + 1, + "?? total time", + "?? min time", + "?? max time", + { + "backtrace": [ + "/ in PDOStatement::execute called at .*\/", + " in test_prepared_stmt called at __FILE__ (??)" + ] + } + ] + ] +] +*/ + +// peer.address is unknown:unknown because instance_reporting is disabled +/*EXPECT_SPAN_EVENTS_LIKE +[ + [ + { + "category": "datastore", + "type": "Span", + "guid": "??", + "traceId": "??", + "transactionId": "??", + "name": "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/select", + "timestamp": "??", + "duration": "??", + "priority": "??", + "sampled": true, + "parentId": "??", + "span.kind": "client", + "component": "ENV[DATASTORE_PRODUCT]" + }, + {}, + { + "peer.address": "unknown:unknown", + "db.statement": "select * from ENV[DATASTORE_COLLECTION] where tbl_name = ? limit ?;" + } + ] +] +*/ + +require_once(realpath (dirname ( __FILE__ )) . '/../../test_prepared_stmt_bind_value.inc'); +require_once(realpath (dirname ( __FILE__ )) . '/../../../../include/config.php'); + +$query = 'select * from sqlite_master where tbl_name = ? limit 1;'; +test_prepared_stmt(new PDO('sqlite::memory:'), $query); diff --git a/tests/integration/pdo/test_query_1.php b/tests/integration/pdo/sqlite/base-class/test_query_1_arg.php similarity index 76% rename from tests/integration/pdo/test_query_1.php rename to tests/integration/pdo/sqlite/base-class/test_query_1_arg.php index 21b932f49..df16dc8a3 100644 --- a/tests/integration/pdo/test_query_1.php +++ b/tests/integration/pdo/sqlite/base-class/test_query_1_arg.php @@ -6,14 +6,12 @@ /*DESCRIPTION The agent should record Datastore metrics for the one argument form of -PDO::query(). +PDO::query() when PDO base class constructor is used to create connection +object. */ /*SKIPIF -=")) { - die("skip: PHP >= 8.1.0 not supported\n"); -} +exec("CREATE TABLE test (id INT, desc VARCHAR(10));"), 'create table'); - - tap_equal(1, $conn->exec("INSERT INTO test VALUES (1, 'one');"), 'insert one'); - tap_equal(1, $conn->exec("INSERT INTO test VALUES (2, 'two');"), 'insert two'); - tap_equal(1, $conn->exec("INSERT INTO test VALUES (3, 'three');"), 'insert three'); - - $expected = array( - array('id' => '1', 'desc' => 'one'), - array('id' => '2', 'desc' => 'two'), - array('id' => '3', 'desc' => 'three') - ); - - $result = $conn->query('SELECT * FROM test;'); - $actual = $result->fetchAll(PDO::FETCH_ASSOC); - $result->closeCursor(); - tap_equal($expected, $actual, 'query (1-arg)'); - - tap_equal(1, $conn->exec("DROP TABLE test;"), 'drop table'); -} - -test_pdo_query(); +test_pdo_query(new PDO('sqlite::memory:')); diff --git a/tests/integration/pdo/test_query_3.php b/tests/integration/pdo/sqlite/base-class/test_query_fetch_class.php similarity index 82% rename from tests/integration/pdo/test_query_3.php rename to tests/integration/pdo/sqlite/base-class/test_query_fetch_class.php index e37919a72..e84fb4027 100644 --- a/tests/integration/pdo/test_query_3.php +++ b/tests/integration/pdo/sqlite/base-class/test_query_fetch_class.php @@ -6,11 +6,12 @@ /*DESCRIPTION The agent should record database metrics for the FETCH_CLASS variant of -PDO::query(). +PDO::query() when PDO base class constructor is used to create connection +object. */ /*SKIPIF -exec("CREATE TABLE test (id INT, desc VARCHAR(10));"), 'create table'); - tap_equal(1, $conn->exec("INSERT INTO test VALUES (1, 'one');"), 'insert row'); - - $expected = new Row(); - $expected->id = '1'; - $expected->desc = 'one'; - - $actual = $conn->query('SELECT * FROM test;', PDO::FETCH_CLASS, 'Row')->fetch(); - tap_assert($expected == $actual, 'fetch row as object'); - - tap_equal(1, $conn->exec("DROP TABLE test;"), 'drop table'); -} - -test_pdo_query(); +test_pdo_query(new PDO('sqlite::memory:')); diff --git a/tests/integration/pdo/test_query_2.php b/tests/integration/pdo/sqlite/base-class/test_query_fetch_column.php similarity index 81% rename from tests/integration/pdo/test_query_2.php rename to tests/integration/pdo/sqlite/base-class/test_query_fetch_column.php index e0269144c..37989527d 100644 --- a/tests/integration/pdo/test_query_2.php +++ b/tests/integration/pdo/sqlite/base-class/test_query_fetch_column.php @@ -6,11 +6,12 @@ /*DESCRIPTION The agent should record database metrics for the FETCH_COLUMN variant of -PDO::query(). +PDO::query() when PDO base class constructor is used to create connection +object. */ /*SKIPIF -exec("CREATE TABLE test (id INT, desc VARCHAR(10));"), 'create table'); - - tap_equal(1, $conn->exec("INSERT INTO test VALUES (1, 'one');"), 'insert one'); - tap_equal(1, $conn->exec("INSERT INTO test VALUES (2, 'two');"), 'insert two'); - tap_equal(1, $conn->exec("INSERT INTO test VALUES (3, 'three');"), 'insert three'); - - $result = $conn->query('SELECT * FROM test;', PDO::FETCH_COLUMN, 1); - $actual = $result->fetchAll(PDO::FETCH_ASSOC); - $result->closeCursor(); - tap_equal(3, count($actual), 'fetch column'); - - tap_equal(1, $conn->exec("DROP TABLE test;"), 'drop table'); -} - -test_pdo_query(); +test_pdo_query(new PDO('sqlite::memory:')); diff --git a/tests/integration/pdo/test_query_2_logging_off.php b/tests/integration/pdo/sqlite/base-class/test_query_fetch_column_logging_off.php similarity index 81% rename from tests/integration/pdo/test_query_2_logging_off.php rename to tests/integration/pdo/sqlite/base-class/test_query_fetch_column_logging_off.php index f3d2da948..76a35f1fc 100644 --- a/tests/integration/pdo/test_query_2_logging_off.php +++ b/tests/integration/pdo/sqlite/base-class/test_query_fetch_column_logging_off.php @@ -6,11 +6,12 @@ /*DESCRIPTION The agent should record database metrics for the FETCH_COLUMN variant of -PDO::query(). +PDO::query() when PDO base class constructor is used to create connection +object. */ /*SKIPIF -exec("CREATE TABLE test (id INT, desc VARCHAR(10));"), 'create table'); - - tap_equal(1, $conn->exec("INSERT INTO test VALUES (1, 'one');"), 'insert one'); - tap_equal(1, $conn->exec("INSERT INTO test VALUES (2, 'two');"), 'insert two'); - tap_equal(1, $conn->exec("INSERT INTO test VALUES (3, 'three');"), 'insert three'); - - $result = $conn->query('SELECT * FROM test;', PDO::FETCH_COLUMN, 1); - $actual = $result->fetchAll(PDO::FETCH_ASSOC); - $result->closeCursor(); - tap_equal(3, count($actual), 'fetch column'); - - tap_equal(1, $conn->exec("DROP TABLE test;"), 'drop table'); -} - -test_pdo_query(); +test_pdo_query(new PDO('sqlite::memory:')); diff --git a/tests/integration/pdo/test_query_4.php b/tests/integration/pdo/sqlite/base-class/test_query_fetch_into.php similarity index 82% rename from tests/integration/pdo/test_query_4.php rename to tests/integration/pdo/sqlite/base-class/test_query_fetch_into.php index 884bb1f8d..63c132317 100644 --- a/tests/integration/pdo/test_query_4.php +++ b/tests/integration/pdo/sqlite/base-class/test_query_fetch_into.php @@ -6,11 +6,12 @@ /*DESCRIPTION The agent should record database metrics for the FETCH_INTO variant of -PDO::query(). +PDO::query() when PDO base class constructor is used to create connection +object. */ /*SKIPIF -exec("CREATE TABLE test (id INT, desc VARCHAR(10));"), 'create table'); - tap_equal(1, $conn->exec("INSERT INTO test VALUES (1, 'one');"), 'insert row'); - - $expected = new Row(); - $expected->id = '1'; - $expected->desc = 'one'; - - $actual = new Row(); - $conn->query('SELECT * FROM test;', PDO::FETCH_INTO, $actual)->fetch(); - tap_assert($expected == $actual, 'fetch row into object'); - - tap_equal(1, $conn->exec("DROP TABLE test;"), 'drop table'); -} - -test_pdo_query(); +test_pdo_query(new PDO('sqlite::memory:')); diff --git a/tests/integration/pdo/sqlite/constructor/test_prepared_stmt_basic.php b/tests/integration/pdo/sqlite/constructor/test_prepared_stmt_basic.php new file mode 100644 index 000000000..bdb32dd76 --- /dev/null +++ b/tests/integration/pdo/sqlite/constructor/test_prepared_stmt_basic.php @@ -0,0 +1,107 @@ +", + "?? SQL id", + "select * from ENV[DATASTORE_COLLECTION] limit ?;", + "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/select", + 1, + "?? total time", + "?? min time", + "?? max time", + { + "backtrace": [ + "/ in PDOStatement::execute called at .*\/", + " in test_prepared_stmt called at __FILE__ (??)" + ] + } + ] + ] +] +*/ + +// peer.address is unknown:unknown because instance_reporting is disabled +/*EXPECT_SPAN_EVENTS_LIKE +[ + [ + { + "category": "datastore", + "type": "Span", + "guid": "??", + "traceId": "??", + "transactionId": "??", + "name": "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/select", + "timestamp": "??", + "duration": "??", + "priority": "??", + "sampled": true, + "parentId": "??", + "span.kind": "client", + "component": "ENV[DATASTORE_PRODUCT]" + }, + {}, + { + "peer.address": "unknown:unknown", + "db.statement": "select * from ENV[DATASTORE_COLLECTION] limit ?;" + } + ] +] +*/ + +require_once(realpath (dirname ( __FILE__ )) . '/../../test_prepared_stmt_basic.inc'); +require_once(realpath (dirname ( __FILE__ )) . '/../../../../include/config.php'); + +$query = 'select * from sqlite_schema limit 1;'; +test_prepared_stmt(new Pdo\Sqlite('sqlite::memory:'), $query); diff --git a/tests/integration/pdo/sqlite/constructor/test_prepared_stmt_bind_value.php b/tests/integration/pdo/sqlite/constructor/test_prepared_stmt_bind_value.php new file mode 100644 index 000000000..36e02cb5e --- /dev/null +++ b/tests/integration/pdo/sqlite/constructor/test_prepared_stmt_bind_value.php @@ -0,0 +1,108 @@ +", + "?? SQL id", + "select * from ENV[DATASTORE_COLLECTION] where tbl_name = ? limit ?;", + "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/select", + 1, + "?? total time", + "?? min time", + "?? max time", + { + "backtrace": [ + "/ in PDOStatement::execute called at .*\/", + " in test_prepared_stmt called at __FILE__ (??)" + ] + } + ] + ] +] +*/ + +// peer.address is unknown:unknown because instance_reporting is disabled +/*EXPECT_SPAN_EVENTS_LIKE +[ + [ + { + "category": "datastore", + "type": "Span", + "guid": "??", + "traceId": "??", + "transactionId": "??", + "name": "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/select", + "timestamp": "??", + "duration": "??", + "priority": "??", + "sampled": true, + "parentId": "??", + "span.kind": "client", + "component": "ENV[DATASTORE_PRODUCT]" + }, + {}, + { + "peer.address": "unknown:unknown", + "db.statement": "select * from ENV[DATASTORE_COLLECTION] where tbl_name = ? limit ?;" + } + ] +] +*/ + +require_once(realpath (dirname ( __FILE__ )) . '/../../test_prepared_stmt_bind_value.inc'); +require_once(realpath (dirname ( __FILE__ )) . '/../../../../include/config.php'); + +$query = 'select * from sqlite_schema where tbl_name = ? limit 1;'; +test_prepared_stmt(new Pdo\Sqlite('sqlite::memory:'), $query); diff --git a/tests/integration/pdo/sqlite/constructor/test_query_1_arg.php b/tests/integration/pdo/sqlite/constructor/test_query_1_arg.php new file mode 100644 index 000000000..d0dc104cf --- /dev/null +++ b/tests/integration/pdo/sqlite/constructor/test_query_1_arg.php @@ -0,0 +1,75 @@ +exec("CREATE TABLE test (id INT, desc VARCHAR(10));"), 'create table'); - - tap_equal(1, $conn->exec("INSERT INTO test VALUES (1, 'one');"), 'insert one'); - tap_equal(1, $conn->exec("INSERT INTO test VALUES (2, 'two');"), 'insert two'); - tap_equal(1, $conn->exec("INSERT INTO test VALUES (3, 'three');"), 'insert three'); - - $expected = array( - array('id' => 1, 'desc' => 'one'), - array('id' => 2, 'desc' => 'two'), - array('id' => 3, 'desc' => 'three') - ); - - $result = $conn->query('SELECT * FROM test;'); - $actual = $result->fetchAll(PDO::FETCH_ASSOC); - $result->closeCursor(); - tap_equal($expected, $actual, 'query (1-arg)'); - - tap_equal(1, $conn->exec("DROP TABLE test;"), 'drop table'); +class MyPDO extends \PDO +{ } -test_pdo_query(); +test_pdo_query(new MyPDO('sqlite::memory:')); diff --git a/tests/integration/pdo/sqlite/factory/test_prepared_stmt_basic.php b/tests/integration/pdo/sqlite/factory/test_prepared_stmt_basic.php new file mode 100644 index 000000000..652f65165 --- /dev/null +++ b/tests/integration/pdo/sqlite/factory/test_prepared_stmt_basic.php @@ -0,0 +1,107 @@ +", + "?? SQL id", + "select * from ENV[DATASTORE_COLLECTION] limit ?;", + "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/select", + 1, + "?? total time", + "?? min time", + "?? max time", + { + "backtrace": [ + "/ in PDOStatement::execute called at .*\/", + " in test_prepared_stmt called at __FILE__ (??)" + ] + } + ] + ] +] +*/ + +// peer.address is unknown:unknown because instance_reporting is disabled +/*EXPECT_SPAN_EVENTS_LIKE +[ + [ + { + "category": "datastore", + "type": "Span", + "guid": "??", + "traceId": "??", + "transactionId": "??", + "name": "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/select", + "timestamp": "??", + "duration": "??", + "priority": "??", + "sampled": true, + "parentId": "??", + "span.kind": "client", + "component": "ENV[DATASTORE_PRODUCT]" + }, + {}, + { + "peer.address": "unknown:unknown", + "db.statement": "select * from ENV[DATASTORE_COLLECTION] limit ?;" + } + ] +] +*/ + +require_once(realpath (dirname ( __FILE__ )) . '/../../test_prepared_stmt_basic.inc'); +require_once(realpath (dirname ( __FILE__ )) . '/../../../../include/config.php'); + +$query = 'select * from sqlite_schema limit 1;'; +test_prepared_stmt(PDO::Connect('sqlite::memory:'), $query); diff --git a/tests/integration/pdo/sqlite/factory/test_prepared_stmt_bind_value.php b/tests/integration/pdo/sqlite/factory/test_prepared_stmt_bind_value.php new file mode 100644 index 000000000..c4c548970 --- /dev/null +++ b/tests/integration/pdo/sqlite/factory/test_prepared_stmt_bind_value.php @@ -0,0 +1,108 @@ +", + "?? SQL id", + "select * from ENV[DATASTORE_COLLECTION] where tbl_name = ? limit ?;", + "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/select", + 1, + "?? total time", + "?? min time", + "?? max time", + { + "backtrace": [ + "/ in PDOStatement::execute called at .*\/", + " in test_prepared_stmt called at __FILE__ (??)" + ] + } + ] + ] +] +*/ + +// peer.address is unknown:unknown because instance_reporting is disabled +/*EXPECT_SPAN_EVENTS_LIKE +[ + [ + { + "category": "datastore", + "type": "Span", + "guid": "??", + "traceId": "??", + "transactionId": "??", + "name": "Datastore/statement/ENV[DATASTORE_PRODUCT]/ENV[DATASTORE_COLLECTION]/select", + "timestamp": "??", + "duration": "??", + "priority": "??", + "sampled": true, + "parentId": "??", + "span.kind": "client", + "component": "ENV[DATASTORE_PRODUCT]" + }, + {}, + { + "peer.address": "unknown:unknown", + "db.statement": "select * from ENV[DATASTORE_COLLECTION] where tbl_name = ? limit ?;" + } + ] +] +*/ + +require_once(realpath (dirname ( __FILE__ )) . '/../../test_prepared_stmt_bind_value.inc'); +require_once(realpath (dirname ( __FILE__ )) . '/../../../../include/config.php'); + +$query = 'select * from sqlite_schema where tbl_name = ? limit 1;'; +test_prepared_stmt(PDO::Connect('sqlite::memory:'), $query); diff --git a/tests/integration/pdo/sqlite/factory/test_query_1_arg.php b/tests/integration/pdo/sqlite/factory/test_query_1_arg.php new file mode 100644 index 000000000..edab45185 --- /dev/null +++ b/tests/integration/pdo/sqlite/factory/test_query_1_arg.php @@ -0,0 +1,75 @@ +", "?? SQL id", - "select * from tables limit ?;", + "select * from information_schema.tables limit ?;", "Datastore/statement/MySQL/tables/select", 1, "?? total time", @@ -85,7 +85,7 @@ function test_slow_sql() global $PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD; $conn = new PDO($PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD, array()); - $result = $conn->query('select * from tables limit 1;'); + $result = $conn->query('select * from information_schema.tables limit 1;'); } test_slow_sql(); diff --git a/tests/integration/pdo/test_empty_driver_options.php81.php b/tests/integration/pdo/test_empty_driver_options.php81.php index 60f3e3778..e29984f62 100644 --- a/tests/integration/pdo/test_empty_driver_options.php81.php +++ b/tests/integration/pdo/test_empty_driver_options.php81.php @@ -32,7 +32,7 @@ "OtherTransaction/php__FILE__", "", "?? SQL id", - "select * from tables limit ?;", + "select * from information_schema.tables limit ?;", "Datastore/statement/MySQL/tables/select", 1, "?? total time", @@ -85,7 +85,7 @@ function test_slow_sql() global $PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD; $conn = new PDO($PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD, array()); - $result = $conn->query('select * from tables limit 1;'); + $result = $conn->query('select * from information_schema.tables limit 1;'); } test_slow_sql(); diff --git a/tests/integration/pdo/test_instance_reporting.inc b/tests/integration/pdo/test_instance_reporting.inc new file mode 100644 index 000000000..0ae7fb6a8 --- /dev/null +++ b/tests/integration/pdo/test_instance_reporting.inc @@ -0,0 +1,33 @@ +exec("CREATE TABLE test (id INT, description VARCHAR(10));"), 'create table'); + tap_equal($want_drop_table_result, $conn->exec("DROP TABLE test;"), 'drop table'); +} diff --git a/tests/integration/pdo/test_instance_slow_sql_1.php b/tests/integration/pdo/test_instance_slow_sql_1.php index 465ab00a1..b767100ba 100644 --- a/tests/integration/pdo/test_instance_slow_sql_1.php +++ b/tests/integration/pdo/test_instance_slow_sql_1.php @@ -45,7 +45,7 @@ "OtherTransaction/php__FILE__", "", "?? SQL id", - "select * from tables limit ?;", + "select * from information_schema.tables limit ?;", "Datastore/statement/MySQL/tables/select", 1, "?? total time", @@ -103,7 +103,7 @@ function test_query() { global $PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD; $conn = new PDO($PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD); - $result = $conn->query('select * from tables limit 1;'); + $result = $conn->query('select * from information_schema.tables limit 1;'); } test_query(); diff --git a/tests/integration/pdo/test_instance_slow_sql_1.php81.php b/tests/integration/pdo/test_instance_slow_sql_1.php81.php index 80a890f2e..1d217e04f 100644 --- a/tests/integration/pdo/test_instance_slow_sql_1.php81.php +++ b/tests/integration/pdo/test_instance_slow_sql_1.php81.php @@ -41,7 +41,7 @@ "OtherTransaction/php__FILE__", "", "?? SQL id", - "select * from tables limit ?;", + "select * from information_schema.tables limit ?;", "Datastore/statement/MySQL/tables/select", 1, "?? total time", @@ -99,7 +99,7 @@ function test_query() { global $PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD; $conn = new PDO($PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD); - $result = $conn->query('select * from tables limit 1;'); + $result = $conn->query('select * from information_schema.tables limit 1;'); } test_query(); diff --git a/tests/integration/pdo/test_instance_slow_sql_2.php b/tests/integration/pdo/test_instance_slow_sql_2.php index afa7e5df6..47330ea78 100644 --- a/tests/integration/pdo/test_instance_slow_sql_2.php +++ b/tests/integration/pdo/test_instance_slow_sql_2.php @@ -40,7 +40,7 @@ "OtherTransaction/php__FILE__", "", "?? SQL id", - "select * from tables limit ?;", + "select * from information_schema.tables limit ?;", "Datastore/statement/MySQL/tables/select", 1, "?? total time", @@ -98,7 +98,7 @@ function test_slow_sql() { global $PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD; $conn = new PDO($PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD); - $stmt = $conn->prepare('select * from tables limit 1;'); + $stmt = $conn->prepare('select * from information_schema.tables limit 1;'); tap_assert($stmt->execute(), 'execute slow query'); } diff --git a/tests/integration/pdo/test_instance_slow_sql_2.php81.php b/tests/integration/pdo/test_instance_slow_sql_2.php81.php index 60e833f34..9a7767cf0 100644 --- a/tests/integration/pdo/test_instance_slow_sql_2.php81.php +++ b/tests/integration/pdo/test_instance_slow_sql_2.php81.php @@ -40,7 +40,7 @@ "OtherTransaction/php__FILE__", "", "?? SQL id", - "select * from tables limit ?;", + "select * from information_schema.tables limit ?;", "Datastore/statement/MySQL/tables/select", 1, "?? total time", @@ -98,7 +98,7 @@ function test_slow_sql() { global $PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD; $conn = new PDO($PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD); - $stmt = $conn->prepare('select * from tables limit 1;'); + $stmt = $conn->prepare('select * from information_schema.tables limit 1;'); tap_assert($stmt->execute(), 'execute slow query'); } diff --git a/tests/integration/pdo/test_instance_slow_sql_for_update.php b/tests/integration/pdo/test_instance_slow_sql_for_update.php index 3ba2a18bc..1aac88955 100644 --- a/tests/integration/pdo/test_instance_slow_sql_for_update.php +++ b/tests/integration/pdo/test_instance_slow_sql_for_update.php @@ -36,7 +36,7 @@ "OtherTransaction/php__FILE__", "", "?? SQL id", - "select * from tables limit ? for update;", + "select * from information_schema.tables limit ? for update;", "Datastore/statement/MySQL/tables/select", 1, "?? total time", @@ -66,7 +66,7 @@ function test_slow_sql() { global $PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD; $conn = new PDO($PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD); - $result = $conn->query('select * from tables limit 1 for update;'); + $result = $conn->query('select * from information_schema.tables limit 1 for update;'); } test_slow_sql(); diff --git a/tests/integration/pdo/test_instance_slow_sql_lock.php b/tests/integration/pdo/test_instance_slow_sql_lock.php index 798d4272d..ea3db1bc7 100644 --- a/tests/integration/pdo/test_instance_slow_sql_lock.php +++ b/tests/integration/pdo/test_instance_slow_sql_lock.php @@ -37,7 +37,7 @@ "OtherTransaction/php__FILE__", "", "?? SQL id", - "select * from tables limit ? lock in share mode;", + "select * from information_schema.tables limit ? lock in share mode;", "Datastore/statement/MySQL/tables/select", 1, "?? total time", @@ -67,7 +67,7 @@ function test_slow_sql() { global $PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD; $conn = new PDO($PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD); - $result = $conn->query('select * from tables limit 1 lock in share mode;'); + $result = $conn->query('select * from information_schema.tables limit 1 lock in share mode;'); } test_slow_sql(); diff --git a/tests/integration/pdo/test_instance_slow_sql_semicolon.php b/tests/integration/pdo/test_instance_slow_sql_semicolon.php index 2c07e0023..c26da78ed 100644 --- a/tests/integration/pdo/test_instance_slow_sql_semicolon.php +++ b/tests/integration/pdo/test_instance_slow_sql_semicolon.php @@ -36,7 +36,7 @@ "OtherTransaction/php__FILE__", "", "?? SQL id", - "select * from tables where engine = ?;", + "select * from information_schema.tables where engine = ?;", "Datastore/statement/MySQL/tables/select", 1, "?? total time", @@ -66,7 +66,7 @@ function test_slow_sql() { global $PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD; $conn = new PDO($PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD); - $result = $conn->query('select * from tables where engine = \';\';'); + $result = $conn->query('select * from information_schema.tables where engine = \';\';'); } test_slow_sql(); diff --git a/tests/integration/pdo/test_null_options.php b/tests/integration/pdo/test_null_options.php index 16e522a57..ea61e7343 100644 --- a/tests/integration/pdo/test_null_options.php +++ b/tests/integration/pdo/test_null_options.php @@ -32,7 +32,7 @@ "OtherTransaction/php__FILE__", "", "?? SQL id", - "select * from tables limit ?;", + "select * from information_schema.tables limit ?;", "Datastore/statement/MySQL/tables/select", 1, "?? total time", @@ -85,7 +85,7 @@ function test_slow_sql() { $options = null; $conn = new PDO($PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD, $options); - $result = $conn->query('select * from tables limit 1;'); + $result = $conn->query('select * from information_schema.tables limit 1;'); } test_slow_sql(); diff --git a/tests/integration/pdo/test_null_options.php81.php b/tests/integration/pdo/test_null_options.php81.php index 528855b81..6f61e3a00 100644 --- a/tests/integration/pdo/test_null_options.php81.php +++ b/tests/integration/pdo/test_null_options.php81.php @@ -32,7 +32,7 @@ "OtherTransaction/php__FILE__", "", "?? SQL id", - "select * from tables limit ?;", + "select * from information_schema.tables limit ?;", "Datastore/statement/MySQL/tables/select", 1, "?? total time", @@ -85,7 +85,7 @@ function test_slow_sql() { $options = null; $conn = new PDO($PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD, $options); - $result = $conn->query('select * from tables limit 1;'); + $result = $conn->query('select * from information_schema.tables limit 1;'); } test_slow_sql(); diff --git a/tests/integration/pdo/test_persistent_conn.php b/tests/integration/pdo/test_persistent_conn.php index b44785305..b5453d889 100644 --- a/tests/integration/pdo/test_persistent_conn.php +++ b/tests/integration/pdo/test_persistent_conn.php @@ -32,7 +32,7 @@ "OtherTransaction/php__FILE__", "", "?? SQL id", - "select * from tables limit ?;", + "select * from information_schema.tables limit ?;", "Datastore/statement/MySQL/tables/select", 1, "?? total time", @@ -86,7 +86,7 @@ function test_slow_sql() $options = array(PDO::ATTR_PERSISTENT => true); $conn = new PDO($PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD, $options); - $result = $conn->query('select * from tables limit 1;'); + $result = $conn->query('select * from information_schema.tables limit 1;'); } test_slow_sql(); diff --git a/tests/integration/pdo/test_persistent_conn.php81.php b/tests/integration/pdo/test_persistent_conn.php81.php index ad185d896..2c669bd7f 100644 --- a/tests/integration/pdo/test_persistent_conn.php81.php +++ b/tests/integration/pdo/test_persistent_conn.php81.php @@ -32,7 +32,7 @@ "OtherTransaction/php__FILE__", "", "?? SQL id", - "select * from tables limit ?;", + "select * from information_schema.tables limit ?;", "Datastore/statement/MySQL/tables/select", 1, "?? total time", @@ -86,7 +86,7 @@ function test_slow_sql() $options = array(PDO::ATTR_PERSISTENT => true); $conn = new PDO($PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD, $options); - $result = $conn->query('select * from tables limit 1;'); + $result = $conn->query('select * from information_schema.tables limit 1;'); } test_slow_sql(); diff --git a/tests/integration/pdo/test_prepared_stmt_basic.inc b/tests/integration/pdo/test_prepared_stmt_basic.inc new file mode 100644 index 000000000..4db6fd87b --- /dev/null +++ b/tests/integration/pdo/test_prepared_stmt_basic.inc @@ -0,0 +1,31 @@ +prepare($query); + tap_assert($stmt->execute(), 'execute prepared statement'); +} diff --git a/tests/integration/pdo/test_prepared_stmt_bind_value.inc b/tests/integration/pdo/test_prepared_stmt_bind_value.inc new file mode 100644 index 000000000..6ba2ffd82 --- /dev/null +++ b/tests/integration/pdo/test_prepared_stmt_bind_value.inc @@ -0,0 +1,32 @@ +prepare($query); + $stmt->bindValue(1, "missing"); + tap_assert($stmt->execute(), 'execute prepared statement'); +} diff --git a/tests/integration/pdo/test_prepared_stmt_params.php b/tests/integration/pdo/test_prepared_stmt_params.php index cd097e04f..7bb92e7c3 100644 --- a/tests/integration/pdo/test_prepared_stmt_params.php +++ b/tests/integration/pdo/test_prepared_stmt_params.php @@ -36,7 +36,7 @@ "OtherTransaction/php__FILE__", "", "?? SQL id", - "select * from tables where table_name = ? limit ?;", + "select * from information_schema.tables where table_name = ? limit ?;", "Datastore/statement/MySQL/tables/select", 1, "?? total time", @@ -88,7 +88,7 @@ function test_prepared_statement() { global $PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD; $conn = new PDO($PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD); - $stmt = $conn->prepare('select * from tables where table_name = ? limit 1;'); + $stmt = $conn->prepare('select * from information_schema.tables where table_name = ? limit 1;'); $stmt->bindValue(1, "missing"); tap_assert($stmt->execute(), 'execute prepared statement with a param'); } diff --git a/tests/integration/pdo/test_prepared_stmt_params.php81.php b/tests/integration/pdo/test_prepared_stmt_params.php81.php index 001b38dd3..5c1b40c99 100644 --- a/tests/integration/pdo/test_prepared_stmt_params.php81.php +++ b/tests/integration/pdo/test_prepared_stmt_params.php81.php @@ -36,7 +36,7 @@ "OtherTransaction/php__FILE__", "", "?? SQL id", - "select * from tables where table_name = ? limit ?;", + "select * from information_schema.tables where table_name = ? limit ?;", "Datastore/statement/MySQL/tables/select", 1, "?? total time", @@ -88,7 +88,7 @@ function test_prepared_statement() { global $PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD; $conn = new PDO($PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD); - $stmt = $conn->prepare('select * from tables where table_name = ? limit 1;'); + $stmt = $conn->prepare('select * from information_schema.tables where table_name = ? limit 1;'); $stmt->bindValue(1, "missing"); tap_assert($stmt->execute(), 'execute prepared statement with a param'); } diff --git a/tests/integration/pdo/test_query_1_arg.inc b/tests/integration/pdo/test_query_1_arg.inc new file mode 100644 index 000000000..104405786 --- /dev/null +++ b/tests/integration/pdo/test_query_1_arg.inc @@ -0,0 +1,51 @@ +exec("CREATE TABLE test (id INT, description VARCHAR(10));"), 'create table'); + + tap_equal(1, $conn->exec("INSERT INTO test VALUES (1, 'one');"), 'insert one'); + tap_equal(1, $conn->exec("INSERT INTO test VALUES (2, 'two');"), 'insert two'); + tap_equal(1, $conn->exec("INSERT INTO test VALUES (3, 'three');"), 'insert three'); + + $expected = array( + array('id' => 1, 'description' => 'one'), + array('id' => 2, 'description' => 'two'), + array('id' => 3, 'description' => 'three') + ); + + $result = $conn->query('SELECT * FROM test;'); + $actual = $result->fetchAll(PDO::FETCH_ASSOC); + $result->closeCursor(); + // normalize id to int type + array_walk($actual, function (&$row, $key) { + $row['id'] = intval($row['id']); + }); + tap_equal($expected, $actual, 'query (1-arg)'); + + tap_equal($want_drop_table_result, $conn->exec("DROP TABLE test;"), 'drop table'); +} diff --git a/tests/integration/pdo/test_query_fetch_class.inc b/tests/integration/pdo/test_query_fetch_class.inc new file mode 100644 index 000000000..4aef4c76f --- /dev/null +++ b/tests/integration/pdo/test_query_fetch_class.inc @@ -0,0 +1,44 @@ +exec("CREATE TABLE test (id INT, description VARCHAR(10));"), 'create table'); + tap_equal(1, $conn->exec("INSERT INTO test VALUES (1, 'one');"), 'insert row'); + + $expected = new Row(); + $expected->id = '1'; + $expected->description = 'one'; + + $actual = $conn->query('SELECT * FROM test;', PDO::FETCH_CLASS, 'Row')->fetch(); + tap_assert($expected == $actual, 'fetch row as object'); + + tap_equal($want_drop_table_result, $conn->exec("DROP TABLE test;"), 'drop table'); +} diff --git a/tests/integration/pdo/test_query_fetch_column.inc b/tests/integration/pdo/test_query_fetch_column.inc new file mode 100644 index 000000000..df1c590e5 --- /dev/null +++ b/tests/integration/pdo/test_query_fetch_column.inc @@ -0,0 +1,40 @@ +exec("CREATE TABLE test (id INT, description VARCHAR(10));"), 'create table'); + + tap_equal(1, $conn->exec("INSERT INTO test VALUES (1, 'one');"), 'insert one'); + tap_equal(1, $conn->exec("INSERT INTO test VALUES (2, 'two');"), 'insert two'); + tap_equal(1, $conn->exec("INSERT INTO test VALUES (3, 'three');"), 'insert three'); + + $result = $conn->query('SELECT * FROM test;', PDO::FETCH_COLUMN, 1); + $actual = $result->fetchAll(PDO::FETCH_ASSOC); + $result->closeCursor(); + tap_equal(3, count($actual), 'fetch column'); + + tap_equal($want_drop_table_result, $conn->exec("DROP TABLE test;"), 'drop table'); +} diff --git a/tests/integration/pdo/test_query_fetch_into.inc b/tests/integration/pdo/test_query_fetch_into.inc new file mode 100644 index 000000000..2cc144881 --- /dev/null +++ b/tests/integration/pdo/test_query_fetch_into.inc @@ -0,0 +1,45 @@ +exec("CREATE TABLE test (id INT, description VARCHAR(10));"), 'create table'); + tap_equal(1, $conn->exec("INSERT INTO test VALUES (1, 'one');"), 'insert row'); + + $expected = new Row(); + $expected->id = '1'; + $expected->description = 'one'; + + $actual = new Row(); + $conn->query('SELECT * FROM test;', PDO::FETCH_INTO, $actual)->fetch(); + tap_assert($expected == $actual, 'fetch row into object'); + + tap_equal($want_drop_table_result, $conn->exec("DROP TABLE test;"), 'drop table'); +} diff --git a/tests/integration/pdo/test_slow_sql_1.php b/tests/integration/pdo/test_slow_sql_1.php index 84e0aa06c..86b4aea7f 100644 --- a/tests/integration/pdo/test_slow_sql_1.php +++ b/tests/integration/pdo/test_slow_sql_1.php @@ -31,7 +31,7 @@ "OtherTransaction/php__FILE__", "", "?? SQL id", - "select * from tables limit ?;", + "select * from information_schema.tables limit ?;", "Datastore/statement/MySQL/tables/select", 1, "?? total time", @@ -83,7 +83,7 @@ function test_slow_sql() { global $PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD; $conn = new PDO($PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD); - $result = $conn->query('select * from tables limit 1;'); + $result = $conn->query('select * from information_schema.tables limit 1;'); } test_slow_sql(); diff --git a/tests/integration/pdo/test_slow_sql_1.php81.php b/tests/integration/pdo/test_slow_sql_1.php81.php index 6d5b4064e..e420b7b97 100644 --- a/tests/integration/pdo/test_slow_sql_1.php81.php +++ b/tests/integration/pdo/test_slow_sql_1.php81.php @@ -31,7 +31,7 @@ "OtherTransaction/php__FILE__", "", "?? SQL id", - "select * from tables limit ?;", + "select * from information_schema.tables limit ?;", "Datastore/statement/MySQL/tables/select", 1, "?? total time", @@ -83,7 +83,7 @@ function test_slow_sql() { global $PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD; $conn = new PDO($PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD); - $result = $conn->query('select * from tables limit 1;'); + $result = $conn->query('select * from information_schema.tables limit 1;'); } test_slow_sql(); diff --git a/tests/integration/pdo/test_slow_sql_2.php b/tests/integration/pdo/test_slow_sql_2.php index f2f928385..2c3bb54d2 100644 --- a/tests/integration/pdo/test_slow_sql_2.php +++ b/tests/integration/pdo/test_slow_sql_2.php @@ -35,7 +35,7 @@ "OtherTransaction/php__FILE__", "", "?? SQL id", - "select * from tables limit ?;", + "select * from information_schema.tables limit ?;", "Datastore/statement/MySQL/tables/select", 1, "?? total time", @@ -87,7 +87,7 @@ function test_slow_sql() { global $PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD; $conn = new PDO($PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD); - $stmt = $conn->prepare('select * from tables limit 1;'); + $stmt = $conn->prepare('select * from information_schema.tables limit 1;'); tap_assert($stmt->execute(), 'execute slow query'); } diff --git a/tests/integration/pdo/test_slow_sql_2.php81.php b/tests/integration/pdo/test_slow_sql_2.php81.php index a80a43510..f52008c2c 100644 --- a/tests/integration/pdo/test_slow_sql_2.php81.php +++ b/tests/integration/pdo/test_slow_sql_2.php81.php @@ -35,7 +35,7 @@ "OtherTransaction/php__FILE__", "", "?? SQL id", - "select * from tables limit ?;", + "select * from information_schema.tables limit ?;", "Datastore/statement/MySQL/tables/select", 1, "?? total time", @@ -87,7 +87,7 @@ function test_slow_sql() { global $PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD; $conn = new PDO($PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD); - $stmt = $conn->prepare('select * from tables limit 1;'); + $stmt = $conn->prepare('select * from information_schema.tables limit 1;'); tap_assert($stmt->execute(), 'execute slow query'); } diff --git a/tests/integration/pdo/test_slow_sql_for_update.php b/tests/integration/pdo/test_slow_sql_for_update.php index 2a074b689..63e75d373 100644 --- a/tests/integration/pdo/test_slow_sql_for_update.php +++ b/tests/integration/pdo/test_slow_sql_for_update.php @@ -28,7 +28,7 @@ "OtherTransaction/php__FILE__", "", "?? SQL id", - "select * from tables limit ? for update;", + "select * from information_schema.tables limit ? for update;", "Datastore/statement/MySQL/tables/select", 1, "?? total time", @@ -51,7 +51,7 @@ function test_slow_sql() { global $PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD; $conn = new PDO($PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD); - $result = $conn->query('select * from tables limit 1 for update;'); + $result = $conn->query('select * from information_schema.tables limit 1 for update;'); } test_slow_sql(); diff --git a/tests/integration/pdo/test_slow_sql_lock.php b/tests/integration/pdo/test_slow_sql_lock.php index c87464ad3..7f1d07722 100644 --- a/tests/integration/pdo/test_slow_sql_lock.php +++ b/tests/integration/pdo/test_slow_sql_lock.php @@ -28,7 +28,7 @@ "OtherTransaction/php__FILE__", "", "?? SQL id", - "select * from tables limit ? lock in share mode;", + "select * from information_schema.tables limit ? lock in share mode;", "Datastore/statement/MySQL/tables/select", 1, "?? total time", @@ -51,7 +51,7 @@ function test_slow_sql() { global $PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD; $conn = new PDO($PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD); - $result = $conn->query('select * from tables limit 1 lock in share mode;'); + $result = $conn->query('select * from information_schema.tables limit 1 lock in share mode;'); } test_slow_sql(); diff --git a/tests/integration/pdo/test_slow_sql_semicolon.php b/tests/integration/pdo/test_slow_sql_semicolon.php index 87901b7e5..4f88e76d5 100644 --- a/tests/integration/pdo/test_slow_sql_semicolon.php +++ b/tests/integration/pdo/test_slow_sql_semicolon.php @@ -28,7 +28,7 @@ "OtherTransaction/php__FILE__", "", "?? SQL id", - "select * from tables where engine = ?;", + "select * from information_schema.tables where engine = ?;", "Datastore/statement/MySQL/tables/select", 1, "?? total time", @@ -51,7 +51,7 @@ function test_slow_sql() { global $PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD; $conn = new PDO($PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD); - $result = $conn->query('select * from tables where engine = \';\';'); + $result = $conn->query('select * from information_schema.tables where engine = \';\';'); } test_slow_sql(); diff --git a/tests/integration/span_events/test_span_events_are_created_upon_caught_error.php b/tests/integration/span_events/test_span_events_are_created_upon_caught_error.php index 91b1420be..56e161179 100644 --- a/tests/integration/span_events/test_span_events_are_created_upon_caught_error.php +++ b/tests/integration/span_events/test_span_events_are_created_upon_caught_error.php @@ -14,6 +14,9 @@ if (version_compare(PHP_VERSION, "7.0", "<")) { die("skip: CLM for PHP 5 not supported\n"); } +if (version_compare(PHP_VERSION, "8.4", ">=")) { + die("skip: newer test for PHP 8.4+\n"); +} */ /*INI @@ -92,7 +95,7 @@ { "error.message": "foo", "error.class": "E_USER_ERROR", - "code.lineno": 136, + "code.lineno": 139, "code.filepath": "__FILE__", "code.function": "a" } @@ -113,7 +116,7 @@ }, {}, { - "code.lineno": 130, + "code.lineno": 133, "code.filepath": "__FILE__", "code.function": "{closure}" } diff --git a/tests/integration/span_events/test_span_events_are_created_upon_caught_error.php5.php b/tests/integration/span_events/test_span_events_are_created_upon_caught_error.php84.php similarity index 80% rename from tests/integration/span_events/test_span_events_are_created_upon_caught_error.php5.php rename to tests/integration/span_events/test_span_events_are_created_upon_caught_error.php84.php index 22a82caa9..fabe4bddd 100644 --- a/tests/integration/span_events/test_span_events_are_created_upon_caught_error.php5.php +++ b/tests/integration/span_events/test_span_events_are_created_upon_caught_error.php84.php @@ -7,6 +7,14 @@ /*DESCRIPTION Test that span events are correctly created from any eligible segment, even when an error is generated and handled. +PHP 8.4+ names closures differently. +*/ + +/*SKIPIF +=")) { + die("skip: newer test for PHP 8.4\n"); +} */ /*INI @@ -92,7 +95,7 @@ { "error.message": "foo", "error.class": "E_USER_ERROR", - "code.lineno": 108, + "code.lineno": 111, "code.filepath": "__FILE__", "code.function": "a" } diff --git a/tests/integration/span_events/test_span_events_are_created_upon_uncaught_error.php5.php b/tests/integration/span_events/test_span_events_are_created_upon_uncaught_error.php5.php index 5353e0da0..3e17f5371 100644 --- a/tests/integration/span_events/test_span_events_are_created_upon_uncaught_error.php5.php +++ b/tests/integration/span_events/test_span_events_are_created_upon_uncaught_error.php5.php @@ -19,6 +19,13 @@ newrelic.code_level_metrics.enabled=false */ +/*SKIPIF +=")) { + die("skip: newer test for PHP 8.4\n"); +} +*/ + /*EXPECT_SPAN_EVENTS [ "?? agent run id", diff --git a/tests/integration/span_events/test_span_events_are_created_upon_uncaught_error.php84.php b/tests/integration/span_events/test_span_events_are_created_upon_uncaught_error.php84.php new file mode 100644 index 000000000..b56ef56a2 --- /dev/null +++ b/tests/integration/span_events/test_span_events_are_created_upon_uncaught_error.php84.php @@ -0,0 +1,122 @@ + 'FakeDB', + ) +); +a(); diff --git a/tests/integration/span_events/test_span_events_are_created_upon_uncaught_handled_exception.php b/tests/integration/span_events/test_span_events_are_created_upon_uncaught_handled_exception.php index 7670f8a27..24d3e6da2 100644 --- a/tests/integration/span_events/test_span_events_are_created_upon_uncaught_handled_exception.php +++ b/tests/integration/span_events/test_span_events_are_created_upon_uncaught_handled_exception.php @@ -16,6 +16,9 @@ if (version_compare(PHP_VERSION, "8.0", "<")) { die("skip: test for oapi agent only\n"); } +if (version_compare(PHP_VERSION, "8.4", ">=")) { + die("skip: newer test for PHP 8.4+\n"); +} */ /*INI diff --git a/tests/integration/span_events/test_span_events_are_created_upon_uncaught_handled_exception.php84.php b/tests/integration/span_events/test_span_events_are_created_upon_uncaught_handled_exception.php84.php new file mode 100644 index 000000000..c9e6a3455 --- /dev/null +++ b/tests/integration/span_events/test_span_events_are_created_upon_uncaught_handled_exception.php84.php @@ -0,0 +1,183 @@ + 'FakeDB', + ) +); +a(); + +echo 'this should never be printed'; diff --git a/tests/integration/synthetics/test_happy_path_with_dt.php b/tests/integration/synthetics/test_happy_path_with_dt.php index 855a35e2a..bd415e684 100644 --- a/tests/integration/synthetics/test_happy_path_with_dt.php +++ b/tests/integration/synthetics/test_happy_path_with_dt.php @@ -62,6 +62,7 @@ "nr.syntheticsJobId": "jjjjjjj-jjjj-1234-jjjj-jjjjjjjjjjjj", "nr.syntheticsMonitorId": "mmmmmmm-mmmm-1234-mmmm-mmmmmmmmmmmm", "externalDuration": "??", + "externalCallCount": 1, "guid": "??", "sampled": true, "priority": "??", diff --git a/tests/lasp/suite-least-secure/test_slow_sql_on.php b/tests/lasp/suite-least-secure/test_slow_sql_on.php index e4b693b0b..003595b14 100644 --- a/tests/lasp/suite-least-secure/test_slow_sql_on.php +++ b/tests/lasp/suite-least-secure/test_slow_sql_on.php @@ -31,8 +31,8 @@ [ "OtherTransaction/php__FILE__", "\u003cunknown\u003e", - 2691358128, - "select * from tables limit ?;", + 2279837883, + "select * from information_schema.tables limit ?;", "Datastore/statement/MySQL/tables/select", "??", "??", @@ -85,7 +85,7 @@ function test_slow_sql() global $PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD; $conn = new PDO($PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD, array()); - $result = $conn->query('select * from tables limit 1;'); + $result = $conn->query('select * from information_schema.tables limit 1;'); } test_slow_sql(); diff --git a/tests/lasp/suite-least-secure/test_slow_sql_on.php81.php b/tests/lasp/suite-least-secure/test_slow_sql_on.php81.php index b4e678a8b..a9696beb7 100644 --- a/tests/lasp/suite-least-secure/test_slow_sql_on.php81.php +++ b/tests/lasp/suite-least-secure/test_slow_sql_on.php81.php @@ -31,8 +31,8 @@ [ "OtherTransaction/php__FILE__", "\u003cunknown\u003e", - 2691358128, - "select * from tables limit ?;", + 2279837883, + "select * from information_schema.tables limit ?;", "Datastore/statement/MySQL/tables/select", "??", "??", @@ -85,7 +85,7 @@ function test_slow_sql() global $PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD; $conn = new PDO($PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD, array()); - $result = $conn->query('select * from tables limit 1;'); + $result = $conn->query('select * from information_schema.tables limit 1;'); } test_slow_sql(); diff --git a/tests/lasp/suite-most-secure/test_slow_sql_off.php b/tests/lasp/suite-most-secure/test_slow_sql_off.php index e5e252eea..e464fd0d0 100644 --- a/tests/lasp/suite-most-secure/test_slow_sql_off.php +++ b/tests/lasp/suite-most-secure/test_slow_sql_off.php @@ -35,7 +35,7 @@ function test_slow_sql() global $PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD; $conn = new PDO($PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD, array()); - $result = $conn->query('select * from tables limit 1;'); + $result = $conn->query('select * from information_schema.tables limit 1;'); } test_slow_sql(); diff --git a/tests/lasp/suite-random-2/test_slow_sql_on.php b/tests/lasp/suite-random-2/test_slow_sql_on.php index b68fb481f..c1e86a5fa 100644 --- a/tests/lasp/suite-random-2/test_slow_sql_on.php +++ b/tests/lasp/suite-random-2/test_slow_sql_on.php @@ -30,8 +30,8 @@ [ "OtherTransaction/php__FILE__", "\u003cunknown\u003e", - 2691358128, - "select * from tables limit ?;", + 2279837883, + "select * from information_schema.tables limit ?;", "Datastore/statement/MySQL/tables/select", "??", "??", @@ -84,7 +84,7 @@ function test_slow_sql() global $PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD; $conn = new PDO($PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD, array()); - $result = $conn->query('select * from tables limit 1;'); + $result = $conn->query('select * from information_schema.tables limit 1;'); } test_slow_sql(); diff --git a/tests/lasp/suite-random-2/test_slow_sql_on.php81.php b/tests/lasp/suite-random-2/test_slow_sql_on.php81.php index d229271ef..c25195200 100644 --- a/tests/lasp/suite-random-2/test_slow_sql_on.php81.php +++ b/tests/lasp/suite-random-2/test_slow_sql_on.php81.php @@ -30,8 +30,8 @@ [ "OtherTransaction/php__FILE__", "\u003cunknown\u003e", - 2691358128, - "select * from tables limit ?;", + 2279837883, + "select * from information_schema.tables limit ?;", "Datastore/statement/MySQL/tables/select", "??", "??", @@ -84,7 +84,7 @@ function test_slow_sql() global $PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD; $conn = new PDO($PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD, array()); - $result = $conn->query('select * from tables limit 1;'); + $result = $conn->query('select * from information_schema.tables limit 1;'); } test_slow_sql(); diff --git a/tests/lasp/suite-random-3/test_slow_sql_off.php b/tests/lasp/suite-random-3/test_slow_sql_off.php index 18c3c7f84..087f130bb 100644 --- a/tests/lasp/suite-random-3/test_slow_sql_off.php +++ b/tests/lasp/suite-random-3/test_slow_sql_off.php @@ -34,7 +34,7 @@ function test_slow_sql() global $PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD; $conn = new PDO($PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD, array()); - $result = $conn->query('select * from tables limit 1;'); + $result = $conn->query('select * from information_schema.tables limit 1;'); } test_slow_sql(); diff --git a/tests/lasp/suite-random-3/test_slow_sql_on.php b/tests/lasp/suite-random-3/test_slow_sql_on.php index d55b78edf..6ec54ea93 100644 --- a/tests/lasp/suite-random-3/test_slow_sql_on.php +++ b/tests/lasp/suite-random-3/test_slow_sql_on.php @@ -34,7 +34,7 @@ function test_slow_sql() global $PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD; $conn = new PDO($PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD, array()); - $result = $conn->query('select * from tables limit 1;'); + $result = $conn->query('select * from information_schema.tables limit 1;'); } test_slow_sql(); diff --git a/tests/regression/test_php_1179_pdo_options_crash.php b/tests/regression/test_php_1179_pdo_options_crash.php index e35ca7f0a..9b6419337 100644 --- a/tests/regression/test_php_1179_pdo_options_crash.php +++ b/tests/regression/test_php_1179_pdo_options_crash.php @@ -59,7 +59,7 @@ function test_slow_sql(array $options) global $PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD; $conn = new PDO($PDO_MYSQL_DSN, $MYSQL_USER, $MYSQL_PASSWD, $options); - $result = $conn->query('select * from tables limit 1;'); + $result = $conn->query('select * from information_schema.tables limit 1;'); } $shared_options = array(PDO::ATTR_PERSISTENT => true);