Add failing test fo when ES server is booting up

This commit is contained in:
Elfo404 2021-06-11 15:22:40 +01:00
parent c26d6233d1
commit fd14a1fd5e
No known key found for this signature in database
GPG Key ID: 586539D9491F0726

View File

@ -15,6 +15,30 @@ import (
func TestResponseParser(t *testing.T) {
t.Run("Elasticsearch response parser test", func(t *testing.T) {
t.Run("Boot Up", func(t *testing.T) {
// This happens when ES is booting up.
// the response is somehow incomplete, Grafana shouldn't panic in this case.
targets := map[string]string{
"A": `{
"timeField": "@timestamp",
"metrics": [{ "type": "count", "id": "1" }],
"bucketAggs": [{ "type": "date_histogram", "field": "@timestamp", "id": "2" }]
}`,
}
response := `{
"responses": [
{
"aggregations": null
}
]
}`
rp, err := newResponseParserForTest(targets, response)
require.NoError(t, err)
result, err := rp.getTimeSeries()
require.NoError(t, err)
require.Len(t, result.Results, 1)
})
t.Run("Simple query and count", func(t *testing.T) {
targets := map[string]string{
"A": `{