Bump JMXFetch version to 0.19#1481
Merged
Merged
Conversation
gmmeyer
previously approved these changes
Mar 19, 2018
gmmeyer
approved these changes
Mar 19, 2018
gh-worker-dd-mergequeue-cf854d Bot
pushed a commit
that referenced
this pull request
Mar 4, 2026
…6913) ### What does this PR do? Replaces `if !assert.XXX(...) { return }` guard patterns with `require.XXX(...)` across test files. The testify PR stretchr/testify#1481 (merged June 2024, included in testify v1.11.1) made `require` work safely with `*assert.CollectT` inside `EventuallyWithT` callbacks. `CollectT.FailNow()` calls `runtime.Goexit()` which exits the callback goroutine — this is caught by the `EventuallyWithT` retry loop, so the test continues retrying as expected. **Changes across 31 test files (~115 replacements):** - `test/new-e2e/tests/containers/` — `base_test.go`, `ecs_test.go`, `k8s_test.go` - `test/new-e2e/tests/` — `discovery/`, `agent-runtimes/`, `cspm/`, `cws/`, `npm/`, `netpath/`, `remote-config/`, `windows/`, `agent-health/`, `agent-log-pipelines/` - `pkg/network/tracer/`, `pkg/dyninst/`, `pkg/util/`, `comp/core/telemetry/`, etc. - Also removed outdated `// Can be replaced by require... once PR #1481 is merged` comments ### Important: `require` must not be used inside raw goroutines While `require` is safe inside `EventuallyWithT` callbacks (thanks to `CollectT.FailNow()` integration), it must **not** be used inside raw `go func()` blocks or HTTP handler callbacks. [`t.FailNow()`](https://pkg.go.dev/testing#T.FailNow) calls `runtime.Goexit()` to stop the current goroutine. The [official Go `testing` documentation](https://pkg.go.dev/testing#T.FailNow) states: > FailNow must be called from the goroutine running the test or benchmark function, not from other goroutines created during the test. `EventuallyWithT` is a special case: testify [runs the condition via `go checkCond()`](https://github.com/stretchr/testify/blob/v1.11.1/assert/assertions.go#L2108), but `CollectT` implements its own `FailNow()` that safely exits the callback goroutine and lets the retry loop continue. **Not converted** (intentionally left as `assert`): - Assertions inside raw `go func()` blocks (e.g., `pkg/util/winutil/eventlog/` tests) - Callbacks/predicates returning `bool` or `error` (not test flow control) - Bodies that only log debug info without returning ### Motivation Using `assert` as a guard is error-prone: if someone forgets the `if !... { return }` wrapper, the test continues and panics when accessing nil/empty results (e.g., `metrics[len(metrics)-1]` on an empty slice). `require` makes the "stop on failure" intent explicit and eliminates the boilerplate. ### Describe how you validated your changes - Verified `require` works correctly inside `EventuallyWithT` callbacks (via `CollectT.FailNow()` → `runtime.Goexit()` caught by retry loop) - Confirmed raw `go func()` call sites were left unchanged - These are mechanical replacements that preserve the exact same test semantics — `require` stops execution on failure, which is exactly what the `if !assert... { return }` pattern was doing manually ### Additional Notes The remaining `if !assert` occurrences across other files were reviewed and intentionally kept because they serve different purposes (returning values from helper functions, setting flags, logging diagnostics without stopping, running inside raw goroutines, etc.). Co-authored-by: nicolas.schweitzer <nicolas.schweitzer@datadoghq.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Bump JMXFetch to 0.19
Motivation
What inspired you to submit this pull request?
Additional Notes
Anything else we should know when reviewing?