Skip to content

Bump JMXFetch version to 0.19#1481

Merged
nmuesch merged 2 commits into
masterfrom
nick/update_jmxfetch_0_19
Mar 19, 2018
Merged

Bump JMXFetch version to 0.19#1481
nmuesch merged 2 commits into
masterfrom
nick/update_jmxfetch_0_19

Conversation

@nmuesch
Copy link
Copy Markdown
Contributor

@nmuesch nmuesch commented Mar 19, 2018

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?

@nmuesch nmuesch requested a review from a team as a code owner March 19, 2018 15:07
gmmeyer
gmmeyer previously approved these changes Mar 19, 2018
@nmuesch nmuesch added the changelog/no-changelog No changelog entry needed label Mar 19, 2018
@nmuesch nmuesch merged commit eb4fb15 into master Mar 19, 2018
@nmuesch nmuesch deleted the nick/update_jmxfetch_0_19 branch March 19, 2018 16:00
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/no-changelog No changelog entry needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants