Skip to content

CCO-837: Replace deprecated golang/mock with go.uber.org/mock#1067

Open
ericahinkleRH wants to merge 1 commit into
openshift:masterfrom
ericahinkleRH:CCO-837
Open

CCO-837: Replace deprecated golang/mock with go.uber.org/mock#1067
ericahinkleRH wants to merge 1 commit into
openshift:masterfrom
ericahinkleRH:CCO-837

Conversation

@ericahinkleRH

@ericahinkleRH ericahinkleRH commented Jul 14, 2026

Copy link
Copy Markdown

Summary

Replaces the deprecated github.com/golang/mock library with the maintained fork go.uber.org/mock.

The golang/mock repository is no longer maintained and officially recommends migrating to go.uber.org/mock:

Update, June 2023: This repo and tool are no longer maintained. Please see go.uber.org/mock for a maintained fork instead.

Changes

  • go.mod: Updated dependency from github.com/golang/mock v1.7.0-rc.1 to go.uber.org/mock v0.6.0
  • Import paths: Updated 27 test files to use go.uber.org/mock/gomock instead of github.com/golang/mock/gomock
  • API compatibility fix: Updated pkg/operator/utils/gcp/utils_test.go to handle gomock API change where InOrder() now expects variadic any parameters
  • Vendor: Updated vendor directory with new mock library

Test Status

✅ All mockgen-related tests pass successfully
❌ Some tests fail due to unrelated blocker: openshift/library-go#2171 (HasSyncedChecker method requirement)

This PR has the same library-go dependency blocker as PR #1066 (CCO-834). Both PRs are waiting for openshift/library-go#2171 to merge before tests can fully pass.

Test Plan

Ran make test - all tests that can run pass. Failures are exclusively from the library-go blocker, not from the mock library migration.

Summary by CodeRabbit

  • Chores
    • Updated the Go toolchain directive and refreshed core Kubernetes and related platform dependencies.
    • Upgraded supporting libraries across APIs, observability, and networking.
    • Migrated GoMock usage from the legacy module to go.uber.org/mock (including generated mocks).
  • Tests
    • Updated tests to use the new GoMock import.
    • Adjusted mock expectation ordering in one test to match updated GoMock behavior.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jul 14, 2026
@openshift-ci-robot

openshift-ci-robot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

@ericahinkleRH: This pull request references CCO-837 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "5.0.0" version, but no target version was set.

Details

In response to this:

Summary

Replaces the deprecated github.com/golang/mock library with the maintained fork go.uber.org/mock.

The golang/mock repository is no longer maintained and officially recommends migrating to go.uber.org/mock:

Update, June 2023: This repo and tool are no longer maintained. Please see go.uber.org/mock for a maintained fork instead.

Changes

  • go.mod: Updated dependency from github.com/golang/mock v1.7.0-rc.1 to go.uber.org/mock v0.6.0
  • Import paths: Updated 27 test files to use go.uber.org/mock/gomock instead of github.com/golang/mock/gomock
  • API compatibility fix: Updated pkg/operator/utils/gcp/utils_test.go to handle gomock API change where InOrder() now expects variadic any parameters
  • Vendor: Updated vendor directory with new mock library

Test Status

✅ All mockgen-related tests pass successfully
❌ Some tests fail due to unrelated blocker: openshift/library-go#2171 (HasSyncedChecker method requirement)

This PR has the same library-go dependency blocker as PR #1066 (CCO-834). Both PRs are waiting for openshift/library-go#2171 to merge before tests can fully pass.

Test Plan

Ran make test - all tests that can run pass. Failures are exclusively from the library-go blocker, not from the mock library migration.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci
openshift-ci Bot requested a review from dlom July 14, 2026 18:13
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉


Walkthrough

The module dependency graph was upgraded, the legacy GoMock dependency was replaced with go.uber.org/mock, generated clients were updated, and affected tests switched imports. One call-order assertion was adapted for the new GoMock API.

Changes

GoMock and dependency migration

Layer / File(s) Summary
Module dependency updates
go.mod
The Go toolchain, GoMock, Kubernetes, controller-runtime, OpenShift, observability, networking, and other module requirements were updated.
Generated mock package migration
pkg/aws/mock/client_generated.go, pkg/azure/mock/client_generated.go, pkg/gcp/mock/client_generated.go, pkg/ibmcloud/mock/client_generated.go
Generated clients now reference go.uber.org/mock/gomock.
Test mock migration and call ordering
pkg/*/*_test.go, pkg/operator/utils/gcp/utils_test.go
GoMock imports were migrated across tests, and the call-order assertion now passes a []any slice to gomock.InOrder.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

  • openshift/ocm-agent#253 — Both changes update overlapping Kubernetes, GoMock, and indirect Go module dependencies.
  • openshift/pagerduty-operator#301 — Both changes update overlapping OpenAPI, Prometheus, and Kubernetes-related Go modules.

Suggested reviewers: dlom, jstuever

🚥 Pre-merge checks | ✅ 14 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (14 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the primary change: swapping deprecated golang/mock for go.uber.org/mock.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed No changed test file adds or edits Ginkgo-style titles; searches found 0 title-like hits, and the diffs are import-only plus one non-Ginkgo t.Test file change.
Test Structure And Quality ✅ Passed Touched tests are import-only except one unit test API compatibility fix; no Ginkgo/cluster-wait logic or cleanup issues were introduced.
Microshift Test Compatibility ✅ Passed No new Ginkgo e2e tests were added; the changed test files are unit-test gomock/import updates only, with no MicroShift-unsupported APIs or guards.
Single Node Openshift (Sno) Test Compatibility ✅ Passed PR only updates gomock imports/vendor; changed test files are standard unit tests, with no new Ginkgo e2e specs or SNO-sensitive assumptions.
Topology-Aware Scheduling Compatibility ✅ Passed Only dependency/test-file churn changed; no deployment manifests or controller code was modified, and the PDB/replica test only switched gomock imports.
Ote Binary Stdout Contract ✅ Passed Changed non-vendor files are tests/mocks only; their init() blocks just set log levels, and no new os.Stdout/fmt.Print writes appear in process-level code.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed No changed files add Ginkgo e2e specs or network/IP assumptions; the PR only updates deps, vendor, and unit-test imports.
No-Weak-Crypto ✅ Passed Touched files only update gomock imports/tests; weak-crypto refs (RC4/3DES/SHA1) pre-existed in vendored files and weren’t newly introduced.
Container-Privileges ✅ Passed No changed manifest or K8s spec contains privileged/hostNetwork/hostIPC/SYS_ADMIN/allowPrivilegeEscalation settings; PR is dependency/test-only.
No-Sensitive-Data-In-Logs ✅ Passed No added actual log calls with passwords/tokens/PII/internal hostnames; changes are dependency/import updates and a test InOrder compatibility fix.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@openshift-ci
openshift-ci Bot requested a review from jstuever July 14, 2026 18:13
@dlom

dlom commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

/approve

@openshift-ci

openshift-ci Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dlom, ericahinkleRH

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 14, 2026
@ericahinkleRH

ericahinkleRH commented Jul 14, 2026

Copy link
Copy Markdown
Author

Blocker Status

This PR is blocked by the same upstream dependency as PR #1066 (CCO-834):

Waiting on: openshift/library-go#2171 to merge
Top-level blocker: openshift/api#2813

The golang/mockgo.uber.org/mock migration is complete and all mock-related tests pass. However, some tests still fail due to the HasSyncedChecker() method requirement from Kubernetes 1.36, which requires the library-go update.

Once library-go#2171 merges, this PR should be ready to merge.

@ericahinkleRH

Copy link
Copy Markdown
Author

Updated toolchain to Go 1.26.5 to fix security scan! ✅

Applied same fix from CCO-834/835/836 PR:

- toolchain go1.26.4
+ toolchain go1.26.5

This should resolve the security scan CVEs (SNYK-GOLANG-STDOS-17905377, SNYK-GOLANG-STDCRYPTOTLS-17905406).

/test security
/retest-required

@ericahinkleRH

ericahinkleRH commented Jul 17, 2026

Copy link
Copy Markdown
Author

Rebased on latest master and applied all CCO-834 fixes! ✅

Changes:

  • 🔧 Updated toolchain to Go 1.26.5 (fixes security CVEs)
  • 📦 Updated library-go to v0.0.0-20260716104731-fdf18b82797f (HasSyncedChecker support)
  • 🎨 Applied gofmt to test files after mock migration
  • 🔄 Rebased on master to remove stale CCO-834 commits

This should now pass all tests! The verify test was failing because vendor/ had outdated library-go.

/retest-required

The golang/mock repository is no longer maintained and recommends
migrating to go.uber.org/mock as a maintained fork.

Changes:
- Updated go.mod dependency from golang/mock v1.7.0-rc.1 to go.uber.org/mock v0.6.0
- Replaced import paths in 27 test files
- Updated toolchain to Go 1.26.5 to fix security scan CVEs
- Updated library-go to v0.0.0-20260716104731-fdf18b82797f for K8s 1.36 compatibility
- Applied gofmt to all affected test files

Jira: https://redhat.atlassian.net/browse/CCO-837

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 47.30%. Comparing base (672b790) to head (a110ff6).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1067   +/-   ##
=======================================
  Coverage   47.30%   47.30%           
=======================================
  Files          97       97           
  Lines       12614    12614           
=======================================
  Hits         5967     5967           
  Misses       5987     5987           
  Partials      660      660           
Files with missing lines Coverage Δ
pkg/aws/mock/client_generated.go 49.74% <ø> (ø)
pkg/azure/mock/client_generated.go 70.08% <ø> (ø)
pkg/gcp/mock/client_generated.go 84.29% <ø> (ø)
pkg/ibmcloud/mock/client_generated.go 82.35% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ericahinkleRH

Copy link
Copy Markdown
Author

/test e2e-gcp-manual-oidc

@ericahinkleRH

Copy link
Copy Markdown
Author

/test e2e-hypershift

@ericahinkleRH

Copy link
Copy Markdown
Author

/test e2e-aws-ovn

@ericahinkleRH

Copy link
Copy Markdown
Author

/test e2e-azure-manual-oidc

@openshift-ci

openshift-ci Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

@ericahinkleRH: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-azure-manual-oidc a110ff6 link true /test e2e-azure-manual-oidc
ci/prow/e2e-gcp-manual-oidc a110ff6 link true /test e2e-gcp-manual-oidc
ci/prow/e2e-aws-ovn a110ff6 link true /test e2e-aws-ovn

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants