Skip to content
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

filebeat stateful inputs - remove source name from context.ID #38603

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions filebeat/input/filestream/input_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func TestFilestreamCloseRenamed(t *testing.T) {
env.mustWriteToFile(testlogName, testlines)

ctx, cancelInput := context.WithCancel(context.Background())
defer cancelInput()
env.startInput(ctx, inp)

// first event has made it successfully
Expand Down Expand Up @@ -100,6 +101,7 @@ func TestFilestreamMetadataUpdatedOnRename(t *testing.T) {
env.mustWriteToFile(testlogName, testline)

ctx, cancelInput := context.WithCancel(context.Background())
defer cancelInput()
env.startInput(ctx, inp)

env.waitUntilEventCount(1)
Expand Down Expand Up @@ -139,6 +141,7 @@ func TestFilestreamCloseRemoved(t *testing.T) {
env.mustWriteToFile(testlogName, testlines)

ctx, cancelInput := context.WithCancel(context.Background())
defer cancelInput()
env.startInput(ctx, inp)

// first event has made it successfully
Expand Down Expand Up @@ -179,6 +182,7 @@ func TestFilestreamCloseEOF(t *testing.T) {
env.mustWriteToFile(testlogName, testlines)

ctx, cancelInput := context.WithCancel(context.Background())
defer cancelInput()
env.startInput(ctx, inp)

// first event has made it successfully
Expand Down Expand Up @@ -209,6 +213,7 @@ func TestFilestreamEmptyLine(t *testing.T) {
})

ctx, cancelInput := context.WithCancel(context.Background())
defer cancelInput()
env.startInput(ctx, inp)

testlines := []byte("first log line\nnext is an empty line\n")
Expand Down Expand Up @@ -247,6 +252,7 @@ func TestFilestreamEmptyLinesOnly(t *testing.T) {
})

ctx, cancelInput := context.WithCancel(context.Background())
defer cancelInput()
env.startInput(ctx, inp)

testlines := []byte("\n\n\n")
Expand Down Expand Up @@ -280,6 +286,7 @@ func TestFilestreamBOMUTF8(t *testing.T) {
env.mustWriteToFile(testlogName, lines)

ctx, cancelInput := context.WithCancel(context.Background())
defer cancelInput()
env.startInput(ctx, inp)

env.waitUntilEventCount(7)
Expand Down Expand Up @@ -314,12 +321,15 @@ func TestFilestreamUTF16BOMs(t *testing.T) {
line := []byte("first line\n")
buf := bytes.NewBuffer(nil)
writer := transform.NewWriter(buf, encoder)
writer.Write(line)
if _, err := writer.Write(line); err != nil {
t.Fatal(err)
}
writer.Close()

env.mustWriteToFile(testlogName, buf.Bytes())

ctx, cancelInput := context.WithCancel(context.Background())
defer cancelInput()
env.startInput(ctx, inp)

env.waitUntilEventCount(1)
Expand Down Expand Up @@ -349,6 +359,7 @@ func TestFilestreamCloseTimeout(t *testing.T) {
env.mustWriteToFile(testlogName, testlines)

ctx, cancelInput := context.WithCancel(context.Background())
defer cancelInput()
env.startInput(ctx, inp)

env.waitUntilEventCount(1)
Expand Down Expand Up @@ -382,6 +393,7 @@ func TestFilestreamCloseAfterInterval(t *testing.T) {
env.mustWriteToFile(testlogName, testlines)

ctx, cancelInput := context.WithCancel(context.Background())
defer cancelInput()
env.startInput(ctx, inp)

env.waitUntilEventCount(3)
Expand Down Expand Up @@ -412,6 +424,7 @@ func TestFilestreamCloseAfterIntervalRemoved(t *testing.T) {
env.mustWriteToFile(testlogName, testlines)

ctx, cancelInput := context.WithCancel(context.Background())
defer cancelInput()
env.startInput(ctx, inp)

env.waitUntilEventCount(3)
Expand Down Expand Up @@ -444,6 +457,7 @@ func TestFilestreamCloseAfterIntervalRenamed(t *testing.T) {
env.mustWriteToFile(testlogName, testlines)

ctx, cancelInput := context.WithCancel(context.Background())
defer cancelInput()
env.startInput(ctx, inp)

env.waitUntilEventCount(3)
Expand Down Expand Up @@ -478,6 +492,7 @@ func TestFilestreamCloseAfterIntervalRotatedAndRemoved(t *testing.T) {
env.mustWriteToFile(testlogName, testlines)

ctx, cancelInput := context.WithCancel(context.Background())
defer cancelInput()
env.startInput(ctx, inp)

env.waitUntilEventCount(3)
Expand Down Expand Up @@ -513,6 +528,7 @@ func TestFilestreamCloseAfterIntervalRotatedAndNewRemoved(t *testing.T) {
env.mustWriteToFile(testlogName, testlines)

ctx, cancelInput := context.WithCancel(context.Background())
defer cancelInput()
env.startInput(ctx, inp)

env.waitUntilEventCount(3)
Expand Down Expand Up @@ -549,6 +565,7 @@ func TestFilestreamTruncatedFileOpen(t *testing.T) {
})

ctx, cancelInput := context.WithCancel(context.Background())
defer cancelInput()
env.startInput(ctx, inp)

testlines := []byte("first line\nsecond line\nthird line\n")
Expand Down Expand Up @@ -583,6 +600,7 @@ func TestFilestreamTruncatedFileClosed(t *testing.T) {
})

ctx, cancelInput := context.WithCancel(context.Background())
defer cancelInput()
env.startInput(ctx, inp)

testlines := []byte("first line\nsecond line\nthird line\n")
Expand Down Expand Up @@ -628,6 +646,7 @@ func TestFilestreamTruncateWithSymlink(t *testing.T) {
env.mustSymlink(testlogName, symlinkName)

ctx, cancelInput := context.WithCancel(context.Background())
defer cancelInput()
env.startInput(ctx, inp)

env.waitUntilEventCount(3)
Expand Down Expand Up @@ -663,6 +682,7 @@ func TestFilestreamTruncateBigScannerInterval(t *testing.T) {
})

ctx, cancelInput := context.WithCancel(context.Background())
defer cancelInput()
env.startInput(ctx, inp)

testlines := []byte("first line\nsecond line\nthird line\n")
Expand Down Expand Up @@ -694,6 +714,7 @@ func TestFilestreamTruncateCheckOffset(t *testing.T) {
})

ctx, cancelInput := context.WithCancel(context.Background())
defer cancelInput()
env.startInput(ctx, inp)

testlines := []byte("first line\nsecond line\nthird line\n")
Expand Down Expand Up @@ -725,6 +746,7 @@ func TestFilestreamTruncateBlockedOutput(t *testing.T) {
env.mustWriteToFile(testlogName, testlines)

ctx, cancelInput := context.WithCancel(context.Background())
defer cancelInput()
env.startInput(ctx, inp)

for env.pipeline.clientsCount() != 1 {
Expand Down Expand Up @@ -779,6 +801,7 @@ func TestFilestreamSymlinksEnabled(t *testing.T) {
env.mustSymlink(testlogName, symlinkName)

ctx, cancelInput := context.WithCancel(context.Background())
defer cancelInput()
env.startInput(ctx, inp)

env.waitUntilEventCount(1)
Expand Down Expand Up @@ -815,6 +838,7 @@ func TestFilestreamSymlinkRotated(t *testing.T) {
env.mustSymlink(firstTestlogName, symlinkName)

ctx, cancelInput := context.WithCancel(context.Background())
defer cancelInput()
env.startInput(ctx, inp)

env.waitUntilEventCount(1)
Expand Down Expand Up @@ -862,6 +886,7 @@ func TestFilestreamSymlinkRemoved(t *testing.T) {
env.mustSymlink(testlogName, symlinkName)

ctx, cancelInput := context.WithCancel(context.Background())
defer cancelInput()
env.startInput(ctx, inp)

env.waitUntilEventCount(1)
Expand Down Expand Up @@ -904,6 +929,7 @@ func TestFilestreamTruncate(t *testing.T) {
env.mustSymlink(testlogName, symlinkName)

ctx, cancelInput := context.WithCancel(context.Background())
defer cancelInput()
env.startInput(ctx, inp)

env.waitUntilEventCount(3)
Expand Down Expand Up @@ -994,6 +1020,7 @@ func TestRotatingCloseInactiveLargerWriteRate(t *testing.T) {
})

ctx, cancelInput := context.WithCancel(context.Background())
defer cancelInput()
env.startInput(ctx, inp)

time.Sleep(1 * time.Second)
Expand All @@ -1008,7 +1035,9 @@ func TestRotatingCloseInactiveLargerWriteRate(t *testing.T) {
}
n := 0
for n <= iterations {
f.Write([]byte(fmt.Sprintf("hello world %d\n", r*iterations+n)))
if _, err = f.Write([]byte(fmt.Sprintf("hello world %d\n", r*iterations+n))); err != nil {
t.Fatal(err)
}
n += 1
time.Sleep(100 * time.Millisecond)
}
Expand Down Expand Up @@ -1040,6 +1069,7 @@ func TestRotatingCloseInactiveLowWriteRate(t *testing.T) {
})

ctx, cancelInput := context.WithCancel(context.Background())
defer cancelInput()
env.startInput(ctx, inp)

time.Sleep(1 * time.Second)
Expand Down
1 change: 0 additions & 1 deletion filebeat/input/v2/input-cursor/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ func (inp *managedInput) Run(
grp.Go(func() (err error) {
// refine per worker context
inpCtx := ctx
inpCtx.ID = ctx.ID + "::" + source.Name()
inpCtx.Logger = ctx.Logger.With("input_source", source.Name())

if err = inp.runSource(inpCtx, inp.manager.store, source, pipeline); err != nil {
Expand Down
Loading