http response prometheus /api/v1/labels 200 {"status":"success","data":["alertname"]}
http response prometheus /api/v1/query_range 200 {"status":"success","data":{"resultType":"matrix","result":[{"metric":{},"values":[]}]}}
http start prometheus 127.0.0.1:9110

exec bash -x ./test.sh &
exec karma --pid-file=karma.pid --alertmanager.uri=http://127.0.0.1:7110 --listen.address=127.0.0.1 --listen.port=8110 --history.enabled=true --history.timeout=10s
! stdout .
cmp stderr stderr.txt
wait

-- stderr.txt --
level=INFO msg="Version: dev"
level=INFO msg="Configured Alertmanager source" name=default cluster=default uri=http://127.0.0.1:7110 proxy=false readonly=false
level=INFO msg="Writing PID file" path=karma.pid
level=INFO msg="Initial Alertmanager collection"
level=INFO msg="Pulling latest alerts and silences from Alertmanager"
level=INFO msg="Collecting alerts and silences" alertmanager=default
level=INFO msg="GET request" uri=http://127.0.0.1:7110/metrics timeout=40s
level=ERROR msg="Request failed" error="Get \"http://127.0.0.1:7110/metrics\": dial tcp 127.0.0.1:7110: connect: connection refused" alertmanager=default uri=http://127.0.0.1:7110
level=ERROR msg="Collection failed" error="Get \"http://127.0.0.1:7110/api/v2/silences\": dial tcp 127.0.0.1:7110: connect: connection refused" alertmanager=default try=1/2
level=INFO msg="GET request" uri=http://127.0.0.1:7110/metrics timeout=40s
level=ERROR msg="Request failed" error="Get \"http://127.0.0.1:7110/metrics\": dial tcp 127.0.0.1:7110: connect: connection refused" alertmanager=default uri=http://127.0.0.1:7110
level=ERROR msg="Collection failed" error="Get \"http://127.0.0.1:7110/api/v2/silences\": dial tcp 127.0.0.1:7110: connect: connection refused" alertmanager=default try=2/2
level=INFO msg="Collection completed"
level=INFO msg="Done, starting HTTP server"
level=INFO msg="Starting HTTP server" address=127.0.0.1:8110
level=INFO msg="Shutting down HTTP server" signal=terminated
level=INFO msg="HTTP server shut down"
level=INFO msg="Removing PID file" path=karma.pid
-- query.json --
{
    "sources": [
        "http://127.0.0.1:9110",
        "http://127.0.0.1:9110"
    ],
    "labels": {
        "alertname": "Fake Alert"
    }
}
-- test.sh --
while [ ! -f karma.pid ]; do sleep 1 ; done
sleep 1
curl -s -f -o /dev/null -XPOST -d @query.json http://127.0.0.1:8110/history.json
cat karma.pid | xargs kill
