-
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
[libbeat] Stop publisher properly #40572
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
6b97469
Stop publisher properly
marc-gr e43c52e
Just call beater.Stop from manager
marc-gr 8be1a17
Delete duplicated lines
marc-gr 0870605
Make call to stopBeat idempotent
marc-gr 87015cc
Merge branch 'main' into fix/publisher-not-closed
marc-gr 464055b
Add context at request creation to not break tracing
marc-gr 84a1e6e
Merge branch 'main' into fix/publisher-not-closed
marc-gr 6cb525f
Remove unused lint
marc-gr 9be3145
Add default WaitClose timeout
marc-gr 28ab3d9
Merge branch 'main' into fix/publisher-not-closed
marc-gr 97908ca
Adjust wait on close time
marc-gr 97af6fb
Add delay to account for the stop of the publisher
marc-gr d1565e3
Fix lint issues
marc-gr 46dee35
Fix lint issues
marc-gr 747b36a
Fix lint
marc-gr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -21,7 +21,7 @@ package integration | |||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
import ( | ||||||||||||||||||||||||||||||||||||||||
"encoding/json" | ||||||||||||||||||||||||||||||||||||||||
"io/ioutil" | ||||||||||||||||||||||||||||||||||||||||
"io" | ||||||||||||||||||||||||||||||||||||||||
"net/http" | ||||||||||||||||||||||||||||||||||||||||
"testing" | ||||||||||||||||||||||||||||||||||||||||
"time" | ||||||||||||||||||||||||||||||||||||||||
|
@@ -57,12 +57,14 @@ output.console: | |||||||||||||||||||||||||||||||||||||||
mockbeat.WriteConfigFile(cfg) | ||||||||||||||||||||||||||||||||||||||||
mockbeat.Start() | ||||||||||||||||||||||||||||||||||||||||
mockbeat.WaitForLogs("Starting stats endpoint", 60*time.Second) | ||||||||||||||||||||||||||||||||||||||||
time.Sleep(time.Second) | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
r, err := http.Get("http://localhost:5066") | ||||||||||||||||||||||||||||||||||||||||
r, err := http.Get("http://localhost:5066") //nolint:noctx // fine for tests | ||||||||||||||||||||||||||||||||||||||||
require.NoError(t, err) | ||||||||||||||||||||||||||||||||||||||||
require.Equal(t, http.StatusOK, r.StatusCode, "incorrect status code") | ||||||||||||||||||||||||||||||||||||||||
Comment on lines
+62
to
64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Blocker] cont. you could use it instead
Suggested change
if you want, you could even remove the |
||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
body, err := ioutil.ReadAll(r.Body) | ||||||||||||||||||||||||||||||||||||||||
body, err := io.ReadAll(r.Body) | ||||||||||||||||||||||||||||||||||||||||
r.Body.Close() | ||||||||||||||||||||||||||||||||||||||||
require.NoError(t, err) | ||||||||||||||||||||||||||||||||||||||||
var m map[string]interface{} | ||||||||||||||||||||||||||||||||||||||||
err = json.Unmarshal(body, &m) | ||||||||||||||||||||||||||||||||||||||||
|
@@ -88,12 +90,14 @@ output.console: | |||||||||||||||||||||||||||||||||||||||
mockbeat.WriteConfigFile(cfg) | ||||||||||||||||||||||||||||||||||||||||
mockbeat.Start() | ||||||||||||||||||||||||||||||||||||||||
mockbeat.WaitForLogs("Starting stats endpoint", 60*time.Second) | ||||||||||||||||||||||||||||||||||||||||
time.Sleep(time.Second) | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
r, err := http.Get("http://localhost:5066/stats") | ||||||||||||||||||||||||||||||||||||||||
r, err := http.Get("http://localhost:5066/stats") //nolint:noctx // fine for tests | ||||||||||||||||||||||||||||||||||||||||
require.NoError(t, err) | ||||||||||||||||||||||||||||||||||||||||
require.Equal(t, http.StatusOK, r.StatusCode, "incorrect status code") | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
body, err := ioutil.ReadAll(r.Body) | ||||||||||||||||||||||||||||||||||||||||
body, err := io.ReadAll(r.Body) | ||||||||||||||||||||||||||||||||||||||||
r.Body.Close() | ||||||||||||||||||||||||||||||||||||||||
require.NoError(t, err) | ||||||||||||||||||||||||||||||||||||||||
var m Stats | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
|
@@ -121,8 +125,10 @@ output.console: | |||||||||||||||||||||||||||||||||||||||
mockbeat.WriteConfigFile(cfg) | ||||||||||||||||||||||||||||||||||||||||
mockbeat.Start() | ||||||||||||||||||||||||||||||||||||||||
mockbeat.WaitForLogs("Starting stats endpoint", 60*time.Second) | ||||||||||||||||||||||||||||||||||||||||
time.Sleep(time.Second) | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
r, err := http.Get("http://localhost:5066/not-exist") | ||||||||||||||||||||||||||||||||||||||||
r, err := http.Get("http://localhost:5066/not-exist") //nolint:noctx // fine for tests | ||||||||||||||||||||||||||||||||||||||||
r.Body.Close() | ||||||||||||||||||||||||||||||||||||||||
require.NoError(t, err) | ||||||||||||||||||||||||||||||||||||||||
require.Equal(t, http.StatusNotFound, r.StatusCode, "incorrect status code") | ||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
|
@@ -143,8 +149,10 @@ output.console: | |||||||||||||||||||||||||||||||||||||||
mockbeat.WriteConfigFile(cfg) | ||||||||||||||||||||||||||||||||||||||||
mockbeat.Start() | ||||||||||||||||||||||||||||||||||||||||
mockbeat.WaitForLogs("Starting stats endpoint", 60*time.Second) | ||||||||||||||||||||||||||||||||||||||||
time.Sleep(time.Second) | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
r, err := http.Get("http://localhost:5066/debug/pprof/") | ||||||||||||||||||||||||||||||||||||||||
r, err := http.Get("http://localhost:5066/debug/pprof/") //nolint:noctx // fine for tests | ||||||||||||||||||||||||||||||||||||||||
r.Body.Close() | ||||||||||||||||||||||||||||||||||||||||
require.NoError(t, err) | ||||||||||||||||||||||||||||||||||||||||
require.Equal(t, http.StatusNotFound, r.StatusCode, "incorrect status code") | ||||||||||||||||||||||||||||||||||||||||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
[Blocker]
I see why just
WaitForLogs("Starting stats endpoint"
isn't enough:beats/libbeat/api/server.go
Lines 69 to 72 in 9249566
but we don't use
time.Sleep
anymore, unless there is no other way. However here there is a better alternative. See below