mirror of https://github.com/grafana/grafana.git
testdata: add query-metadata scenario (#111627)
* testdata: add query-metadata scenario * updated test specs
This commit is contained in:
parent
8f56f1df98
commit
b8fd7b5e18
|
@ -72,6 +72,7 @@ const (
|
|||
TestDataQueryTypeNodeGraph TestDataQueryType = "node_graph"
|
||||
TestDataQueryTypePredictableCsvWave TestDataQueryType = "predictable_csv_wave"
|
||||
TestDataQueryTypePredictablePulse TestDataQueryType = "predictable_pulse"
|
||||
TestDataQueryTypeQueryMeta TestDataQueryType = "query_meta"
|
||||
TestDataQueryTypeRandomWalk TestDataQueryType = "random_walk"
|
||||
TestDataQueryTypeRandomWalkTable TestDataQueryType = "random_walk_table"
|
||||
TestDataQueryTypeRandomWalkWithError TestDataQueryType = "random_walk_with_error"
|
||||
|
|
|
@ -229,7 +229,7 @@
|
|||
"additionalProperties": false
|
||||
},
|
||||
"scenarioId": {
|
||||
"description": "Possible enum values:\n - `\"annotations\"` \n - `\"arrow\"` \n - `\"csv_content\"` \n - `\"csv_file\"` \n - `\"csv_metric_values\"` \n - `\"datapoints_outside_range\"` \n - `\"error_with_source\"` \n - `\"exponential_heatmap_bucket_data\"` \n - `\"flame_graph\"` \n - `\"grafana_api\"` \n - `\"linear_heatmap_bucket_data\"` \n - `\"live\"` \n - `\"logs\"` \n - `\"manual_entry\"` \n - `\"no_data_points\"` \n - `\"node_graph\"` \n - `\"predictable_csv_wave\"` \n - `\"predictable_pulse\"` \n - `\"random_walk\"` \n - `\"random_walk_table\"` \n - `\"random_walk_with_error\"` \n - `\"raw_frame\"` \n - `\"server_error_500\"` \n - `\"steps\"` \n - `\"simulation\"` \n - `\"slow_query\"` \n - `\"streaming_client\"` \n - `\"table_static\"` \n - `\"trace\"` \n - `\"usa\"` \n - `\"variables-query\"` ",
|
||||
"description": "Possible enum values:\n - `\"annotations\"` \n - `\"arrow\"` \n - `\"csv_content\"` \n - `\"csv_file\"` \n - `\"csv_metric_values\"` \n - `\"datapoints_outside_range\"` \n - `\"error_with_source\"` \n - `\"exponential_heatmap_bucket_data\"` \n - `\"flame_graph\"` \n - `\"grafana_api\"` \n - `\"linear_heatmap_bucket_data\"` \n - `\"live\"` \n - `\"logs\"` \n - `\"manual_entry\"` \n - `\"no_data_points\"` \n - `\"node_graph\"` \n - `\"predictable_csv_wave\"` \n - `\"predictable_pulse\"` \n - `\"query_meta\"` \n - `\"random_walk\"` \n - `\"random_walk_table\"` \n - `\"random_walk_with_error\"` \n - `\"raw_frame\"` \n - `\"server_error_500\"` \n - `\"steps\"` \n - `\"simulation\"` \n - `\"slow_query\"` \n - `\"streaming_client\"` \n - `\"table_static\"` \n - `\"trace\"` \n - `\"usa\"` \n - `\"variables-query\"` ",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"annotations",
|
||||
|
@ -250,6 +250,7 @@
|
|||
"node_graph",
|
||||
"predictable_csv_wave",
|
||||
"predictable_pulse",
|
||||
"query_meta",
|
||||
"random_walk",
|
||||
"random_walk_table",
|
||||
"random_walk_with_error",
|
||||
|
|
|
@ -239,7 +239,7 @@
|
|||
"additionalProperties": false
|
||||
},
|
||||
"scenarioId": {
|
||||
"description": "Possible enum values:\n - `\"annotations\"` \n - `\"arrow\"` \n - `\"csv_content\"` \n - `\"csv_file\"` \n - `\"csv_metric_values\"` \n - `\"datapoints_outside_range\"` \n - `\"error_with_source\"` \n - `\"exponential_heatmap_bucket_data\"` \n - `\"flame_graph\"` \n - `\"grafana_api\"` \n - `\"linear_heatmap_bucket_data\"` \n - `\"live\"` \n - `\"logs\"` \n - `\"manual_entry\"` \n - `\"no_data_points\"` \n - `\"node_graph\"` \n - `\"predictable_csv_wave\"` \n - `\"predictable_pulse\"` \n - `\"random_walk\"` \n - `\"random_walk_table\"` \n - `\"random_walk_with_error\"` \n - `\"raw_frame\"` \n - `\"server_error_500\"` \n - `\"steps\"` \n - `\"simulation\"` \n - `\"slow_query\"` \n - `\"streaming_client\"` \n - `\"table_static\"` \n - `\"trace\"` \n - `\"usa\"` \n - `\"variables-query\"` ",
|
||||
"description": "Possible enum values:\n - `\"annotations\"` \n - `\"arrow\"` \n - `\"csv_content\"` \n - `\"csv_file\"` \n - `\"csv_metric_values\"` \n - `\"datapoints_outside_range\"` \n - `\"error_with_source\"` \n - `\"exponential_heatmap_bucket_data\"` \n - `\"flame_graph\"` \n - `\"grafana_api\"` \n - `\"linear_heatmap_bucket_data\"` \n - `\"live\"` \n - `\"logs\"` \n - `\"manual_entry\"` \n - `\"no_data_points\"` \n - `\"node_graph\"` \n - `\"predictable_csv_wave\"` \n - `\"predictable_pulse\"` \n - `\"query_meta\"` \n - `\"random_walk\"` \n - `\"random_walk_table\"` \n - `\"random_walk_with_error\"` \n - `\"raw_frame\"` \n - `\"server_error_500\"` \n - `\"steps\"` \n - `\"simulation\"` \n - `\"slow_query\"` \n - `\"streaming_client\"` \n - `\"table_static\"` \n - `\"trace\"` \n - `\"usa\"` \n - `\"variables-query\"` ",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"annotations",
|
||||
|
@ -260,6 +260,7 @@
|
|||
"node_graph",
|
||||
"predictable_csv_wave",
|
||||
"predictable_pulse",
|
||||
"query_meta",
|
||||
"random_walk",
|
||||
"random_walk_table",
|
||||
"random_walk_with_error",
|
||||
|
|
|
@ -151,7 +151,7 @@
|
|||
"type": "string"
|
||||
},
|
||||
"scenarioId": {
|
||||
"description": "Possible enum values:\n - `\"annotations\"` \n - `\"arrow\"` \n - `\"csv_content\"` \n - `\"csv_file\"` \n - `\"csv_metric_values\"` \n - `\"datapoints_outside_range\"` \n - `\"error_with_source\"` \n - `\"exponential_heatmap_bucket_data\"` \n - `\"flame_graph\"` \n - `\"grafana_api\"` \n - `\"linear_heatmap_bucket_data\"` \n - `\"live\"` \n - `\"logs\"` \n - `\"manual_entry\"` \n - `\"no_data_points\"` \n - `\"node_graph\"` \n - `\"predictable_csv_wave\"` \n - `\"predictable_pulse\"` \n - `\"random_walk\"` \n - `\"random_walk_table\"` \n - `\"random_walk_with_error\"` \n - `\"raw_frame\"` \n - `\"server_error_500\"` \n - `\"steps\"` \n - `\"simulation\"` \n - `\"slow_query\"` \n - `\"streaming_client\"` \n - `\"table_static\"` \n - `\"trace\"` \n - `\"usa\"` \n - `\"variables-query\"` ",
|
||||
"description": "Possible enum values:\n - `\"annotations\"` \n - `\"arrow\"` \n - `\"csv_content\"` \n - `\"csv_file\"` \n - `\"csv_metric_values\"` \n - `\"datapoints_outside_range\"` \n - `\"error_with_source\"` \n - `\"exponential_heatmap_bucket_data\"` \n - `\"flame_graph\"` \n - `\"grafana_api\"` \n - `\"linear_heatmap_bucket_data\"` \n - `\"live\"` \n - `\"logs\"` \n - `\"manual_entry\"` \n - `\"no_data_points\"` \n - `\"node_graph\"` \n - `\"predictable_csv_wave\"` \n - `\"predictable_pulse\"` \n - `\"query_meta\"` \n - `\"random_walk\"` \n - `\"random_walk_table\"` \n - `\"random_walk_with_error\"` \n - `\"raw_frame\"` \n - `\"server_error_500\"` \n - `\"steps\"` \n - `\"simulation\"` \n - `\"slow_query\"` \n - `\"streaming_client\"` \n - `\"table_static\"` \n - `\"trace\"` \n - `\"usa\"` \n - `\"variables-query\"` ",
|
||||
"enum": [
|
||||
"annotations",
|
||||
"arrow",
|
||||
|
@ -171,6 +171,7 @@
|
|||
"node_graph",
|
||||
"predictable_csv_wave",
|
||||
"predictable_pulse",
|
||||
"query_meta",
|
||||
"random_walk",
|
||||
"random_walk_table",
|
||||
"random_walk_with_error",
|
||||
|
|
|
@ -158,6 +158,12 @@ Timestamps will line up evenly on timeStepSeconds (For example, 60 seconds means
|
|||
handler: s.handleRandomWalkWithErrorScenario,
|
||||
})
|
||||
|
||||
s.registerScenario(&Scenario{
|
||||
ID: kinds.TestDataQueryTypeQueryMeta,
|
||||
Name: "Query Metadata",
|
||||
handler: s.handleQueryMetaScenario,
|
||||
})
|
||||
|
||||
s.registerScenario(&Scenario{
|
||||
// Is no longer strictly a _server_ error scenario, but ID is kept for legacy :)
|
||||
ID: kinds.TestDataQueryTypeServerError500,
|
||||
|
@ -390,6 +396,31 @@ func (s *Service) handleCSVMetricValuesScenario(ctx context.Context, req *backen
|
|||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *Service) handleQueryMetaScenario(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error) {
|
||||
resp := backend.NewQueryDataResponse()
|
||||
|
||||
if len(req.Queries) == 0 {
|
||||
return nil, errors.New("no queries")
|
||||
}
|
||||
|
||||
refId := req.Queries[0].RefID
|
||||
|
||||
username := req.PluginContext.User.Name
|
||||
|
||||
keys := []string{"username"}
|
||||
values := []string{username}
|
||||
|
||||
frame := data.NewFrame("",
|
||||
data.NewField("keys", nil, keys),
|
||||
data.NewField("values", nil, values),
|
||||
)
|
||||
r := backend.DataResponse{}
|
||||
r.Frames = data.Frames{frame}
|
||||
|
||||
resp.Responses[refId] = r
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *Service) handleRandomWalkWithErrorScenario(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error) {
|
||||
resp := backend.NewQueryDataResponse()
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ export enum TestDataQueryType {
|
|||
NodeGraph = 'node_graph',
|
||||
PredictableCSVWave = 'predictable_csv_wave',
|
||||
PredictablePulse = 'predictable_pulse',
|
||||
QueryMeta = 'query_meta',
|
||||
RandomWalk = 'random_walk',
|
||||
RandomWalkTable = 'random_walk_table',
|
||||
RandomWalkWithError = 'random_walk_with_error',
|
||||
|
|
|
@ -74,6 +74,12 @@ export const scenarios = [
|
|||
name: 'Predictable Pulse',
|
||||
stringInput: '',
|
||||
},
|
||||
{
|
||||
description: '',
|
||||
id: TestDataQueryType.QueryMeta,
|
||||
name: 'Query Metadata',
|
||||
stringInput: '',
|
||||
},
|
||||
{
|
||||
description: '',
|
||||
id: TestDataQueryType.RandomWalk,
|
||||
|
|
Loading…
Reference in New Issue