Chore: Rename Id to ID in alerting models (#62777)
* Chore: Rename Id to ID in alerting models * Add xorm tags for datasource * Add xorm tag for uid
This commit is contained in:
@@ -129,11 +129,11 @@ func TestIntegrationAdminConfiguration_SendingToExternalAlertmanagers(t *testing
|
||||
// Add an alertmanager datasource
|
||||
{
|
||||
cmd := datasources.AddDataSourceCommand{
|
||||
OrgId: 1,
|
||||
OrgID: 1,
|
||||
Name: "AM1",
|
||||
Type: datasources.DS_ALERTMANAGER,
|
||||
Access: "proxy",
|
||||
Url: fakeAM1.URL(),
|
||||
URL: fakeAM1.URL(),
|
||||
JsonData: simplejson.NewFromAny(map[string]interface{}{
|
||||
"handleGrafanaManagedAlerts": true,
|
||||
"implementation": "prometheus",
|
||||
@@ -156,11 +156,11 @@ func TestIntegrationAdminConfiguration_SendingToExternalAlertmanagers(t *testing
|
||||
// Add another alertmanager datasource
|
||||
{
|
||||
cmd := datasources.AddDataSourceCommand{
|
||||
OrgId: 1,
|
||||
OrgID: 1,
|
||||
Name: "AM2",
|
||||
Type: datasources.DS_ALERTMANAGER,
|
||||
Access: "proxy",
|
||||
Url: fakeAM2.URL(),
|
||||
URL: fakeAM2.URL(),
|
||||
JsonData: simplejson.NewFromAny(map[string]interface{}{
|
||||
"handleGrafanaManagedAlerts": true,
|
||||
"implementation": "prometheus",
|
||||
@@ -285,11 +285,11 @@ func TestIntegrationAdminConfiguration_SendingToExternalAlertmanagers(t *testing
|
||||
// Add an alertmanager datasource fot the other organisation
|
||||
{
|
||||
cmd := datasources.AddDataSourceCommand{
|
||||
OrgId: 2,
|
||||
OrgID: 2,
|
||||
Name: "AM3",
|
||||
Type: datasources.DS_ALERTMANAGER,
|
||||
Access: "proxy",
|
||||
Url: fakeAM3.URL(),
|
||||
URL: fakeAM3.URL(),
|
||||
JsonData: simplejson.NewFromAny(map[string]interface{}{
|
||||
"handleGrafanaManagedAlerts": true,
|
||||
"implementation": "prometheus",
|
||||
|
||||
@@ -62,9 +62,9 @@ func TestBacktesting(t *testing.T) {
|
||||
Name: "Backtesting-TestDatasource",
|
||||
Type: "testdata",
|
||||
Access: datasources.DS_ACCESS_PROXY,
|
||||
Uid: query.DatasourceUID,
|
||||
UserId: userId,
|
||||
OrgId: 1,
|
||||
UID: query.DatasourceUID,
|
||||
UserID: userId,
|
||||
OrgID: 1,
|
||||
}
|
||||
err := env.Server.HTTPServer.DataSourcesService.AddDataSource(context.Background(), dsCmd)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -65,12 +65,12 @@ func TestIntegrationAzureMonitor(t *testing.T) {
|
||||
|
||||
uid := "azuremonitor"
|
||||
err := testEnv.Server.HTTPServer.DataSourcesService.AddDataSource(ctx, &datasources.AddDataSourceCommand{
|
||||
OrgId: 1,
|
||||
OrgID: 1,
|
||||
Access: datasources.DS_ACCESS_PROXY,
|
||||
Name: "Azure Monitor",
|
||||
Type: datasources.DS_AZURE_MONITOR,
|
||||
Uid: uid,
|
||||
Url: outgoingServer.URL,
|
||||
UID: uid,
|
||||
URL: outgoingServer.URL,
|
||||
JsonData: jsonData,
|
||||
SecureJsonData: secureJSONData,
|
||||
})
|
||||
|
||||
@@ -45,18 +45,18 @@ func TestIntegrationCreateCorrelation(t *testing.T) {
|
||||
Name: "read-only",
|
||||
Type: "loki",
|
||||
ReadOnly: true,
|
||||
OrgId: 1,
|
||||
OrgID: 1,
|
||||
}
|
||||
ctx.createDs(createDsCommand)
|
||||
readOnlyDS := createDsCommand.Result.Uid
|
||||
readOnlyDS := createDsCommand.Result.UID
|
||||
|
||||
createDsCommand = &datasources.AddDataSourceCommand{
|
||||
Name: "writable",
|
||||
Type: "loki",
|
||||
OrgId: 1,
|
||||
OrgID: 1,
|
||||
}
|
||||
ctx.createDs(createDsCommand)
|
||||
writableDs := createDsCommand.Result.Uid
|
||||
writableDs := createDsCommand.Result.UID
|
||||
|
||||
t.Run("Unauthenticated users shouldn't be able to create correlations", func(t *testing.T) {
|
||||
res := ctx.Post(PostParams{
|
||||
|
||||
@@ -45,19 +45,19 @@ func TestIntegrationDeleteCorrelation(t *testing.T) {
|
||||
Name: "read-only",
|
||||
Type: "loki",
|
||||
ReadOnly: true,
|
||||
OrgId: 1,
|
||||
OrgID: 1,
|
||||
}
|
||||
ctx.createDs(createDsCommand)
|
||||
readOnlyDS := createDsCommand.Result.Uid
|
||||
readOnlyDS := createDsCommand.Result.UID
|
||||
|
||||
createDsCommand = &datasources.AddDataSourceCommand{
|
||||
Name: "writable",
|
||||
Type: "loki",
|
||||
OrgId: 1,
|
||||
OrgID: 1,
|
||||
}
|
||||
ctx.createDs(createDsCommand)
|
||||
writableDs := createDsCommand.Result.Uid
|
||||
writableDsOrgId := createDsCommand.Result.OrgId
|
||||
writableDs := createDsCommand.Result.UID
|
||||
writableDsOrgId := createDsCommand.Result.OrgID
|
||||
|
||||
t.Run("Unauthenticated users shouldn't be able to delete correlations", func(t *testing.T) {
|
||||
res := ctx.Delete(DeleteParams{
|
||||
|
||||
@@ -68,14 +68,14 @@ func TestIntegrationReadCorrelation(t *testing.T) {
|
||||
createDsCommand := &datasources.AddDataSourceCommand{
|
||||
Name: "with-correlations",
|
||||
Type: "loki",
|
||||
OrgId: 1,
|
||||
OrgID: 1,
|
||||
}
|
||||
ctx.createDs(createDsCommand)
|
||||
dsWithCorrelations := createDsCommand.Result
|
||||
correlation := ctx.createCorrelation(correlations.CreateCorrelationCommand{
|
||||
SourceUID: dsWithCorrelations.Uid,
|
||||
TargetUID: &dsWithCorrelations.Uid,
|
||||
OrgId: dsWithCorrelations.OrgId,
|
||||
SourceUID: dsWithCorrelations.UID,
|
||||
TargetUID: &dsWithCorrelations.UID,
|
||||
OrgId: dsWithCorrelations.OrgID,
|
||||
Config: correlations.CorrelationConfig{
|
||||
Type: correlations.ConfigTypeQuery,
|
||||
Field: "foo",
|
||||
@@ -86,7 +86,7 @@ func TestIntegrationReadCorrelation(t *testing.T) {
|
||||
createDsCommand = &datasources.AddDataSourceCommand{
|
||||
Name: "without-correlations",
|
||||
Type: "loki",
|
||||
OrgId: 1,
|
||||
OrgID: 1,
|
||||
}
|
||||
ctx.createDs(createDsCommand)
|
||||
dsWithoutCorrelations := createDsCommand.Result
|
||||
@@ -99,13 +99,13 @@ func TestIntegrationReadCorrelation(t *testing.T) {
|
||||
created, err := sess.InsertMulti(&[]correlations.Correlation{
|
||||
{
|
||||
UID: "uid-1",
|
||||
SourceUID: dsWithoutCorrelations.Uid,
|
||||
SourceUID: dsWithoutCorrelations.UID,
|
||||
TargetUID: &nonExistingDsUID,
|
||||
},
|
||||
{
|
||||
UID: "uid-2",
|
||||
SourceUID: "THIS-DOES-NOT_EXIST",
|
||||
TargetUID: &dsWithoutCorrelations.Uid,
|
||||
TargetUID: &dsWithoutCorrelations.UID,
|
||||
},
|
||||
})
|
||||
require.Equal(t, int64(2), created)
|
||||
@@ -215,7 +215,7 @@ func TestIntegrationReadCorrelation(t *testing.T) {
|
||||
|
||||
t.Run("If no correlation exists it should return 200", func(t *testing.T) {
|
||||
res := ctx.Get(GetParams{
|
||||
url: fmt.Sprintf("/api/datasources/uid/%s/correlations", dsWithoutCorrelations.Uid),
|
||||
url: fmt.Sprintf("/api/datasources/uid/%s/correlations", dsWithoutCorrelations.UID),
|
||||
user: adminUser,
|
||||
})
|
||||
require.Equal(t, http.StatusOK, res.StatusCode)
|
||||
@@ -234,7 +234,7 @@ func TestIntegrationReadCorrelation(t *testing.T) {
|
||||
|
||||
t.Run("Should correctly return correlations", func(t *testing.T) {
|
||||
res := ctx.Get(GetParams{
|
||||
url: fmt.Sprintf("/api/datasources/uid/%s/correlations", dsWithCorrelations.Uid),
|
||||
url: fmt.Sprintf("/api/datasources/uid/%s/correlations", dsWithCorrelations.UID),
|
||||
user: adminUser,
|
||||
})
|
||||
require.Equal(t, http.StatusOK, res.StatusCode)
|
||||
@@ -304,7 +304,7 @@ func TestIntegrationReadCorrelation(t *testing.T) {
|
||||
|
||||
t.Run("If no correlation exists it should return 404", func(t *testing.T) {
|
||||
res := ctx.Get(GetParams{
|
||||
url: fmt.Sprintf("/api/datasources/uid/%s/correlations/%s", dsWithoutCorrelations.Uid, "some-correlation-uid"),
|
||||
url: fmt.Sprintf("/api/datasources/uid/%s/correlations/%s", dsWithoutCorrelations.UID, "some-correlation-uid"),
|
||||
user: adminUser,
|
||||
})
|
||||
require.Equal(t, http.StatusNotFound, res.StatusCode)
|
||||
@@ -323,7 +323,7 @@ func TestIntegrationReadCorrelation(t *testing.T) {
|
||||
|
||||
t.Run("Should correctly return correlation", func(t *testing.T) {
|
||||
res := ctx.Get(GetParams{
|
||||
url: fmt.Sprintf("/api/datasources/uid/%s/correlations/%s", dsWithCorrelations.Uid, correlation.UID),
|
||||
url: fmt.Sprintf("/api/datasources/uid/%s/correlations/%s", dsWithCorrelations.UID, correlation.UID),
|
||||
user: adminUser,
|
||||
})
|
||||
require.Equal(t, http.StatusOK, res.StatusCode)
|
||||
|
||||
@@ -45,19 +45,19 @@ func TestIntegrationUpdateCorrelation(t *testing.T) {
|
||||
Name: "read-only",
|
||||
Type: "loki",
|
||||
ReadOnly: true,
|
||||
OrgId: 1,
|
||||
OrgID: 1,
|
||||
}
|
||||
ctx.createDs(createDsCommand)
|
||||
readOnlyDS := createDsCommand.Result.Uid
|
||||
readOnlyDS := createDsCommand.Result.UID
|
||||
|
||||
createDsCommand = &datasources.AddDataSourceCommand{
|
||||
Name: "writable",
|
||||
Type: "loki",
|
||||
OrgId: 1,
|
||||
OrgID: 1,
|
||||
}
|
||||
ctx.createDs(createDsCommand)
|
||||
writableDs := createDsCommand.Result.Uid
|
||||
writableDsOrgId := createDsCommand.Result.OrgId
|
||||
writableDs := createDsCommand.Result.UID
|
||||
writableDsOrgId := createDsCommand.Result.OrgID
|
||||
|
||||
t.Run("Unauthenticated users shouldn't be able to update correlations", func(t *testing.T) {
|
||||
res := ctx.Patch(PatchParams{
|
||||
|
||||
@@ -57,12 +57,12 @@ func TestIntegrationElasticsearch(t *testing.T) {
|
||||
|
||||
uid := "es"
|
||||
err := testEnv.Server.HTTPServer.DataSourcesService.AddDataSource(ctx, &datasources.AddDataSourceCommand{
|
||||
OrgId: 1,
|
||||
OrgID: 1,
|
||||
Access: datasources.DS_ACCESS_PROXY,
|
||||
Name: "Elasticsearch",
|
||||
Type: datasources.DS_ES,
|
||||
Uid: uid,
|
||||
Url: outgoingServer.URL,
|
||||
UID: uid,
|
||||
URL: outgoingServer.URL,
|
||||
BasicAuth: true,
|
||||
BasicAuthUser: "basicAuthUser",
|
||||
JsonData: jsonData,
|
||||
|
||||
@@ -55,12 +55,12 @@ func TestIntegrationGraphite(t *testing.T) {
|
||||
|
||||
uid := "graphite"
|
||||
err := testEnv.Server.HTTPServer.DataSourcesService.AddDataSource(ctx, &datasources.AddDataSourceCommand{
|
||||
OrgId: 1,
|
||||
OrgID: 1,
|
||||
Access: datasources.DS_ACCESS_PROXY,
|
||||
Name: "graphite",
|
||||
Type: datasources.DS_GRAPHITE,
|
||||
Uid: uid,
|
||||
Url: outgoingServer.URL,
|
||||
UID: uid,
|
||||
URL: outgoingServer.URL,
|
||||
BasicAuth: true,
|
||||
BasicAuthUser: "basicAuthUser",
|
||||
JsonData: jsonData,
|
||||
|
||||
@@ -55,12 +55,12 @@ func TestIntegrationInflux(t *testing.T) {
|
||||
|
||||
uid := "influxdb"
|
||||
err := testEnv.Server.HTTPServer.DataSourcesService.AddDataSource(ctx, &datasources.AddDataSourceCommand{
|
||||
OrgId: 1,
|
||||
OrgID: 1,
|
||||
Access: datasources.DS_ACCESS_PROXY,
|
||||
Name: "InfluxDB",
|
||||
Type: datasources.DS_INFLUXDB,
|
||||
Uid: uid,
|
||||
Url: outgoingServer.URL,
|
||||
UID: uid,
|
||||
URL: outgoingServer.URL,
|
||||
BasicAuth: true,
|
||||
BasicAuthUser: "basicAuthUser",
|
||||
JsonData: jsonData,
|
||||
|
||||
@@ -55,12 +55,12 @@ func TestIntegrationLoki(t *testing.T) {
|
||||
|
||||
uid := "loki"
|
||||
err := testEnv.Server.HTTPServer.DataSourcesService.AddDataSource(ctx, &datasources.AddDataSourceCommand{
|
||||
OrgId: 1,
|
||||
OrgID: 1,
|
||||
Access: datasources.DS_ACCESS_PROXY,
|
||||
Name: "Loki",
|
||||
Type: datasources.DS_LOKI,
|
||||
Uid: uid,
|
||||
Url: outgoingServer.URL,
|
||||
UID: uid,
|
||||
URL: outgoingServer.URL,
|
||||
BasicAuth: true,
|
||||
BasicAuthUser: "basicAuthUser",
|
||||
JsonData: jsonData,
|
||||
|
||||
@@ -55,12 +55,12 @@ func TestIntegrationOpenTSDB(t *testing.T) {
|
||||
|
||||
uid := "influxdb"
|
||||
err := testEnv.Server.HTTPServer.DataSourcesService.AddDataSource(ctx, &datasources.AddDataSourceCommand{
|
||||
OrgId: 1,
|
||||
OrgID: 1,
|
||||
Access: datasources.DS_ACCESS_PROXY,
|
||||
Name: "opentsdb",
|
||||
Type: datasources.DS_OPENTSDB,
|
||||
Uid: uid,
|
||||
Url: outgoingServer.URL,
|
||||
UID: uid,
|
||||
URL: outgoingServer.URL,
|
||||
BasicAuth: true,
|
||||
BasicAuthUser: "basicAuthUser",
|
||||
JsonData: jsonData,
|
||||
|
||||
@@ -284,12 +284,12 @@ func newTestScenario(t *testing.T, name string, opts []testScenarioOption, callb
|
||||
|
||||
tsCtx.uid = "test-plugin"
|
||||
cmd := &datasources.AddDataSourceCommand{
|
||||
OrgId: 1,
|
||||
OrgID: 1,
|
||||
Access: datasources.DS_ACCESS_PROXY,
|
||||
Name: "TestPlugin",
|
||||
Type: tsCtx.testPluginID,
|
||||
Uid: tsCtx.uid,
|
||||
Url: tsCtx.outgoingServer.URL,
|
||||
UID: tsCtx.uid,
|
||||
URL: tsCtx.outgoingServer.URL,
|
||||
JsonData: jsonData,
|
||||
SecureJsonData: secureJSONData,
|
||||
}
|
||||
@@ -306,8 +306,8 @@ func newTestScenario(t *testing.T, name string, opts []testScenarioOption, callb
|
||||
require.NoError(t, err)
|
||||
|
||||
getDataSourceQuery := &datasources.GetDataSourceQuery{
|
||||
OrgId: 1,
|
||||
Uid: tsCtx.uid,
|
||||
OrgID: 1,
|
||||
UID: tsCtx.uid,
|
||||
}
|
||||
err = testEnv.Server.HTTPServer.DataSourcesService.GetDataSource(ctx, getDataSourceQuery)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -56,12 +56,12 @@ func TestIntegrationPrometheus(t *testing.T) {
|
||||
|
||||
uid := "prometheus"
|
||||
err := testEnv.Server.HTTPServer.DataSourcesService.AddDataSource(ctx, &datasources.AddDataSourceCommand{
|
||||
OrgId: 1,
|
||||
OrgID: 1,
|
||||
Access: datasources.DS_ACCESS_PROXY,
|
||||
Name: "Prometheus",
|
||||
Type: datasources.DS_PROMETHEUS,
|
||||
Uid: uid,
|
||||
Url: outgoingServer.URL,
|
||||
UID: uid,
|
||||
URL: outgoingServer.URL,
|
||||
BasicAuth: true,
|
||||
BasicAuthUser: "basicAuthUser",
|
||||
JsonData: jsonData,
|
||||
|
||||
Reference in New Issue
Block a user