Skip to content

Commit

Permalink
Tests: Query grafana datasource via UID
Browse files Browse the repository at this point in the history
Set UID of datasources manually and use that UID to query using tests.
The older API is deprecated and soon to be removed.

Signed-off-by: Jacob Baungard Hansen <[email protected]>
  • Loading branch information
jacobbaungard committed Sep 2, 2024
1 parent 798d027 commit 4f1e12c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ type GrafanaDatasource struct {
Type string `yaml:"type,omitempty"`
URL string `yaml:"url,omitempty"`
Version int `yaml:"version,omitempty"`
UID string `yaml:"uid,omitempty"`
JSONData *JsonData `yaml:"jsonData,omitempty"`
SecureJSONData *SecureJsonData `yaml:"secureJsonData,omitempty"`
}
Expand Down Expand Up @@ -101,6 +102,7 @@ func GenerateGrafanaDataSource(
config.ProxyServiceName,
config.GetDefaultNamespace(),
),
UID: "000000001",
JSONData: &JsonData{
Timeout: "300",
CustomQueryParameters: "max_source_resolution=auto",
Expand All @@ -118,6 +120,7 @@ func GenerateGrafanaDataSource(
config.ProxyServiceName,
config.GetDefaultNamespace(),
),
UID: "000000002",
JSONData: &JsonData{
Timeout: "300",
CustomQueryParameters: "max_source_resolution=auto",
Expand Down
2 changes: 1 addition & 1 deletion tests/pkg/utils/mco_metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (r GrafanaResponse) String() string {

func QueryGrafana(opt TestOptions, query string) (*GrafanaResponse, error) {
grafanaConsoleURL := GetGrafanaURL(opt)
path := "/api/datasources/proxy/1/api/v1/query?"
path := "/api/datasources/proxy/uid/000000001/api/v1/query?"
queryParams := url.PathEscape(fmt.Sprintf("query=%s", query))
req, err := http.NewRequest(
"GET",
Expand Down

0 comments on commit 4f1e12c

Please sign in to comment.