|
256 | 256 |
|
257 | 257 | message " Stop containers "
|
258 | 258 | docker stop http-echo-tests
|
| 259 | +sleep 5 |
259 | 260 |
|
260 | 261 | message " Start container with DISABLE_REQUEST_LOGS "
|
261 | 262 | docker run -d --rm -e DISABLE_REQUEST_LOGS=true --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo
|
@@ -442,18 +443,39 @@ message " Stop containers "
|
442 | 443 | docker stop http-echo-tests
|
443 | 444 | sleep 5
|
444 | 445 |
|
445 |
| -message " Start container with PROMETHEUS " |
446 |
| -docker run -d --rm -e --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo |
| 446 | +message " Start container with PROMETHEUS disabled " |
| 447 | +docker run -d --rm --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo |
447 | 448 | sleep 5
|
448 | 449 | curl -s -k -X POST -d "tiramisu" https://localhost:8443/ > /dev/null
|
449 |
| -METRICS_CHECK="$(curl -sk http://localhost:8080/metrics | grep http_request_duration_seconds_count | grep GET | cut -d' ' -f2)" |
450 | 450 |
|
451 |
| -if [ "$METRICS_CHECK" == "1" ] |
| 451 | +# grep for http_request_duration_seconds_count ensure it is not present at /metric path |
| 452 | + |
| 453 | +METRICS_CHECK="$(curl -sk http://localhost:8080/metrics | grep -v http_request_duration_seconds_count )" |
| 454 | + |
| 455 | +if [[ "$METRICS_CHECK" == *"http_request_duration_seconds_count"* ]] |
452 | 456 | then
|
453 |
| - passed "PROMETHEUS metrics are working" |
| 457 | + failed "PROMETHEUS metrics are enabled" |
| 458 | + exit 1 |
454 | 459 | else
|
455 |
| - failed "PROMETHEUS metrics are not working" |
456 |
| - docker logs http-echo-tests |
| 460 | + passed "PROMETHEUS metrics are disabled by default" |
| 461 | +fi |
| 462 | + |
| 463 | +message " Stop containers " |
| 464 | +docker stop http-echo-tests |
| 465 | +sleep 5 |
| 466 | + |
| 467 | +message " Start container with PROMETHEUS enabled " |
| 468 | +docker run -d -e PROMETHEUS_ENABLED=true --rm --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo |
| 469 | +sleep 5 |
| 470 | +curl -s -k -X POST -d "tiramisu" https://localhost:8443/ > /dev/null |
| 471 | + |
| 472 | +METRICS_CHECK="$(curl -sk http://localhost:8080/metrics | grep http_request_duration_seconds_count )" |
| 473 | + |
| 474 | +if [[ "$METRICS_CHECK" == *"http_request_duration_seconds_count"* ]] |
| 475 | +then |
| 476 | + passed "PROMETHEUS metrics are enabled" |
| 477 | +else |
| 478 | + failed "PROMETHEUS metrics are disabled" |
457 | 479 | exit 1
|
458 | 480 | fi
|
459 | 481 |
|
|
0 commit comments