Skip to content

Count every FeatureGate tag in test names for unique_test_count#3368

Merged
openshift-merge-bot[bot] merged 1 commit intoopenshift:mainfrom
deepsm007:fix/feature-gate-count-all-name-tags
Mar 26, 2026
Merged

Count every FeatureGate tag in test names for unique_test_count#3368
openshift-merge-bot[bot] merged 1 commit intoopenshift:mainfrom
deepsm007:fix/feature-gate-count-all-name-tags

Conversation

@deepsm007
Copy link
Contributor

@deepsm007 deepsm007 commented Mar 25, 2026

Problem

unique_test_count on feature gates only considered the first [FeatureGate:…] / [OCPFeatureGate:…] in each test name. Tests that list multiple gates could show 0 for gates that appear after the first tag, even when those tests had recent runs and appeared elsewhere in Sippy.

Solution

  • Use regexp_matches(..., 'g') with CROSS JOIN LATERAL so every gate tag in the test name contributes a row.
  • Keep the install case: UNION ALL rows with NULL gate_name for install should succeed, with the same join behavior for Install-related gates.
  • Build the tag and install halves with Table + Joins / Where; use Raw("? UNION ALL ?", …) only to merge the two subqueries (this GORM version has no Union on *gorm.DB).

Impact

Counts may increase when one test name references more than one gate; that is intended so each gate is attributed correctly.

https://redhat-internal.slack.com/archives/CBN38N3MW/p1774459082318689

Summary by CodeRabbit

  • Refactor
    • Improved efficiency of feature gate query extraction and matching logic.

@openshift-ci-robot
Copy link

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: automatic mode

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 25, 2026

Important

Review skipped

Auto reviews are limited based on label configuration.

🚫 Review skipped — only excluded labels are configured. (1)
  • do-not-merge/work-in-progress

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro

Run ID: 25f9fcbc-ccbb-4c06-89d5-bb7068afbc6d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Refactored the feature gates SQL query to replace a single regex extraction pattern with two separate UNIONed data sources: one for tag-based feature gate matching using global regex matching, and one for install path matching, with updated LEFT JOIN logic to handle both cases.

Changes

Cohort / File(s) Summary
SQL Query Refactoring
pkg/db/query/feature_gates.go
Replaced single regex-based match[2] extraction with two separate UNIONed query paths: tag-based source emitting gate_name per captured FeatureGate|OCPFeatureGate tag, and install path source with gate_name set to NULL. Updated subsequent LEFT JOIN to filter feature gate matches on fg.feature_gate = mt.gate_name and install fallback matches on mt.gate_name IS NULL.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Go Error Handling ✅ Passed The modified code in pkg/db/query/feature_gates.go follows all proper Go error handling patterns with explicit error capture and checking.
Sql Injection Prevention ✅ Passed The pull request properly prevents SQL injection vulnerabilities by using GORM's parameterized queries with ? placeholders for all user-supplied input.
Excessive Css In React Should Use Styles ✅ Passed Custom check about React CSS styling is not applicable to this PR which modifies a Go backend database query file.
Single Responsibility And Clear Naming ✅ Passed The PR changes focus on a single responsibility—correctly counting feature gate tags by splitting query logic into two clear, semantically distinct data sources (tag-based and install-based paths) UNIONed together. Variable names clearly communicate purpose without generic or unclear terminology.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@openshift-ci openshift-ci bot requested review from deads2k and xueqzhan March 25, 2026 18:37
@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 25, 2026
Copy link
Contributor

@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)
pkg/db/query/feature_gates.go (1)

48-48: Avoid extra join fan-out on install rows.

Line 48 can also match tagged rows from byTag whenever the same test name contains install should succeed. Since byInstall already contributes a dedicated NULL row for that case, restricting the fallback to mt.gate_name IS NULL keeps the special case explicit and avoids unnecessary duplicate join work.

Suggested fix
-		Joins("LEFT JOIN (?) AS mt ON fg.feature_gate = mt.gate_name OR (fg.feature_gate LIKE '%Install%' AND mt.name LIKE '%install should succeed%')", subQuery).
+		Joins(`LEFT JOIN (?) AS mt
+			ON fg.feature_gate = mt.gate_name
+			OR (
+				mt.gate_name IS NULL
+				AND fg.feature_gate LIKE '%Install%'
+				AND mt.name LIKE '%install should succeed%'
+			)`, subQuery).
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/db/query/feature_gates.go` at line 48, The LEFT JOIN condition currently
allows matches from the byTag subQuery (aliased mt) when the test name contains
"install should succeed", causing extra fan-out; update the join expression used
in the Joins call so the fallback OR clause only applies when mt.gate_name IS
NULL (i.e., change the OR branch to include "AND mt.gate_name IS NULL"),
referencing the existing aliases fg.feature_gate and mt.gate_name and the
subQuery to ensure the dedicated byInstall NULL row remains the only match for
the install special-case.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@pkg/db/query/feature_gates.go`:
- Line 48: The LEFT JOIN condition currently allows matches from the byTag
subQuery (aliased mt) when the test name contains "install should succeed",
causing extra fan-out; update the join expression used in the Joins call so the
fallback OR clause only applies when mt.gate_name IS NULL (i.e., change the OR
branch to include "AND mt.gate_name IS NULL"), referencing the existing aliases
fg.feature_gate and mt.gate_name and the subQuery to ensure the dedicated
byInstall NULL row remains the only match for the install special-case.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro

Run ID: 0225e538-b652-4c05-9a06-c9741e2e177a

📥 Commits

Reviewing files that changed from the base of the PR and between 27d7b72 and 29723d9.

📒 Files selected for processing (1)
  • pkg/db/query/feature_gates.go

@openshift-ci-robot
Copy link

Scheduling required tests:
/test e2e

1 similar comment
@openshift-ci-robot
Copy link

Scheduling required tests:
/test e2e

@neisw
Copy link
Contributor

neisw commented Mar 25, 2026

/lgtm

Verified locally

image

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Mar 25, 2026
@deepsm007
Copy link
Contributor Author

/test lint

@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Mar 26, 2026
@deepsm007 deepsm007 force-pushed the fix/feature-gate-count-all-name-tags branch 5 times, most recently from fb23e00 to 20a9201 Compare March 26, 2026 02:36
@deepsm007 deepsm007 force-pushed the fix/feature-gate-count-all-name-tags branch from 20a9201 to 7fa95c9 Compare March 26, 2026 02:50
@stbenjam
Copy link
Member

Lint is because of #3372, will be fixed soon

@deepsm007
Copy link
Contributor Author

/test lint

@openshift-ci-robot
Copy link

Scheduling required tests:
/test e2e

@neisw
Copy link
Contributor

neisw commented Mar 26, 2026

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Mar 26, 2026
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 26, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: deepsm007, neisw

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
Copy link
Contributor

openshift-ci bot commented Mar 26, 2026

@deepsm007: all tests passed!

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.

@openshift-merge-bot openshift-merge-bot bot merged commit c6d1bfe into openshift:main Mar 26, 2026
8 checks passed
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. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants