Skip to content

Commit

Permalink
Fix tests and add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
thegridman committed Jul 9, 2024
1 parent b51de99 commit d214eb7
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
19 changes: 19 additions & 0 deletions docs/installation/01_installation.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ easily be installed into a Kubernetes cluster.
*** <<helm-sec-context,Install the Operator with a Security Context>>
*** <<helm-labels,Set Additional Labels>>
*** <<helm-annotations,Set Additional Annotations>>
*** <<helm-job,CoherenceJob CRD Support>>
*** <<helm-uninstall,Uninstall the Coherence Operator Helm chart>>
** <<kubectl,Kubectl with Kustomize>>
** <<tanzu,VMWare Tanzu Package (kapp-controller)>>
Expand Down Expand Up @@ -637,6 +638,24 @@ deploymentAnnotations:
two: value-two
----
[#helm-job]
=== CoherenceJob CRD Support
By default, the Operator will install both CRDs, `Coherence` and `CoherenceJob`.
If support for `CoherenceJob` is not required then it can be excluded from being installed setting the
Operator command line parameter `--install-job-crd` to `false`.
When installing with Helm, the `allowCoherenceJobs` value can be set to `false` to disable support for `CoherenceJob`
resources (the default value is `true`).
[source,bash]
----
helm install \
--namespace <namespace> \
--set allowCoherenceJobs=false \
coherence \
coherence/coherence-operator
----
[#helm-uninstall]
=== Uninstall the Coherence Operator Helm chart
Expand Down
42 changes: 41 additions & 1 deletion pkg/operator/operator_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2023, Oracle and/or its affiliates.
* Copyright (c) 2019, 2024, Oracle and/or its affiliates.
* Licensed under the Universal Permissive License v 1.0 as shown at
* http://oss.oracle.com/licenses/upl.
*/
Expand All @@ -12,6 +12,8 @@ import (
. "github.com/onsi/gomega"
v1 "github.com/oracle/coherence-operator/api/v1"
"github.com/oracle/coherence-operator/pkg/fakes"
"github.com/oracle/coherence-operator/pkg/operator"
"github.com/spf13/viper"
crdv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
"testing"
)
Expand All @@ -29,6 +31,7 @@ func TestShouldCreateV1CRDs(t *testing.T) {
ctx := context.TODO()
log := logr.New(fakes.TestLogSink{T: t})

viper.GetViper().Set(operator.FlagJobCRD, true)
err = v1.EnsureV1CRDs(ctx, log, mgr.Scheme, mgr.Client)
g.Expect(err).NotTo(HaveOccurred())

Expand All @@ -53,6 +56,43 @@ func TestShouldCreateV1CRDs(t *testing.T) {
}
}

func TestShouldNotCreateJobCRDWhenFlagIsFalse(t *testing.T) {
var err error

g := NewGomegaWithT(t)
mgr, err := fakes.NewFakeManager()
g.Expect(err).NotTo(HaveOccurred())

err = crdv1.AddToScheme(mgr.Scheme)
g.Expect(err).NotTo(HaveOccurred())

ctx := context.TODO()
log := logr.New(fakes.TestLogSink{T: t})

viper.GetViper().Set(operator.FlagJobCRD, false)
err = v1.EnsureV1CRDs(ctx, log, mgr.Scheme, mgr.Client)
g.Expect(err).NotTo(HaveOccurred())

crdList := crdv1.CustomResourceDefinitionList{}
err = mgr.Client.List(ctx, &crdList)
g.Expect(err).NotTo(HaveOccurred())

g.Expect(len(crdList.Items)).To(Equal(1))

expected := make(map[string]bool)
expected["coherence.coherence.oracle.com"] = false

for _, crd := range crdList.Items {
expected[crd.Name] = true
}

for crd, found := range expected {
if !found {
t.Errorf("Failed to create CRD " + crd)
}
}
}

func TestShouldUpdateV1CRDs(t *testing.T) {
var err error

Expand Down

0 comments on commit d214eb7

Please sign in to comment.