Jelajahi Sumber

feat(alerting): fixed build issues

Torkel Ödegaard 9 tahun lalu
induk
melakukan
8c30babdf1

+ 0 - 6
pkg/services/alerting/extractor_test.go

@@ -44,7 +44,6 @@ func TestAlertRuleExtraction(t *testing.T) {
               "handler": 1,
               "enabled": true,
               "frequency": "60s",
-              "severity": "critical",
               "conditions": [
               {
                 "type": "query",
@@ -129,11 +128,6 @@ func TestAlertRuleExtraction(t *testing.T) {
 					So(alerts[1].Handler, ShouldEqual, 0)
 				})
 
-				Convey("should extract Severity property", func() {
-					So(alerts[0].Severity, ShouldEqual, "critical")
-					So(alerts[1].Severity, ShouldEqual, "warning")
-				})
-
 				Convey("should extract frequency in seconds", func() {
 					So(alerts[0].Frequency, ShouldEqual, 60)
 					So(alerts[1].Frequency, ShouldEqual, 60)

+ 2 - 6
pkg/services/alerting/notifiers/base_test.go

@@ -1,12 +1,8 @@
 package notifiers
 
-import (
-	"testing"
+import . "github.com/smartystreets/goconvey/convey"
 
-	. "github.com/smartystreets/goconvey/convey"
-)
-
-func TestBaseNotifier(t *testing.T) {
+func TestBaseNotifier( /* t *testing.T */ ) {
 	// Convey("Parsing base notification state", t, func() {
 	//
 	// 	Convey("matches", func() {

+ 1 - 0
pkg/services/annotations/annotations.go

@@ -40,6 +40,7 @@ type Item struct {
 	OrgId       int64    `json:"orgId"`
 	DashboardId int64    `json:"dashboardId"`
 	PanelId     int64    `json:"panelId"`
+	CategoryId  int64    `json:"panelId"`
 	Type        ItemType `json:"type"`
 	Title       string   `json:"title"`
 	Text        string   `json:"text"`

+ 11 - 8
pkg/services/sqlstore/migrations/annotation_mig.go

@@ -15,6 +15,7 @@ func addAnnotationMig(mg *Migrator) {
 			{Name: "user_id", Type: DB_BigInt, Nullable: true},
 			{Name: "dashboard_id", Type: DB_BigInt, Nullable: true},
 			{Name: "panel_id", Type: DB_BigInt, Nullable: true},
+			{Name: "category_id", Type: DB_BigInt, Nullable: true},
 			{Name: "type", Type: DB_NVarchar, Length: 25, Nullable: false},
 			{Name: "title", Type: DB_Text, Nullable: false},
 			{Name: "text", Type: DB_Text, Nullable: false},
@@ -27,18 +28,20 @@ func addAnnotationMig(mg *Migrator) {
 		Indices: []*Index{
 			{Cols: []string{"org_id", "alert_id"}, Type: IndexType},
 			{Cols: []string{"org_id", "type"}, Type: IndexType},
-			{Cols: []string{"dashboard_id", "panel_id"}, Type: IndexType},
-			{Cols: []string{"epoch"}, Type: IndexType},
+			{Cols: []string{"org_id", "category_id"}, Type: IndexType},
+			{Cols: []string{"org_id", "dashboard_id", "panel_id", "epoch"}, Type: IndexType},
+			{Cols: []string{"org_id", "epoch"}, Type: IndexType},
 		},
 	}
 
-	mg.AddMigration("Drop old annotation table v3", NewDropTableMigration("annotation"))
+	mg.AddMigration("Drop old annotation table v4", NewDropTableMigration("annotation"))
 
-	mg.AddMigration("create annotation table v4", NewAddTableMigration(table))
+	mg.AddMigration("create annotation table v5", NewAddTableMigration(table))
 
 	// create indices
-	mg.AddMigration("add index annotation org_id & alert_id v3", NewAddIndexMigration(table, table.Indices[0]))
-	mg.AddMigration("add index annotation org_id & type v3", NewAddIndexMigration(table, table.Indices[1]))
-	mg.AddMigration("add index annotation dashboard_id panel_id", NewAddIndexMigration(table, table.Indices[2]))
-	mg.AddMigration("add index annotation epoch v3", NewAddIndexMigration(table, table.Indices[3]))
+	mg.AddMigration("add index annotation 0 v3", NewAddIndexMigration(table, table.Indices[0]))
+	mg.AddMigration("add index annotation 1 v3", NewAddIndexMigration(table, table.Indices[1]))
+	mg.AddMigration("add index annotation 2 v3", NewAddIndexMigration(table, table.Indices[2]))
+	mg.AddMigration("add index annotation 3 v3", NewAddIndexMigration(table, table.Indices[3]))
+	mg.AddMigration("add index annotation 4 v3", NewAddIndexMigration(table, table.Indices[4]))
 }