Skip to content

Migrate remaining TCs from mco.go to mco.go, mco_units.go, mco_kubele…#6024

Open
ptalgulk01 wants to merge 1 commit into
openshift:mainfrom
ptalgulk01:migrate-mco-remaining-tcs
Open

Migrate remaining TCs from mco.go to mco.go, mco_units.go, mco_kubele…#6024
ptalgulk01 wants to merge 1 commit into
openshift:mainfrom
ptalgulk01:migrate-mco-remaining-tcs

Conversation

@ptalgulk01
Copy link
Copy Markdown
Contributor

@ptalgulk01 ptalgulk01 commented May 8, 2026

  • Add 6 general MCO TCs (42347, 43124, 43726, 63868, 68695, 75258) to mco.go
  • Add TC 72025 (nmstate keeps service yamls) to mco_units.go
  • Add TC 74540 (kubelet dependency issue after reboot) to mco_kubelet_and_containerruntime.go
  • Add change-worker-ign-version.yaml template for TC 43124

Summary by CodeRabbit

  • Tests
    • Added comprehensive tests for machine configuration operations, including Ignition version validation and Azure platform consistency checks.
    • Added disruptive tests for systemd unit management (ensuring unit updates and continued service activity) and nmstate config persistence across service restarts.

@openshift-merge-bot
Copy link
Copy Markdown
Contributor

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: LGTM mode

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 8, 2026

Warning

Rate limit exceeded

@ptalgulk01 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 52 minutes and 30 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: ba115500-c97f-494e-bc27-f2dabaa4ef96

📥 Commits

Reviewing files that changed from the base of the PR and between 64c63d2 and df0c8fa.

📒 Files selected for processing (4)
  • test/extended-priv/mco.go
  • test/extended-priv/mco_kubelet_and_containerruntime.go
  • test/extended-priv/mco_units.go
  • test/extended-priv/testdata/files/change-worker-ign-version.yaml

Walkthrough

Adds multiple disruptive long-duration Ginkgo tests to the extended MCO suite plus a MachineConfig template and helper: tests cover Ignition-version error handling, operator/MCP health checks, Azure platform status consistency, controllerconfig sync after Infrastructure labeling, ImageRegistry-capability behavior, node log scanning, nmstate config persistence, and systemd unit lifecycle across MachineConfig updates.

Changes

MCO Extended Test Suite Expansion

Layer / File(s) Summary
Test Data Template
test/extended-priv/testdata/files/change-worker-ign-version.yaml
New OpenShift Template change-worker-ign-version-to-empty with parameters NAME, POOL, IGNITION_VERSION; produces a MachineConfig whose spec.config.ignition.version is parameterized (used to inject invalid/empty Ignition versions).
Helpers / Test Infra
test/extended-priv/mco.go
Adds encoding/json and time imports and new helper createMcAndVerifyIgnitionVersion(...) which instantiates the template with IGNITION_VERSION, skips waiting for MCP completion, and invokes validateMcpRenderDegraded with expected error message/reason patterns for invalid Ignition versions.
High-level MCO Tests
test/extended-priv/mco.go
Introduces a new Ginkgo Describe suite containing long/disruptive/serial tests that: verify CO and MCP are not degraded; exercise invalid Ignition version MachineConfig creation and expected render degradation; check Azure platformStatus/azure.cloudName consistency when on Azure; confirm controllerconfig sync after Infrastructure labeling; assert operator not degraded when ImageRegistry capability is absent; and scan node logs for “Found ordering cycle” using debug tooling.
nmstate persistence test
test/extended-priv/mco_units.go
Adds strings import and a new disruptive test (PolarionID:72025) that writes an nmstate YAML file on a node, restarts the nmstate service, asserts both the original file and its .applied clone persist, and defers cleanup (remove files + restart service).
systemd unit lifecycle test
test/extended-priv/mco_kubelet_and_containerruntime.go
New disruptive test (PolarionID:74540) that creates a MachineConfig installing a hello.service unit (WantedBy=default.target), verifies unit file content and service active state on a worker, patches the MC to change WantedBy to multi-user.target, waits for pool reconciliation, verifies old/new unit symlink locations, and ensures hello.service remains active after the update.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 8 | ❌ 4

❌ Failed checks (4 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title is incomplete and truncated ('Migrate remaining TCs from mco.go to mco.go, mco_kubele…'), making it unclear about the actual changes being made. The actual PR adds tests to multiple files (mco.go, mco_units.go, mco_kubelet_and_containerruntime.go) and a template file, but the title appears cut off and contains an apparent typo ('mco.go to mco.go'). Revise the title to be more accurate and complete, such as: 'Add MCO test cases for Ignition version validation, nmstate persistence, and kubelet dependencies' or 'Migrate remaining MCO test cases to dedicated test files'.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Test Structure And Quality ⚠️ Warning Multiple assertions lack meaningful failure messages. Test 42347 line 169 and test 43726 lines 188-200 violate requirement #4 for assertion diagnostic messages. Add diagnostic messages to assertions in test 42347 (line 169) and test 43726 (lines 188, 189, 192, 200) to match patterns used in existing tests.
Microshift Test Compatibility ⚠️ Warning Tests use MicroShift-incompatible APIs without protection tags: ClusterOperator, Infrastructure, ControllerConfig, ImageRegistry operator. Add [apigroup:config.openshift.io], [apigroup:machine.openshift.io], and [apigroup:imageregistry.operator.openshift.io] tags to tests or guard with IsMicroShiftCluster().
✅ Passed checks (8 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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.
Stable And Deterministic Test Names ✅ Passed All 8 new test titles use static descriptive strings without dynamic information like node names, timestamps, UUIDs, or IP addresses.
Single Node Openshift (Sno) Test Compatibility ✅ Passed All 8 new tests are SNO-compatible. They use SNO-aware helpers (GetCompactCompatiblePool) and don't assume multiple nodes or multi-node cluster behavior.
Topology-Aware Scheduling Compatibility ✅ Passed PR adds test code only - no deployment manifests, scheduling constraints, affinity rules, or topology assumptions affecting SNO, Two-Node, or HyperShift.
Ote Binary Stdout Contract ✅ Passed All changes comply with OTE Binary Stdout Contract. No direct stdout writes in process-level code. Logger properly configured to use GinkgoWriter. All test cases use standard Ginkgo patterns.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed All 8 new Ginkgo e2e tests in this PR contain no IPv4 assumptions or external connectivity requirements. Tests are compatible with IPv6-only disconnected CI environments.

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

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

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.

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 8, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ptalgulk01
Once this PR has been reviewed and has the lgtm label, please assign dkhater-redhat for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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 openshift-ci Bot requested review from cheesesashimi and pablintino May 8, 2026 15:08
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.

Actionable comments posted: 1

🧹 Nitpick comments (2)
test/extended-priv/mco_units.go (1)

385-402: 💤 Low value

Minor: typo nsmtate in the error messages and duplicated restart logic.

The same systemctl restart nmstate plus error-string assertion is repeated in the deferred cleanup (Lines 388-390) and the test body (Lines 400-401), and both error strings misspell nmstate as nsmtate. Consider extracting a tiny local helper and fixing the typo while you're touching it.

Proposed tweak
+		restartNMState := func() {
+			logger.Infof("Restarting nmstate service")
+			_, err := node.DebugNodeWithChroot("systemctl", "restart", "nmstate")
+			o.Expect(err).NotTo(o.HaveOccurred(), "Error restarting the nmstate service in node %s", node.GetName())
+		}
 		defer func() {
 			nmstateConfigRemote.Rm("-f")
 			nmstateConfigAppliedRemote.Rm("-f")
-			logger.Infof("Restarting nmstate service")
-			_, err := node.DebugNodeWithChroot("systemctl", "restart", "nmstate")
-			o.Expect(err).NotTo(o.HaveOccurred(), "Error restarting the nsmtate service in node %s", node.GetName())
+			restartNMState()
 		}()
 		...
 		exutil.By(fmt.Sprintf("Restart nmstate service in node %s", node.GetName()))
-		_, err := node.DebugNodeWithChroot("systemctl", "restart", "nmstate")
-		o.Expect(err).NotTo(o.HaveOccurred(), "Error restarting the nsmtate service in node %s", node.GetName())
+		restartNMState()
🤖 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/extended-priv/mco_units.go` around lines 385 - 402, The deferred cleanup
and the test body both call systemctl restart nmstate with duplicated logic and
misspell "nmstate" as "nsmtate"; extract a small helper (e.g., restartNmstate or
restartNmstateWithAssert) that calls
node.DebugNodeWithChroot("systemctl","restart","nmstate") and performs the
o.Expect(err).NotTo(o.HaveOccurred(), ...) assertion using the correct service
name, then replace the inline restart calls in the defer func and the main test
flow to call that helper; update any related log messages (logger.Infof / error
strings) to use "nmstate" consistently and remove the duplicate restart logic.
test/extended-priv/mco.go (1)

178-201: 💤 Low value

Optional: structural compare instead of string compare for platformStatus.

mccPlatformStatus and infraPlatformStatus are both produced by jsonpath extraction, so ordering should be stable in practice, but a single field-order or whitespace difference between the two paths would make this assertion fail in a way that is hard to debug. Decoding both into map[string]interface{} (or unmarshaling into the same typed struct) and comparing with reflect.DeepEqual / Gomega's o.Equal on the maps would be more robust.

🤖 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/extended-priv/mco.go` around lines 178 - 201, The test currently
compares mccPlatformStatus and infraPlatformStatus as raw strings which is
brittle; instead decode both JSONPath results into the same Go structure (e.g.,
map[string]interface{} via json.Unmarshal) — parse mccPlatformStatus into a
variable like jsonMccPlatformStatus (already present) and likewise unmarshal
infraPlatformStatus into jsonInfraPlatformStatus, assert both unmarshals
succeed, then compare the parsed maps using
o.Expect(jsonMccPlatformStatus).To(o.Equal(jsonInfraPlatformStatus)) (or
reflect.DeepEqual) so ordering/whitespace differences won’t cause false
failures; update the check in the test function that currently does
o.Expect(mccPlatformStatus).To(o.Equal(infraPlatformStatus)).
🤖 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/extended-priv/testdata/files/change-worker-ign-version.yaml`:
- Around line 12-17: The YAML has kernelArguments at the top-level instead of
under the MachineConfig spec; move the kernelArguments sequence into the spec
block (so it is a child of spec alongside config), or remove the kernelArguments
entry altogether if it's not needed for this invalid-ignition-version test;
target the kernelArguments key and the spec mapping in the YAML so the
MachineConfig schema is valid.

---

Nitpick comments:
In `@test/extended-priv/mco_units.go`:
- Around line 385-402: The deferred cleanup and the test body both call
systemctl restart nmstate with duplicated logic and misspell "nmstate" as
"nsmtate"; extract a small helper (e.g., restartNmstate or
restartNmstateWithAssert) that calls
node.DebugNodeWithChroot("systemctl","restart","nmstate") and performs the
o.Expect(err).NotTo(o.HaveOccurred(), ...) assertion using the correct service
name, then replace the inline restart calls in the defer func and the main test
flow to call that helper; update any related log messages (logger.Infof / error
strings) to use "nmstate" consistently and remove the duplicate restart logic.

In `@test/extended-priv/mco.go`:
- Around line 178-201: The test currently compares mccPlatformStatus and
infraPlatformStatus as raw strings which is brittle; instead decode both
JSONPath results into the same Go structure (e.g., map[string]interface{} via
json.Unmarshal) — parse mccPlatformStatus into a variable like
jsonMccPlatformStatus (already present) and likewise unmarshal
infraPlatformStatus into jsonInfraPlatformStatus, assert both unmarshals
succeed, then compare the parsed maps using
o.Expect(jsonMccPlatformStatus).To(o.Equal(jsonInfraPlatformStatus)) (or
reflect.DeepEqual) so ordering/whitespace differences won’t cause false
failures; update the check in the test function that currently does
o.Expect(mccPlatformStatus).To(o.Equal(infraPlatformStatus)).
🪄 Autofix (Beta)

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: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: cf56ce46-bf1e-4f69-95b4-ac1b44b9d849

📥 Commits

Reviewing files that changed from the base of the PR and between 3320406 and d0e6c2d.

📒 Files selected for processing (4)
  • test/extended-priv/mco.go
  • test/extended-priv/mco_kubelet_and_containerruntime.go
  • test/extended-priv/mco_units.go
  • test/extended-priv/testdata/files/change-worker-ign-version.yaml

Comment thread test/extended-priv/testdata/files/change-worker-ign-version.yaml Outdated
@ptalgulk01 ptalgulk01 force-pushed the migrate-mco-remaining-tcs branch from d0e6c2d to 64c63d2 Compare May 11, 2026 05:43
…t_and_containerruntime.go

- Add 6 general MCO TCs (42347, 43124, 43726, 63868, 68695, 75258) to mco.go
- Add TC 72025 (nmstate keeps service yamls) to mco_units.go
- Add TC 74540 (kubelet dependency issue after reboot) to mco_kubelet_and_containerruntime.go
- Add change-worker-ign-version.yaml template for TC 43124

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ptalgulk01 ptalgulk01 force-pushed the migrate-mco-remaining-tcs branch from 64c63d2 to df0c8fa Compare May 11, 2026 13:01
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 11, 2026

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

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.

1 participant