Modify the Server Error scenario to return frontend errors (#47157) (#47425)

(cherry picked from commit 41642fd5f4)

Co-authored-by: Josh Hunt <joshhunt@users.noreply.github.com>
This commit is contained in:
Grot (@grafanabot)
2022-04-20 16:11:23 +01:00
committed by GitHub
co-authored by Josh Hunt
parent 690c08b80d
commit f08c5a796c
5 changed files with 92 additions and 5 deletions
+19 -4
View File
@@ -177,9 +177,12 @@ Timestamps will line up evenly on timeStepSeconds (For example, 60 seconds means
})
s.registerScenario(&Scenario{
ID: string(serverError500Query),
Name: "Server Error (500)",
handler: s.handleServerError500Scenario,
// Is no longer strictly a _server_ error scenario, but ID is kept for legacy :)
ID: string(serverError500Query),
Name: "Conditional Error",
handler: s.handleServerError500Scenario,
StringInput: "1,20,90,30,5,0",
Description: "Returns an error when the String Input field is empty",
})
s.registerScenario(&Scenario{
@@ -449,7 +452,19 @@ func (s *Service) handlePredictablePulseScenario(ctx context.Context, req *backe
}
func (s *Service) handleServerError500Scenario(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error) {
panic("Test Data Panic!")
for _, q := range req.Queries {
model, err := simplejson.NewJson(q.JSON)
if err != nil {
continue
}
stringInput := model.Get("stringInput").MustString()
if stringInput == "" {
panic("Test Data Panic!")
}
}
return s.handleCSVMetricValuesScenario(ctx, req)
}
func (s *Service) handleClientSideScenario(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error) {