Skip to content

[8.19](backport #8308) chore: exclude goconst from test files - #8312

Merged
samuelvl merged 2 commits into
8.19from
mergify/bp/8.19/pr-8308
Nov 20, 2026
Merged

samuelvl merged 2 commits into
8.19from
mergify/bp/8.19/pr-8308

Conversation

@mergify

@mergify mergify Bot commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

What is the problem this PR solves?

Since #8248 golangci-lint also checks the test files without the integration tag. goconst reports 345 repeated strings in _test.go files, and a fix needs a constant or a nolint:goconst directive for each one.

How does this PR solve the problem?

Excludes goconst from _test.go files in .golangci.yml and removes the 11 nolint:goconst directives that this makes unused.

migration_integration_test.go also gets a preallocated slice, because lint reports it for every file that a PR touches.

How to test this PR locally

golangci-lint run --enable-only goconst

It reports no findings in _test.go files.

Related issues


This is an automatic backport of pull request #8308 done by [Mergify](https://mergify.com).

(cherry picked from commit 8107f04)

# Conflicts:
#	internal/pkg/api/handleOpAMP_test.go
#	internal/pkg/api/router_test.go
#	internal/pkg/dl/policies_test.go
@mergify mergify Bot added backport conflicts There is a conflict in the backported pull request labels Nov 20, 2026
@mergify
mergify Bot requested a review from a team as a code owner November 20, 2026 13:37
@mergify
mergify Bot requested review from blakerouse and removed request for a team November 20, 2026 13:37
@mergify
mergify Bot requested a review from a team November 20, 2026 13:37
@mergify

mergify Bot commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

Cherry-pick of 8107f04 has failed:

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

You are currently cherry-picking commit 8107f04.
  (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)

Changes to be committed:
	modified:   .golangci.yml
	modified:   internal/pkg/dl/migration_integration_test.go
	modified:   internal/pkg/logger/logger_test.go
	modified:   internal/pkg/server/fleet_integration_test.go

Unmerged paths:
  (use "git add/rm <file>..." as appropriate to mark resolution)
	deleted by us:   internal/pkg/api/handleOpAMP_test.go
	both modified:   internal/pkg/api/router_test.go
	both modified:   internal/pkg/dl/policies_test.go

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

mergify Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor Author

This pull request is merged.

Copilot AI 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.

🟡 Changes recommended

Unresolved merge conflicts and tests referencing definitions absent from this branch prevent the affected Go test packages and linting from compiling.

3 open issues
What changed in this PR

Backports #8308 to Fleet Server 8.19 to exclude test files from goconst checks following the expanded lint coverage in #8248.

Changes:

  • Adds a test-file exclusion for goconst and removes redundant suppression comments.
  • Preallocates the migration test helper’s agent-ID slice.
  • Also includes policy and router conflict blocks and an unrelated OpAMP test suite.
File Description
internal/​pkg/​server/​fleet_integration_test.go Removes the goconst suppression while retaining dupl.
internal/​pkg/​logger/​logger_test.go Removes the file-level goconst suppression.
internal/​pkg/​dl/​policies_test.go Contains a backport conflict with incoming policy-query tests.
internal/​pkg/​dl/​migration_integration_test.go Preallocates agent IDs and removes a goconst suppression.
internal/​pkg/​api/​router_test.go Contains a backport conflict over OpAMP route cases.
internal/​pkg/​api/​handleOpAMP_test.go Adds an OpAMP test suite unrelated to the lint cleanup.
.golangci.yml Excludes _test.go files from goconst reporting.

Review effort: Balanced

Comment thread internal/pkg/api/handleOpAMP_test.go Resolved
Comment thread internal/pkg/api/router_test.go Resolved
Comment thread internal/pkg/dl/policies_test.go Resolved
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Dependency review finished without posting an analysis comment.

If you expected a review, push a new commit to this pull request (or close and reopen it) to try again.

Workflow run: https://github.com/elastic/fleet-server/actions/runs/44748987928

@github-actions

Copy link
Copy Markdown
Contributor

TL;DR

Buildkite failed in check-ci because this backport commit contains unresolved Git conflict markers in test files, which breaks Go parsing before linting can run. Resolve the conflicts in the two affected files and rerun CI.

Remediation

  • Remove conflict markers and keep the intended merged code in:
    • internal/pkg/api/router_test.go (around line 38)
    • internal/pkg/dl/policies_test.go (around line 134)
  • Re-run .buildkite/scripts/check_ci.sh (or at minimum mage check:all) to confirm parsing/lint passes.
Investigation details

Root Cause

The PR head commit 9991384a02c07062af48001c0678384ced02ccd1 includes unresolved merge conflict markers (<<<<<<<, =======, >>>>>>>) from backport/cherry-pick resolution. These markers make the Go files invalid syntax, causing goimports (via check-ci) to fail immediately.

Evidence

  • Build: https://buildkite.com/elastic/fleet-server/builds/18233
  • Job/step: Run check-ci (.buildkite/scripts/check_ci.sh)
  • Key log excerpt:
    • internal/pkg/api/router_test.go:38:1: expected operand, found '<<'
    • internal/pkg/dl/policies_test.go:134:1: expected statement, found '<<'
    • Error: running "go tool -modfile dev-tools/go.mod golang.org/x/tools/cmd/goimports -w ." failed with exit code 2
  • PR content at head also shows conflict markers in:
    • internal/pkg/api/router_test.go
    • internal/pkg/dl/policies_test.go

Verification

  • Not run locally on PR head SHA in this workspace (current checkout is a different commit), but build log and PR-head file contents conclusively show parse-breaking conflict markers.

Follow-up

  • After conflict resolution, if CI still fails, re-check for additional conflict markers in other touched files.

What is this? | From workflow: Observability Agentic Workflow — Status

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

Remove internal/pkg/api/handleOpAMP_test.go and restore internal/pkg/api/router_test.go and internal/pkg/dl/policies_test.go because those tests do not exist on 8.19. Preallocate allurls and remove the unused staticcheck nolint directive in internal/pkg/server/fleet_integration_test.go.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Copilot AI balanced review requested due to automatic review settings November 20, 2026 13:58

Copilot AI 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.

🟢 Approval recommended

No active review issues were identified for the lint-configuration backport and related test cleanup.

No open issues 🎉

3 resolved since last review

Review effort: Balanced

@samuelvl
samuelvl enabled auto-merge (squash) November 20, 2026 14:34
@samuelvl
samuelvl merged commit d30157a into 8.19 Nov 20, 2026
29 checks passed
@samuelvl
samuelvl deleted the mergify/bp/8.19/pr-8308 branch November 20, 2026 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport cleanup conflicts There is a conflict in the backported pull request skip-changelog Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants