Skip to content

[Filebeat] Fix flaky filestream delete retry integration subtest - #50037

Merged
mauri870 merged 4 commits into
mainfrom
fix-filestream-delete-retries-flaky-49987-f00b308050c1171d
Apr 10, 2026
Merged

[Filebeat] Fix flaky filestream delete retry integration subtest#50037
mauri870 merged 4 commits into
mainfrom
fix-filestream-delete-retries-flaky-49987-f00b308050c1171d

Conversation

@github-actions

@github-actions github-actions Bot commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

Summary

This updates TestFilestreamDeleteFileRemoveRetries/file_is_externally_removed to wait for the asynchronous retry counter deterministically.

  • Replaced the immediate count.Load() != 2 assertion with require.Eventually(...)
  • Wait window: 1s with 1ms polling
  • Keeps the same assertion message while removing timing race on goroutine scheduling

Validation

  • ./script/stresstest.sh --tags integration ./filebeat/input/filestream '^TestFilestreamDeleteFileRemoveRetries$' -p 1

Both commands passed in this environment.

Note

🔒 Integrity filtering filtered 1 item

Integrity filtering activated and filtered the following item during workflow execution.
This happens when a tool call accesses a resource that does not meet the required integrity or secrecy level of the workflow.


What is this? | From workflow: Mention in Issue

Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not.

Use require.Eventually to wait for the async remove retry counter to reach the expected value before asserting. This removes a race where the assertion can run before the second retry increments the counter.

Assisted-By: GPT-5.3-Codex
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added the ai label Apr 9, 2026
@botelastic botelastic Bot added the needs_team Indicates that the issue/PR needs a Team:* label label Apr 9, 2026
@mergify

mergify Bot commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

This pull request does not have a backport label.
If this is a bug or security fix, could you label this PR @github-actions[bot]? 🙏.
For such, you'll need to label your PR with:

  • The upcoming major version of the Elastic Stack
  • The upcoming minor version of the Elastic Stack (if you're not pushing a breaking change)

To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-8./d is the label to automatically backport to the 8./d branch. /d is the digit
  • backport-active-all is the label that automatically backports to all active branches.
  • backport-active-8 is the label that automatically backports to all active minor branches for the 8 major.
  • backport-active-9 is the label that automatically backports to all active minor branches for the 9 major.

@mauri870 mauri870 added Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team backport-active-all Automated backport with mergify to all the active branches skip-changelog and removed needs_team Indicates that the issue/PR needs a Team:* label labels Apr 9, 2026
@mauri870 mauri870 self-assigned this Apr 9, 2026
@mauri870
mauri870 marked this pull request as ready for review April 9, 2026 13:17
@mauri870
mauri870 requested a review from a team as a code owner April 9, 2026 13:17
@elasticmachine

Copy link
Copy Markdown
Contributor

Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane)

@coderabbitai

coderabbitai Bot commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cd269041-1987-48d7-98d2-265ea7d5fe07

📥 Commits

Reviewing files that changed from the base of the PR and between 83a9c69 and 3ef688d.

📒 Files selected for processing (1)
  • filebeat/input/filestream/input_delete_integration_test.go

📝 Walkthrough

Walkthrough

The integration test TestFilestreamDeleteFileRemoveRetries (filebeat/input/filestream/input_delete_integration_test.go) was changed to synchronize on a channel that is closed when the second removeFn call occurs instead of performing an immediate synchronous assertion that removeFn had been called twice and checking deleteDone.Load(). The removeFn hook now closes the retried channel on the second invocation and reports an error if invoked more than twice; the prior immediate fatal checks were removed.

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed PR addresses the flaky test by replacing immediate assertion with deterministic polling (require.Eventually), eliminating timing-dependent goroutine scheduling race.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing the flaky test in TestFilestreamDeleteFileRemoveRetries/file_is_externally_removed; no unrelated modifications present.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-filestream-delete-retries-flaky-49987-f00b308050c1171d
  • 🛠️ Update Documentation: Commit on current branch
  • 🛠️ Update Documentation: Create PR

Comment @coderabbitai help to get the list of available commands and usage tips.

@orestisfl orestisfl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A suggestion about synchronization

Comment thread filebeat/input/filestream/input_delete_integration_test.go Outdated
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@mauri870
mauri870 requested a review from orestisfl April 9, 2026 19:19
@github-actions

github-actions Bot commented Apr 9, 2026

Copy link
Copy Markdown
Contributor Author

TL;DR

make -C filebeat check update failed because a test imports the Azure Event Hubs SDK without the /v2 module suffix, which introduces an undeclared module (github.com/Azure/azure-sdk-for-go/sdk/messaging/azeventhubs) and causes check-no-changes to fail after generated go.mod/go.sum edits.

Remediation

  • Change the import in x-pack/filebeat/input/azureeventhub/v2_input_test.go:16 from github.com/Azure/azure-sdk-for-go/sdk/messaging/azeventhubs to github.com/Azure/azure-sdk-for-go/sdk/messaging/azeventhubs/v2.
  • Re-run make -C filebeat check update (or minimally go test ./x-pack/filebeat/input/azureeventhub) and confirm go.mod/go.sum stay unchanged.
Investigation details

Root Cause

The new/updated test file x-pack/filebeat/input/azureeventhub/v2_input_test.go imports the non-versioned SDK package:

  • x-pack/filebeat/input/azureeventhub/v2_input_test.go:16
    • "github.com/Azure/azure-sdk-for-go/sdk/messaging/azeventhubs"

But the codebase uses v2 everywhere else for this input (.../azeventhubs/v2). That mismatch makes Go resolve a new module (v1.4.0) and dirties module files during the check/update pipeline.

Evidence

  • Build: https://buildkite.com/elastic/beats/builds/43934
  • Job/step: Filebeat: Run check/update (make -C filebeat check update then make check-no-changes)
  • Key log excerpt:
    • go: finding module for package github.com/Azure/azure-sdk-for-go/sdk/messaging/azeventhubs
    • go: found github.com/Azure/azure-sdk-for-go/sdk/messaging/azeventhubs in ... v1.4.0
    • diff --git a/go.mod b/go.mod (adds github.com/Azure/azure-sdk-for-go/sdk/messaging/azeventhubs v1.4.0)
    • go.mod: needs update
    • go.sum: needs update

Verification

  • Ran: go test ./x-pack/filebeat/input/azureeventhub -run TestProcessReceivedEventsUpdatesProcessingTimeOnce -count=1
  • Result: setup failed with no required module provides package github.com/Azure/azure-sdk-for-go/sdk/messaging/azeventhubs; to add it: go get ...

Follow-up

If the test intentionally requires the non-v2 module (unlikely given current package usage), then a deliberate go.mod/go.sum update is needed in the PR. Otherwise, switch the import to /v2 and the CI failure should clear.

Note

🔒 Integrity filtering filtered 1 item

Integrity filtering activated and filtered the following item during workflow execution.
This happens when a tool call accesses a resource that does not meet the required integrity or secrecy level of the workflow.


What is this? | From workflow: PR Buildkite Detective

Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not.

@mauri870
mauri870 merged commit d27bf57 into main Apr 10, 2026
49 checks passed
@mauri870
mauri870 deleted the fix-filestream-delete-retries-flaky-49987-f00b308050c1171d branch April 10, 2026 13:59
@github-actions

Copy link
Copy Markdown
Contributor Author

@Mergifyio backport 8.19 9.3 9.4

@mergify

mergify Bot commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

backport 8.19 9.3 9.4

✅ Backports have been created

Details

Cherry-pick of d27bf57 has failed:

On branch mergify/bp/8.19/pr-50037
Your branch is up to date with 'origin/8.19'.

You are currently cherry-picking commit d27bf5775.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Unmerged paths:
  (use "git add/rm <file>..." as appropriate to mark resolution)
	deleted by us:   filebeat/input/filestream/input_delete_integration_test.go

no changes added to commit (use "git add" and/or "git commit -a")

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

mergify Bot pushed a commit that referenced this pull request Apr 10, 2026
)

* filebeat: stabilize filestream delete retry test

Use require.Eventually to wait for the async remove retry counter to reach the expected value before asserting. This removes a race where the assertion can run before the second retry increments the counter.

Assisted-By: GPT-5.3-Codex
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* apply suggestion from code review

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
(cherry picked from commit d27bf57)

# Conflicts:
#	filebeat/input/filestream/input_delete_integration_test.go
mergify Bot pushed a commit that referenced this pull request Apr 10, 2026
)

* filebeat: stabilize filestream delete retry test

Use require.Eventually to wait for the async remove retry counter to reach the expected value before asserting. This removes a race where the assertion can run before the second retry increments the counter.

Assisted-By: GPT-5.3-Codex
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* apply suggestion from code review

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
(cherry picked from commit d27bf57)
mergify Bot pushed a commit that referenced this pull request Apr 10, 2026
)

* filebeat: stabilize filestream delete retry test

Use require.Eventually to wait for the async remove retry counter to reach the expected value before asserting. This removes a race where the assertion can run before the second retry increments the counter.

Assisted-By: GPT-5.3-Codex
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* apply suggestion from code review

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
(cherry picked from commit d27bf57)
mauri870 added a commit that referenced this pull request Apr 10, 2026
) (#50065)

* filebeat: stabilize filestream delete retry test

Use require.Eventually to wait for the async remove retry counter to reach the expected value before asserting. This removes a race where the assertion can run before the second retry increments the counter.

Assisted-By: GPT-5.3-Codex


* apply suggestion from code review

---------




(cherry picked from commit d27bf57)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
mauri870 added a commit that referenced this pull request Apr 10, 2026
) (#50066)

* filebeat: stabilize filestream delete retry test

Use require.Eventually to wait for the async remove retry counter to reach the expected value before asserting. This removes a race where the assertion can run before the second retry increments the counter.

Assisted-By: GPT-5.3-Codex


* apply suggestion from code review

---------




(cherry picked from commit d27bf57)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai backport-active-all Automated backport with mergify to all the active branches skip-changelog Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Flaky Test] github.com/elastic/beats/v7/filebeat/input/filestream TestFilestreamDeleteFileRemoveRetries/file_is_externally_removed

3 participants