tech(alerting): fixes broken unit-tests
This commit is contained in:
@@ -30,10 +30,16 @@ type AlertRule struct {
|
||||
Updated time.Time `json:"updated"`
|
||||
}
|
||||
|
||||
type HeartBeat struct {
|
||||
type AlertingClusterInfo struct {
|
||||
ServerId string
|
||||
ClusterSize int
|
||||
UptimePosition int
|
||||
}
|
||||
|
||||
type HeartBeatCommand struct {
|
||||
ServerId string
|
||||
Updated time.Time
|
||||
Created time.Time
|
||||
|
||||
Result AlertingClusterInfo
|
||||
}
|
||||
|
||||
type AlertRuleChange struct {
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/grafana/grafana/pkg/bus"
|
||||
"github.com/grafana/grafana/pkg/log"
|
||||
m "github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
@@ -47,9 +48,16 @@ func (this *Scheduler) heartBeat() {
|
||||
//write heartBeat to db.
|
||||
//get the modulus position of active servers
|
||||
|
||||
cmd := &m.HeartBeatCommand{ServerId: this.serverId}
|
||||
log.Info("Heartbeat: Sending heartbeat from " + this.serverId)
|
||||
this.clusterSize = 1
|
||||
this.serverPosition = 1
|
||||
err := bus.Dispatch(cmd)
|
||||
|
||||
if err != nil {
|
||||
log.Error(1, "Failed to send heartbeat.")
|
||||
} else {
|
||||
this.clusterSize = cmd.Result.ClusterSize
|
||||
this.serverPosition = cmd.Result.UptimePosition
|
||||
}
|
||||
}
|
||||
|
||||
func (this *Scheduler) Dispatch(reader RuleReader) {
|
||||
|
||||
@@ -43,7 +43,7 @@ func TestAlertingScheduler(t *testing.T) {
|
||||
|
||||
scheduler.updateJobs(mockFn)
|
||||
So(len(scheduler.jobs), ShouldEqual, 3)
|
||||
So(scheduler.jobs[0].id, ShouldEqual, 1)
|
||||
So(scheduler.jobs[0].rule.Id, ShouldEqual, 1)
|
||||
})
|
||||
|
||||
Convey("six servers", func() {
|
||||
@@ -57,7 +57,7 @@ func TestAlertingScheduler(t *testing.T) {
|
||||
|
||||
scheduler.updateJobs(mockFn)
|
||||
So(len(scheduler.jobs), ShouldEqual, 1)
|
||||
So(scheduler.jobs[0].id, ShouldEqual, 6)
|
||||
So(scheduler.jobs[0].rule.Id, ShouldEqual, 6)
|
||||
})
|
||||
|
||||
Convey("more servers then alerts", func() {
|
||||
|
||||
Reference in New Issue
Block a user