diff options
author | kballou <kballou@devnulllabs.io> | 2016-03-25 15:58:27 -0600 |
---|---|---|
committer | kballou <kballou@devnulllabs.io> | 2016-03-25 16:27:39 -0600 |
commit | 050dab3186453c84cbab324d386a4dfb7b2e809c (patch) | |
tree | 5b0886f4ceb27ba15b402038bb2a7278a7e2232a /test/ex_prometheus_io_test.exs | |
parent | a4b25d32f063f9f2982dc6961dd6a7ed13709e12 (diff) | |
download | ex_prometheus_io-050dab3186453c84cbab324d386a4dfb7b2e809c.tar.gz ex_prometheus_io-050dab3186453c84cbab324d386a4dfb7b2e809c.tar.xz |
Add http fixtures and tests
* Add general data query tests
* Add tests for query process death and timeout
Diffstat (limited to 'test/ex_prometheus_io_test.exs')
-rw-r--r-- | test/ex_prometheus_io_test.exs | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/test/ex_prometheus_io_test.exs b/test/ex_prometheus_io_test.exs index 8990325..dc4e55c 100644 --- a/test/ex_prometheus_io_test.exs +++ b/test/ex_prometheus_io_test.exs @@ -2,4 +2,59 @@ defmodule ExPrometheusIoTest do use ExUnit.Case doctest ExPrometheusIo + test "can query for up data" do + {pid, ref} = ExPrometheusIo.query("up") + assert_receive {:prometheus_results, ^ref, results} + assert results["results"] != [] + assert results["resultType"] == "vector" + refute Process.alive?(pid) + end + + test "can query range for up data" do + {pid, ref} = ExPrometheusIo.range("up", 1458855801, 1458855810, 1) + assert_receive {:prometheus_results, ^ref, results} + assert results["results"] != [] + assert results["resultType"] == "matrix" + refute Process.alive?(pid) + end + + test "can query up series data" do + {pid, ref} = ExPrometheusIo.series(["up"]) + assert_receive {:prometheus_results, ^ref, results} + refute Process.alive?(pid) + end + + test "http query failure doesn't break the world" do + {pid, ref} = ExPrometheusIo.query("kill") + refute_receive {:prometheus_results, ^ref, _} + refute Process.alive?(pid) + end + + test "http range failure doesn't break the wolrd" do + {pid, ref} = ExPrometheusIo.range("kill", 0, 1, 0.5) + refute_receive {:prometheus_results, ^ref, _} + refute Process.alive?(pid) + end + + test "http series failure doesn't break the world" do + {pid, ref} = ExPrometheusIo.series(["kill"]) + refute_receive {:prometheus_results, ^ref, _} + refute Process.alive?(pid) + end + + test "http query timeout doesn't stop the world" do + {_, ref} = ExPrometheusIo.query("timeout") + refute_receive {:prometheus_results, ^ref, _}, 10 + end + + test "http range timeout doesn't stop the world" do + {_, ref} = ExPrometheusIo.range("timeout", 0, 1, 0.5) + refute_receive {:prometheus_results, ^ref, _}, 10 + end + + test "http series timeout doesn't stop the world" do + {_, ref} = ExPrometheusIo.series(["timeout"]) + refute_receive {:prometheus_results, ^ref, _}, 10 + end + end |