Skip to content

Add OETF workflow-labels scenario tests - #1260

Merged
jiaenren merged 1 commit into
mainfrom
jiaenr/osmo-6501-d1-label-oetf
Aug 11, 2026
Merged

Add OETF workflow-labels scenario tests#1260
jiaenren merged 1 commit into
mainfrom
jiaenr/osmo-6501-d1-label-oetf

Conversation

@jiaenren

@jiaenren jiaenren commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

Issue - None

Adds an OETF end-to-end suite for the workflow-labels feature, split into two Bazel targets so the fast subset can gate PRs and the heavy subset runs against a real deployment. Both drive the feature purely through the OSMO API (a sandboxed OETF test has no in-cluster kubeconfig).

//test/scenarios:workflow-labels (WorkflowLabels, KIND-gated) — fast, API-only checks:

  • Policy gate off / warn / enforce via validation-only submits (no rows, nothing schedules): warn surfaces warnings, enforce rejects with 400 and leaves no row, off accepts anything.
  • Label-syntax rejection: nested value, invalid key, empty value.
  • List filtering: exact label, glob, and no_label.
  • Submit-time round-trip: a labeled workflow's labels survive submit → persistence → workflow API + list filtering.
  • Pod-label prefix (pod_label_prefix): validated against the merged key at submission (a bare key merges to a valid Kubernetes key; a key that already carries a prefix is rejected), and never leaks into the workflow API/list, which keep the bare keys.

The policy tests mutate labels_config, so they need DB-mode config and skipTest on a ConfigMap-mode target.

//test/scenarios:workflow-labels-lifecycle (WorkflowLabelsLifecycle, not KIND-gated) — heavy end-to-end checks that run a labeled workflow to a terminal status and assert the labels survive the whole lifecycle:

  • A COMPLETED run and a FAILED run each keep their labels on the workflow API and stay selectable by a list filter after the run finishes.

These run real pods to completion, so they're deliberately off the KIND PR gate (which runs only validation scenarios) and run against a real deployment instead.

Deployment-agnostic

The suite is meant to pass on any OSMO deployment:

  • List queries pass all_pools so label filters resolve when the submit pool (OETF_POOL) differs from the caller's profile pool — otherwise every filter comes back empty on a multi-pool target. No-op on single-pool KIND.
  • The lifecycle tests use a non-curated label key and skipTest when a target's baked policy would reject the generic label set. Curated-key enforcement is deployment-specific, so those checks live in the internal overlay, not here.

Scope note (pod-object verification)

A literal in-cluster pod-label assertion is not reachable from OETF: scenarios run via bazel test with only OETF_URL + auth + OETF_POOL forwarded, so the test can't reach the cluster with kubectl. The lifecycle target therefore asserts the label round-trip through a real run (submit → schedule → run → terminal, labels still echoed + filterable), not the literal pod label. The pod stamping itself (apply_workflow_labels / prefix application) is covered by unit tests.

Verification

  • bazel build //test/scenarios:workflow-labels //test/scenarios:workflow-labels-lifecycle pass locally.
  • The full-stack KIND gate (oetf:deploy_and_run --env kind) runs the workflow-labels target on this PR.
  • Both targets were run against a live multi-pool deployment: the KIND-safe target passes (Ran 7, skipped 4 — the config-mutation tests skip on ConfigMap; filters + round-trip pass via all_pools), and the lifecycle target passes (Ran 2 — the COMPLETED and FAILED runs both keep their labels).

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added workflow label validation for accepted, warned, rejected, malformed, and filtered labels.
    • Added verification that labels persist for successfully completed and failed workflows.
    • Added a configurable workflow-label scenario supporting custom names, labels, teams, platforms, resources, timeouts, and exit codes.
  • Tests

    • Added automated Kind coverage for workflow label validation and lifecycle behavior.
    • Added CI execution for the workflow-label scenario.

@jiaenren
jiaenren requested a review from a team as a code owner August 4, 2026 23:16
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

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

Walkthrough

Adds a portable workflow-labels OETF scenario. Registers validation and lifecycle targets in Bazel and the KIND workflow. Tests label policies, malformed labels, filtering, persistence, pod-label-prefix handling, and terminal workflow states.

Changes

Workflow labels scenario

Layer / File(s) Summary
Scenario fixture and execution wiring
test/scenarios/workflow_labels.yaml, test/scenarios/BUILD, .github/workflows/oetf-kind.yaml
Defines the workflow fixture and registers separate validation and lifecycle targets with their execution environments.
Scenario lifecycle and API helpers
test/scenarios/workflow_labels.py
Adds configuration handling, workflow submission, retrieval, listing, tracking, cancellation, and cleanup helpers.
Workflow label validation and persistence
test/scenarios/workflow_labels.py
Tests policy modes, malformed labels, list filters, submit-time label persistence, pod-label-prefix handling, and standalone execution.
Terminal workflow label persistence
test/scenarios/workflow_labels.py
Tests label retention for completed and failed workflows through the workflow API and list filters.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant WorkflowLabels
  participant WorkflowAPI
  participant WorkflowListAPI
  WorkflowLabels->>WorkflowAPI: submit labeled workflow
  WorkflowAPI-->>WorkflowLabels: return workflow metadata
  WorkflowLabels->>WorkflowAPI: retrieve workflow labels
  WorkflowLabels->>WorkflowListAPI: list with label filters
  WorkflowListAPI-->>WorkflowLabels: return matching workflows
Loading
sequenceDiagram
  participant WorkflowLabelsLifecycle
  participant WorkflowAPI
  participant WorkflowExecution
  participant WorkflowListAPI
  WorkflowLabelsLifecycle->>WorkflowAPI: submit labeled workflow
  WorkflowAPI->>WorkflowExecution: execute workflow
  WorkflowExecution-->>WorkflowAPI: report completed or failed state
  WorkflowLabelsLifecycle->>WorkflowAPI: retrieve terminal workflow labels
  WorkflowLabelsLifecycle->>WorkflowListAPI: filter terminal workflow by labels
  WorkflowListAPI-->>WorkflowLabelsLifecycle: return labeled workflow
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 6.90% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the added OETF workflow-labels scenario tests.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jiaenr/osmo-6501-d1-label-oetf

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

@jiaenren
jiaenren force-pushed the jiaenr/osmo-6501-d1-label-oetf branch 2 times, most recently from eddf44d to 8380b0f Compare August 5, 2026 00:11
Base automatically changed from jiaenr/osmo-6501-e1-pod-label-prefix to main August 5, 2026 18:26
@jiaenren
jiaenren force-pushed the jiaenr/osmo-6501-d1-label-oetf branch from 8380b0f to 1ca3c68 Compare August 5, 2026 18:26

@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: 2

🧹 Nitpick comments (1)
test/scenarios/workflow_labels.py (1)

186-195: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Type the callback parameter.

_expect_rejected always invokes call, but Any prevents static checking of that contract. Use Callable[[], object] and import Callable.

As per coding guidelines, "Use strict typing in Python where it improves clarity."

Proposed correction
-from typing import Any, Dict, List, Optional
+from typing import Any, Callable, Dict, List, Optional
...
-    def _expect_rejected(self, call: Any, *, status: int = 400,
+    def _expect_rejected(self, call: Callable[[], object], *, status: int = 400,
🤖 Prompt for 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.

In `@test/scenarios/workflow_labels.py` around lines 186 - 195, Update the
_expect_rejected callback annotation from Any to Callable[[], object], and add
Callable to the typing imports. Keep the existing invocation and rejection
assertions unchanged.

Source: Coding guidelines

🤖 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 @.github/workflows/oetf-kind.yaml:
- Around line 170-173: Update the workflow-labels comment in the oetf-kind
workflow to accurately describe test/scenarios/workflow_labels.py coverage: API
label round-trip behavior, label persistence, and filtering. Remove claims that
it waits for workflow completion or verifies pod stamping.

In `@test/scenarios/workflow_labels.py`:
- Around line 248-257: Update test_malformed_labels_are_rejected to verify the
syntax-specific error code or message for every malformed-label submission
instead of accepting any HTTP 400. Configure policy as off where mutation is
permitted so badkey and emptyval reach label syntax validation, while preserving
the existing validation_only coverage for nested labels.

---

Nitpick comments:
In `@test/scenarios/workflow_labels.py`:
- Around line 186-195: Update the _expect_rejected callback annotation from Any
to Callable[[], object], and add Callable to the typing imports. Keep the
existing invocation and rejection assertions unchanged.
🪄 Autofix

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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 0b6f5e14-2b98-4e2b-8580-4153b8a4f0ce

📥 Commits

Reviewing files that changed from the base of the PR and between 6ba2b2d and 1ca3c68.

📒 Files selected for processing (4)
  • .github/workflows/oetf-kind.yaml
  • test/scenarios/BUILD
  • test/scenarios/workflow_labels.py
  • test/scenarios/workflow_labels.yaml

Comment thread .github/workflows/oetf-kind.yaml Outdated
Comment thread test/scenarios/workflow_labels.py Outdated
@jiaenren
jiaenren force-pushed the jiaenr/osmo-6501-d1-label-oetf branch from 1ca3c68 to e0bf0d3 Compare August 10, 2026 21:08

@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: 2

🧹 Nitpick comments (1)
test/scenarios/workflow_labels.py (1)

185-194: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Type the callback contract.

Replace Any with Callable[[], object]. This method requires a zero-argument callable and ignores its return value.

As per coding guidelines, “Use type annotations where they improve clarity and help catch errors.”

🤖 Prompt for 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.

In `@test/scenarios/workflow_labels.py` around lines 185 - 194, Update the
_expect_rejected method’s call parameter annotation from Any to Callable[[],
object], adding or using the appropriate Callable import. Preserve the
zero-argument invocation and ignored return value behavior.

Source: Coding guidelines

🤖 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 `@test/scenarios/workflow_labels.py`:
- Around line 260-270: Make the label-policy-dependent tests independent of the
baseline policy: in test/scenarios/workflow_labels.py ranges 260-270, 291-295,
and 316-332, configure an off policy before submissions, combining it with
pod_label_prefix for the prefix-validation test; when database policy is
immutable, skip unless the existing ConfigMap policy is compatible.

In `@test/scenarios/workflow_labels.yaml`:
- Around line 21-26: Update the lint configuration or workflow for the scenario
containing the Jinja blocks so templated YAML is rendered before YAMLlint
validation, or exclude templated scenario files from raw YAMLlint. Preserve
plain YAMLlint coverage for non-templated scenario files.

---

Nitpick comments:
In `@test/scenarios/workflow_labels.py`:
- Around line 185-194: Update the _expect_rejected method’s call parameter
annotation from Any to Callable[[], object], adding or using the appropriate
Callable import. Preserve the zero-argument invocation and ignored return value
behavior.
🪄 Autofix

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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: c96e3d63-1169-46db-be07-17e6bb7e61ed

📥 Commits

Reviewing files that changed from the base of the PR and between 1ca3c68 and e0bf0d3.

📒 Files selected for processing (4)
  • .github/workflows/oetf-kind.yaml
  • test/scenarios/BUILD
  • test/scenarios/workflow_labels.py
  • test/scenarios/workflow_labels.yaml
🚧 Files skipped from review as they are similar to previous changes (2)
  • test/scenarios/BUILD
  • .github/workflows/oetf-kind.yaml

Comment thread test/scenarios/workflow_labels.py
Comment thread test/scenarios/workflow_labels.yaml
@jiaenren jiaenren changed the title test(oetf): KIND-safe workflow-labels scenario + pod_label_prefix coverage Add OETF workflow-labels scenario + pod_label_prefix coverage Aug 10, 2026
@jiaenren
jiaenren force-pushed the jiaenr/osmo-6501-d1-label-oetf branch 3 times, most recently from 59266ce to 3d424b2 Compare August 11, 2026 00:52

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

♻️ Duplicate comments (1)
test/scenarios/workflow_labels.py (1)

309-319: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Make these tests independent of the baseline label policy.

A baseline enforce policy can reject the submissions before these tests reach their filter, round-trip, or prefix assertions. A non-curated key does not bypass a required team policy. team_a can also be absent from a target allow-list.

  • test/scenarios/workflow_labels.py#L309-L319: Set an off policy in database mode before the filter submissions. Skip when ConfigMap-mode policy compatibility is unknown.
  • test/scenarios/workflow_labels.py#L340-L344: Set an off policy before the round-trip submission, or verify that the baseline policy permits team_a.
  • test/scenarios/workflow_labels.py#L365-L388: Set the off policy and pod_label_prefix together before the prefix submissions. Skip when ConfigMap-mode policy is incompatible.
🤖 Prompt for 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.

In `@test/scenarios/workflow_labels.py` around lines 309 - 319, Make the label
tests independent of baseline policy: in
test/scenarios/workflow_labels.py#L309-L319, configure an off policy before
filter submissions and skip when ConfigMap-mode compatibility is unknown; at
`#L340-L344`, configure off before the round-trip submission or verify baseline
acceptance of team_a; and at `#L365-L388`, configure off together with
pod_label_prefix before prefix submissions and skip when ConfigMap-mode policy
is incompatible.
🤖 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.

Duplicate comments:
In `@test/scenarios/workflow_labels.py`:
- Around line 309-319: Make the label tests independent of baseline policy: in
test/scenarios/workflow_labels.py#L309-L319, configure an off policy before
filter submissions and skip when ConfigMap-mode compatibility is unknown; at
`#L340-L344`, configure off before the round-trip submission or verify baseline
acceptance of team_a; and at `#L365-L388`, configure off together with
pod_label_prefix before prefix submissions and skip when ConfigMap-mode policy
is incompatible.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 99d55933-4b13-49fb-a721-c6eda28cae5d

📥 Commits

Reviewing files that changed from the base of the PR and between 59266ce and 3d424b2.

📒 Files selected for processing (1)
  • test/scenarios/workflow_labels.py

KIND-safe policy/filter/round-trip checks (WorkflowLabels, gated on
oetf:deploy_and_run --env kind) plus heavy run-to-terminal label-
persistence checks (WorkflowLabelsLifecycle, runs on a real deployment,
not KIND-gated). List queries pass all_pools so label filters resolve on
multi-pool targets, not just single-pool KIND.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jiaenren
jiaenren force-pushed the jiaenr/osmo-6501-d1-label-oetf branch from 3d424b2 to a81b2fb Compare August 11, 2026 01:16
@jiaenren jiaenren changed the title Add OETF workflow-labels scenario + pod_label_prefix coverage Add OETF workflow-labels scenario tests Aug 11, 2026
@jiaenren
jiaenren merged commit b07f1d3 into main Aug 11, 2026
10 checks passed
@jiaenren
jiaenren deleted the jiaenr/osmo-6501-d1-label-oetf branch August 11, 2026 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants