Skip to content

Commit f34e9ad

Browse files
orestisflmergify[bot]
authored andcommitted
Fix flaky test TestFilestreamDelete (#47828)
## Proposed commit message The two log messages are logged from different goroutines that race: - "Closing reader of filestream" is logged from a background goroutine spawned by ctxtool.WithFunc when streamCancel() triggers cancellation - "Stopped harvester for file" is logged from the main harvester goroutine via a defer in harvester.go When streamCancel() executes, it closes a channel that wakes the background goroutine to log "Closing reader", while the main goroutine continues and logs "Stopped harvester". These two goroutines race to write to the log file, making the order non-deterministic. The original test used sequential WaitLogsContains calls which track file offset - when messages appeared in the "wrong" order, the first check would advance the offset past both messages, causing the second to fail. Changed to WaitLogsContainsAnyOrder which checks for both messages without relying on order. Closes #47784 ## How to test this PR locally 1. Start the integration test containers: ```bash cd filebeat && mage docker:composeUp ``` 2. Build the test binary: ```bash mage buildSystemTestBinary ``` 3. Run the specific test with FIPS mode (reproduces original failure without fix): ```bash GODEBUG=fips140=only \ ES_HOST=localhost ES_USER=beats ES_PASS=testing \ ES_SUPERUSER_USER=admin ES_SUPERUSER_PASS=testing \ go test -v -failfast -tags "integration,requirefips" \ -run "TestFilestreamDelete/Inactive_resource_not_finished_and_data_added_during_grace_period" \ ./tests/integration/ -count=20 ``` 4. Clean up: ```bash mage docker:composeDown ``` (cherry picked from commit 5ce630a) # Conflicts: # filebeat/tests/integration/filestream_delete_test.go
1 parent d167dfc commit f34e9ad

File tree

1 file changed

+620
-0
lines changed

1 file changed

+620
-0
lines changed

0 commit comments

Comments
 (0)