Skip to content

Conversation

@spolti
Copy link
Member

@spolti spolti commented Nov 26, 2025

…n Time

cherry-picked from community: clean-up raw-controller tests (kserve#4781)

What this PR does / why we need it:

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

Type of changes
Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Feature/Issue validation/testing:

Please describe the tests that you ran to verify your changes and relevant result summary. Provide instructions so it can be reproduced.
Please also list any relevant details for your test configuration.

  • Test A

  • Test B

  • Logs

Special notes for your reviewer:

  1. Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.

Checklist:

  • Have you added unit/e2e tests that prove your fix is effective or that this feature works?
  • Has code been commented, particularly in hard-to-understand areas?
  • Have you made corresponding changes to the documentation?
  • Have you linked the JIRA issue(s) to this PR?

Release note:


Re-running failed tests

  • /rerun-all - rerun all failed workflows.
  • /rerun-workflow <workflow name> - rerun a specific failed workflow. Only one workflow name can be specified. Multiple /rerun-workflow commands are allowed per comment.

Summary by CodeRabbit

  • Tests
    • Added test helper utilities and constants to standardize construction of InferenceService test objects and expected states.
    • Added a diagnostic script to run tests, save full logs, and identify slow-running tests.
    • Improves test consistency and simplifies slow-test identification for maintainers.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Nov 26, 2025

Walkthrough

Adds a new test utilities file providing constants and multiple factory/helper functions to build v1beta1 InferenceService test objects and expected Kubernetes/Knative resources, and introduces a Bash script that runs Go tests, captures verbose output, and identifies slow tests by duration thresholds.

Changes

Cohort / File(s) Summary
Test utilities (Inferenceservice)
pkg/controller/v1beta1/inferenceservice/tests_common.go
New file adding public constants (REPLICAS, REVISION_HISTORY, PROGRESSION_DEADLINE_SECODS, GRACE_PERIOD) and many helper/factory functions to construct ServingRuntime, Service, InferenceServiceStatus, PredictorExtensionSpec, default annotations/metrics/rolling strategy, and expected Deployments for predictor/explainer scenarios.
Test analysis script
test/scripts/identify_slow_tests.sh
New Bash script that runs go test with verbose output, saves full logs to detailed_test_output.log, and scans the log to report tests exceeding configured duration thresholds (≥30s, 40s, 50s, 70s).

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Dev as Developer/CI
    participant Script as identify_slow_tests.sh
    participant GoTest as go test
    participant Log as detailed_test_output.log
    participant Analyzer as log parser

    Dev->>Script: invoke script (package target)
    Script->>GoTest: run `go test -v` (captures stdout/stderr)
    GoTest-->>Script: verbose test output stream
    Script->>Log: write full output to file
    Script->>Analyzer: scan output for timing markers (>=30s,40s,50s,70s)
    Analyzer-->>Script: list of slow tests and thresholds
    Script-->>Dev: print summary and path to `detailed_test_output.log`
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Areas to focus:
    • tests_common.go: verify correctness of Kubernetes/Knative object fields (labels, selectors, ports, probes, annotations, resource requests/limits) and consistency with expected types/versions.
    • Ensure constants (replicas, revisionHistory, deadlines, grace period) match test expectations and do not conflict with other tests.
    • identify_slow_tests.sh: validate regex/threshold logic, handling of edge cases (no matches, partial output), and portability (bash features, go test flags).

Poem

🐰 I hop through fixtures, tidy and spry,

Builders for pods and services I ply.
I log the slow ones, then point where they hide,
Tests leap faster — I twitch with pride. 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title references a Jira ticket (RHOAIENG-36758) and mentions investigating/optimizing KServe unit test execution, which aligns with the changes (test helper utilities and slow test identification script).
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between aab8f83 and 6a6e91e.

📒 Files selected for processing (2)
  • pkg/controller/v1beta1/inferenceservice/tests_common.go (1 hunks)
  • test/scripts/identify_slow_tests.sh (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • pkg/controller/v1beta1/inferenceservice/tests_common.go
  • test/scripts/identify_slow_tests.sh
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
  • GitHub Check: precommit-check
  • GitHub Check: test
  • GitHub Check: test
  • GitHub Check: test
  • GitHub Check: build (3.11)
  • GitHub Check: build (3.9)
  • GitHub Check: build (3.10)
  • GitHub Check: build (3.12)
  • GitHub Check: test
  • GitHub Check: Test
  • GitHub Check: test
  • GitHub Check: test

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 and usage tips.

Copy link

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
pkg/controller/v1beta1/inferenceservice/tests_common.go (2)

40-44: Fix typos in constant and helper names for readability

There are a couple of small but visible typos that are worth fixing before these helpers spread:

  • Constant: PROGRESSION_DEADLINE_SECODSPROGRESSION_DEADLINE_SECONDS.
  • Function: getExectedServicegetExpectedService.

Suggested change (plus updating call sites accordingly):

-const (
-    REPLICAS                    int32 = 1
-    REVISION_HISTORY            int32 = 10
-    PROGRESSION_DEADLINE_SECODS int32 = 600
-    GRACE_PERIOD                int64 = 30
-)
+const (
+    REPLICAS                   int32 = 1
+    REVISION_HISTORY           int32 = 10
+    PROGRESSION_DEADLINE_SECONDS int32 = 600
+    GRACE_PERIOD               int64 = 30
+)

-func getExectedService(predictorServiceKey types.NamespacedName, serviceName string) corev1.Service {
+func getExpectedService(predictorServiceKey types.NamespacedName, serviceName string) corev1.Service {

-            ProgressDeadlineSeconds: ptr.To(PROGRESSION_DEADLINE_SECODS),
+            ProgressDeadlineSeconds: ptr.To(PROGRESSION_DEADLINE_SECONDS),

This keeps the helpers self‑explanatory for future readers and avoids typo propagation.

Also applies to: 126-148, 265-331, 404-407


335-402: Document or guard against nil InferenceService model fields

getDeploymentWithKServiceLabel dereferences several nested pointers:

  • *isvc.Spec.Predictor.Model.StorageURI
  • *isvc.Spec.Predictor.Model.RuntimeVersion

If any of isvc, isvc.Spec.Predictor.Model, StorageURI, or RuntimeVersion is nil, tests will panic.

If the intended contract is “only call this with a fully‑initialized InferenceService”, it’d help to either:

  • Add a brief comment stating that precondition, or
  • Add explicit checks with a clear panic message so failures are easier to diagnose, e.g.:
 func getDeploymentWithKServiceLabel(predictorDeploymentKey types.NamespacedName, serviceName string, isvc *v1beta1.InferenceService) appsv1.Deployment {
+    if isvc == nil || isvc.Spec.Predictor.Model == nil ||
+        isvc.Spec.Predictor.Model.StorageURI == nil ||
+        isvc.Spec.Predictor.Model.RuntimeVersion == nil {
+        panic("getDeploymentWithKServiceLabel: isvc.Spec.Predictor.Model.{StorageURI,RuntimeVersion} must be non-nil")
+    }

This keeps the helper safer to reuse in new tests that might construct partial specs.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ea020d0 and aab8f83.

📒 Files selected for processing (2)
  • pkg/controller/v1beta1/inferenceservice/tests_common.go (1 hunks)
  • test/scripts/identify_slow_tests.sh (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
test/scripts/identify_slow_tests.sh (1)
pkg/controller/v1beta1/inferenceservice/suite_test.go (1)
  • TestV1beta1APIs (62-65)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
  • GitHub Check: test
  • GitHub Check: test
  • GitHub Check: test
  • GitHub Check: build (3.10)
  • GitHub Check: test
  • GitHub Check: build (3.12)
  • GitHub Check: build (3.11)
  • GitHub Check: build (3.9)
  • GitHub Check: Test
  • GitHub Check: test
  • GitHub Check: test
  • GitHub Check: precommit-check

@Jooho
Copy link

Jooho commented Nov 26, 2025

/lgtm

…n Time

cherry-picked from community: clean-up raw-controller tests (kserve#4781)

Signed-off-by: Spolti <[email protected]>
@mwaykole
Copy link
Member

/lgtm

@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD ea020d0 and 2 for PR HEAD 6a6e91e in total

Copy link

@Jooho Jooho left a comment

Choose a reason for hiding this comment

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

2 CI fails were expected because there is an issue.

So I will merge this manually.

/lgtm

@openshift-ci
Copy link

openshift-ci bot commented Nov 27, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Jooho, spolti

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

The pull request process is described here

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

openshift-ci bot commented Nov 27, 2025

@spolti: 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-predictor 6a6e91e link true /test e2e-predictor
ci/prow/e2e-path-based-routing 6a6e91e link true /test e2e-path-based-routing

Full PR test history. Your PR dashboard.

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.

@spolti spolti merged commit 0207b4a into opendatahub-io:master Nov 27, 2025
29 of 32 checks passed
@spolti spolti deleted the RHOAIENG-36758 branch November 27, 2025 19:19
@github-project-automation github-project-automation bot moved this from New/Backlog to Done in ODH Model Serving Planning Nov 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants