Skip to content

Commit

Permalink
Merge pull request #284 from jupp0r/telegraf-integration-test
Browse files Browse the repository at this point in the history
Fix Telegraf scrape test
  • Loading branch information
gjasny committed Jul 1, 2019
2 parents 8274a80 + 396a72d commit 86360e1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ addons:
script:
- bazel build //...
- bazel test --test_output=all //core/... //pull/...
# - bazel test --test_output=all //pull/tests/integration:scrape-test
- bazel test --test_output=all //pull/tests/integration:scrape-test
# - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then bazel test --test_output=all //pull/tests/integration:lint-test; fi
- bazel run -c opt //core/benchmarks

Expand Down
2 changes: 2 additions & 0 deletions pull/tests/integration/scrape.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[[inputs.prometheus]]
# An array of urls to scrape metrics from.
urls = ["http://localhost:8080/metrics"]
interval = '1s'
[[outputs.file]]
files = ["stdout"]
flush_interval = "1s"
26 changes: 8 additions & 18 deletions pull/tests/integration/scrape.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,14 @@ if [ ! -x "$telegraf" ] ; then
exit 1
fi

pull/tests/integration/sample-server&
sample_server_pid=$!
sleep 1
telegraf_output="$(telegraf -test -config pull/tests/integration/scrape.conf)"
telegraf_run_result=$?
kill -9 $sample_server_pid
function timeout_after
{
( echo failing after $1 seconds for execution && sleep $1 && kill $$ ) &
}

if [ $telegraf_run_result -ne 0 ] ; then
exit $telegraf_run_result
fi

if [[ ! $telegraf_output == *"time_running_seconds_total"* ]] ; then
echo "Could not find time_running_seconds_total in exposed metrics:"
echo "${telegraf_run_output}"
exit 1
fi
trap 'kill $(jobs -p)' EXIT

echo "Success:"
echo "${telegraf_output}"
timeout_after 10

exit 0
pull/tests/integration/sample-server &
telegraf --config pull/tests/integration/scrape.conf --quiet | grep -m1 time_running_seconds_total

0 comments on commit 86360e1

Please sign in to comment.