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

Invoke m.Run on TestMain and fix test flakiness #41891

Merged
merged 5 commits into from
Dec 5, 2024
Merged

Conversation

AndersonQ
Copy link
Member

@AndersonQ AndersonQ commented Dec 4, 2024

Proposed commit message

invoke m.Run on TestMain and reduce test flakiness

Some TestMain were not running any tests as they did not invoke m.Run. This change fixes that.

Also other tests were presenting some flakyness, therefore this change also attempts to fix the flakiness by setting really unique IDs for filestream tests and increasing a timeout for TestTranslateGUIDWithLDAP.

The following 4 packages were not running any test as the TestMain was not invoking m.Run() to actually run the test. The packages were:

  • filebeat/autodiscover/builder/hints
  • filebeat/processor/add_kubernetes_metadata
  • metricbeat/autodiscover/appender/kubernetes/token
  • metricbeat/autodiscover/builder/hints

Checklist

  • My code follows the style guidelines of this project
  • [ ] I have commented my code, particularly in hard-to-understand areas
  • [ ] I have made corresponding changes to the documentation
  • [ ] I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • [ ] I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Disruptive User Impact

  • N/A

How to test this PR locally

Run the test for the affected packages, the tests should run.

go test -v ./filebeat/autodiscover/builder/hints
go test -v ./filebeat/processor/add_kubernetes_metadata
go test -v ./metricbeat/autodiscover/appender/kubernetes/token
go test -v ./metricbeat/autodiscover/builder/hints

Before the fix:

❯ go test -v .
ok  	github.com/elastic/beats/v7/filebeat/autodiscover/builder/hints	0.530s

After the fix

❯ go test -v .
=== RUN   TestUnpackCopiesDefault
--- PASS: TestUnpackCopiesDefault (0.00s)
=== RUN   TestGenerateHints
--- PASS: TestGenerateHints (0.01s)
=== RUN   TestGenerateHintsWithPaths
--- PASS: TestGenerateHintsWithPaths (0.00s)
PASS
ok  	github.com/elastic/beats/v7/filebeat/autodiscover/builder/hints	0.172s

Related issues

@AndersonQ AndersonQ added the Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team label Dec 4, 2024
@AndersonQ AndersonQ self-assigned this Dec 4, 2024
@AndersonQ AndersonQ requested a review from a team as a code owner December 4, 2024 16:41
@elasticmachine
Copy link
Collaborator

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

@botelastic botelastic bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels Dec 4, 2024
Copy link
Contributor

mergify bot commented Dec 4, 2024

This pull request does not have a backport label.
If this is a bug or security fix, could you label this PR @AndersonQ? 🙏.
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

Copy link
Contributor

mergify bot commented Dec 4, 2024

backport-8.x has been added to help with the transition to the new branch 8.x.
If you don't need it please use backport-skip label and remove the backport-8.x label.

@mergify mergify bot added the backport-8.x Automated backport to the 8.x branch with mergify label Dec 4, 2024
belimawr
belimawr previously approved these changes Dec 4, 2024
@AndersonQ AndersonQ enabled auto-merge (squash) December 4, 2024 16:49
@AndersonQ AndersonQ added backport-7.17 Automated backport to the 7.17 branch with mergify backport-8.15 Automated backport to the 8.15 branch with mergify backport-8.16 Automated backport with mergify labels Dec 4, 2024
mauri870
mauri870 previously approved these changes Dec 4, 2024
Copy link
Member

@mauri870 mauri870 left a comment

Choose a reason for hiding this comment

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

Good catch!

Copy link
Member Author

Choose a reason for hiding this comment

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

I've seem more than once tests failing like that (see output below). So as this PR is already to fix tests, let's fix those as well.

2024-12-04 17:57:18 CEST	=== FAIL: filebeat/input/filestream TestFilestreamCloseRemoved (unknown)
2024-12-04 17:57:18 CEST	panic: name fake-ID already used
2024-12-04 17:57:18 CEST	
2024-12-04 17:57:18 CEST	goroutine 279 [running]:
2024-12-04 17:57:18 CEST	github.com/elastic/elastic-agent-libs/monitoring.panicErr(...)
2024-12-04 17:57:18 CEST		/opt/buildkite-agent/.asdf/installs/golang/1.22.9/packages/pkg/mod/github.com/elastic/[email protected]/monitoring/registry.go:257
2024-12-04 17:57:18 CEST	github.com/elastic/elastic-agent-libs/monitoring.(*Registry).Add(0xc00060dd80, {0xf4003b?, 0x0?}, {0x10f39a0, 0xc00295ad40}, 0xe0?)
2024-12-04 17:57:18 CEST		/opt/buildkite-agent/.asdf/installs/golang/1.22.9/packages/pkg/mod/github.com/elastic/[email protected]/monitoring/registry.go:155 +0xcc
2024-12-04 17:57:18 CEST	github.com/elastic/elastic-agent-libs/monitoring.(*Registry).NewRegistry(0xc00060dd80, {0xf4003b, 0x7}, {0x0?, 0x0?, 0xf45374?})
2024-12-04 17:57:18 CEST		/opt/buildkite-agent/.asdf/installs/golang/1.22.9/packages/pkg/mod/github.com/elastic/[email protected]/monitoring/registry.go:94 +0x15d
2024-12-04 17:57:18 CEST	github.com/elastic/beats/v7/libbeat/monitoring/inputmon.NewInputRegistry({0xf43ba8, 0xa}, {0xf4003b, 0x7}, 0xe7faa0?)
2024-12-04 17:57:18 CEST		/opt/buildkite-agent/builds/bk-agent-prod-gcp-1733331086222823672/elastic/filebeat/libbeat/monitoring/inputmon/input.go:65 +0x38c
2024-12-04 17:57:18 CEST	github.com/elastic/beats/v7/filebeat/input/filestream/internal/input-logfile.NewMetrics({0xf4003b, 0x7})
2024-12-04 17:57:18 CEST		/opt/buildkite-agent/builds/bk-agent-prod-gcp-1733331086222823672/elastic/filebeat/filebeat/input/filestream/internal/input-logfile/metrics.go:66 +0x94
2024-12-04 17:57:18 CEST	github.com/elastic/beats/v7/filebeat/input/filestream/internal/input-logfile.(*managedInput).Run(_, {0xc00f8624f0, {0xf4003b, 0x7}, {0x0, 0x0}, {{0x0, 0x0}, {0x0, 0x0}, ...}, ...}, ...)
2024-12-04 17:57:18 CEST		/opt/buildkite-agent/builds/bk-agent-prod-gcp-1733331086222823672/elastic/filebeat/filebeat/input/filestream/internal/input-logfile/input.go:67 +0x205
2024-12-04 17:57:18 CEST	github.com/elastic/beats/v7/filebeat/input/filestream.(*inputTestingEnvironment).startInput.func1(0xc0004e9f90?, 0xc0004e9f90?)
2024-12-04 17:57:18 CEST		/opt/buildkite-agent/builds/bk-agent-prod-gcp-1733331086222823672/elastic/filebeat/filebeat/input/filestream/environment_test.go:132 +0x163
2024-12-04 17:57:18 CEST	created by github.com/elastic/beats/v7/filebeat/input/filestream.(*inputTestingEnvironment).startInput in goroutine 159
2024-12-04 17:57:18 CEST		/opt/buildkite-agent/builds/bk-agent-prod-gcp-1733331086222823672/elastic/filebeat/filebeat/input/filestream/environment_test.go:128 +0x11b

@AndersonQ AndersonQ disabled auto-merge December 5, 2024 08:57
@AndersonQ AndersonQ changed the title Invoke m.Run on TestMain Invoke m.Run on TestMain and fix test flakiness Dec 5, 2024
@AndersonQ AndersonQ dismissed stale reviews from mauri870 and belimawr December 5, 2024 08:58

added more changes

@AndersonQ AndersonQ enabled auto-merge (squash) December 5, 2024 09:00
@AndersonQ AndersonQ added backport-8.17 Automated backport with mergify and removed backport-7.17 Automated backport to the 7.17 branch with mergify labels Dec 5, 2024
@AndersonQ AndersonQ merged commit 83251ea into main Dec 5, 2024
47 of 49 checks passed
@AndersonQ AndersonQ deleted the fix-testmains branch December 5, 2024 11:15
mergify bot pushed a commit that referenced this pull request Dec 5, 2024
Some TestMain were not running any tests as they did not invoke m.Run. This change fixes that.

Also other tests were presenting some flakyness, therefore this change also attempts to fix the flakiness by setting really unique IDs for filestream tests and increasing a timeout for TestTranslateGUIDWithLDAP.

(cherry picked from commit 83251ea)

# Conflicts:
#	filebeat/tests/integration/translate_ldap_attribute_test.go
mergify bot pushed a commit that referenced this pull request Dec 5, 2024
Some TestMain were not running any tests as they did not invoke m.Run. This change fixes that.

Also other tests were presenting some flakyness, therefore this change also attempts to fix the flakiness by setting really unique IDs for filestream tests and increasing a timeout for TestTranslateGUIDWithLDAP.

(cherry picked from commit 83251ea)

# Conflicts:
#	filebeat/tests/integration/translate_ldap_attribute_test.go
mergify bot pushed a commit that referenced this pull request Dec 5, 2024
Some TestMain were not running any tests as they did not invoke m.Run. This change fixes that.

Also other tests were presenting some flakyness, therefore this change also attempts to fix the flakiness by setting really unique IDs for filestream tests and increasing a timeout for TestTranslateGUIDWithLDAP.

(cherry picked from commit 83251ea)
mergify bot pushed a commit that referenced this pull request Dec 5, 2024
Some TestMain were not running any tests as they did not invoke m.Run. This change fixes that.

Also other tests were presenting some flakyness, therefore this change also attempts to fix the flakiness by setting really unique IDs for filestream tests and increasing a timeout for TestTranslateGUIDWithLDAP.

(cherry picked from commit 83251ea)
AndersonQ added a commit that referenced this pull request Dec 5, 2024
Some TestMain were not running any tests as they did not invoke m.Run. This change fixes that.

Also other tests were presenting some flakyness, therefore this change also attempts to fix the flakiness by setting really unique IDs for filestream tests and increasing a timeout for TestTranslateGUIDWithLDAP.

(cherry picked from commit 83251ea)

Co-authored-by: Anderson Queiroz <[email protected]>
AndersonQ added a commit that referenced this pull request Dec 6, 2024
Some TestMain were not running any tests as they did not invoke m.Run. This change fixes that.

Also other tests were presenting some flakyness, therefore this change also attempts to fix the flakiness by setting really unique IDs for filestream tests and increasing a timeout for TestTranslateGUIDWithLDAP.

(cherry picked from commit 83251ea)

Co-authored-by: Anderson Queiroz <[email protected]>
AndersonQ added a commit that referenced this pull request Dec 6, 2024
…iness (#41906)

* invoke m.Run on TestMain and reduce test flakiness (#41891)

Some TestMain were not running any tests as they did not invoke m.Run. This change fixes that.

Also other tests were presenting some flakyness, therefore this change also attempts to fix the flakiness by setting really unique IDs for filestream tests and increasing a timeout for TestTranslateGUIDWithLDAP.

(cherry picked from commit 83251ea)

---------

Co-authored-by: Anderson Queiroz <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-8.x Automated backport to the 8.x branch with mergify backport-8.15 Automated backport to the 8.15 branch with mergify backport-8.16 Automated backport with mergify backport-8.17 Automated backport with mergify 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.

4 participants