Skip to content

Commit 3960caa

Browse files
committed
add one more test
1 parent f8c7526 commit 3960caa

File tree

1 file changed

+60
-1
lines changed

1 file changed

+60
-1
lines changed

filebeat/tests/integration/filestream_gzip_test.go

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1188,9 +1188,9 @@ func TestFilestreamGZIPWithPathIdentity(t *testing.T) {
11881188
filebeat.inputs:
11891189
- type: filestream
11901190
id: "test-filestream-path-identity"
1191+
gzip_experimental: true
11911192
paths:
11921193
- %s
1193-
file_identity.native: ~
11941194
output.file:
11951195
path: ${path.home}
11961196
filename: "output"
@@ -1216,6 +1216,65 @@ logging.level: debug
12161216
filepath.Join(tempDir, "output"), lines)
12171217
}
12181218

1219+
// TestFilestreamGZIPWithPathIdentity verifies that filestream can ingest both
1220+
// a plain text file and a gzip file when not using file_identity.fingerprint
1221+
// configuration.
1222+
func TestFilestreamGZIPExperimentalIsIgnored(t *testing.T) {
1223+
sufix := "===================================================================================================="
1224+
lines := make([]string, 0, 500)
1225+
1226+
var dataGzipPlain []byte
1227+
for i := range 500 {
1228+
l := fmt.Sprintf("gzip file line %d %s%s", i, sufix, sufix)
1229+
lines = append(lines, l)
1230+
dataGzipPlain = append(dataGzipPlain, []byte(l+"\n")...)
1231+
}
1232+
dataGZ := gziptest.Compress(t, dataGzipPlain, gziptest.CorruptNone)
1233+
if len(dataGZ) < 1024 {
1234+
t.Fatalf("not enought gzip data, only %d", len(dataGZ))
1235+
}
1236+
filebeat := integration.NewBeat(
1237+
t,
1238+
"filebeat",
1239+
"../../filebeat.test",
1240+
)
1241+
tempDir := filebeat.TempDir()
1242+
logPathGZ := filepath.Join(tempDir, "gzip.log.gz")
1243+
1244+
err := os.WriteFile(logPathGZ, dataGZ, 0644)
1245+
require.NoError(t, err, "could not write gzip file to disk")
1246+
1247+
cfg := fmt.Sprintf(`
1248+
filebeat.inputs:
1249+
- type: filestream
1250+
id: "test-filestream-path-identity"
1251+
gzip_experimental: true
1252+
paths:
1253+
- %s
1254+
output.file:
1255+
path: ${path.home}
1256+
filename: "output"
1257+
rotate_on_startup: false
1258+
logging.level: debug
1259+
`, filepath.Join(tempDir, "*.log*"))
1260+
1261+
filebeat.WriteConfigFile(cfg)
1262+
filebeat.Start()
1263+
1264+
filebeat.WaitLogsContainsAnyOrder(
1265+
[]string{
1266+
fmt.Sprintf("EOF has been reached. Closing. Path='%s'", logPathGZ)},
1267+
30*time.Second,
1268+
"Filebeat did not reach EOF for gzip file. Did not find log [%s]",
1269+
)
1270+
1271+
filebeat.Stop()
1272+
1273+
filebeat.WaitPublishedEvents(time.Second, 500)
1274+
matchPublishedLinesFromFile(t,
1275+
filepath.Join(tempDir, "output"), lines)
1276+
}
1277+
12191278
func getOutputFilesSorted(t *testing.T, outputFilePattern string, tempDir string) []string {
12201279
globPattern := outputFilePattern + "-*.ndjson"
12211280
files, err := filepath.Glob(filepath.Join(tempDir, globPattern))

0 commit comments

Comments
 (0)