-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Additional Heartbeat Reload Tests #8228
Conversation
heartbeat/monitors/pluginconf.go
Outdated
return fmt.Sprintf("Monitor not loaded, plugin is disabled") | ||
} | ||
|
||
type MonitorPluginInfo struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exported type MonitorPluginInfo should have comment or be unexported
heartbeat/monitors/pluginconf.go
Outdated
"github.com/elastic/beats/libbeat/common" | ||
) | ||
|
||
type PluginDisabledError struct{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exported type PluginDisabledError should have comment or be unexported
heartbeat/monitors/monitor.go
Outdated
} | ||
} | ||
|
||
func (m *Monitor) Stop() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exported method Monitor.Stop should have comment or be unexported
heartbeat/monitors/monitor.go
Outdated
return nil | ||
} | ||
|
||
func (m *Monitor) Start() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exported method Monitor.Start should have comment or be unexported
42df612
to
f766544
Compare
This is now ready for review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good do me but one of the new tests seems to fail. I wonder if it's the timeout or something else.
heartbeat/monitors/monitor_test.go
Outdated
require.Equal(t, 1, len(pipelineConnector.clients)) | ||
pcClient := pipelineConnector.clients[0] | ||
|
||
time.Sleep(time.Duration(100 * time.Millisecond)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sleeps in tests ;-)
c4a805c
to
35a9170
Compare
@ruflin fixed and improved in 35a9170 The issue was that the mock impl was doing a copy into a zero size slice with the right capacity, instead of an empty slice of the right capacity. I also improved the timeout code to exit early by spinning on the condition. Wouldn't mind some review on this, my understanding is that the go scheduler is not safe to spin in this situation and still make forward-progress without explicit sleeps in it, even on a single core system. Is that correct? I added microsecond sleeps in the loop to make sure we yield. Looking at golang/go#10958 seems to confirm that aspect of the go scheduler behavior. |
It seems on Jenkins Mac build this causes a problem in libbeat: https://beats-ci.elastic.co/job/elastic+beats+pull-request+multijob-darwin/483/beat=libbeat,label=macosx/console I can't really see how this is related to the interface change in libbeat TBH. Perhaps it's flaky but it's not one I have seen before. |
35a9170
to
edc168c
Compare
* Adds a mocked test of the Monitor type * Minimizes the required mockable area by introducing a PipelineConnector type that is easier to mock than a Pipeline. * Introduces a number of useful mocks for future tests potentially. (cherry picked from commit 0417f98)
* Adds a mocked test of the Monitor type * Minimizes the required mockable area by introducing a PipelineConnector type that is easier to mock than a Pipeline. * Introduces a number of useful mocks for future tests potentially. (cherry picked from commit 0417f98)
This PR attempts to improve the testing and testability of heartbeat in the following ways:
Monitor
typePipelineConnector
type that is easier to mock than aPipeline
.