Skip to content

Fixes the data-validation tests#457

Open
jlpadilla wants to merge 2 commits intomainfrom
jorge/fix-data-validation
Open

Fixes the data-validation tests#457
jlpadilla wants to merge 2 commits intomainfrom
jorge/fix-data-validation

Conversation

@jlpadilla
Copy link
Copy Markdown
Contributor

@jlpadilla jlpadilla commented Apr 10, 2026

Problem:

Tests where incorrectly building the list of resource kinds in the cluster. This happened because the output of oc api-resources was parsed incorrectly.

Summary by CodeRabbit

  • Tests

    • Standardized resource naming in validation tests so kind values match expected capitalization, improving which resources are validated.
  • Refactor

    • Simplified API resource discovery and parsing logic for more accurate and efficient identification of available resource kinds.

Signed-off-by: Jorge Padilla <jpadilla@redhat.com>
@openshift-ci
Copy link
Copy Markdown

openshift-ci bot commented Apr 10, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jlpadilla

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

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 10, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 65b0a927-66e9-429e-85f0-da2dea08ca35

📥 Commits

Reviewing files that changed from the base of the PR and between e03ff23 and 5628fec.

📒 Files selected for processing (1)
  • tests/common-lib/index.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/common-lib/index.js

📝 Walkthrough

Walkthrough

Two test and utility files were modified: test ignored resource kinds were changed to capitalized Kubernetes Kind values, and a test helper that fetches API resources was refactored to use oc api-resources --verbs=list,watch --no-headers, returning objects with kind_plural, preserved kind casing, and extracted apigroup.

Changes

Cohort / File(s) Summary
Test Data Update
tests/api/data-validation.test.js
Updated ignoreKindResourceList entries from lowercase (clusterclaim, event, networkattachmentdefinition) to capitalized Kind names (ClusterClaim, Event, NetworkAttachmentDefinition) so filtering matches resource.kind.
API Resource Fetching Refactor
tests/common-lib/index.js
Replaced grep-based parsing with oc api-resources --verbs=list,watch --no-headers. Parsing simplified to split on spaces; returned objects now include kind_plural, preserve kind casing, and set apigroup by stripping /version from the groupVersion token.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I nibbled lines and hopped with glee,

Kinds now tall where small used to be.
Commands made tidy, parsing light,
Tests and helpers dancing bright. ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly addresses the main objective of the PR—fixing data-validation tests by correcting resource kind parsing.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 jorge/fix-data-validation

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

@qodo-code-review
Copy link
Copy Markdown

Review Summary by Qodo

Fix data validation tests with corrected resource kinds

🐞 Bug fix 🧪 Tests

Grey Divider

Walkthroughs

Description
• Update resource kind names to use proper CamelCase format
• Refactor API resource fetching to use simplified oc command
• Improve parsing logic to extract kind_plural and apigroup correctly
• Remove unnecessary string slicing and filtering complexity
Diagram
flowchart LR
  A["oc command with grep filter"] -->|"Simplified to use verbs flag"| B["oc api-resources with verbs filter"]
  C["Lowercase kind names"] -->|"Updated to CamelCase"| D["Proper resource kind format"]
  E["Complex string slicing logic"] -->|"Refactored parsing"| F["Direct split and filter approach"]
  B --> G["Improved resource extraction"]
  D --> G
  F --> G
Loading

Grey Divider

File Changes

1. tests/api/data-validation.test.js 🐞 Bug fix +1/-1

Update resource kind names to CamelCase format

• Updated ignoreKindResourceList array to use proper CamelCase resource names
• Changed from lowercase names ('clusterclaim', 'event', 'networkattachmentdefinition') to CamelCase
 ('ClusterClaim', 'Event', 'NetworkAttachmentDefinition')

tests/api/data-validation.test.js


2. tests/common-lib/index.js 🐞 Bug fix +12/-13

Refactor API resource fetching and parsing logic

• Simplified oc command from complex grep pattern to use --verbs=list,watch and --no-headers
 flags
• Refactored resource parsing logic to remove unnecessary string slicing before method extraction
• Added kind_plural field to resource object and removed .toLowerCase() call on kind
• Improved apigroup extraction to handle both versioned and non-versioned formats

tests/common-lib/index.js


Grey Divider

Qodo Logo

@qodo-code-review
Copy link
Copy Markdown

qodo-code-review bot commented Apr 10, 2026

Code Review by Qodo

🐞 Bugs (1)   📘 Rule violations (0)   📎 Requirement gaps (0)   🎨 UX Issues (0)
🐞\ ≡ Correctness (1)

Grey Divider


Action required

1. Empty apigroup breaks queries 🐞
Description
fetchAPIResourcesWithListWatchMethods now sets core (v1) resources' apigroup to an empty string, and
downstream code treats that as a real API group when disambiguating kinds across multiple groups.
This can generate invalid oc get . commands and add an empty apigroup filter to Search queries,
breaking data-validation for kinds that exist in both core and grouped APIs (e.g., Event).
Code

tests/common-lib/index.js[R25-33]

+          const groupVersion = item.length < 5 ? item[1] : item[2]
+          // Remove the /version from the apigroup.
+          const apigroup = groupVersion.includes('/') ? groupVersion.split('/')[0] : ''
+
+          resourceList.push({
+            kind_plural: item[0],
+            kind: item[item.length - 1], // Kind is the last item.
+            apigroup: apigroup,
+          })
Evidence
The PR change sets apigroup to '' when the apiVersion has no '/', which happens for core v1
resources. When a kind appears more than once, shouldUseAPIGroup enables API-group disambiguation;
the OC CLI path then appends .${apigroup.name} (creating a trailing '.') and the Search path adds
an apigroup filter for any group name not equal to 'v1' (so '' becomes a filter value).

tests/common-lib/index.js[12-35]
tests/common-lib/index.js[152-155]
tests/common-lib/cliClient.js[44-52]
tests/common-lib/searchClient.js[135-155]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`fetchAPIResourcesWithListWatchMethods()` now maps core `v1` resources to `apigroup: ''`. Downstream code uses `group.name != 'v1'` as the sentinel for “needs group filtering / qualification”, so `''` is treated as a real group, causing invalid `oc get <kind>.` and wrong Search `apigroup` filters.
## Issue Context
Historically, this test harness has treated core resources as `apigroup: 'v1'` (special-cased to mean “no group qualifier needed”). The PR changed this by converting no-slash apiVersions into empty string.
## Fix Focus Areas
- tests/common-lib/index.js[25-33]
## Suggested change
Set `apigroup` to `'v1'` when `groupVersion` has no `/` (or more generally, keep `apigroup = groupVersion.split('/')[0]` so `v1` stays `v1`). Keep the `/version` stripping behavior only for grouped apiVersions like `apps/v1` => `apps`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
tests/common-lib/index.js (1)

24-33: Minor: Array truthiness check is always true.

The condition if (item) on line 24 is always truthy since item is an array (arrays are truthy in JavaScript, even when empty). For defensive coding, consider checking the array length to ensure there are enough elements for the parsing logic.

Suggested improvement
-        if (item) {
+        if (item.length >= 4) {
           const groupVersion = item.length < 5 ? item[1] : item[2]
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/common-lib/index.js` around lines 24 - 33, The check `if (item)` is
ineffective because arrays are always truthy; update the guard in the loop that
builds resourceList to verify the array has the expected elements (e.g., use
item.length >= N) before accessing indexes: ensure the logic around computing
groupVersion (variable groupVersion), extracting apigroup (variable apigroup),
and pushing to resourceList only runs when item has sufficient length for
item[0] and item[item.length - 1]; use a specific length check rather than a
truthiness check to prevent out-of-bounds access.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@tests/common-lib/index.js`:
- Around line 24-33: The check `if (item)` is ineffective because arrays are
always truthy; update the guard in the loop that builds resourceList to verify
the array has the expected elements (e.g., use item.length >= N) before
accessing indexes: ensure the logic around computing groupVersion (variable
groupVersion), extracting apigroup (variable apigroup), and pushing to
resourceList only runs when item has sufficient length for item[0] and
item[item.length - 1]; use a specific length check rather than a truthiness
check to prevent out-of-bounds access.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 56fa5e0a-5f53-45b6-a849-32cdf3d0b49f

📥 Commits

Reviewing files that changed from the base of the PR and between 4250da2 and e03ff23.

📒 Files selected for processing (2)
  • tests/api/data-validation.test.js
  • tests/common-lib/index.js

Comment on lines +25 to +33
const groupVersion = item.length < 5 ? item[1] : item[2]
// Remove the /version from the apigroup.
const apigroup = groupVersion.includes('/') ? groupVersion.split('/')[0] : ''

resourceList.push({
kind_plural: item[0],
kind: item[item.length - 1], // Kind is the last item.
apigroup: apigroup,
})
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. Empty apigroup breaks queries 🐞 Bug ≡ Correctness

fetchAPIResourcesWithListWatchMethods now sets core (v1) resources' apigroup to an empty string, and
downstream code treats that as a real API group when disambiguating kinds across multiple groups.
This can generate invalid oc get <kind>. commands and add an empty apigroup filter to Search
queries, breaking data-validation for kinds that exist in both core and grouped APIs (e.g., Event).
Agent Prompt
## Issue description
`fetchAPIResourcesWithListWatchMethods()` now maps core `v1` resources to `apigroup: ''`. Downstream code uses `group.name != 'v1'` as the sentinel for “needs group filtering / qualification”, so `''` is treated as a real group, causing invalid `oc get <kind>.` and wrong Search `apigroup` filters.

## Issue Context
Historically, this test harness has treated core resources as `apigroup: 'v1'` (special-cased to mean “no group qualifier needed”). The PR changed this by converting no-slash apiVersions into empty string.

## Fix Focus Areas
- tests/common-lib/index.js[25-33]

## Suggested change
Set `apigroup` to `'v1'` when `groupVersion` has no `/` (or more generally, keep `apigroup = groupVersion.split('/')[0]` so `v1` stays `v1`). Keep the `/version` stripping behavior only for grouped apiVersions like `apps/v1` => `apps`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Signed-off-by: Jorge Padilla <jpadilla@redhat.com>
@openshift-ci
Copy link
Copy Markdown

openshift-ci bot commented Apr 10, 2026

@jlpadilla: The following test 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/deploy-and-run-e2e-api 5628fec link true /test deploy-and-run-e2e-api

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant