Skip to content

Commit 68fdc82

Browse files
committed
tests: Handle Cgi/Non-Cgi scenarios
1 parent 55fbecc commit 68fdc82

5 files changed

Lines changed: 120 additions & 6 deletions

tests/Integrations/CodeIgniter/V3_1/CommonScenariosTest.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ protected static function getEnvs()
2121
]);
2222
}
2323

24+
protected static function codeIgniterCgiCheck()
25+
{
26+
return strpos(getenv('DD_TRACE_TEST_SAPI'), 'cgi') === 0;
27+
}
28+
2429
public function testScenarioGetReturnString()
2530
{
2631
$this->tracesFromWebRequestSnapshot(function () {
@@ -45,8 +50,44 @@ public function testScenarioGetWithView()
4550
});
4651
}
4752

53+
public function testScenarioGetWithExceptionCgi()
54+
{
55+
if (!self::codeIgniterCgiCheck()) {
56+
$this->markTestSkipped('Skip: Test only runs with cgi SAPIs');
57+
}
58+
59+
$this->tracesFromWebRequestSnapshot(function () {
60+
$this->call(
61+
GetSpec::create(
62+
'A GET request with an exception',
63+
'/error?key=value&pwd=should_redact'
64+
)
65+
);
66+
});
67+
}
68+
69+
public function testScenarioGetToMissingRouteCgi()
70+
{
71+
if (!self::codeIgniterCgiCheck()) {
72+
$this->markTestSkipped('Skip: Test only runs with cgi SAPIs');
73+
}
74+
75+
$this->tracesFromWebRequestSnapshot(function () {
76+
$this->call(
77+
GetSpec::create(
78+
'A GET request to a missing route',
79+
'/does_not_exist?key=value&pwd=should_redact'
80+
)
81+
);
82+
});
83+
}
84+
4885
public function testScenarioGetWithException()
4986
{
87+
if (self::codeIgniterCgiCheck()) {
88+
$this->markTestSkipped('Skip: Test doesn\'t run with cgi SAPIs');
89+
}
90+
5091
$this->tracesFromWebRequestSnapshot(function () {
5192
$this->call(
5293
GetSpec::create(
@@ -59,6 +100,10 @@ public function testScenarioGetWithException()
59100

60101
public function testScenarioGetToMissingRoute()
61102
{
103+
if (self::codeIgniterCgiCheck()) {
104+
$this->markTestSkipped('Skip: Test doesn\'t run with cgi SAPIs');
105+
}
106+
62107
$this->tracesFromWebRequestSnapshot(function () {
63108
$this->call(
64109
GetSpec::create(

tests/snapshots/tests.integrations.code_igniter.v3_1.common_scenarios_test.test_scenario_get_to_missing_route.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55
"resource": "GET /does_not_exist",
66
"trace_id": 0,
77
"span_id": 1,
8-
"parent_id": 1569360189764723184,
8+
"parent_id": 1061763603094000520,
99
"type": "web",
1010
"meta": {
1111
"_dd.p.dm": "-0",
12-
"_dd.p.tid": "660bca3700000000",
12+
"_dd.p.tid": "660beae300000000",
1313
"component": "codeigniter",
1414
"http.method": "GET",
1515
"http.route": "does_not_exist",
1616
"http.status_code": "404",
1717
"http.url": "http://localhost:9999/does_not_exist?key=value&<redacted>",
18-
"runtime-id": "26ab24e6-051f-4e1f-9adf-3d609bef6946",
18+
"runtime-id": "232799b0-3a18-4d64-9c97-4f6b441bb91e",
1919
"span.kind": "server"
2020
},
2121
"metrics": {
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[[
2+
{
3+
"name": "codeigniter.request",
4+
"service": "codeigniter_test_app",
5+
"resource": "GET /does_not_exist",
6+
"trace_id": 0,
7+
"span_id": 1,
8+
"parent_id": 2162643876065918024,
9+
"type": "web",
10+
"meta": {
11+
"_dd.p.dm": "-0",
12+
"_dd.p.tid": "660beb1600000000",
13+
"component": "codeigniter",
14+
"http.method": "GET",
15+
"http.route": "does_not_exist",
16+
"http.status_code": "200",
17+
"http.url": "http://localhost:9999/does_not_exist?key=value&<redacted>",
18+
"runtime-id": "0caac976-2232-42e0-a186-9f73b4c27f50",
19+
"span.kind": "server"
20+
},
21+
"metrics": {
22+
"_sampling_priority_v1": 1.0
23+
}
24+
}]]

tests/snapshots/tests.integrations.code_igniter.v3_1.common_scenarios_test.test_scenario_get_with_exception.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
"resource": "GET /error",
66
"trace_id": 0,
77
"span_id": 1,
8-
"parent_id": 14316491551034217378,
8+
"parent_id": 2762893716144464546,
99
"type": "web",
1010
"error": 1,
1111
"meta": {
1212
"_dd.p.dm": "-0",
13-
"_dd.p.tid": "660bca3200000000",
13+
"_dd.p.tid": "660bead900000000",
1414
"app.endpoint": "Error_::index",
1515
"component": "codeigniter",
1616
"error.message": "Uncaught Exception (500): datadog in /home/circleci/datadog/tests/Frameworks/CodeIgniter/Version_3_1/application/controllers/Error_.php:5",
@@ -20,7 +20,7 @@
2020
"http.route": "error",
2121
"http.status_code": "500",
2222
"http.url": "http://localhost:9999/error?key=value&<redacted>",
23-
"runtime-id": "26ab24e6-051f-4e1f-9adf-3d609bef6946",
23+
"runtime-id": "91489364-94f6-4030-b3ed-5df886a158a0",
2424
"span.kind": "server"
2525
},
2626
"metrics": {
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
[[
2+
{
3+
"name": "codeigniter.request",
4+
"service": "codeigniter_test_app",
5+
"resource": "GET /error",
6+
"trace_id": 0,
7+
"span_id": 1,
8+
"parent_id": 2789725972881216242,
9+
"type": "web",
10+
"error": 1,
11+
"meta": {
12+
"_dd.p.dm": "-0",
13+
"_dd.p.tid": "660beb1100000000",
14+
"app.endpoint": "Error_::index",
15+
"component": "codeigniter",
16+
"error.message": "Uncaught Exception: datadog in /home/circleci/datadog/tests/Frameworks/CodeIgniter/Version_3_1/application/controllers/Error_.php:5",
17+
"error.stack": "#0 /home/circleci/datadog/tests/Frameworks/CodeIgniter/Version_3_1/system/core/CodeIgniter.php(533): Error_->index()\n#1 /home/circleci/datadog/tests/Frameworks/CodeIgniter/Version_3_1/index.php(315): require_once()\n#2 /home/circleci/datadog/tests/Frameworks/CodeIgniter/Version_3_1/ddshim.php(8): require()\n#3 {main}",
18+
"error.type": "Exception",
19+
"http.method": "GET",
20+
"http.route": "error",
21+
"http.status_code": "200",
22+
"http.url": "http://localhost:9999/error?key=value&<redacted>",
23+
"runtime-id": "0caac976-2232-42e0-a186-9f73b4c27f50",
24+
"span.kind": "server"
25+
},
26+
"metrics": {
27+
"_sampling_priority_v1": 1.0
28+
}
29+
},
30+
{
31+
"name": "Error_.index",
32+
"service": "codeigniter_test_app",
33+
"resource": "Error_.index",
34+
"trace_id": 0,
35+
"span_id": 2,
36+
"parent_id": 1,
37+
"type": "web",
38+
"error": 1,
39+
"meta": {
40+
"component": "codeigniter",
41+
"error.message": "Thrown Exception: datadog in /home/circleci/datadog/tests/Frameworks/CodeIgniter/Version_3_1/application/controllers/Error_.php:5",
42+
"error.stack": "#0 /home/circleci/datadog/tests/Frameworks/CodeIgniter/Version_3_1/system/core/CodeIgniter.php(533): Error_->index()\n#1 /home/circleci/datadog/tests/Frameworks/CodeIgniter/Version_3_1/index.php(315): require_once()\n#2 /home/circleci/datadog/tests/Frameworks/CodeIgniter/Version_3_1/ddshim.php(8): require()\n#3 {main}",
43+
"error.type": "Exception"
44+
}
45+
}]]

0 commit comments

Comments
 (0)