Skip to content

Conversation

@evakhoni
Copy link
Contributor

@evakhoni evakhoni commented Dec 23, 2025

follow-up #202: operator: sensible defaults to allow minimal configuration Jumpstarter resource creation.
this PR is adding unit test coverage

Coverage

ApplyEndpointDefaults function:

  • Verifies that endpoint generation is skipped when baseDomain is empty
  • Ensures correct generation of controller GRPC endpoints, prioritizing Route, then Ingress, and falling back to ClusterIP based on cluster capabilities
  • Confirms that router GRPC endpoints are generated with the $(replica) placeholder
  • Validates that existing endpoints are not overridden
  • Ensures that existing endpoints, if they lack a specified service type, are automatically assigned one based on cluster capabilities

ensureEndpointServiceType helper function:

  • Tests that the function does not modify an endpoint if a service type is already explicitly enabled
  • Verifies the auto-selection logic: Route is preferred when available, otherwise Ingress is selected if available, and ClusterIP is used as a final fallback

Summary by CodeRabbit

  • Tests
    • Added comprehensive tests for endpoint defaulting and service-type selection, covering baseDomain handling, controller/router endpoint generation (including replica placeholders), non-overwrite of existing endpoints, and correct fallback to Route → Ingress → ClusterIP.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 23, 2025

Walkthrough

Adds a new Go test file that validates ApplyEndpointDefaults and ensureEndpointServiceType behaviors, including baseDomain handling, controller/router/ingress/clusterIP selection, replica placeholder usage, and preservation of existing service types.

Changes

Cohort / File(s) Change Summary
Endpoint defaults tests
deploy/operator/internal/controller/jumpstarter/endpoints/defaults_test.go
Added Ginkgo/Gomega unit tests for ApplyEndpointDefaults and ensureEndpointServiceType, covering: skip when baseDomain empty; controller endpoint generation via Route or Ingress; fallback to ClusterIP; router endpoint uses $(replica) placeholder; do-not-override existing endpoints; service-type precedence (Route → Ingress → ClusterIP).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • mangelajo

Pre-merge checks and finishing touches

✅ 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 accurately and concisely summarizes the main change—adding test coverage for the ApplyEndpointDefaults function.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 64fb2d9 and 7373ba3.

📒 Files selected for processing (1)
  • deploy/operator/internal/controller/jumpstarter/endpoints/defaults_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • deploy/operator/internal/controller/jumpstarter/endpoints/defaults_test.go
⏰ 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). (7)
  • GitHub Check: deploy-kind
  • GitHub Check: e2e-test-operator
  • GitHub Check: tests
  • GitHub Check: lint-go
  • GitHub Check: e2e-tests-release-0-7
  • GitHub Check: e2e-tests (ubuntu-24.04)
  • GitHub Check: e2e-tests (ubuntu-24.04-arm)

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.

@evakhoni evakhoni changed the title operator: add ApplyEndpointDefaults tests operator: test coverage for ApplyEndpointDefaults Dec 23, 2025
Copy link
Contributor

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

🧹 Nitpick comments (1)
deploy/operator/internal/controller/jumpstarter/endpoints/defaults_test.go (1)

70-77: Consider verifying the router endpoint's service type as well.

The test correctly verifies the $(replica) placeholder in the address, but based on the source code (defaults.go), the router endpoint should also receive a service type via ensureEndpointServiceType. Consider adding an assertion to verify that the router endpoint gets the expected service type (Route in this case).

💡 Suggested enhancement
 		It("should generate router endpoint with $(replica) placeholder", func() {
 			spec := &operatorv1alpha1.JumpstarterSpec{BaseDomain: "example.com"}
 
 			ApplyEndpointDefaults(spec, true, true)
 
 			Expect(spec.Routers.GRPC.Endpoints).To(HaveLen(1))
 			Expect(spec.Routers.GRPC.Endpoints[0].Address).To(Equal("router-$(replica).example.com"))
+			Expect(spec.Routers.GRPC.Endpoints[0].Route).NotTo(BeNil())
+			Expect(spec.Routers.GRPC.Endpoints[0].Route.Enabled).To(BeTrue())
 		})
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ccb8e17 and 64fb2d9.

📒 Files selected for processing (1)
  • deploy/operator/internal/controller/jumpstarter/endpoints/defaults_test.go
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: NickCao
Repo: jumpstarter-dev/jumpstarter-controller PR: 137
File: hack/deploy_with_helm.sh:26-34
Timestamp: 2025-05-13T19:57:56.811Z
Learning: The jumpstarter project uses a custom kind cluster configuration with an expanded NodePort range (3000-32767) and explicit port mappings for ingress (5080/5443) and gRPC services (30010/30011 mapped to 8082/8083).
Learnt from: mangelajo
Repo: jumpstarter-dev/jumpstarter-controller PR: 170
File: deploy/operator/internal/controller/jumpstarter/jumpstarter_controller.go:328-333
Timestamp: 2025-10-24T11:57:23.796Z
Learning: In the jumpstarter-controller operator (deploy/operator/), the design allows only one Jumpstarter CR per namespace, which will be enforced by a validation webhook. This constraint eliminates concerns about resource name collisions within a namespace.
Learnt from: NickCao
Repo: jumpstarter-dev/jumpstarter-controller PR: 137
File: hack/deploy_with_helm.sh:26-34
Timestamp: 2025-05-13T19:57:56.811Z
Learning: The jumpstarter-dev repository uses a custom kind cluster configuration that allows NodePort services to use non-standard ports 5080 and 5443, outside the default Kubernetes NodePort range (30000-32767).
🧬 Code graph analysis (1)
deploy/operator/internal/controller/jumpstarter/endpoints/defaults_test.go (2)
deploy/operator/api/v1alpha1/jumpstarter_types.go (5)
  • JumpstarterSpec (130-156)
  • ControllerConfig (195-234)
  • GRPCConfig (248-264)
  • ClusterIPConfig (503-515)
  • NodePortConfig (458-477)
deploy/operator/internal/controller/jumpstarter/endpoints/defaults.go (1)
  • ApplyEndpointDefaults (51-85)
⏰ 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). (7)
  • GitHub Check: e2e-tests (ubuntu-24.04-arm)
  • GitHub Check: e2e-test-operator
  • GitHub Check: e2e-tests-release-0-7
  • GitHub Check: e2e-tests (ubuntu-24.04)
  • GitHub Check: tests
  • GitHub Check: deploy-kind
  • GitHub Check: lint-go
🔇 Additional comments (4)
deploy/operator/internal/controller/jumpstarter/endpoints/defaults_test.go (4)

1-24: LGTM! Clean test setup.

The imports are appropriate and the use of Ginkgo/Gomega is idiomatic for this testing framework.


26-78: Well-structured tests with comprehensive coverage.

The test cases properly cover:

  • Empty baseDomain skip logic
  • Service type selection hierarchy (Route → Ingress → ClusterIP)
  • Router endpoint placeholder format

The tests are clear and verify the expected behavior accurately.


80-117: Excellent coverage of existing endpoint scenarios.

These tests properly verify:

  • Preservation of user-defined endpoints
  • Automatic service type assignment for endpoints without one

The assertions correctly validate the expected behavior.


120-163: Comprehensive testing of service type selection logic.

The test suite thoroughly covers:

  • Preservation of existing service types (NodePort example)
  • Automatic selection hierarchy: Route → Ingress → ClusterIP
  • All three fallback scenarios

The tests accurately verify the expected behavior and edge cases.

@evakhoni
Copy link
Contributor Author

@CodeRabbit please assign reviewers mangelajo bkhizgiy bennyz

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 23, 2025

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Add reviewers to PR #205
gh pr edit 205 --add-reviewer mangelajo,bkhizgiy,bennyz

Length of output: 252


@evakhoni I'm unable to assign reviewers programmatically due to workflow restrictions. You'll need to add the reviewers mangelajo, bkhizgiy, and bennyz manually through the GitHub UI:

  1. Go to the pull request page
  2. Click on "Reviewers" in the right sidebar
  3. Search for and select each reviewer

Alternatively, if you have repository admin access, you can configure the necessary permissions to allow me to manage reviewers through the GitHub CLI.

@evakhoni
Copy link
Contributor Author

evakhoni commented Dec 23, 2025

thanks @bennyz
seems I cannot add reviewers myself either in this repo. any ideas how I can get those permissions too? or should we allow the bunny to do it wdyt?

@evakhoni evakhoni force-pushed the test-operator-endpoint-defaults branch from 64fb2d9 to 7373ba3 Compare December 23, 2025 10:14
@evakhoni
Copy link
Contributor Author

End-to-end tests / e2e-tests-release-0-7 (pull_request) failure seems unrelated:

Error: INSTALLATION FAILED: Get "https://github.com/dexidp/helm-charts/releases/download/dex-0.24.0/dex-0.24.0.tgz": 
context deadline exceeded (Client.Timeout exceeded while awaiting headers)

@coderabbitai how can we rerun this pipeline?

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 23, 2025

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

@evakhoni You're correct that the failure is unrelated to your changes—it's a network timeout while fetching an external Helm chart.

You can rerun the workflow using the GitHub CLI:

Alternatively, you can rerun it through the GitHub UI:

  1. Go to the workflow run page
  2. Click the "Re-run jobs" button in the upper right
  3. Select "Re-run failed jobs" or "Re-run all jobs"

The --failed flag will only rerun the jobs that failed, which is more efficient than rerunning the entire workflow.


🏁 Script executed:

#!/bin/bash
# Rerun the failed workflow
gh run rerun 20463354452 --failed

Length of output: 71


@evakhoni I don't have the necessary permissions to rerun workflows programmatically. This is a GitHub API restriction—my integration token lacks the actions:write scope required to trigger workflow reruns.

You have two options:

Option 1: Use the GitHub UI (easiest)

  1. Go to the workflow run page
  2. Click the "Re-run jobs" button (top right corner)
  3. Select "Re-run failed jobs"

Option 2: Use your own GitHub CLI
If you have gh installed and authenticated, run:

gh run rerun 20463354452 --failed

This will work with your personal credentials.

Since you mentioned earlier that you also lack certain repository permissions (like assigning reviewers), you may want to reach out to a repository maintainer (like @mangelajo or @bennyz) to either rerun the workflow or grant you the necessary permissions for managing PRs in this repository.

@evakhoni
Copy link
Contributor Author

Since you mentioned earlier that you also lack certain repository permissions (like assigning reviewers), you may want to reach out to a repository maintainer (like @mangelajo or @bennyz) to either rerun the workflow or grant you the necessary permissions for managing PRs in this repository.

indeed 🤷‍♂️

run 20463354452 cannot be rerun; Must have admin rights to Repository.

@bennyz to the rescue ;)

@bennyz bennyz merged commit 133c015 into jumpstarter-dev:main Dec 24, 2025
12 of 13 checks passed
@evakhoni evakhoni deleted the test-operator-endpoint-defaults branch December 24, 2025 06:05
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