-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add batch_read_size config to Winlogbeat
This configuration option allows users to control the number of event log records that are read, processed, and published in its event loop.
- Loading branch information
1 parent
f1af264
commit 0fb5ce7
Showing
3 changed files
with
78 additions
and
12 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// +build windows | ||
|
||
package eventlog | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestWinEventLogBatchReadSize(t *testing.T) { | ||
configureLogp() | ||
log, err := initLog(providerName, sourceName, eventCreateMsgFile) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
defer func() { | ||
err := uninstallLog(providerName, sourceName, log) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
}() | ||
|
||
// Publish test messages: | ||
for k, m := range messages { | ||
err = log.Report(m.eventType, k, []string{m.message}) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
} | ||
|
||
batchReadSize := 2 | ||
eventlog, err := newWinEventLog(map[string]interface{}{"name": providerName, "batch_read_size": batchReadSize}) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
err = eventlog.Open(0) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
defer func() { | ||
err := eventlog.Close() | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
}() | ||
|
||
records, err := eventlog.Read() | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
assert.Len(t, records, batchReadSize) | ||
} |