Skip to content

tests(graphql): Add interface-implementation method alignment tests - #21543

Merged
rhybrillou merged 3 commits into
masterfrom
master-yann/graphql/interface_implementation_tests
Jul 9, 2026
Merged

rhybrillou merged 3 commits into
masterfrom
master-yann/graphql/interface_implementation_tests

Conversation

@rhybrillou

@rhybrillou rhybrillou commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Description

Multiple dependabot pull-requests to upgrade the github.com/graph-gophers/graphql-go failed after the dependency introduced a breaking behaviour change ( see graph-gophers/graphql-go#763 ).

The investigation pointed out that part of the failure was due to the fact that the (reflection) indices of the interface method and the indices of the method in the implementing types are not always aligned.

This PR adds a set of unit-tests (some of them disabled) that validate that the method indices of the graphql resolvers are aligned between interface and implementation (the disabled tests are for the case where the indices are not aligned).

The pull request is part of a stack:

User-facing documentation

Testing and quality

  • the change is production ready: the change is GA, or otherwise the functionality is gated by a feature flag
  • CI results are inspected

Automated testing

  • added unit tests

How I validated my change

Test-only -> CI run

@openshift-ci

openshift-ci Bot commented Jul 3, 2026

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@github-actions

github-actions Bot commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

🚀 Build Images Ready

Images are ready for commit c2f6da1. To use with deploy scripts:

export MAIN_IMAGE_TAG=4.12.x-424-gc2f6da1ef5

@codecov

codecov Bot commented Jul 3, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 50.33%. Comparing base (efd15a5) to head (65156ce).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #21543      +/-   ##
==========================================
- Coverage   50.38%   50.33%   -0.06%     
==========================================
  Files        2844     2844              
  Lines      218476   218476              
==========================================
- Hits       110074   109960     -114     
- Misses     100422   100512      +90     
- Partials     7980     8004      +24     
Flag Coverage Δ
go-unit-tests 50.33% <ø> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rhybrillou
rhybrillou marked this pull request as ready for review July 3, 2026 14:12
@rhybrillou
rhybrillou force-pushed the master-yann/graphql/image_component_tests branch from 3c9dd40 to 475c4c2 Compare July 6, 2026 12:51
@rhybrillou
rhybrillou force-pushed the master-yann/graphql/interface_implementation_tests branch from 42ec8bc to 0087ec6 Compare July 6, 2026 12:51

@jschnath jschnath 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.

Good test coverage for what the first PR implemented as far as I can see.

Comment thread central/graphql/resolvers/test_utils_test.go Outdated
Comment thread central/graphql/resolvers/cluster_vulnerabilities_test.go
@rhybrillou
rhybrillou force-pushed the master-yann/graphql/interface_implementation_tests branch from 0087ec6 to 6194f8a Compare July 7, 2026 10:02
Base automatically changed from master-yann/graphql/image_component_tests to master July 8, 2026 09:29
@rhybrillou
rhybrillou force-pushed the master-yann/graphql/interface_implementation_tests branch from 6194f8a to 12736e9 Compare July 8, 2026 09:51
@coderabbitai

coderabbitai Bot commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: e59fb88b-28d9-4c94-bbf8-1996b040c138

📥 Commits

Reviewing files that changed from the base of the PR and between 12736e9 and 65156ce.

📒 Files selected for processing (7)
  • central/graphql/resolvers/cluster_vulnerabilities_test.go
  • central/graphql/resolvers/image_components_test.go
  • central/graphql/resolvers/image_resolver_test.go
  • central/graphql/resolvers/image_vulnerabilities_test.go
  • central/graphql/resolvers/node_components_test.go
  • central/graphql/resolvers/node_vulnerabilities_test.go
  • central/graphql/resolvers/test_utils_test.go
✅ Files skipped from review due to trivial changes (1)
  • central/graphql/resolvers/image_resolver_test.go
🚧 Files skipped from review as they are similar to previous changes (6)
  • central/graphql/resolvers/node_components_test.go
  • central/graphql/resolvers/image_components_test.go
  • central/graphql/resolvers/image_vulnerabilities_test.go
  • central/graphql/resolvers/cluster_vulnerabilities_test.go
  • central/graphql/resolvers/node_vulnerabilities_test.go
  • central/graphql/resolvers/test_utils_test.go

📝 Walkthrough

Summary by CodeRabbit

  • Tests
    • Added reflection-based type alignment tests for multiple GraphQL resolver categories (image, node, and cluster vulnerability-related resolvers).
    • Improved automated validation to ensure resolver interfaces stay in sync with their concrete implementations.
    • Some resolver alignment checks are temporarily disabled due to known method-index mismatches pending an upstream fix.

Walkthrough

This PR adds a shared reflection-based test helper and new GraphQL resolver type-alignment tests for cluster, image, and node resolvers. Several tests are skipped, and the helper verifies method counts and method-name ordering between interfaces and concrete implementations.

Changes

Resolver Method-Alignment Tests

Layer / File(s) Summary
Shared reflection validation helper
central/graphql/resolvers/test_utils_test.go
Adds validateAlignedMethodIndex to compare reflected method counts and names, plus dumpTypeMethods to log method details and signatures for debugging.
Image resolver alignment tests
central/graphql/resolvers/image_resolver_test.go, central/graphql/resolvers/image_components_test.go, central/graphql/resolvers/image_vulnerabilities_test.go
Adds reflection-based tests for ImageResolver, ImageComponentResolver, and ImageVulnerabilityResolver; the component and vulnerability checks are skipped.
Node resolver alignment tests
central/graphql/resolvers/node_components_test.go, central/graphql/resolvers/node_vulnerabilities_test.go
Adds reflection-based tests for NodeComponentResolver and NodeVulnerabilityResolver; the vulnerability check is skipped.
Cluster resolver alignment test
central/graphql/resolvers/cluster_vulnerabilities_test.go
Adds a skipped reflection-based test for ClusterVulnerabilityResolver alignment.

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

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: adding GraphQL resolver method-alignment tests.
Description check ✅ Passed The PR description follows the template and includes the required sections, with validation noted as CI-only.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch master-yann/graphql/interface_implementation_tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@central/graphql/resolvers/test_utils_test.go`:
- Around line 13-16: The assertion message in the NumMethod comparison has a
grammar typo in the string passed to assert.Equalf; update the failure text in
the helper that compares type methods so it reads correctly without the extra
leading “have”. Use the existing type comparison assertion around type1 and
type2 in test_utils_test.go, and keep the rest of the message structure
unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 4f181927-8363-4b25-bf3b-505c819f5f60

📥 Commits

Reviewing files that changed from the base of the PR and between c1fd65e and 12736e9.

📒 Files selected for processing (7)
  • central/graphql/resolvers/cluster_vulnerabilities_test.go
  • central/graphql/resolvers/image_components_test.go
  • central/graphql/resolvers/image_resolver_test.go
  • central/graphql/resolvers/image_vulnerabilities_test.go
  • central/graphql/resolvers/node_components_test.go
  • central/graphql/resolvers/node_vulnerabilities_test.go
  • central/graphql/resolvers/test_utils_test.go

Comment thread central/graphql/resolvers/test_utils_test.go
@rhybrillou
rhybrillou force-pushed the master-yann/graphql/interface_implementation_tests branch from 12736e9 to 65156ce Compare July 8, 2026 16:04
@rhybrillou

Copy link
Copy Markdown
Contributor Author

/retest

@rhybrillou
rhybrillou merged commit c2f6da1 into master Jul 9, 2026
111 of 112 checks passed
@rhybrillou
rhybrillou deleted the master-yann/graphql/interface_implementation_tests branch July 9, 2026 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants