-
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
Add Offset to libbeat/reader.Message
#39873
Merged
AndersonQ
merged 13 commits into
elastic:main
from
AndersonQ:39653-filestream-include-msg-parser
Jun 21, 2024
Merged
Changes from 9 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
4d2f713
wip
AndersonQ a5db930
add Offset to message
AndersonQ 4b94cc4
account for the offset of discarded messages
AndersonQ c388c96
add test for include_message parser
AndersonQ 0725d66
avoid tests hanging forever
AndersonQ eef16ea
fix double import
AndersonQ 3b29d3b
Merge branch 'main' into 39653-filestream-include-msg-parser
AndersonQ 16fa60b
add changelog
AndersonQ 8789e72
Merge branch '39653-filestream-include-msg-parser' of github.com:Ande…
AndersonQ e8b9edd
fix changelog
AndersonQ fed6f10
fix linter issues
AndersonQ 9582100
Merge branch 'main' into 39653-filestream-include-msg-parser
pierrehilbert 4bcb18a
Merge branch 'main' into 39653-filestream-include-msg-parser
AndersonQ 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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -33,7 +33,6 @@ | |||||
"github.com/stretchr/testify/require" | ||||||
|
||||||
loginp "github.com/elastic/beats/v7/filebeat/input/filestream/internal/input-logfile" | ||||||
input "github.com/elastic/beats/v7/filebeat/input/v2" | ||||||
v2 "github.com/elastic/beats/v7/filebeat/input/v2" | ||||||
"github.com/elastic/beats/v7/libbeat/beat" | ||||||
"github.com/elastic/beats/v7/libbeat/common/acker" | ||||||
|
@@ -95,7 +94,7 @@ | |||||
e.t.Helper() | ||||||
e.grp = unison.TaskGroup{} | ||||||
manager := e.getManager() | ||||||
manager.Init(&e.grp) | ||||||
c := conf.MustNewConfigFrom(config) | ||||||
inp, err := manager.Create(c) | ||||||
if err != nil { | ||||||
|
@@ -107,7 +106,7 @@ | |||||
func (e *inputTestingEnvironment) createInput(config map[string]interface{}) (v2.Input, error) { | ||||||
e.grp = unison.TaskGroup{} | ||||||
manager := e.getManager() | ||||||
manager.Init(&e.grp) | ||||||
c := conf.MustNewConfigFrom(config) | ||||||
inp, err := manager.Create(c) | ||||||
if err != nil { | ||||||
|
@@ -128,9 +127,9 @@ | |||||
e.wg.Add(1) | ||||||
go func(wg *sync.WaitGroup, grp *unison.TaskGroup) { | ||||||
defer wg.Done() | ||||||
defer grp.Stop() | ||||||
inputCtx := input.Context{Logger: logp.L(), Cancelation: ctx, ID: "fake-ID"} | ||||||
inputCtx := v2.Context{Logger: logp.L(), Cancelation: ctx, ID: "fake-ID"} | ||||||
inp.Run(inputCtx, e.pipeline) | ||||||
}(&e.wg, &e.grp) | ||||||
} | ||||||
|
||||||
|
@@ -359,13 +358,13 @@ | |||||
err := inputStore.Get(key, &entry) | ||||||
if err != nil { | ||||||
keys := []string{} | ||||||
inputStore.Each(func(key string, _ statestore.ValueDecoder) (bool, error) { | ||||||
keys = append(keys, key) | ||||||
return false, nil | ||||||
}) | ||||||
e.t.Logf("keys in store: %v", keys) | ||||||
|
||||||
return registryEntry{}, fmt.Errorf("error when getting expected key '%s' from store: %+v", key, err) | ||||||
} | ||||||
|
||||||
return entry, nil | ||||||
|
@@ -385,16 +384,20 @@ | |||||
|
||||||
// waitUntilEventCount waits until total count events arrive to the client. | ||||||
func (e *inputTestingEnvironment) waitUntilEventCount(count int) { | ||||||
for { | ||||||
sum := len(e.pipeline.GetAllEvents()) | ||||||
msg := &strings.Builder{} | ||||||
require.Eventuallyf(e.t, func() bool { | ||||||
msg.Reset() | ||||||
|
||||||
events := e.pipeline.GetAllEvents() | ||||||
sum := len(events) | ||||||
if sum == count { | ||||||
return | ||||||
return true | ||||||
} | ||||||
if count < sum { | ||||||
e.t.Fatalf("too many events; expected: %d, actual: %d", count, sum) | ||||||
} | ||||||
time.Sleep(10 * time.Millisecond) | ||||||
} | ||||||
fmt.Fprintf(msg, "unexpected number of events; expected: %d, actual: %d", | ||||||
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.
Suggested change
|
||||||
count, sum) | ||||||
|
||||||
return false | ||||||
}, 2*time.Minute, 10*time.Millisecond, "%s", msg) | ||||||
} | ||||||
|
||||||
// waitUntilEventCountCtx calls waitUntilEventCount, but fails if ctx is cancelled. | ||||||
|
@@ -489,7 +492,7 @@ | |||||
func (e *inputTestingEnvironment) requireEventContents(nr int, key, value string) { | ||||||
events := make([]beat.Event, 0) | ||||||
for _, c := range e.pipeline.clients { | ||||||
for _, evt := range c.GetEvents() { | ||||||
events = append(events, evt) | ||||||
} | ||||||
} | ||||||
|
@@ -514,7 +517,7 @@ | |||||
} | ||||||
events := make([]beat.Event, 0) | ||||||
for _, c := range e.pipeline.clients { | ||||||
for _, evt := range c.GetEvents() { | ||||||
events = append(events, evt) | ||||||
} | ||||||
} | ||||||
|
@@ -578,7 +581,7 @@ | |||||
} | ||||||
c.ackHandler.ACKEvents(len(events)) | ||||||
|
||||||
for _, event := range events { | ||||||
c.published = append(c.published, event) | ||||||
} | ||||||
} | ||||||
|
@@ -652,7 +655,7 @@ | |||||
} | ||||||
} | ||||||
|
||||||
func (pc *mockPipelineConnector) cancelClient(i int) { | ||||||
pc.mtx.Lock() | ||||||
defer pc.mtx.Unlock() | ||||||
|
||||||
|
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
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.
You don't need this in the user facing changelog, this is more of a developer only detail.
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.
I agree with Craig, the other item you wrote is enough.