deployment-operator

module
v0.6.72 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2026 License: AGPL-3.0, Apache-2.0, MIT

README

Deployment Operator

Integration Testing

Every PR should be fully e2e tested on a realistic cluster. The simplest mechanism to do this is to:

  1. Grab the image tag that was created from your pr, should be here: https://github.com/pluralsh/deployment-operator/pkgs/container/deployment-operator
  2. Find a safe test cluster in a Plural Console, go to its deploy-operator service, and add a tag secret pointing to that tag. (note this is defined in charts/deployment-operator/values.yaml.liquid)
  3. Virtually all deployment-operator derived functionality will now derive from that tag, including stacks, sentinels and agent runtime runs.

Helm Chart Tests

To test that the deployment-operator Helm chart can be successfully installed, run:

./test/helm/test-chart-install.sh

This script will:

  1. Create a temporary Kind cluster
  2. Validate the chart using helm lint
  3. Verify template rendering with helm template
  4. Perform a dry-run installation with helm install --dry-run
  5. Automatically clean up the cluster when the test completes

See test/helm/README.md for more details.

Unit Tests

Pre Reqs

Ensure that the cluster in your current kube context is reachable

Helm tests will run against this cluster You can test with:

kubectl cluster-info
Install dependencies with make
make tools
Setup Environment

Set the KUBEBUILDER_ASSETS directory

# Mac
export KUBEBUILDER_ASSETS=${GOBIN}/k8s/1.28.3-darwin-arm64

# Linux
export KUBEBUILDER_ASSETS=${GOBIN}/k8s/1.28.3-linux-amd64

Running Unit Tests

make test

Adding Tests

Reference the Ginkgo Getting Started to see the expected structure

Install the Ginkgo CLI
go install github.com/onsi/ginkgo/v2/ginkgo
The Test Suites for several Packages are already Generated in the Deployment-Operator Repo

If creating a new package or testing a package that doesn't already have a test suite

cd pkg/package/that/needs/suite
ginkgo bootstrap
Generate A Basic test

I'm creating a test for ./pkg/manifests/template/tpl.go

cd ./pkg/manifests/template
ginkgo generate tpl

example output

Generating ginkgo test for Tpl in:
  tpl_test.go

It generates: ./pkg/manifests/template/tpl_test.go

# ./pkg/manifests/template/tpl_test.go
package template_test

import (
	. "github.com/onsi/ginkgo/v2"
	. "github.com/onsi/gomega"

	"github.com/pluralsh/deployment-operator/pkg/manifests/template"
)

var _ = Describe("Tpl", func() {

})

From here you can begin adding specs (test) to your generated file
# ./pkg/manifests/template/tpl_test.go
var _ = Describe("Tpl", func() {

	Context("Example Test", func() {
		It("Should always Pass", func() {
			Expect(1).To(Equal(1))
		})
	})

    Context("Test Should Fail for example output", func() {
		It("Should always fail", func() {
			Expect(1).To(Equal(2))
		})
	})

})
Run the Suite with your New Test

I'm doing this here just for an example and to check that my tests are bing added to the Suite


make test
# ... other output

[GIN-debug] GET    /version                  --> github.com/pluralsh/deployment-operator/pkg/manifests/template.init.func1.1 (3 handlers)
Running Suite: Controller Suite - /Users/kjj/git/plrl/deployment-operator/pkg/manifests/template
================================================================================================
Random Seed: 1715288079

Will run 6 of 6 specs
# Warning: 'bases' is deprecated. Please use 'resources' instead. Run 'kustomize edit fix' to update your Kustomization automatically.
# Warning: 'patchesStrategicMerge' is deprecated. Please use 'patches' instead. Run 'kustomize edit fix' to update your Kustomization automatically.
••
------------------------------
• [FAILED] [0.000 seconds]
Tpl Test Should Fail for example output [It] Should always Fail
/Users/kjj/git/plrl/deployment-operator/pkg/manifests/template/tpl_test.go:17

  [FAILED] Expected
      <int>: 1
  to equal
      <int>: 2
  In [It] at: /Users/kjj/git/plrl/deployment-operator/pkg/manifests/template/tpl_test.go:18 @ 05/09/24 16:54:41.29
------------------------------
2024/05/09 16:54:41 render helm templates: enable dependency update= false dependencies= 0
Found unknown types unknown resource types: apiextensions.k8s.io/v1/CustomResourceDefinition,apiextensions.k8s.io/v1/CustomResourceDefinition, ignoring for now2024/05/09 16:54:41 Server exiting
•••

Summarizing 1 Failure:
  [FAIL] Tpl Test Should Fail for example output [It] Should always Fail
  /Users/kjj/git/plrl/deployment-operator/pkg/manifests/template/tpl_test.go:18

Ran 6 of 6 Specs in 2.810 seconds
FAIL! -- 5 Passed | 1 Failed | 0 Pending | 0 Skipped
--- FAIL: TestControllers (2.81s)
FAIL
FAIL    github.com/pluralsh/deployment-operator/pkg/manifests/template  3.421s
FAIL
make: *** [test] Error 1

Directories

Path Synopsis
api
v1alpha1
Package v1alpha1 contains API Schema definitions for the deployments v1alpha1 API group +kubebuilder:object:generate=true +groupName=deployments.plural.sh
Package v1alpha1 contains API Schema definitions for the deployments v1alpha1 API group +kubebuilder:object:generate=true +groupName=deployments.plural.sh
cmd
agent command
agent-bootstrap command
agent-harness command
harness command
mcpserver/agent command
internal
pkg
agentrun-harness/attachments
Package attachments downloads files attached to an agent run or its prompts and describes them to the coding agent.
Package attachments downloads files attached to an agent run or its prompts and describes them to the coding agent.
agentrun-harness/tool/acp
Package acp contains the provider-neutral Agent Client Protocol engine.
Package acp contains the provider-neutral Agent Client Protocol engine.
agentrun-harness/tool/pi
Package pi implements the Pi coding-agent runtime for the agent harness.
Package pi implements the Pi coding-agent runtime for the agent harness.
insightpriority
Package insightpriority evaluates the CustomInsightPriority scripts that override the built-in priority of failing objects in the cluster insights and the cluster health score.
Package insightpriority evaluates the CustomInsightPriority scripts that override the built-in priority of failing objects in the cluster insights and the cluster health score.
log
lua
python
Package python executes the user-provided Python used by Helm value templating.
Package python executes the user-provided Python used by Helm value templating.
scm

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL