@@ -68,12 +68,12 @@ function wait_for_port() {
68
68
}
69
69
70
70
function run_nginx() {
71
- eval " nginx -g \ " daemon off;\ " 1>/tmp/nginx_log.txt &"
71
+ nginx -g " daemon off;" 1> /tmp/nginx_log.txt &
72
72
NGINX_PID=$!
73
73
wait_for_port 80
74
74
}
75
75
76
- echo " Test 1: Ensure the right traces sent to the agent."
76
+ echo " ======== Test 1: Ensure the right traces sent to the agent. ======== "
77
77
# Start wiremock in background
78
78
wiremock --port 8126 > /dev/null 2>&1 &
79
79
# Wait for wiremock to start
105
105
fi
106
106
107
107
reset_test
108
- echo " Test 2: Check that libcurl isn't writing to stdout"
108
+ echo " ======== Test 2: Check that libcurl isn't writing to stdout ======== "
109
109
run_nginx
110
110
curl -s localhost? [1-10000] 1> /tmp/curl_log.txt
111
111
118
118
fi
119
119
120
120
reset_test
121
- echo " Test 3: Check that creating a root span doesn't produce an error"
121
+ echo " ======== Test 3: Check that creating a root span doesn't produce an error ======== "
122
122
run_nginx
123
123
curl -s localhost? [1-5] 1> /tmp/curl_log.txt
124
124
137
137
fi
138
138
139
139
reset_test
140
- echo " Test 4: Check that priority sampling works."
140
+ echo
8B92
" ======== Test 4: Check that priority sampling works. ======== "
141
141
# Start the mock agent
142
142
wiremock --port 8126 > /dev/null 2>&1 & wait_for_port 8126
143
143
curl -s -X POST --data ' { "priority":10, "request": { "method": "ANY", "urlPattern": ".*" }, "response": { "status": 200, "body": "{\"rate_by_service\":{\"service:nginx,env:prod\":0.5, \"service:nginx,env:\":0.2, \"service:wrong,env:\":0.1, \"service:nginx,env:wrong\":0.9}}" }}' http://localhost:8126/__admin/mappings/new
189
189
fi
190
190
191
191
reset_test
192
- echo " Test 5: Ensure that NGINX errors are reported to Datadog"
192
+ echo " ======== Test 5: Ensure that NGINX errors are reported to Datadog ======== "
193
193
wiremock --port 8126 > /dev/null 2>&1 &
194
194
# Wait for wiremock to start
195
195
wait_for_port 8126
213
213
214
214
reset_test
215
215
216
- echo " Test 6: Origin header is propagated and adds a tag"
216
+ echo " ======== Test 6: Origin header is propagated and adds a tag ======== "
217
217
wiremock --port 8126 > /dev/null 2>&1 & wait_for_port 8126
218
218
curl -s -X POST --data ' { "priority":10, "request": { "method": "ANY", "urlPattern": ".*" }, "response": { "status": 200, "body": "OK" }}' http://localhost:8126/__admin/mappings/new
219
219
wiremock --port 8080 > /dev/null 2>&1 & wait_for_port 8080
@@ -248,3 +248,37 @@ then
248
248
echo " ${DIFF} "
249
249
exit 1
250
250
fi
251
+
252
+ reset_test
253
+ echo " ======== Test 7: Check that extracting a child span without X-Datadog-Tags doesn't produce an error ========"
254
+ # See <https://github.com/DataDog/dd-opentracing-cpp/issues/241>.
255
+
256
+ wiremock --port 8080 > /dev/null 2>&1 & wait_for_port 8080
257
+ curl -s -X POST --data ' { "priority":10, "request": { "method": "ANY", "urlPattern": ".*" }, "response": { "status": 200, "body": "Hello World" }}' http://localhost:8080/__admin/mappings/new
258
+
259
+ echo ' {
260
+ "service": "nginx",
261
+ "operation_name_override": "nginx.handle"
262
+ }' > ${TRACER_CONF_PATH}
263
+
264
+ run_nginx
265
+
266
+ curl -s \
267
+ -H ' X-Datadog-Trace-Id: 1234' \
268
+ -H ' X-Datadog-Parent-Id: 1234' \
269
+ -H ' X-Datadog-Sampling-Priority: 0' \
270
+ http://localhost/proxy/ > /tmp/curl_log.txt
271
+
272
+ if [ " $( cat ${NGINX_ERROR_LOG} | grep ' no opentracing context value found for span context key ' | wc -l) " != " 0" ]
273
+ then
274
+ echo " Extraction errors in nginx log file:"
275
+ cat ${NGINX_ERROR_LOG}
276
+ echo " "
277
+ exit 1
278
+ elif [ " $( cat ${NGINX_ERROR_LOG} ) " != " " ]
279
+ then
280
+ echo " Other errors in nginx log file:"
281
+ cat ${NGINX_ERROR_LOG}
282
+ echo " "
283
+ exit 1
284
+ fi
0 commit comments