diff --git a/VERSION b/VERSION index b85c6c7b0..f628d2eaf 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -11.2.0 +11.3.0 diff --git a/agent/Makefile.frag b/agent/Makefile.frag index 648fc84b3..fbff46d69 100644 --- a/agent/Makefile.frag +++ b/agent/Makefile.frag @@ -93,6 +93,7 @@ TEST_BINARIES = \ tests/test_internal_instrument \ tests/test_hash \ tests/test_lib_aws_sdk_php \ + tests/test_memcached \ tests/test_mongodb \ tests/test_monolog \ tests/test_mysql \ diff --git a/agent/config.m4 b/agent/config.m4 index ee0859e30..5806caac5 100644 --- a/agent/config.m4 +++ b/agent/config.m4 @@ -215,7 +215,7 @@ if test "$PHP_NEWRELIC" = "yes"; then php_error.c php_execute.c php_explain.c php_explain_mysqli.c \ php_explain_pdo_mysql.c php_extension.c php_file_get_contents.c \ php_globals.c php_hash.c php_header.c php_httprequest_send.c \ - php_internal_instrument.c php_minit.c php_mshutdown.c php_mysql.c \ + php_internal_instrument.c php_memcached.c php_minit.c php_mshutdown.c php_mysql.c \ php_mysqli.c php_newrelic.c php_nrini.c php_observer.c php_output.c php_pdo.c \ php_pdo_mysql.c php_pdo_pgsql.c php_pgsql.c php_psr7.c php_redis.c \ php_rinit.c php_rshutdown.c php_samplers.c php_stack.c \ diff --git a/agent/php_execute.c b/agent/php_execute.c index 83ff4d5a9..e54dc7828 100644 --- a/agent/php_execute.c +++ b/agent/php_execute.c @@ -603,14 +603,17 @@ static size_t num_logging_frameworks typedef struct _nr_vuln_mgmt_table_t { const char* package_name; const char* file_to_check; + size_t file_to_check_len; nr_vuln_mgmt_enable_fn_t enable; } nr_vuln_mgmt_table_t; /* Note that all paths should be in lowercase. */ +// clang-format: off static const nr_vuln_mgmt_table_t vuln_mgmt_packages[] = { - {"Drupal", "drupal/component/dependencyinjection/container.php", nr_drupal_version}, - {"Wordpress", "wp-includes/version.php", nr_wordpress_version}, + {"Drupal", NR_PSTR("drupal/component/dependencyinjection/container.php"), nr_drupal_version}, + {"Wordpress", NR_PSTR("wp-includes/version.php"), nr_wordpress_version}, }; +// clang-format: on static const size_t num_packages = sizeof(vuln_mgmt_packages) / sizeof(nr_vuln_mgmt_table_t); @@ -990,28 +993,22 @@ static void nr_execute_handle_logging_framework(const char* filename, } } -#undef STR_AND_LEN - -static void nr_execute_handle_package(const char* filename) { - if (NULL == filename || 0 >= nr_strlen(filename)) { - nrl_verbosedebug(NRL_FRAMEWORK, "%s: The file name is NULL", - __func__); - return; - } - char* filename_lower = nr_string_to_lowercase(filename); +static void nr_execute_handle_package(const char* filename, + const size_t filename_len) { size_t i = 0; for (i = 0; i < num_packages; i++) { - if (nr_stridx(filename_lower, vuln_mgmt_packages[i].file_to_check) >= 0) { + if (nr_striendswith(STR_AND_LEN(filename), + STR_AND_LEN(vuln_mgmt_packages[i].file_to_check))) { if (NULL != vuln_mgmt_packages[i].enable) { vuln_mgmt_packages[i].enable(); } } } - - nr_free(filename_lower); } +#undef STR_AND_LEN + /* * Purpose : Detect library and framework usage from a PHP file. * @@ -1036,7 +1033,7 @@ static void nr_php_user_instrumentation_from_file(const char* filename, nr_execute_handle_autoload(filename, filename_len); nr_execute_handle_logging_framework(filename, filename_len TSRMLS_CC); if (NRINI(vulnerability_management_package_detection_enabled)) { - nr_execute_handle_package(filename); + nr_execute_handle_package(filename, filename_len); } } diff --git a/agent/php_internal_instrument.c b/agent/php_internal_instrument.c index 821379edb..ce6c089ec 100644 --- a/agent/php_internal_instrument.c +++ b/agent/php_internal_instrument.c @@ -13,8 +13,10 @@ #include "php_explain_mysqli.h" #include "php_file_get_contents.h" #include "php_globals.h" +#include "php_hash.h" #include "php_httprequest_send.h" #include "php_internal_instrument.h" +#include "php_memcached.h" #include "php_mysql.h" #include "php_mysqli.h" #include "php_pdo.h" @@ -1531,6 +1533,57 @@ NR_INNER_WRAPPER(memcache_function) { INTERNAL_FUNCTION_PARAM_PASSTHRU); } +NR_INNER_WRAPPER(memcached_add_server) { + char* host = NULL; + nr_string_len_t host_len = 0; + zend_long port = 0; + zend_long weight = 0; + int zcaught = 0; + + if (SUCCESS + == zend_parse_parameters_ex( + ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "s|ll", &host, + &host_len, &port, &weight) && + NULL != host) { + nr_php_memcached_create_instance_metric(host, port); + } + zcaught = nr_zend_call_old_handler(nr_wrapper->oldhandler, + INTERNAL_FUNCTION_PARAM_PASSTHRU); + if (zcaught) { + zend_bailout(); + /* NOTREACHED */ + } +} + +NR_INNER_WRAPPER(memcached_add_servers) { + zval* servers = NULL; + zval* server = NULL; + int zcaught = 0; + + if (SUCCESS + == zend_parse_parameters_ex( + ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "a", &servers)) { + if (NULL != servers && Z_TYPE_P(servers) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(servers), server) { + zval* host = nr_php_zend_hash_index_find(Z_ARRVAL_P(server), 0); + zval* port = nr_php_zend_hash_index_find(Z_ARRVAL_P(server), 1); + if (nr_php_is_zval_valid_string(host) && + nr_php_is_zval_valid_integer(port)) { + nr_php_memcached_create_instance_metric(Z_STRVAL_P(host), Z_LVAL_P(port)); + } + } + ZEND_HASH_FOREACH_END(); + } + } + zcaught = nr_zend_call_old_handler(nr_wrapper->oldhandler, + INTERNAL_FUNCTION_PARAM_PASSTHRU); + + if (zcaught) { + zend_bailout(); + /* NOTREACHED */ + } +} + /* * Handle * bool redis::connect ( string $host[, int $port = 6379 ... ] ) @@ -3098,6 +3151,8 @@ NR_OUTER_WRAPPER(memcached_set) NR_OUTER_WRAPPER(memcached_setbykey) NR_OUTER_WRAPPER(memcached_setmulti) NR_OUTER_WRAPPER(memcached_setmultibykey) +NR_OUTER_WRAPPER(memcached_addserver) +NR_OUTER_WRAPPER(memcached_addservers) NR_OUTER_WRAPPER(redis_append) NR_OUTER_WRAPPER(redis_bitcount) @@ -3511,6 +3566,10 @@ void nr_php_generate_internal_wrap_records(void) { memcache_function, 0, "set") NR_INTERNAL_WRAPREC("memcached::setmultibykey", memcached_setmultibykey, memcache_function, 0, "set") + NR_INTERNAL_WRAPREC("memcached::addserver", memcached_addserver, + memcached_add_server, 0, 0); + NR_INTERNAL_WRAPREC("memcached::addservers", memcached_addservers, + memcached_add_servers, 0, 0); NR_INTERNAL_WRAPREC("redis::connect", redis_connect, redis_connect, 0, "connect") diff --git a/agent/php_memcached.c b/agent/php_memcached.c new file mode 100644 index 000000000..ee13e1e73 --- /dev/null +++ b/agent/php_memcached.c @@ -0,0 +1,34 @@ +/* + * Copyright 2020 New Relic Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "php_memcached.h" +#include "nr_datastore_instance.h" +#include "php_agent.h" + +nr_datastore_instance_t* nr_php_memcached_create_datastore_instance( + const char* host_or_socket, + zend_long port) { + nr_datastore_instance_t* instance = NULL; + if (port == 0) { // local socket + instance = nr_datastore_instance_create("localhost", host_or_socket, NULL); + } else { + char* port_str = nr_formatf("%ld", (long)port); + instance = nr_datastore_instance_create(host_or_socket, port_str, NULL); + nr_free(port_str); + } + return instance; +} + +void nr_php_memcached_create_instance_metric( + const char* host_or_socket, + zend_long port) { + nr_datastore_instance_t* instance + = nr_php_memcached_create_datastore_instance(host_or_socket, port); + char* instance_metric = nr_formatf("Datastore/instance/Memcached/%s/%s", + instance->host, instance->port_path_or_id); + nrm_force_add(NRPRG(txn)->unscoped_metrics, instance_metric, 0); + nr_datastore_instance_destroy(&instance); + nr_free(instance_metric); +} diff --git a/agent/php_memcached.h b/agent/php_memcached.h new file mode 100644 index 000000000..f449030ea --- /dev/null +++ b/agent/php_memcached.h @@ -0,0 +1,35 @@ +/* + * Copyright 2020 New Relic Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef PHP_MEMCACHED_HDR +#define PHP_MEMCACHED_HDR + +#include "nr_datastore_instance.h" +#include "php_includes.h" + +/* + * Purpose : Create a datastore instance metadata for a Memcached server. + * + * Params : 1. The memcached host or socket name as given to Memcached::addServer(). + * 2. The memcached port as given as given to Memcached::addServer(). + * + * Returns: nr_datastore_instance_t* that the caller is responsible for freeing + */ +nr_datastore_instance_t* nr_php_memcached_create_datastore_instance( + const char* host_or_socket, + zend_long port); + +/* + * Purpose : Create a memcached instance metric + * + * Params : 1. The memcached host or socket name as given to Memcached::addServer(). + * 2. The memcached port as given as given to Memcached::addServer(). + */ +extern void nr_php_memcached_create_instance_metric( + const char* host_or_socket, + zend_long port); + + +#endif diff --git a/agent/tests/test_memcached.c b/agent/tests/test_memcached.c new file mode 100644 index 000000000..1f05c2443 --- /dev/null +++ b/agent/tests/test_memcached.c @@ -0,0 +1,127 @@ +/* + * Copyright 2020 New Relic Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 + */ +#include "tlib_php.h" +#include "tlib_datastore.h" + +#include "php_agent.h" +#include "php_memcached.h" +#include "util_system.h" + +tlib_parallel_info_t parallel_info + = {.suggested_nthreads = -1, .state_size = 0}; + +static char* system_host_name; + +static void test_create_datastore_instance(void) { + assert_datastore_instance_equals_destroy( + "named socket", + &((nr_datastore_instance_t){ + .host = system_host_name, + .database_name = "unknown", + .port_path_or_id = "/tmp/memcached.sock", + }), + nr_php_memcached_create_datastore_instance("/tmp/memcached.sock", 0)); + + assert_datastore_instance_equals_destroy( + "empty socket", + &((nr_datastore_instance_t){ + .host = system_host_name, + .database_name = "unknown", + .port_path_or_id = "unknown", + }), + nr_php_memcached_create_datastore_instance("", 0)); + + assert_datastore_instance_equals_destroy( + "empty host", + &((nr_datastore_instance_t){ + .host = system_host_name, + .database_name = "unknown", + .port_path_or_id = "unknown", + }), + nr_php_memcached_create_datastore_instance(NULL, 0)); + + assert_datastore_instance_equals_destroy( + "host.name socket", + &((nr_datastore_instance_t){ + .host = "host.name", + .database_name = "unknown", + .port_path_or_id = "11211", + }), + nr_php_memcached_create_datastore_instance("host.name", 11211)); + + assert_datastore_instance_equals_destroy( + "host and port", + &((nr_datastore_instance_t){ + .host = "unknown", + .database_name = "unknown", + .port_path_or_id = "6379", + }), + nr_php_memcached_create_datastore_instance("", 6379)); + + assert_datastore_instance_equals_destroy( + "NULL socket", + &((nr_datastore_instance_t){ + .host = "unknown", + .database_name = "unknown", + .port_path_or_id = "11211", + }), + nr_php_memcached_create_datastore_instance(NULL, 11211)); +} + +static void test_create_instance_metric(void) { + nrtxn_t* txn; + nrmetric_t* metric; + char* metric_str; + tlib_php_engine_create(""); + tlib_php_request_start(); + txn = NRPRG(txn); + + nr_php_memcached_create_instance_metric("host", 11211); + metric = nrm_find(txn->unscoped_metrics, "Datastore/instance/Memcached/host/11211"); + tlib_pass_if_not_null("metric found", metric); + + nr_php_memcached_create_instance_metric("", 11211); + metric = nrm_find(txn->unscoped_metrics, "Datastore/instance/Memcached/unknown/11211"); + tlib_pass_if_not_null("metric found", metric); + + nr_php_memcached_create_instance_metric(NULL, 7); + metric = nrm_find(txn->unscoped_metrics, "Datastore/instance/Memcached/unknown/7"); + tlib_pass_if_not_null("metric found", metric); + + nr_php_memcached_create_instance_metric("path/to/sock", 0); + metric_str = nr_formatf("Datastore/instance/Memcached/%s/path/to/sock", system_host_name); + metric = nrm_find(txn->unscoped_metrics, metric_str); + nr_free(metric_str); + tlib_pass_if_not_null("metric found", metric); + + nr_php_memcached_create_instance_metric("", 0); + metric_str = nr_formatf("Datastore/instance/Memcached/%s/unknown", system_host_name); + metric = nrm_find(txn->unscoped_metrics, metric_str); + nr_free(metric_str); + tlib_pass_if_not_null("metric found", metric); + + // restart the transaction because the next metric is the same as a previous metric + tlib_php_request_end(); + tlib_php_request_start(); + txn = NRPRG(txn); + + nr_php_memcached_create_instance_metric(NULL, 0); + metric_str = nr_formatf("Datastore/instance/Memcached/%s/unknown", system_host_name); + metric = nrm_find(txn->unscoped_metrics, metric_str); + nr_free(metric_str); + tlib_pass_if_not_null("metric found", metric); + + tlib_php_request_end(); + tlib_php_engine_destroy(); +} + +void test_main(void* p NRUNUSED) { + system_host_name = nr_system_get_hostname(); + + test_create_datastore_instance(); + test_create_instance_metric(); + + nr_free(system_host_name); +} diff --git a/axiom/nr_version.c b/axiom/nr_version.c index e608278e9..2c950be4f 100644 --- a/axiom/nr_version.c +++ b/axiom/nr_version.c @@ -21,9 +21,8 @@ #endif /* - * Current version naming scheme is flowers + * Current version naming scheme is gemstones * - * dahlia 19Sep2022 (10.1) * echinacea 03Oct2022 (10.2) * freesia 03Nov2022 (10.3) * goldenrod 12Dec2022 (10.4) @@ -47,8 +46,9 @@ * yarrow 26Jun2024 (10.22) * zinnia 30Jul2024 (11.0) * amethyst 26Aug2024 (11.1) + * bowenite 30Sep2024 (11.2) */ -#define NR_CODENAME "bowenite" +#define NR_CODENAME "corundum" const char* nr_version(void) { return NR_STR2(NR_VERSION); diff --git a/tests/integration/memcached/test_add_servers.php b/tests/integration/memcached/test_add_servers.php new file mode 100644 index 000000000..41e9b5a63 --- /dev/null +++ b/tests/integration/memcached/test_add_servers.php @@ -0,0 +1,39 @@ + +*/ + +/*INI +*/ + +/*EXPECT_METRICS_EXIST +Datastore/instance/Memcached/host1/1, 1 +Datastore/instance/Memcached/host2/2, 1 +Datastore/instance/Memcached/host3/11211, 1 +Datastore/instance/Memcached/host4/1, 1 +*/ + +/*EXPECT_ERROR_EVENTS null */ + +require_once(realpath (dirname ( __FILE__ )) . '/../../include/helpers.php'); +require_once(realpath (dirname ( __FILE__ )) . '/../../include/tap.php'); +require_once(realpath (dirname ( __FILE__ )) . '/memcache.inc'); + +$memcached = new Memcached(); +$memcached->addServers(array( + array("host1", 1), + array("host2", 2), + array("host3", 11211))); +$memcached->addServers(array()); +$memcached->addServers(array(array("host4", 1, "test field"))); +$memcached->quit(); diff --git a/tests/integration/memcached/test_add_servers_bad.php b/tests/integration/memcached/test_add_servers_bad.php new file mode 100644 index 000000000..c4887584f --- /dev/null +++ b/tests/integration/memcached/test_add_servers_bad.php @@ -0,0 +1,68 @@ + +*/ + +/*INI +*/ + +/*EXPECT_REGEX + +.*(PHP )?Warning:.*could not add entry.* + +.*(PHP )?Warning:.*could not add entry.* + +*/ + +/*EXPECT_ERROR_EVENTS +[ + "?? agent run id", + { + "reservoir_size": "??", + "events_seen": 1 + }, + [ + [ + { + "type": "TransactionError", + "timestamp": "??", + "error.class": "E_WARNING", + "error.message": "Memcached::addServers(): could not add entry #2 to the server list", + "transactionName": "OtherTransaction\/php__FILE__", + "duration": "??", + "nr.transactionGuid": "??", + "guid": "??", + "sampled": true, + "priority": "??", + "traceId": "??", + "spanId": "??" + }, + {}, + {} + ] + ] +] +*/ + +require_once(realpath (dirname ( __FILE__ )) . '/../../include/helpers.php'); +require_once(realpath (dirname ( __FILE__ )) . '/../../include/tap.php'); +require_once(realpath (dirname ( __FILE__ )) . '/memcache.inc'); + +$memcached = new Memcached(); +$memcached->addServer(5, 5); +//$memcached->addServer("host", string); crashes PHP +$memcached->addServers(array(array(1))); +$memcached->addServers(array(array("host1"))); +$memcached->addServers(array(array(1, "host1"))); +//$memcahed->addServers("string"); crashes PHP +$memcached->quit(); diff --git a/tests/integration/memcached/test_basic.php b/tests/integration/memcached/test_basic.php index 6ccde57b7..1e24bfd7e 100644 --- a/tests/integration/memcached/test_basic.php +++ b/tests/integration/memcached/test_basic.php @@ -46,6 +46,7 @@ [{"name":"Datastore/allOther"}, [15, "??", "??", "??", "??", "??"]], [{"name":"Datastore/Memcached/all"}, [15, "??", "??", "??", "??", "??"]], [{"name":"Datastore/Memcached/allOther"}, [15, "??", "??", "??", "??", "??"]], + [{"name":"Datastore/instance/Memcached/ENV[MEMCACHE_HOST]/11211"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Datastore/operation/Memcached/add"}, [2, "??", "??", "??", "??", "??"]], [{"name":"Datastore/operation/Memcached/add", "scope":"OtherTransaction/php__FILE__"}, [2, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/memcached/test_basic_logging_off.php b/tests/integration/memcached/test_basic_logging_off.php index 521fc1d44..05e87a4c1 100644 --- a/tests/integration/memcached/test_basic_logging_off.php +++ b/tests/integration/memcached/test_basic_logging_off.php @@ -49,6 +49,7 @@ [{"name":"Datastore/allOther"}, [15, "??", "??", "??", "??", "??"]], [{"name":"Datastore/Memcached/all"}, [15, "??", "??", "??", "??", "??"]], [{"name":"Datastore/Memcached/allOther"}, [15, "??", "??", "??", "??", "??"]], + [{"name":"Datastore/instance/Memcached/ENV[MEMCACHE_HOST]/11211"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Datastore/operation/Memcached/add"}, [2, "??", "??", "??", "??", "??"]], [{"name":"Datastore/operation/Memcached/add", "scope":"OtherTransaction/php__FILE__"}, [2, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/memcached/test_by_key.php b/tests/integration/memcached/test_by_key.php index 006d6cd7d..ceb2758d8 100644 --- a/tests/integration/memcached/test_by_key.php +++ b/tests/integration/memcached/test_by_key.php @@ -48,6 +48,7 @@ [{"name":"Datastore/allOther"}, [11, "??", "??", "??", "??", "??"]], [{"name":"Datastore/Memcached/all"}, [11, "??", "??", "??", "??", "??"]], [{"name":"Datastore/Memcached/allOther"}, [11, "??", "??", "??", "??", "??"]], + [{"name":"Datastore/instance/Memcached/ENV[MEMCACHE_HOST]/11211"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Datastore/operation/Memcached/add"}, [2, "??", "??", "??", "??", "??"]], [{"name":"Datastore/operation/Memcached/add", "scope":"OtherTransaction/php__FILE__"}, [2, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/memcached/test_cas.php7.php b/tests/integration/memcached/test_cas.php7.php index b69010e59..650bb22ec 100644 --- a/tests/integration/memcached/test_cas.php7.php +++ b/tests/integration/memcached/test_cas.php7.php @@ -42,6 +42,7 @@ [{"name":"Datastore/allOther"}, [5, "??", "??", "??", "??", "??"]], [{"name":"Datastore/Memcached/all"}, [5, "??", "??", "??", "??", "??"]], [{"name":"Datastore/Memcached/allOther"}, [5, "??", "??", "??", "??", "??"]], + [{"name":"Datastore/instance/Memcached/ENV[MEMCACHE_HOST]/11211"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Datastore/operation/Memcached/delete"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Datastore/operation/Memcached/delete", "scope":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/memcached/test_cas_by_key.php7.php b/tests/integration/memcached/test_cas_by_key.php7.php index f43a6dc29..10b073016 100644 --- a/tests/integration/memcached/test_cas_by_key.php7.php +++ b/tests/integration/memcached/test_cas_by_key.php7.php @@ -42,6 +42,7 @@ [{"name":"Datastore/allOther"}, [5, "??", "??", "??", "??", "??"]], [{"name":"Datastore/Memcached/all"}, [5, "??", "??", "??", "??", "??"]], [{"name":"Datastore/Memcached/allOther"}, [5, "??", "??", "??", "??", "??"]], + [{"name":"Datastore/instance/Memcached/ENV[MEMCACHE_HOST]/11211"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Datastore/operation/Memcached/delete"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Datastore/operation/Memcached/delete", "scope":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/memcached/test_concat.php b/tests/integration/memcached/test_concat.php index 092bd5683..0a526adcd 100644 --- a/tests/integration/memcached/test_concat.php +++ b/tests/integration/memcached/test_concat.php @@ -35,6 +35,7 @@ [{"name":"Datastore/allOther"}, [5, "??", "??", "??", "??", "??"]], [{"name":"Datastore/Memcached/all"}, [5, "??", "??", "??", "??", "??"]], [{"name":"Datastore/Memcached/allOther"}, [5, "??", "??", "??", "??", "??"]], + [{"name":"Datastore/instance/Memcached/ENV[MEMCACHE_HOST]/11211"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Datastore/operation/Memcached/delete"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Datastore/operation/Memcached/delete", "scope":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/memcached/test_concat_by_key.php b/tests/integration/memcached/test_concat_by_key.php index 7339eed12..2cb041974 100644 --- a/tests/integration/memcached/test_concat_by_key.php +++ b/tests/integration/memcached/test_concat_by_key.php @@ -35,6 +35,7 @@ [{"name":"Datastore/allOther"}, [5, "??", "??", "??", "??", "??"]], [{"name":"Datastore/Memcached/all"}, [5, "??", "??", "??", "??", "??"]], [{"name":"Datastore/Memcached/allOther"}, [5, "??", "??", "??", "??", "??"]], + [{"name":"Datastore/instance/Memcached/ENV[MEMCACHE_HOST]/11211"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Datastore/operation/Memcached/delete"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Datastore/operation/Memcached/delete", "scope":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/memcached/test_concat_by_key_logging_off.php b/tests/integration/memcached/test_concat_by_key_logging_off.php index d4e3f2d60..4d644a74d 100644 --- a/tests/integration/memcached/test_concat_by_key_logging_off.php +++ b/tests/integration/memcached/test_concat_by_key_logging_off.php @@ -38,6 +38,7 @@ [{"name":"Datastore/allOther"}, [5, "??", "??", "??", "??", "??"]], [{"name":"Datastore/Memcached/all"}, [5, "??", "??", "??", "??", "??"]], [{"name":"Datastore/Memcached/allOther"}, [5, "??", "??", "??", "??", "??"]], + [{"name":"Datastore/instance/Memcached/ENV[MEMCACHE_HOST]/11211"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Datastore/operation/Memcached/delete"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Datastore/operation/Memcached/delete", "scope":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/memcached/test_multi.php b/tests/integration/memcached/test_multi.php index 82328762a..78dbd2fa3 100644 --- a/tests/integration/memcached/test_multi.php +++ b/tests/integration/memcached/test_multi.php @@ -42,6 +42,7 @@ [{"name":"Datastore/allOther"}, [5, "??", "??", "??", "??", "??"]], [{"name":"Datastore/Memcached/all"}, [5, "??", "??", "??", "??", "??"]], [{"name":"Datastore/Memcached/allOther"}, [5, "??", "??", "??", "??", "??"]], + [{"name":"Datastore/instance/Memcached/ENV[MEMCACHE_HOST]/11211"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Datastore/operation/Memcached/get"}, [4, "??", "??", "??", "??", "??"]], [{"name":"Datastore/operation/Memcached/get", "scope":"OtherTransaction/php__FILE__"}, [4, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/memcached/test_multi_by_key.php b/tests/integration/memcached/test_multi_by_key.php index d5867c36d..5d4c2e9d3 100644 --- a/tests/integration/memcached/test_multi_by_key.php +++ b/tests/integration/memcached/test_multi_by_key.php @@ -42,6 +42,7 @@ [{"name":"Datastore/allOther"}, [5, "??", "??", "??", "??", "??"]], [{"name":"Datastore/Memcached/all"}, [5, "??", "??", "??", "??", "??"]], [{"name":"Datastore/Memcached/allOther"}, [5, "??", "??", "??", "??", "??"]], + [{"name":"Datastore/instance/Memcached/ENV[MEMCACHE_HOST]/11211"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Datastore/operation/Memcached/get"}, [4, "??", "??", "??", "??", "??"]], [{"name":"Datastore/operation/Memcached/get", "scope":"OtherTransaction/php__FILE__"}, [4, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/memcached/test_socket.php b/tests/integration/memcached/test_socket.php new file mode 100644 index 000000000..19a1787e9 --- /dev/null +++ b/tests/integration/memcached/test_socket.php @@ -0,0 +1,30 @@ + +*/ + +/*INI +*/ + +/*EXPECT_METRICS_EXIST +Datastore/instance/Memcached/__HOST__/my/socket, 1 +*/ + +/*EXPECT_ERROR_EVENTS null */ + +require_once(realpath (dirname ( __FILE__ )) . '/../../include/helpers.php'); +require_once(realpath (dirname ( __FILE__ )) . '/../../include/tap.php'); +require_once(realpath (dirname ( __FILE__ )) . '/memcache.inc'); + +$memcached = new Memcached(); +$memcached->addServer("my/socket", 0); +$memcached->quit();