Skip to content

Commit

Permalink
test(agent): update Guzzle 6 test cases and add Guzzle 7 test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
hahuja2 committed Aug 1, 2022
1 parent 84c3086 commit ed6b655
Show file tree
Hide file tree
Showing 12 changed files with 616 additions and 2 deletions.
1 change: 1 addition & 0 deletions tests/integration/external/guzzle6/test_cat.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
[{"name":"Supportability/library/Guzzle 4-5/detected"},
[1, 0, 0, 0, 0, 0]],
[{"name":"Supportability/library/Guzzle 6/detected"}, [1, 0, 0, 0, 0, 0]],
[{"name":"Supportability/library/Guzzle 7/detected"}, [1, 0, 0, 0, 0, 0]],
[{"name":"Supportability/Unsupported/curl_setopt/CURLOPT_HEADERFUNCTION/closure"},
[3, 0, 0, 0, 0, 0]]
]
Expand Down
3 changes: 3 additions & 0 deletions tests/integration/external/guzzle6/test_dt.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
[{"name":"Supportability/library/Guzzle 4-5/detected"},
[1, 0, 0, 0, 0, 0]],
[{"name":"Supportability/library/Guzzle 6/detected"}, [1, 0, 0, 0, 0, 0]],
[{"name":"Supportability/library/Guzzle 7/detected"}, [1, 0, 0, 0, 0, 0]],
[{"name":"Supportability/Unsupported/curl_setopt/CURLOPT_HEADERFUNCTION/closure"},
[3, 0, 0, 0, 0, 0]],
[{"name":"DurationByCaller/Unknown/Unknown/Unknown/Unknown/all"},
Expand All @@ -75,6 +76,8 @@

/* Create URL. */
$url = "http://" . make_tracing_url(realpath(dirname(__FILE__)) . '/../../../include/tracing_endpoint.php');
//echo "\n";
//echo $url."\n";

/* Use guzzle 6 to make an http request. */
use GuzzleHttp\Client;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
[{"name":"Supportability/library/Guzzle 4-5/detected"},
[1, 0, 0, 0, 0, 0]],
[{"name":"Supportability/library/Guzzle 6/detected"}, [1, 0, 0, 0, 0, 0]],
[{"name":"Supportability/library/Guzzle 7/detected"}, [1, 0, 0, 0, 0, 0]],
[{"name":"Supportability/Unsupported/curl_setopt/CURLOPT_HEADERFUNCTION/closure"},
[3, 0, 0, 0, 0, 0]],
[{"name":"DurationByCaller/Unknown/Unknown/Unknown/Unknown/all"},
Expand Down
1 change: 1 addition & 0 deletions tests/integration/external/guzzle6/test_dt_synthetics.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
[{"name":"Supportability/library/Guzzle 4-5/detected"},
[1, 0, 0, 0, 0, 0]],
[{"name":"Supportability/library/Guzzle 6/detected"}, [1, 0, 0, 0, 0, 0]],
[{"name":"Supportability/library/Guzzle 7/detected"}, [1, 0, 0, 0, 0, 0]],
[{"name":"Supportability/Unsupported/curl_setopt/CURLOPT_HEADERFUNCTION/closure"},
[3, 0, 0, 0, 0, 0]],
[{"name":"DurationByCaller/Unknown/Unknown/Unknown/Unknown/all"},
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/external/guzzle6/test_no_cat_no_dt.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
[{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]],
[{"name":"Supportability/library/Guzzle 4-5/detected"},
[1, 0, 0, 0, 0, 0]],
[{"name":"Supportability/library/Guzzle 6/detected"}, [1, 0, 0, 0, 0, 0]]
[{"name":"Supportability/library/Guzzle 6/detected"}, [1, 0, 0, 0, 0, 0]],
[{"name":"Supportability/library/Guzzle 7/detected"}, [1, 0, 0, 0, 0, 0]]
]
]
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"timestamp": "??",
"parentId": "??",
"span.kind": "client",
"component": "Guzzle 6"
"component": "Guzzle 6-7"
},
{},
{
Expand Down
98 changes: 98 additions & 0 deletions tests/integration/external/guzzle7/test_cat.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<?php
/*
* Copyright 2020 New Relic Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/

/*DESCRIPTION
Test that CAT works with guzzle 7.
*/

/*SKIPIF
<?php
require_once(realpath(dirname(__FILE__)) . '/../../../include/unpack_guzzle.php');
if (version_compare(phpversion(), '7.2.0', '<=')) {
die("skip: PHP > 7.2.0 required\n");
}
if (!unpack_guzzle(7)) {
die("skip: guzzle 7 installation required\n");
}
if (!isset($_ENV["ACCOUNT_supportability"]) || !isset($_ENV["APP_supportability"])) {
die("skip: env vars required");
}
*/

/*INI
newrelic.distributed_tracing_enabled=0
newrelic.cross_application_tracer.enabled = true
*/

/*EXPECT
tracing endpoint reached
tracing endpoint reached
Customer-Header=found tracing endpoint reached
*/

/*EXPECT_RESPONSE_HEADERS
X-NewRelic-App-Data=??
X-NewRelic-App-Data=??
X-NewRelic-App-Data=??
*/

/*EXPECT_METRICS
[
"?? agent run id",
"?? timeframe start",
"?? timeframe stop",
[
[{"name":"External/127.0.0.1/all"}, [3, "??", "??", "??", "??", "??"]],
[{"name":"External/all"}, [3, "??", "??", "??", "??", "??"]],
[{"name":"External/allOther"}, [3, "??", "??", "??", "??", "??"]],
[{"name":"ExternalApp/127.0.0.1/ENV[ACCOUNT_supportability]#ENV[APP_supportability]/all"},
[3, "??", "??", "??", "??", "??"]],
[{"name":"ExternalTransaction/127.0.0.1/ENV[ACCOUNT_supportability]#ENV[APP_supportability]/WebTransaction/Custom/tracing"},
[3, "??", "??", "??", "??", "??"]],
[{"name":"ExternalTransaction/127.0.0.1/ENV[ACCOUNT_supportability]#ENV[APP_supportability]/WebTransaction/Custom/tracing",
"scope":"OtherTransaction/php__FILE__"}, [3, "??", "??", "??", "??", "??"]],
[{"name":"OtherTransaction/all"}, [1, "??", "??", "??", "??", "??"]],
[{"name":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]],
[{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]],
[{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]],
[{"name":"Supportability/library/Guzzle 4-5/detected"},
[2, 0, 0, 0, 0, 0]],
[{"name":"Supportability/library/Guzzle 7/detected"}, [1, 0, 0, 0, 0, 0]],
[{"name":"Supportability/Unsupported/curl_setopt/CURLOPT_HEADERFUNCTION/closure"},
[3, 0, 0, 0, 0, 0]]
]
]
*/

?>
<?php
require_once(realpath(dirname(__FILE__)) . '/../../../include/config.php');
require_once(realpath(dirname(__FILE__)) . '/../../../include/unpack_guzzle.php');
require_guzzle(7);

/* Create URL. */
$url = "http://" . make_tracing_url(realpath(dirname(__FILE__)) . '/../../../include/tracing_endpoint.php');

/* Use guzzle 7 to make an http request. */
use GuzzleHttp\Client;

$client = new Client();
$response = $client->get($url);
echo $response->getBody();

$response = $client->get($url, [
'headers' => [
'zip' => 'zap']]);
echo $response->getBody();

$response = $client->get($url, [
'headers' => [
'zip' => 'zap',
CUSTOMER_HEADER => 'zap']]);
echo $response->getBody();
98 changes: 98 additions & 0 deletions tests/integration/external/guzzle7/test_dt.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<?php
/*
* Copyright 2020 New Relic Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/

/*DESCRIPTION
Test that Distributed Tracing works with guzzle 7.
*/

/*SKIPIF
<?php
require_once(realpath(dirname(__FILE__)) . '/../../../include/unpack_guzzle.php');
if (version_compare(phpversion(), '7.2.0', '<=')) {
die("skip: PHP > 7.2.0 required\n");
}
if (!unpack_guzzle(7)) {
die("skip: guzzle 7 installation required\n");
}
*/

/*INI
newrelic.distributed_tracing_enabled = true
newrelic.cross_application_tracer.enabled = false
*/

/*EXPECT
traceparent=found tracestate=found newrelic=found X-NewRelic-ID=missing X-NewRelic-Transaction=missing tracing endpoint reached
traceparent=found tracestate=found newrelic=found X-NewRelic-ID=missing X-NewRelic-Transaction=missing tracing endpoint reached
traceparent=found tracestate=found newrelic=found X-NewRelic-ID=missing X-NewRelic-Transaction=missing Customer-Header=found tracing endpoint reached
*/

/*EXPECT_RESPONSE_HEADERS
*/

/*EXPECT_METRICS
[
"?? agent run id",
"?? timeframe start",
"?? timeframe stop",
[
[{"name":"External/127.0.0.1/all"}, [3, "??", "??", "??", "??", "??"]],
[{"name":"External/127.0.0.1/all",
"scope":"OtherTransaction/php__FILE__"}, [3, "??", "??", "??", "??", "??"]],
[{"name":"External/all"}, [3, "??", "??", "??", "??", "??"]],
[{"name":"External/allOther"}, [3, "??", "??", "??", "??", "??"]],
[{"name":"OtherTransaction/all"}, [1, "??", "??", "??", "??", "??"]],
[{"name":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]],
[{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]],
[{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]],
[{"name":"Supportability/library/Guzzle 4-5/detected"},
[2, 0, 0, 0, 0, 0]],
[{"name":"Supportability/library/Guzzle 6/detected"}, [1, 0, 0, 0, 0, 0]],
[{"name":"Supportability/library/Guzzle 7/detected"}, [1, 0, 0, 0, 0, 0]],
[{"name":"Supportability/Unsupported/curl_setopt/CURLOPT_HEADERFUNCTION/closure"},
[3, 0, 0, 0, 0, 0]],
[{"name":"DurationByCaller/Unknown/Unknown/Unknown/Unknown/all"},
[1, "??", "??", "??", "??", "??"]],
[{"name":"DurationByCaller/Unknown/Unknown/Unknown/Unknown/allOther"},
[1, "??", "??", "??", "??", "??"]],
[{"name":"Supportability/TraceContext/Create/Success"},
[3, "??", "??", "??", "??", "??"]],
[{"name":"Supportability/DistributedTrace/CreatePayload/Success"},
[3, "??", "??", "??", "??", "??"]]
]
]
*/

?>
<?php
require_once(realpath(dirname(__FILE__)) . '/../../../include/config.php');
require_once(realpath(dirname(__FILE__)) . '/../../../include/unpack_guzzle.php');
require_guzzle(7);

/* Create URL. */
$url = "http://" . make_tracing_url(realpath(dirname(__FILE__)) . '/../../../include/tracing_endpoint.php');
//echo "\n";
//echo $url."\n";

/* Use guzzle 7 to make an http request. */
use GuzzleHttp\Client;

$client = new Client();
$response = $client->get($url);
echo $response->getBody();

$response = $client->get($url, [
'headers' => [
'zip' => 'zap']]);
echo $response->getBody();

$response = $client->get($url, [
'headers' => [
'zip' => 'zap',
CUSTOMER_HEADER => 'zap']]);
echo $response->getBody();
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?php
/*
* Copyright 2020 New Relic Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/

/*DESCRIPTION
Test that DT works with guzzle 7.
*/

/*SKIPIF
<?php
require_once(realpath(dirname(__FILE__)) . '/../../../include/unpack_guzzle.php');
if (version_compare(phpversion(), '7.2.0', '<=')) {
die("skip: PHP > 7.2.0 required\n");
}
if (!unpack_guzzle(7)) {
die("skip: guzzle 7 installation required\n");
}
*/

/*INI
newrelic.distributed_tracing_enabled = true
newrelic.cross_application_tracer.enabled = false
newrelic.distributed_tracing_exclude_newrelic_header = true
*/

/*EXPECT
traceparent=found tracestate=found X-NewRelic-ID=missing X-NewRelic-Transaction=missing tracing endpoint reached
traceparent=found tracestate=found X-NewRelic-ID=missing X-NewRelic-Transaction=missing tracing endpoint reached
traceparent=found tracestate=found X-NewRelic-ID=missing X-NewRelic-Transaction=missing Customer-Header=found tracing endpoint reached
*/

/*EXPECT_RESPONSE_HEADERS
*/

/*EXPECT_METRICS
[
"?? agent run id",
"?? timeframe start",
"?? timeframe stop",
[
[{"name":"External/127.0.0.1/all"}, [3, "??", "??", "??", "??", "??"]],
[{"name":"External/127.0.0.1/all",
"scope":"OtherTransaction/php__FILE__"}, [3, "??", "??", "??", "??", "??"]],
[{"name":"External/all"}, [3, "??", "??", "??", "??", "??"]],
[{"name":"External/allOther"}, [3, "??", "??", "??", "??", "??"]],
[{"name":"OtherTransaction/all"}, [1, "??", "??", "??", "??", "??"]],
[{"name":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]],
[{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]],
[{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]],
[{"name":"Supportability/library/Guzzle 4-5/detected"},
[2, 0, 0, 0, 0, 0]],
[{"name":"Supportability/library/Guzzle 6/detected"}, [1, 0, 0, 0, 0, 0]],
[{"name":"Supportability/library/Guzzle 7/detected"}, [1, 0, 0, 0, 0, 0]],
[{"name":"Supportability/Unsupported/curl_setopt/CURLOPT_HEADERFUNCTION/closure"},
[3, 0, 0, 0, 0, 0]],
[{"name":"DurationByCaller/Unknown/Unknown/Unknown/Unknown/all"},
[1, "??", "??", "??", "??", "??"]],
[{"name":"DurationByCaller/Unknown/Unknown/Unknown/Unknown/allOther"},
[1, "??", "??", "??", "??", "??"]],
[{"name":"Supportability/TraceContext/Create/Success"},
[3, "??", "??", "??", "??", "??"]]
]
]
*/

?>
<?php
require_once(realpath(dirname(__FILE__)) . '/../../../include/config.php');
require_once(realpath(dirname(__FILE__)) . '/../../../include/unpack_guzzle.php');
require_guzzle(7);

// create URL
$url = "http://" . make_tracing_url(realpath(dirname(__FILE__)) . '/../../../include/tracing_endpoint.php');

//and now use guzzle 7 to make an http request
use GuzzleHttp\Client;

$client = new Client();
$response = $client->get($url);
echo $response->getBody();

$response = $client->get($url, [
'headers' => [
'zip' => 'zap']]);
echo $response->getBody();

$response = $client->get($url, [
'headers' => [
'zip' => 'zap',
CUSTOMER_HEADER => 'zap']]);
echo $response->getBody();
Loading

0 comments on commit ed6b655

Please sign in to comment.