@@ -6,6 +6,7 @@ package integration
66import (
77 "crypto/x509"
88 "crypto/x509/pkix"
9+ "encoding/json"
910 "fmt"
1011 "os"
1112 "path/filepath"
@@ -35,6 +36,14 @@ type queryFrontendTestConfig struct {
3536 setup func (t * testing.T , s * e2e.Scenario ) (configFile string , flags map [string ]string )
3637}
3738
39+ type response struct {
40+ Status status `json:"status"`
41+ Data interface {} `json:"data,omitempty"`
42+ ErrorType errorType `json:"errorType,omitempty"`
43+ Error string `json:"error,omitempty"`
44+ Warnings []string `json:"warnings,omitempty"`
45+ }
46+
3847func TestQueryFrontendWithBlocksStorageViaFlags (t * testing.T ) {
3948 runQueryFrontendTest (t , queryFrontendTestConfig {
4049 testMissingMetricName : false ,
@@ -345,6 +354,26 @@ func runQueryFrontendTest(t *testing.T, cfg queryFrontendTestConfig) {
345354 assert .Equal (t , model.LabelSet {labels .MetricName : "series_1" }, result [0 ])
346355 }
347356
357+ // No need to repeat the query 400 test for each user.
358+ if userID == 0 {
359+ start := time .Unix (1595846748 , 806 * 1e6 )
360+ end := time .Unix (1595846750 , 806 * 1e6 )
361+
362+ _ , err := c .QueryRange ("up)" , start , end , time .Second )
363+ require .Error (t , err )
364+
365+ // Expect the error response format to be correct.
366+ type response struct {
367+ Status string `json:"status"`
368+ ErrorType string `json:"errorType,omitempty"`
369+ Error string `json:"error,omitempty"`
370+ }
371+ var res response
372+ err = json .Unmarshal ([]byte (err .Error ()), & res )
373+ require .NoError (t , err )
374+ require .Equal (t , response .ErrorType , "bad_data" )
375+ }
376+
348377 for q := 0 ; q < numQueriesPerUser ; q ++ {
349378 go func () {
350379 defer wg .Done ()
@@ -359,7 +388,7 @@ func runQueryFrontendTest(t *testing.T, cfg queryFrontendTestConfig) {
359388
360389 wg .Wait ()
361390
362- extra := float64 (2 )
391+ extra := float64 (3 )
363392 if cfg .testMissingMetricName {
364393 extra ++
365394 }
0 commit comments