mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Glue: Return correlation config in GET /correlations (#55801)
* Fix getting and creating correlations config * Fix tests
This commit is contained in:
parent
43dc92d12c
commit
a8f43b97a2
@ -15,7 +15,7 @@ var (
|
||||
|
||||
// CorrelationConfigTarget is the target data query specific to target data source (Correlation.TargetUID)
|
||||
// swagger:model
|
||||
type CorrelationConfigTarget struct{}
|
||||
type CorrelationConfigTarget interface{}
|
||||
|
||||
// swagger:model
|
||||
type CorrelationConfig struct {
|
||||
|
@ -233,7 +233,7 @@ func TestDatasourceAsConfig(t *testing.T) {
|
||||
|
||||
require.Equal(t, dsCfg.APIVersion, int64(0))
|
||||
|
||||
validateDatasource(t, dsCfg)
|
||||
validateDatasourceV0(t, dsCfg)
|
||||
validateDeleteDatasources(t, dsCfg)
|
||||
})
|
||||
|
||||
@ -292,7 +292,7 @@ func validateDeleteDatasources(t *testing.T, dsCfg *configs) {
|
||||
require.Equal(t, deleteDs.OrgID, int64(2))
|
||||
}
|
||||
|
||||
func validateDatasource(t *testing.T, dsCfg *configs) {
|
||||
func validateDatasourceV0(t *testing.T, dsCfg *configs) {
|
||||
ds := dsCfg.Datasources[0]
|
||||
require.Equal(t, ds.Name, "name")
|
||||
require.Equal(t, ds.Type, "type")
|
||||
@ -308,12 +308,6 @@ func validateDatasource(t *testing.T, dsCfg *configs) {
|
||||
require.True(t, ds.Editable)
|
||||
require.Equal(t, ds.Version, 10)
|
||||
|
||||
require.Equal(t, []map[string]interface{}{{
|
||||
"targetUID": "a target",
|
||||
"label": "a label",
|
||||
"description": "a description",
|
||||
}}, ds.Correlations)
|
||||
|
||||
require.Greater(t, len(ds.JSONData), 2)
|
||||
require.Equal(t, ds.JSONData["graphiteVersion"], "1.1")
|
||||
require.Equal(t, ds.JSONData["tlsAuth"], true)
|
||||
@ -326,9 +320,20 @@ func validateDatasource(t *testing.T, dsCfg *configs) {
|
||||
}
|
||||
|
||||
func validateDatasourceV1(t *testing.T, dsCfg *configs) {
|
||||
validateDatasource(t, dsCfg)
|
||||
validateDatasourceV0(t, dsCfg)
|
||||
ds := dsCfg.Datasources[0]
|
||||
require.Equal(t, ds.UID, "test_uid")
|
||||
require.Equal(t, []map[string]interface{}{{
|
||||
"targetUID": "a target",
|
||||
"label": "a label",
|
||||
"description": "a description",
|
||||
"config": map[string]interface{}{
|
||||
"field": "fieldName",
|
||||
"target": map[string]interface{}{
|
||||
"target": "test.query",
|
||||
},
|
||||
},
|
||||
}}, ds.Correlations)
|
||||
}
|
||||
|
||||
type mockOrgStore struct{ ExpectedOrg *models.Org }
|
||||
|
@ -16,6 +16,10 @@ datasources:
|
||||
- targetUID: a target
|
||||
label: a label
|
||||
description: a description
|
||||
config:
|
||||
field: "fieldName"
|
||||
target:
|
||||
target: "test.query"
|
||||
jsonData:
|
||||
graphiteVersion: "1.1"
|
||||
tlsAuth: true
|
||||
|
@ -12,4 +12,4 @@ datasources:
|
||||
description: a description
|
||||
- targetUID: graphite
|
||||
label: a second label
|
||||
description: a second description
|
||||
description: a second description
|
||||
|
@ -10,10 +10,6 @@ datasources:
|
||||
basic_auth_user: basic_auth_user
|
||||
with_credentials: true
|
||||
is_default: true
|
||||
correlations:
|
||||
- targetUID: a target
|
||||
label: a label
|
||||
description: a description
|
||||
json_data:
|
||||
graphiteVersion: "1.1"
|
||||
tlsAuth: true
|
||||
|
@ -272,6 +272,7 @@ func TestIntegrationCreateCorrelation(t *testing.T) {
|
||||
require.Equal(t, description, response.Result.Description)
|
||||
require.Equal(t, label, response.Result.Label)
|
||||
require.Equal(t, "fieldName", response.Result.Config.Field)
|
||||
require.Equal(t, map[string]interface{}{"expr": "foo"}, response.Result.Config.Target)
|
||||
|
||||
require.NoError(t, res.Body.Close())
|
||||
})
|
||||
|
@ -77,7 +77,7 @@ func TestIntegrationReadCorrelation(t *testing.T) {
|
||||
OrgId: dsWithCorrelations.OrgId,
|
||||
Config: correlations.CorrelationConfig{
|
||||
Field: "foo",
|
||||
Target: struct{}{},
|
||||
Target: map[string]interface{}{},
|
||||
},
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user