Skip to content

Commit ed6b655

Browse files
committed
test(agent): update Guzzle 6 test cases and add Guzzle 7 test cases
1 parent 84c3086 commit ed6b655

12 files changed

+616
-2
lines changed

tests/integration/external/guzzle6/test_cat.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
[{"name":"Supportability/library/Guzzle 4-5/detected"},
6565
[1, 0, 0, 0, 0, 0]],
6666
[{"name":"Supportability/library/Guzzle 6/detected"}, [1, 0, 0, 0, 0, 0]],
67+
[{"name":"Supportability/library/Guzzle 7/detected"}, [1, 0, 0, 0, 0, 0]],
6768
[{"name":"Supportability/Unsupported/curl_setopt/CURLOPT_HEADERFUNCTION/closure"},
6869
[3, 0, 0, 0, 0, 0]]
6970
]

tests/integration/external/guzzle6/test_dt.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
[{"name":"Supportability/library/Guzzle 4-5/detected"},
5454
[1, 0, 0, 0, 0, 0]],
5555
[{"name":"Supportability/library/Guzzle 6/detected"}, [1, 0, 0, 0, 0, 0]],
56+
[{"name":"Supportability/library/Guzzle 7/detected"}, [1, 0, 0, 0, 0, 0]],
5657
[{"name":"Supportability/Unsupported/curl_setopt/CURLOPT_HEADERFUNCTION/closure"},
5758
[3, 0, 0, 0, 0, 0]],
5859
[{"name":"DurationByCaller/Unknown/Unknown/Unknown/Unknown/all"},
@@ -75,6 +76,8 @@
7576

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

7982
/* Use guzzle 6 to make an http request. */
8083
use GuzzleHttp\Client;

tests/integration/external/guzzle6/test_dt_newrelic_header_disabled.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
[{"name":"Supportability/library/Guzzle 4-5/detected"},
5555
[1, 0, 0, 0, 0, 0]],
5656
[{"name":"Supportability/library/Guzzle 6/detected"}, [1, 0, 0, 0, 0, 0]],
57+
[{"name":"Supportability/library/Guzzle 7/detected"}, [1, 0, 0, 0, 0, 0]],
5758
[{"name":"Supportability/Unsupported/curl_setopt/CURLOPT_HEADERFUNCTION/closure"},
5859
[3, 0, 0, 0, 0, 0]],
5960
[{"name":"DurationByCaller/Unknown/Unknown/Unknown/Unknown/all"},

tests/integration/external/guzzle6/test_dt_synthetics.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
[{"name":"Supportability/library/Guzzle 4-5/detected"},
7777
[1, 0, 0, 0, 0, 0]],
7878
[{"name":"Supportability/library/Guzzle 6/detected"}, [1, 0, 0, 0, 0, 0]],
79+
[{"name":"Supportability/library/Guzzle 7/detected"}, [1, 0, 0, 0, 0, 0]],
7980
[{"name":"Supportability/Unsupported/curl_setopt/CURLOPT_HEADERFUNCTION/closure"},
8081
[3, 0, 0, 0, 0, 0]],
8182
[{"name":"DurationByCaller/Unknown/Unknown/Unknown/Unknown/all"},

tests/integration/external/guzzle6/test_no_cat_no_dt.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@
5252
[{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]],
5353
[{"name":"Supportability/library/Guzzle 4-5/detected"},
5454
[1, 0, 0, 0, 0, 0]],
55-
[{"name":"Supportability/library/Guzzle 6/detected"}, [1, 0, 0, 0, 0, 0]]
55+
[{"name":"Supportability/library/Guzzle 6/detected"}, [1, 0, 0, 0, 0, 0]],
56+
[{"name":"Supportability/library/Guzzle 7/detected"}, [1, 0, 0, 0, 0, 0]]
5657
]
5758
]
5859
*/

tests/integration/external/guzzle6/test_spans_are_created_correctly.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
"timestamp": "??",
8686
"parentId": "??",
8787
"span.kind": "client",
88-
"component": "Guzzle 6"
88+
"component": "Guzzle 6-7"
8989
},
9090
{},
9191
{
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<?php
2+
/*
3+
* Copyright 2020 New Relic Corporation. All rights reserved.
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/*DESCRIPTION
8+
Test that CAT works with guzzle 7.
9+
*/
10+
11+
/*SKIPIF
12+
<?php
13+
require_once(realpath(dirname(__FILE__)) . '/../../../include/unpack_guzzle.php');
14+
15+
if (version_compare(phpversion(), '7.2.0', '<=')) {
16+
die("skip: PHP > 7.2.0 required\n");
17+
}
18+
19+
if (!unpack_guzzle(7)) {
20+
die("skip: guzzle 7 installation required\n");
21+
}
22+
23+
if (!isset($_ENV["ACCOUNT_supportability"]) || !isset($_ENV["APP_supportability"])) {
24+
die("skip: env vars required");
25+
}
26+
*/
27+
28+
/*INI
29+
newrelic.distributed_tracing_enabled=0
30+
newrelic.cross_application_tracer.enabled = true
31+
*/
32+
33+
/*EXPECT
34+
tracing endpoint reached
35+
tracing endpoint reached
36+
Customer-Header=found tracing endpoint reached
37+
*/
38+
39+
/*EXPECT_RESPONSE_HEADERS
40+
X-NewRelic-App-Data=??
41+
X-NewRelic-App-Data=??
42+
X-NewRelic-App-Data=??
43+
*/
44+
45+
/*EXPECT_METRICS
46+
[
47+
"?? agent run id",
48+
"?? timeframe start",
49+
"?? timeframe stop",
50+
[
51+
[{"name":"External/127.0.0.1/all"}, [3, "??", "??", "??", "??", "??"]],
52+
[{"name":"External/all"}, [3, "??", "??", "??", "??", "??"]],
53+
[{"name":"External/allOther"}, [3, "??", "??", "??", "??", "??"]],
54+
[{"name":"ExternalApp/127.0.0.1/ENV[ACCOUNT_supportability]#ENV[APP_supportability]/all"},
55+
[3, "??", "??", "??", "??", "??"]],
56+
[{"name":"ExternalTransaction/127.0.0.1/ENV[ACCOUNT_supportability]#ENV[APP_supportability]/WebTransaction/Custom/tracing"},
57+
[3, "??", "??", "??", "??", "??"]],
58+
[{"name":"ExternalTransaction/127.0.0.1/ENV[ACCOUNT_supportability]#ENV[APP_supportability]/WebTransaction/Custom/tracing",
59+
"scope":"OtherTransaction/php__FILE__"}, [3, "??", "??", "??", "??", "??"]],
60+
[{"name":"OtherTransaction/all"}, [1, "??", "??", "??", "??", "??"]],
61+
[{"name":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]],
62+
[{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]],
63+
[{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]],
64+
[{"name":"Supportability/library/Guzzle 4-5/detected"},
65+
[2, 0, 0, 0, 0, 0]],
66+
[{"name":"Supportability/library/Guzzle 7/detected"}, [1, 0, 0, 0, 0, 0]],
67+
[{"name":"Supportability/Unsupported/curl_setopt/CURLOPT_HEADERFUNCTION/closure"},
68+
[3, 0, 0, 0, 0, 0]]
69+
]
70+
]
71+
*/
72+
73+
?>
74+
<?php
75+
require_once(realpath(dirname(__FILE__)) . '/../../../include/config.php');
76+
require_once(realpath(dirname(__FILE__)) . '/../../../include/unpack_guzzle.php');
77+
require_guzzle(7);
78+
79+
/* Create URL. */
80+
$url = "http://" . make_tracing_url(realpath(dirname(__FILE__)) . '/../../../include/tracing_endpoint.php');
81+
82+
/* Use guzzle 7 to make an http request. */
83+
use GuzzleHttp\Client;
84+
85+
$client = new Client();
86+
$response = $client->get($url);
87+
echo $response->getBody();
88+
89+
$response = $client->get($url, [
90+
'headers' => [
91+
'zip' => 'zap']]);
92+
echo $response->getBody();
93+
94+
$response = $client->get($url, [
95+
'headers' => [
96+
'zip' => 'zap',
97+
CUSTOMER_HEADER => 'zap']]);
98+
echo $response->getBody();
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<?php
2+
/*
3+
* Copyright 2020 New Relic Corporation. All rights reserved.
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/*DESCRIPTION
8+
Test that Distributed Tracing works with guzzle 7.
9+
*/
10+
11+
/*SKIPIF
12+
<?php
13+
require_once(realpath(dirname(__FILE__)) . '/../../../include/unpack_guzzle.php');
14+
15+
if (version_compare(phpversion(), '7.2.0', '<=')) {
16+
die("skip: PHP > 7.2.0 required\n");
17+
}
18+
19+
if (!unpack_guzzle(7)) {
20+
die("skip: guzzle 7 installation required\n");
21+
}
22+
*/
23+
24+
/*INI
25+
newrelic.distributed_tracing_enabled = true
26+
newrelic.cross_application_tracer.enabled = false
27+
*/
28+
29+
/*EXPECT
30+
traceparent=found tracestate=found newrelic=found X-NewRelic-ID=missing X-NewRelic-Transaction=missing tracing endpoint reached
31+
traceparent=found tracestate=found newrelic=found X-NewRelic-ID=missing X-NewRelic-Transaction=missing tracing endpoint reached
32+
traceparent=found tracestate=found newrelic=found X-NewRelic-ID=missing X-NewRelic-Transaction=missing Customer-Header=found tracing endpoint reached
33+
*/
34+
35+
/*EXPECT_RESPONSE_HEADERS
36+
*/
37+
38+
/*EXPECT_METRICS
39+
[
40+
"?? agent run id",
41+
"?? timeframe start",
42+
"?? timeframe stop",
43+
[
44+
[{"name":"External/127.0.0.1/all"}, [3, "??", "??", "??", "??", "??"]],
45+
[{"name":"External/127.0.0.1/all",
46+
"scope":"OtherTransaction/php__FILE__"}, [3, "??", "??", "??", "??", "??"]],
47+
[{"name":"External/all"}, [3, "??", "??", "??", "??", "??"]],
48+
[{"name":"External/allOther"}, [3, "??", "??", "??", "??", "??"]],
49+
[{"name":"OtherTransaction/all"}, [1, "??", "??", "??", "??", "??"]],
50+
[{"name":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]],
51+
[{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]],
52+
[{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]],
53+
[{"name":"Supportability/library/Guzzle 4-5/detected"},
54+
[2, 0, 0, 0, 0, 0]],
55+
[{"name":"Supportability/library/Guzzle 6/detected"}, [1, 0, 0, 0, 0, 0]],
56+
[{"name":"Supportability/library/Guzzle 7/detected"}, [1, 0, 0, 0, 0, 0]],
57+
[{"name":"Supportability/Unsupported/curl_setopt/CURLOPT_HEADERFUNCTION/closure"},
58+
[3, 0, 0, 0, 0, 0]],
59+
[{"name":"DurationByCaller/Unknown/Unknown/Unknown/Unknown/all"},
60+
[1, "??", "??", "??", "??", "??"]],
61+
[{"name":"DurationByCaller/Unknown/Unknown/Unknown/Unknown/allOther"},
62+
[1, "??", "??", "??", "??", "??"]],
63+
[{"name":"Supportability/TraceContext/Create/Success"},
64+
[3, "??", "??", "??", "??", "??"]],
65+
[{"name":"Supportability/DistributedTrace/CreatePayload/Success"},
66+
[3, "??", "??", "??", "??", "??"]]
67+
]
68+
]
69+
*/
70+
71+
?>
72+
<?php
73+
require_once(realpath(dirname(__FILE__)) . '/../../../include/config.php');
74+
require_once(realpath(dirname(__FILE__)) . '/../../../include/unpack_guzzle.php');
75+
require_guzzle(7);
76+
77+
/* Create URL. */
78+
$url = "http://" . make_tracing_url(realpath(dirname(__FILE__)) . '/../../../include/tracing_endpoint.php');
79+
//echo "\n";
80+
//echo $url."\n";
81+
82+
/* Use guzzle 7 to make an http request. */
83+
use GuzzleHttp\Client;
84+
85+
$client = new Client();
86+
$response = $client->get($url);
87+
echo $response->getBody();
88+
89+
$response = $client->get($url, [
90+
'headers' => [
91+
'zip' => 'zap']]);
92+
echo $response->getBody();
93+
94+
$response = $client->get($url, [
95+
'headers' => [
96+
'zip' => 'zap',
97+
CUSTOMER_HEADER => 'zap']]);
98+
echo $response->getBody();
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<?php
2+
/*
3+
* Copyright 2020 New Relic Corporation. All rights reserved.
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/*DESCRIPTION
8+
Test that DT works with guzzle 7.
9+
*/
10+
11+
/*SKIPIF
12+
<?php
13+
require_once(realpath(dirname(__FILE__)) . '/../../../include/unpack_guzzle.php');
14+
15+
if (version_compare(phpversion(), '7.2.0', '<=')) {
16+
die("skip: PHP > 7.2.0 required\n");
17+
}
18+
19+
if (!unpack_guzzle(7)) {
20+
die("skip: guzzle 7 installation required\n");
21+
}
22+
*/
23+
24+
/*INI
25+
newrelic.distributed_tracing_enabled = true
26+
newrelic.cross_application_tracer.enabled = false
27+
newrelic.distributed_tracing_exclude_newrelic_header = true
28+
*/
29+
30+
/*EXPECT
31+
traceparent=found tracestate=found X-NewRelic-ID=missing X-NewRelic-Transaction=missing tracing endpoint reached
32+
traceparent=found tracestate=found X-NewRelic-ID=missing X-NewRelic-Transaction=missing tracing endpoint reached
33+
traceparent=found tracestate=found X-NewRelic-ID=missing X-NewRelic-Transaction=missing Customer-Header=found tracing endpoint reached
34+
*/
35+
36+
/*EXPECT_RESPONSE_HEADERS
37+
*/
38+
39+
/*EXPECT_METRICS
40+
[
41+
"?? agent run id",
42+
"?? timeframe start",
43+
"?? timeframe stop",
44+
[
45+
[{"name":"External/127.0.0.1/all"}, [3, "??", "??", "??", "??", "??"]],
46+
[{"name":"External/127.0.0.1/all",
47+
"scope":"OtherTransaction/php__FILE__"}, [3, "??", "??", "??", "??", "??"]],
48+
[{"name":"External/all"}, [3, "??", "??", "??", "??", "??"]],
49+
[{"name":"External/allOther"}, [3, "??", "??", "??", "??", "??"]],
50+
[{"name":"OtherTransaction/all"}, [1, "??", "??", "??", "??", "??"]],
51+
[{"name":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]],
52+
[{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]],
53+
[{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]],
54+
[{"name":"Supportability/library/Guzzle 4-5/detected"},
55+
[2, 0, 0, 0, 0, 0]],
56+
[{"name":"Supportability/library/Guzzle 6/detected"}, [1, 0, 0, 0, 0, 0]],
57+
[{"name":"Supportability/library/Guzzle 7/detected"}, [1, 0, 0, 0, 0, 0]],
58+
[{"name":"Supportability/Unsupported/curl_setopt/CURLOPT_HEADERFUNCTION/closure"},
59+
[3, 0, 0, 0, 0, 0]],
60+
[{"name":"DurationByCaller/Unknown/Unknown/Unknown/Unknown/all"},
61+
[1, "??", "??", "??", "??", "??"]],
62+
[{"name":"DurationByCaller/Unknown/Unknown/Unknown/Unknown/allOther"},
63+
[1, "??", "??", "??", "??", "??"]],
64+
[{"name":"Supportability/TraceContext/Create/Success"},
65+
[3, "??", "??", "??", "??", "??"]]
66+
]
67+
]
68+
*/
69+
70+
?>
71+
<?php
72+
require_once(realpath(dirname(__FILE__)) . '/../../../include/config.php');
73+
require_once(realpath(dirname(__FILE__)) . '/../../../include/unpack_guzzle.php');
74+
require_guzzle(7);
75+
76+
// create URL
77+
$url = "http://" . make_tracing_url(realpath(dirname(__FILE__)) . '/../../../include/tracing_endpoint.php');
78+
79+
//and now use guzzle 7 to make an http request
80+
use GuzzleHttp\Client;
81+
82+
$client = new Client();
83+
$response = $client->get($url);
84+
echo $response->getBody();
85+
86+
$response = $client->get($url, [
87+
'headers' => [
88+
'zip' => 'zap']]);
89+
echo $response->getBody();
90+
91+
$response = $client->get($url, [
92+
'headers' => [
93+
'zip' => 'zap',
94+
CUSTOMER_HEADER => 'zap']]);
95+
echo $response->getBody();

0 commit comments

Comments
 (0)