Bladeren bron

feat(alerting): fixed test issues

Torkel Ödegaard 9 jaren geleden
bovenliggende
commit
8105ec4660

+ 0 - 1
pkg/services/alerting/engine.go

@@ -89,7 +89,6 @@ func (e *Engine) executeJob(job *AlertJob) {
 			AlertJob: job,
 			AlertJob: job,
 		}
 		}
 		e.log.Debug("Job Execution timeout", "alertRuleId", job.Rule.Id)
 		e.log.Debug("Job Execution timeout", "alertRuleId", job.Rule.Id)
-
 	case result := <-resultChan:
 	case result := <-resultChan:
 		result.Duration = float64(time.Since(now).Nanoseconds()) / float64(1000000)
 		result.Duration = float64(time.Since(now).Nanoseconds()) / float64(1000000)
 		e.log.Debug("Job Execution done", "timeTakenMs", result.Duration, "ruleId", job.Rule.Id)
 		e.log.Debug("Job Execution done", "timeTakenMs", result.Duration, "ruleId", job.Rule.Id)

+ 1 - 1
pkg/services/alerting/executor.go

@@ -137,7 +137,7 @@ func (e *ExecutorImpl) GetRequestForAlertRule(rule *AlertRule, datasource *m.Dat
 			To:   "now",
 			To:   "now",
 		},
 		},
 		Queries: tsdb.QuerySlice{
 		Queries: tsdb.QuerySlice{
-			&tsdb.Query{
+			{
 				RefId: rule.QueryRefId,
 				RefId: rule.QueryRefId,
 				Query: rule.Query,
 				Query: rule.Query,
 				DataSource: &tsdb.DataSourceInfo{
 				DataSource: &tsdb.DataSourceInfo{

+ 1 - 2
pkg/services/sqlstore/alert_rule_changes_test.go

@@ -21,7 +21,7 @@ func TestAlertRuleChangesDataAccess(t *testing.T) {
 
 
 		Convey("When dashboard is removed", func() {
 		Convey("When dashboard is removed", func() {
 			items := []*m.AlertRule{
 			items := []*m.AlertRule{
-				&m.AlertRule{
+				{
 					PanelId:      1,
 					PanelId:      1,
 					DashboardId:  testDash.Id,
 					DashboardId:  testDash.Id,
 					Query:        "Query",
 					Query:        "Query",
@@ -48,7 +48,6 @@ func TestAlertRuleChangesDataAccess(t *testing.T) {
 
 
 			SaveAlerts(&cmd)
 			SaveAlerts(&cmd)
 
 
-			query := &m.GetAlertChangesQuery{OrgId: FakeOrgId}
 			er := GetAlertRuleChanges(query)
 			er := GetAlertRuleChanges(query)
 			So(er, ShouldBeNil)
 			So(er, ShouldBeNil)
 			So(len(query.Result), ShouldEqual, 1)
 			So(len(query.Result), ShouldEqual, 1)

+ 1 - 1
pkg/services/sqlstore/sqlstore.go

@@ -81,7 +81,7 @@ func NewEngine() {
 	err = SetEngine(x, setting.Env == setting.DEV)
 	err = SetEngine(x, setting.Env == setting.DEV)
 
 
 	if err != nil {
 	if err != nil {
-		sqlog.Error("Fail to initialize orm engine: %v", err)
+		sqlog.Error("Fail to initialize orm engine", "error", err)
 		os.Exit(1)
 		os.Exit(1)
 	}
 	}
 }
 }