Skip to content

HYPERFLEET-864 - test: add Go template conditional coverage to cl-maestro e2e test#69

Open
xueli181114 wants to merge 1 commit intoopenshift-hyperfleet:mainfrom
xueli181114:HYPERFLEET-864
Open

HYPERFLEET-864 - test: add Go template conditional coverage to cl-maestro e2e test#69
xueli181114 wants to merge 1 commit intoopenshift-hyperfleet:mainfrom
xueli181114:HYPERFLEET-864

Conversation

@xueli181114
Copy link
Copy Markdown
Contributor

@xueli181114 xueli181114 commented Apr 2, 2026

Summary

  • Extracts cl-maestro ManifestWork manifest to ref file with Go template structural syntax ({{ if }}, {{ else }}, {{ end }})
  • Adds CEL captures for cluster-spec-sourced dynamic values (platformType from spec.platform.type, environment from labels.environment)
  • Adds e2e assertions to verify conditional labels and ConfigMap data rendered correctly via Maestro transport
  • Adds cl-template adapter config with standalone Go template e2e test for K8s transport
  • Fixes base_url: CHANGE_ME in cl-maestro adapter-config.yaml

Test plan

  • make build passes
  • make check passes (fmt, vet, lint, unit tests)
  • cl-maestro happy path e2e test passes — all 6 steps verified:
    • ManifestWork created on Maestro with conditional hyperfleet.io/platform-type: gcp label
    • K8s resources created with conditional environment: test ConfigMap data
    • Adapter status reported successfully (Applied, Available, Health)

Depends on: openshift-hyperfleet/hyperfleet-adapter#96

Relates to: HYPERFLEET-864

Summary by CodeRabbit

  • New Features

    • Support for multiple GCP subnets in cluster specs.
    • Conditional platform-type metadata labels and environment-aware templating in deployed manifests.
    • Generated manifests now include per-subnet entries rendered from subnet lists.
  • Tests

    • Expanded tests to validate template conditionals and range-based subnet rendering in manifest outputs.

@openshift-ci
Copy link
Copy Markdown

openshift-ci bot commented Apr 2, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign aredenba-rh 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 ciaranRoche and rafabene April 2, 2026 07:36
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 2, 2026

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

This pull request externalizes an inline ManifestWork into a separate templated manifest file, adds CEL preconditions to capture platformType, environment, and subnets, and updates test data/values to include the templated manifest. End-to-end tests were extended to assert rendered Go-template conditionals and range iterations: a conditional hyperfleet.io/platform-type label on the ManifestWork and environment/subnet-derived entries in the created ConfigMap.

Sequence Diagram(s)

sequenceDiagram
    participant TestClient as Test Client
    participant Adapter as Adapter
    participant Maestro as Maestro Transport
    participant Managed as Managed Cluster (K8s API)

    TestClient->>Adapter: create cluster with platform & labels
    Adapter->>Adapter: evaluate CEL preconditions (platformType, environment, subnets)
    Adapter->>Adapter: render manifest.ref template (ManifestWork with {{if}}/{{range}})
    Adapter->>Maestro: submit ManifestWork reference (resourceBundle)
    Maestro->>Managed: apply ManifestWork (Namespace + ConfigMap)
    Managed-->>Maestro: resource creation status & feedback (.status/.data)
    Maestro-->>Adapter: feedback rules/results (resourceVersion, data)
    Adapter-->>TestClient: test assertions validate conditional label and rendered ConfigMap entries
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main change: adding Go template conditional coverage to the cl-maestro e2e test, which aligns with the core modifications across test assertions, configuration files, and manifest work definitions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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.

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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@e2e/adapter/manifest_go_template.go`:
- Around line 75-76: The test reads the generated ConfigMap once with
h.GetConfigMap which can race with Kubernetes propagation; replace the single
read with a retry/assert-until-success pattern (e.g., use a polling loop or
Gomega's Eventually) that repeatedly calls h.GetConfigMap for
"template-test-"+clusterID until it succeeds or a timeout elapses, then assert
Expect(err).NotTo(HaveOccurred()) and use the returned cm for subsequent
assertions; update the block around h.GetConfigMap/Expect to perform the
retry/backoff to eliminate flakiness.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: de37bcba-1173-4486-8c10-ef7c1de57cc5

📥 Commits

Reviewing files that changed from the base of the PR and between faa2d6f and 95ef3fc.

📒 Files selected for processing (5)
  • e2e/adapter/manifest_go_template.go
  • testdata/adapter-configs/cl-template/adapter-config.yaml
  • testdata/adapter-configs/cl-template/adapter-task-config.yaml
  • testdata/adapter-configs/cl-template/adapter-task-resource-configmap.yaml
  • testdata/adapter-configs/cl-template/values.yaml

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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@testdata/adapter-configs/cl-template/adapter-task-resource-configmap.yaml`:
- Around line 4-20: The template references .clusterId, .clusterName, .testRunId
and .ci but the templateVars struct in pkg/client/payload.go only contains
Timestamp/TimestampMs/Random/UUID, so those fields render empty; fix by
extending templateVars to include ClusterID (string), ClusterName (string),
TestRunID (string or *string) and CI (bool or string) and ensure the code path
that builds/passes templateVars (the payload/template rendering callsite)
populates these fields from the cluster/test context before invoking
text/template execution; alternatively, if you prefer not to change payload.go,
refactor the YAML template to use only the existing
Timestamp/TimestampMs/Random/UUID fields and remove references to
.clusterId/.clusterName/.testRunId/.ci.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e6b65de3-540d-438e-b6c8-872dffaa353b

📥 Commits

Reviewing files that changed from the base of the PR and between 95ef3fc and 375f798.

📒 Files selected for processing (10)
  • e2e/adapter/adapter_with_maestro.go
  • e2e/adapter/manifest_go_template.go
  • testdata/adapter-configs/cl-maestro/adapter-config.yaml
  • testdata/adapter-configs/cl-maestro/adapter-task-config.yaml
  • testdata/adapter-configs/cl-maestro/adapter-task-resource-manifestwork.yaml
  • testdata/adapter-configs/cl-maestro/values.yaml
  • testdata/adapter-configs/cl-template/adapter-config.yaml
  • testdata/adapter-configs/cl-template/adapter-task-config.yaml
  • testdata/adapter-configs/cl-template/adapter-task-resource-configmap.yaml
  • testdata/adapter-configs/cl-template/values.yaml
✅ Files skipped from review due to trivial changes (6)
  • testdata/adapter-configs/cl-maestro/adapter-config.yaml
  • testdata/adapter-configs/cl-template/adapter-config.yaml
  • testdata/adapter-configs/cl-template/values.yaml
  • testdata/adapter-configs/cl-maestro/values.yaml
  • e2e/adapter/manifest_go_template.go
  • testdata/adapter-configs/cl-template/adapter-task-config.yaml

@xueli181114 xueli181114 changed the title HYPERFLEET-864 - test: add e2e test for Go template manifest refs HYPERFLEET-864 - test: add Go template conditional coverage to cl-maestro e2e test Apr 3, 2026
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: 2

🧹 Nitpick comments (1)
test-design/testcases/adapter-with-maestro-transport.md (1)

69-72: Add one non-test case if you want real else coverage.

The new payload only drives labels.environment: "test" and the expected result only checks "test", so this scenario proves the template containing {{ else }} parses, but not that the else branch renders. A second case with a non-test or missing label would close that gap.

Also applies to: 110-112, 275-278

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test-design/testcases/adapter-with-maestro-transport.md` around lines 69 -
72, Add a second test case in the adapter-with-maestro-transport.md test matrix
that drives a non-"test" environment (e.g., labels.environment: "prod" or omit
labels.environment) so the Go template conditional using {{ if eq .environment
"test" }} / {{ else }} exercises the else branch; update the expected result
assertions to verify the alternate ConfigMap data produced by the else branch
(or absence of the "test" value) and mirror this change for the other similar
scenarios referenced (the places exercising {{ else }} behavior).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@test-design/testcases/adapter-with-maestro-transport.md`:
- Around line 95-96: Update the precondition text that describes how the Adapter
task config captures fields so it reflects the actual source: change the
statement that `environment` is captured from the cluster spec to say it is
captured from `labels.environment` (as implemented in
testdata/adapter-configs/cl-maestro/adapter-task-config.yaml); ensure the bullet
(currently "Adapter task config captures `platformType`, `environment`, and
`subnets` from cluster spec via CEL expressions") is edited to mention
`environment` comes from `labels.environment` while keeping `platformType` and
`subnets` as from the cluster spec.

In `@testdata/adapter-configs/cl-maestro/adapter-task-resource-manifestwork.yaml`:
- Around line 29-31: The checked-in YAML contains unrendered Go-template control
blocks (e.g., the "{{ if .platformType }}" / "hyperfleet.io/platform-type"
lines) which break YAML parsing; either move this asset to a template-aware
location or change its filename/extension (for example to .tmpl, .tpl, or
.yaml.tmpl) so tools treat it as a template, or update your CI/lint config to
exclude this file from YAML validation; ensure references to the template
markers ({{ if .platformType }}, {{ end }}) remain intact so rendering still
works.

---

Nitpick comments:
In `@test-design/testcases/adapter-with-maestro-transport.md`:
- Around line 69-72: Add a second test case in the
adapter-with-maestro-transport.md test matrix that drives a non-"test"
environment (e.g., labels.environment: "prod" or omit labels.environment) so the
Go template conditional using {{ if eq .environment "test" }} / {{ else }}
exercises the else branch; update the expected result assertions to verify the
alternate ConfigMap data produced by the else branch (or absence of the "test"
value) and mirror this change for the other similar scenarios referenced (the
places exercising {{ else }} behavior).
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fb4a8e03-2143-4bee-8744-4847a7378761

📥 Commits

Reviewing files that changed from the base of the PR and between 375f798 and 8862621.

📒 Files selected for processing (5)
  • e2e/adapter/adapter_with_maestro.go
  • test-design/testcases/adapter-with-maestro-transport.md
  • testdata/adapter-configs/cl-maestro/adapter-task-config.yaml
  • testdata/adapter-configs/cl-maestro/adapter-task-resource-manifestwork.yaml
  • testdata/payloads/clusters/cluster-request.json
✅ Files skipped from review due to trivial changes (2)
  • testdata/payloads/clusters/cluster-request.json
  • e2e/adapter/adapter_with_maestro.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • testdata/adapter-configs/cl-maestro/adapter-task-config.yaml

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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@testdata/adapter-configs/cl-maestro/adapter-task-resource-manifestwork.yaml`:
- Around line 79-83: The manifest template expects a .subnets array but the
render context only includes platformType/environment; update the data passed
into manifest.ref so it includes a "subnets" slice with each element having id,
name, cidr, and role fields (matching the template's {{ range $i, $subnet :=
.subnets }} usage). Locate the code that constructs the render data for
manifest.ref (the same place you added platformType and environment) and add the
subnets list there so the template can emit subnet_{{ $subnet.id }}_name,
subnet_{{ $subnet.id }}_cidr, and subnet_{{ $subnet.id }}_role for the e2e
assertions in adapter_with_maestro.go.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: da74f1e9-fc44-4525-9591-c112c4a32bb2

📥 Commits

Reviewing files that changed from the base of the PR and between 8ad8204 and 6bb95f9.

📒 Files selected for processing (6)
  • e2e/adapter/adapter_with_maestro.go
  • test-design/testcases/adapter-with-maestro-transport.md
  • testdata/adapter-configs/cl-maestro/adapter-task-config.yaml
  • testdata/adapter-configs/cl-maestro/adapter-task-resource-manifestwork.yaml
  • testdata/adapter-configs/cl-maestro/values.yaml
  • testdata/payloads/clusters/cluster-request.json
✅ Files skipped from review due to trivial changes (3)
  • testdata/adapter-configs/cl-maestro/values.yaml
  • testdata/payloads/clusters/cluster-request.json
  • test-design/testcases/adapter-with-maestro-transport.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • e2e/adapter/adapter_with_maestro.go
  • testdata/adapter-configs/cl-maestro/adapter-task-config.yaml

@xueli181114
Copy link
Copy Markdown
Contributor Author

Re: CodeRabbit comment on adapter-task-resource-manifestwork.yaml:83 about subnets not being wired:

Not valid. The subnets capture is defined at lines 49-53 of adapter-task-config.yaml. All precondition captures are automatically available as template variables when rendering manifest.ref files — the adapter framework handles this. The e2e test passes with this configuration.

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