Skip to content

Commit

Permalink
[Heartbeat] Fix linting issues introduced by auto-merge #41077 (#41128)
Browse files Browse the repository at this point in the history
(cherry picked from commit efb563c)

# Conflicts:
#	heartbeat/monitors/monitor.go
#	heartbeat/monitors/monitor_test.go
  • Loading branch information
emilioalvap authored and mergify[bot] committed Oct 4, 2024
1 parent fa798fc commit 51c23b4
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
8 changes: 8 additions & 0 deletions heartbeat/monitors/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ type Monitor struct {
stats plugin.RegistryRecorder

monitorStateTracker *monitorstate.Tracker
<<<<<<< HEAD

Check failure on line 74 in heartbeat/monitors/monitor.go

View workflow job for this annotation

GitHub Actions / lint (darwin)

expected '}', found '<<' (typecheck)
=======
statusReporter status.StatusReporter
}

func (m *Monitor) SetStatusReporter(statusReporter status.StatusReporter) {
m.statusReporter = statusReporter
>>>>>>> efb563c890 ([Heartbeat] Fix linting issues introduced by auto-merge #41077 (#41128))

Check failure on line 81 in heartbeat/monitors/monitor.go

View workflow job for this annotation

GitHub Actions / lint (darwin)

illegal character U+0023 '#' (typecheck)
}

// String prints a description of the monitor in a threadsafe way. It is important that this use threadsafe
Expand Down
60 changes: 60 additions & 0 deletions heartbeat/monitors/monitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,63 @@ func TestCheckInvalidConfig(t *testing.T) {

require.Error(t, checkMonitorConfig(serverMonConf, reg))
}
<<<<<<< HEAD

Check failure on line 134 in heartbeat/monitors/monitor_test.go

View workflow job for this annotation

GitHub Actions / lint (darwin)

expected declaration, found '<<' (typecheck)
=======

type MockStatusReporter struct {
us func(status status.Status, msg string)
}

func (sr *MockStatusReporter) UpdateStatus(status status.Status, msg string) {
sr.us(status, msg)
}

func TestStatusReporter(t *testing.T) {
confMap := map[string]interface{}{
"type": "fail",
"urls": []string{"http://example.net"},
"schedule": "@every 1ms",
"name": "myName",
"id": "myId",
}
cfg, err := conf.NewConfigFrom(confMap)
require.NoError(t, err)

reg, _, _ := mockPluginsReg()
pipel := &MockPipeline{}
monReg := monitoring.NewRegistry()

mockDegradedPluginFactory := plugin.PluginFactory{
Name: "fail",
Aliases: []string{"failAlias"},
Make: func(s string, cfg *conf.C) (plugin.Plugin, error) {
return plugin.Plugin{}, fmt.Errorf("error plugin")
},
Stats: plugin.NewPluginCountersRecorder("fail", monReg),
}
_ = reg.Add(mockDegradedPluginFactory)

sched := scheduler.Create(1, monitoring.NewRegistry(), time.Local, nil, true)
defer sched.Stop()

c, err := pipel.Connect()
require.NoError(t, err)
m, err := newMonitor(cfg, reg, c, sched.Add, nil, nil)
require.NoError(t, err)

// Track status marked as failed during run_once execution
failed := false
m.SetStatusReporter(&MockStatusReporter{
us: func(s status.Status, msg string) {
if s == status.Failed {
failed = true
}
},
})
m.Start()

sched.WaitForRunOnce()

require.True(t, failed)
}
>>>>>>> efb563c890 ([Heartbeat] Fix linting issues introduced by auto-merge #41077 (#41128))

Check failure on line 193 in heartbeat/monitors/monitor_test.go

View workflow job for this annotation

GitHub Actions / lint (darwin)

expected declaration, found '>>' (typecheck)

0 comments on commit 51c23b4

Please sign in to comment.