8000 fix(e2e): add parameters to Component CR in verify_cms_bridge_reconciliation by janzak-dev · Pull Request #1276 · google/xmc · GitHub
[go: up one dir, main page]

Skip to content

fix(e2e): add parameters to Component CR in verify_cms_bridge_reconciliation - #1276

Merged
janzak-dev merged 3 commits into
mainfrom
fix/e2e-cms-bridge-crd-validation
Oct 14, 2026
Merged

janzak-dev merged 3 commits into
mainfrom
fix/e2e-cms-bridge-crd-validation

Conversation

@janzak-dev
@janzak-dev janzak-dev commented Oct 14, 2026 •
Copy link
Copy Markdown
Collaborator

Summary

Fixes the failing headless E2E test stage [5/5] Verifying Authenticated xmc-bridge -> CMS Reconciliation on main by adding parameters to the e2e-cms-auth-check Component CR manifest.

Motivation & Context

Commit c5bb4a7a (#1219) introduced verify_cms_bridge_reconciliation() in test/e2e/test_e2e_flow.py, which applies a Component CR (e2e-cms-auth-check) with componentType: COMPONENT_TYPE_CUSTOM_3P_WRAPPER while omitting both wrapperRef and parameters. The Component CRD (deploy/helm/templates/components/crd.yaml) enforces the OpenAPI CEL admission rule:

!has(self.spec.componentType) || self.spec.componentType != 'COMPONENT_TYPE_CUSTOM_3P_WRAPPER' || has(self.spec.wrapperRef) || has(self.spec.parameters)

This caused kubectl apply to fail immediately at Kubernetes API server admission on every merge_group E2E run starting from c5bb4a7a. Providing parameters: {"authCheck": "true"} satisfies the CEL rule while keeping the operatorless disabled-component reconciliation path intact.

Key Changes

  • E2E Component Manifest Fix (test/e2e/test_e2e_flow.py):
    • Added "parameters": {"authCheck": "true"} to the e2e-cms-auth-check Component CR spec in verify_cms_bridge_reconciliation().

Assumptions

  • None — requirements were fully specified.

Verification & Testing

  • Commands Executed:
    • ./.githooks/pre-commit
    • bazel test //test/e2e/...
    • ./tools/analyze_diff_size.py --base-ref origin/main...
    • gh workflow run e2e-tests.yml --ref fix/e2e-cms-bridge-crd-validation
  • Coverage & Test Status:
    • 21 / 21 Bazel test targets in //test/e2e/... passed.
    • Full Headless KinD & Playwright E2E Run: Run 38570364368 (Job 115873658863) passed in 3m 51s on commit 5d5e2390:
      2026-10-14 13:19:42,766 [INFO] === [5/5] Verifying Authenticated xmc-bridge -> CMS Reconciliation ===
      component.xmc.dev/e2e-cms-auth-check created
      2026-10-14 13:19:45,005 [INFO] ✓ xmc-bridge authenticated to CMS and reconciled Component CR.
      component.xmc.dev "e2e-cms-auth-check" deleted
      2026-10-14 13:19:46,122 [INFO] ==================================================
      2026-10-14 13:19:46,123 [INFO] 🎉 ALL E2E PLAYWRIGHT TESTS PASSED SUCCESSFULLY! 🎉
      2026-10-14 13:19:46,123 [INFO] ==================================================
      

Related Issues / Bugs

Fixes bug 569895291

TAG=agy
CONV=7e782875-965d-4097-a513-2b68b39b5ca3

…liation

Include `parameters: {"authCheck": "true"}` in the `e2e-cms-auth-check`
Component manifest in `verify_cms_bridge_reconciliation` so that it satisfies
the Kubernetes CRD OpenAPI CEL validation rule requiring either `wrapperRef`
or `parameters` when `componentType` is `COMPONENT_TYPE_CUSTOM_3P_WRAPPER`.
Also add hermetic unit test coverage in `test_e2e_flow_test.py`.

Bug: b/569895291

TAG=agy
CONV=7e782875-965d-4097-a513-2b68b39b5ca3
…e2e_flow_test

Inline the single-caller `_poll_component_disabled` helper back into
`verify_cms_bridge_reconciliation` to eliminate the unused `timeout_sec`
default parameter and keep the production test diff minimal. Also simplify
mock subprocess return values and direct parameter assertions in
`test_e2e_flow_test.py`.

Bug: b/569895291

TAG=agy
CONV=7e782875-965d-4097-a513-2b68b39b5ca3
@gemini-code-assist gemini-code-assist Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new end-to-end flow test target in Bazel, extracts the component polling logic into a helper function _poll_component_disabled in test_e2e_flow.py, and adds comprehensive unit tests in test_e2e_flow_test.py. The feedback recommends using time.monotonic() instead of time.time() to measure deadlines robustly against system clock changes, adding a timeout to the subprocess.run call to prevent hangs, and updating the unit tests to mock time.monotonic accordingly.

I am having trouble creating individual review comments. Click here to see my feedback.

test/e2e/test_e2e_flow.py (490-497)

medium

Using time.time() to measure elapsed time or deadlines can be problematic if the system clock is adjusted (e.g., via NTP synchronization or manual changes). It is highly recommended to use time.monotonic() instead, as it is guaranteed to never go backwards. Additionally, adding a timeout to subprocess.run prevents the test from hanging indefinitely if the kubectl command hangs.

    deadline, last_yaml = time.monotonic() + timeout_sec, ""
    while time.monotonic() < deadline:
        try:
            res = subprocess.run(get_cmd, capture_output=True, text=True, check=False, timeout=5.0)
            last_yaml = res.stdout or ""
        except subprocess.SubprocessError as e:
            last_yaml = f"kubectl execution failed: {e}"
        if "state: COMPONENT_STATE_DISABLED" in last_yaml:
            logger.info("✓ xmc-bridge authenticated to CMS and reconciled Component CR.")
            return
        time.sleep(1.0)

test/e2e/test_e2e_flow_test.py (85)

medium

Since verify_cms_bridge_reconciliation is updated to use time.monotonic() for measuring deadlines, we should patch time.monotonic instead of time.time in this test to ensure the timeout behavior is correctly mocked.

    @mock.patch("test.e2e.test_e2e_flow.time.monotonic", side_effect=[100.0, 100.5, 131.0])

Drop `test_e2e_flow_test.py` and its `BUILD.bazel` target since
`test_e2e_flow.py` is the E2E scenario script itself and is verified
directly against the Kubernetes CRD OpenAPI CEL admission rule in the
headless KinD E2E suite.

Bug: b/569895291

TAG=agy
CONV=7e782875-965d-4097-a513-2b68b39b5ca3
@janzak-dev
janzak-dev marked this pull request as ready for review October 14, 2026 13:23
@github-actions
github-actions Bot requested a review from andrzejfudro October 14, 2026 13:23
@janzak-dev janzak-dev added the priority::2-high top of mind. should not wait. label Oct 14, 2026
@janzak-dev
janzak-dev enabled auto-merge October 14, 2026 13:24
@janzak-dev
janzak-dev added this pull request to the merge queue Oct 14, 2026
Merged via the queue into main with commit aa8650e Oct 14, 2026
17 checks passed
@janzak-dev
janzak-dev deleted the fix/e2e-cms-bridge-crd-validation branch October 14, 2026 13:40

This branch was previously deployed

1 inactive deployment
e2e-test — 5d5e2390 Deployed Oct 14, 2026 by janzak-dev via Execute KinD & Playwright Headless E2E #1367
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority::2-high top of mind. should not wait.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0