Skip to content

Commit

Permalink
test(scorecard): multi-namespace scorecard test for 3.0 (#773)
Browse files Browse the repository at this point in the history
* 3.0 multi-namespace scorecard test

* refractor testResources
  • Loading branch information
mwangggg authored Apr 5, 2024
1 parent 3fcbfab commit 461096c
Show file tree
Hide file tree
Showing 14 changed files with 286 additions and 159 deletions.
2 changes: 1 addition & 1 deletion api/v1beta1/cryostat_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ type JmxCacheOptions struct {
// Cryostat allows you to install Cryostat for a single namespace.
// It contains configuration options for controlling the Deployment of the Cryostat
// application and its related components.
// A ClusterCryostat or Cryostat instance must be created to instruct the operator
// A Cryostat instance must be created to instruct the operator
// to deploy the Cryostat application.
// +operator-sdk:csv:customresourcedefinitions:resources={{Deployment,v1},{Ingress,v1},{PersistentVolumeClaim,v1},{Secret,v1},{Service,v1},{Route,v1},{ConsoleLink,v1}}
// +kubebuilder:printcolumn:name="Application URL",type=string,JSONPath=`.status.applicationUrl`
Expand Down
6 changes: 3 additions & 3 deletions bundle/manifests/cryostat-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ metadata:
capabilities: Seamless Upgrades
categories: Monitoring, Developer Tools
containerImage: quay.io/cryostat/cryostat-operator:3.0.0-dev
createdAt: "2024-03-27T18:30:58Z"
createdAt: "2024-04-04T17:19:02Z"
description: JVM monitoring and profiling tool
operatorframework.io/initialization-resource: |-
{
Expand Down Expand Up @@ -85,8 +85,8 @@ spec:
owned:
- description: Cryostat allows you to install Cryostat for a single namespace.
It contains configuration options for controlling the Deployment of the Cryostat
application and its related components. A ClusterCryostat or Cryostat instance
must be created to instruct the operator to deploy the Cryostat application.
application and its related components. A Cryostat instance must be created
to instruct the operator to deploy the Cryostat application.
displayName: Cryostat
kind: Cryostat
name: cryostats.operator.cryostat.io
Expand Down
5 changes: 2 additions & 3 deletions bundle/manifests/operator.cryostat.io_cryostats.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ spec:
openAPIV3Schema:
description: Cryostat allows you to install Cryostat for a single namespace.
It contains configuration options for controlling the Deployment of the
Cryostat application and its related components. A ClusterCryostat or Cryostat
instance must be created to instruct the operator to deploy the Cryostat
application.
Cryostat application and its related components. A Cryostat instance must
be created to instruct the operator to deploy the Cryostat application.
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
Expand Down
20 changes: 15 additions & 5 deletions bundle/tests/scorecard/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ stages:
- entrypoint:
- cryostat-scorecard-tests
- operator-install
image: quay.io/cryostat/cryostat-operator-scorecard:3.0.0-20240327182927
image: quay.io/cryostat/cryostat-operator-scorecard:3.0.0-20240404165315
labels:
suite: cryostat
test: operator-install
Expand All @@ -80,17 +80,27 @@ stages:
- entrypoint:
- cryostat-scorecard-tests
- cryostat-cr
image: quay.io/cryostat/cryostat-operator-scorecard:3.0.0-20240327182927
image: quay.io/cryostat/cryostat-operator-scorecard:3.0.0-20240404165315
labels:
suite: cryostat
test: cryostat-cr
storage:
spec:
mountPath: {}
- entrypoint:
- cryostat-scorecard-tests
- cryostat-multi-namespace
image: quay.io/cryostat/cryostat-operator-scorecard:3.0.0-20240404165315
labels:
suite: cryostat
test: cryostat-multi-namespace
storage:
spec:
mountPath: {}
- entrypoint:
- cryostat-scorecard-tests
- cryostat-recording
image: quay.io/cryostat/cryostat-operator-scorecard:3.0.0-20240327182927
image: quay.io/cryostat/cryostat-operator-scorecard:3.0.0-20240404165315
labels:
suite: cryostat
test: cryostat-recording
Expand All @@ -100,7 +110,7 @@ stages:
- entrypoint:
- cryostat-scorecard-tests
- cryostat-config-change
image: quay.io/cryostat/cryostat-operator-scorecard:3.0.0-20240327182927
image: quay.io/cryostat/cryostat-operator-scorecard:3.0.0-20240404165315
labels:
suite: cryostat
test: cryostat-config-change
Expand All @@ -110,7 +120,7 @@ stages:
- entrypoint:
- cryostat-scorecard-tests
- cryostat-report
image: quay.io/cryostat/cryostat-operator-scorecard:3.0.0-20240327182927
image: quay.io/cryostat/cryostat-operator-scorecard:3.0.0-20240404165315
labels:
suite: cryostat
test: cryostat-report
Expand Down
5 changes: 2 additions & 3 deletions config/crd/bases/operator.cryostat.io_cryostats.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ spec:
openAPIV3Schema:
description: Cryostat allows you to install Cryostat for a single namespace.
It contains configuration options for controlling the Deployment of the
Cryostat application and its related components. A ClusterCryostat or Cryostat
instance must be created to instruct the operator to deploy the Cryostat
application.
Cryostat application and its related components. A Cryostat instance must
be created to instruct the operator to deploy the Cryostat application.
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,8 @@ spec:
version: v1beta2
- description: Cryostat allows you to install Cryostat for a single namespace.
It contains configuration options for controlling the Deployment of the Cryostat
application and its related components. A ClusterCryostat or Cryostat instance
must be created to instruct the operator to deploy the Cryostat application.
application and its related components. A Cryostat instance must be created
to instruct the operator to deploy the Cryostat application.
displayName: Cryostat
kind: Cryostat
name: cryostats.operator.cryostat.io
Expand Down
20 changes: 15 additions & 5 deletions config/scorecard/patches/custom.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
entrypoint:
- cryostat-scorecard-tests
- operator-install
image: "quay.io/cryostat/cryostat-operator-scorecard:3.0.0-20240327182927"
image: "quay.io/cryostat/cryostat-operator-scorecard:3.0.0-20240404171904"
labels:
suite: cryostat
test: operator-install
Expand All @@ -18,17 +18,27 @@
entrypoint:
- cryostat-scorecard-tests
- cryostat-cr
image: "quay.io/cryostat/cryostat-operator-scorecard:3.0.0-20240327182927"
image: "quay.io/cryostat/cryostat-operator-scorecard:3.0.0-20240404171904"
labels:
suite: cryostat
test: cryostat-cr
- op: add
path: /stages/1/tests/-
value:
entrypoint:
- cryostat-scorecard-tests
- cryostat-multi-namespace
image: "quay.io/cryostat/cryostat-operator-scorecard:3.0.0-20240404171904"
labels:
suite: cryostat
test: cryostat-multi-namespace
- op: add
path: /stages/1/tests/-
value:
entrypoint:
- cryostat-scorecard-tests
- cryostat-recording
image: "quay.io/cryostat/cryostat-operator-scorecard:3.0.0-20240327182927"
image: "quay.io/cryostat/cryostat-operator-scorecard:3.0.0-20240404171904"
labels:
suite: cryostat
test: cryostat-recording
Expand All @@ -38,7 +48,7 @@
entrypoint:
- cryostat-scorecard-tests
- cryostat-config-change
image: "quay.io/cryostat/cryostat-operator-scorecard:3.0.0-20240327182927"
image: "quay.io/cryostat/cryostat-operator-scorecard:3.0.0-20240404171904"
labels:
suite: cryostat
test: cryostat-config-change
Expand All @@ -48,7 +58,7 @@
entrypoint:
- cryostat-scorecard-tests
- cryostat-report
image: "quay.io/cryostat/cryostat-operator-scorecard:3.0.0-20240327182927"
image: "quay.io/cryostat/cryostat-operator-scorecard:3.0.0-20240404171904"
labels:
suite: cryostat
test: cryostat-report
10 changes: 10 additions & 0 deletions hack/custom.config.yaml.in
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@
labels:
suite: cryostat
test: cryostat-cr
- op: add
path: /stages/1/tests/-
value:
entrypoint:
- cryostat-scorecard-tests
- cryostat-multi-namespace
image: "${CUSTOM_SCORECARD_IMG}"
labels:
suite: cryostat
test: cryostat-multi-namespace
- op: add
path: /stages/1/tests/-
value:
Expand Down
4 changes: 4 additions & 0 deletions internal/images/custom-scorecard-tests/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func printValidTests() []scapiv1alpha3.TestResult {
str := fmt.Sprintf("valid tests for this image include: %s", strings.Join([]string{
tests.OperatorInstallTestName,
tests.CryostatCRTestName,
tests.CryostatMultiNamespaceTestName,
tests.CryostatRecordingTestName,
tests.CryostatConfigChangeTestName,
tests.CryostatReportTestName,
Expand All @@ -93,6 +94,7 @@ func validateTests(testNames []string) bool {
switch testName {
case tests.OperatorInstallTestName:
case tests.CryostatCRTestName:
case tests.CryostatMultiNamespaceTestName:
case tests.CryostatRecordingTestName:
case tests.CryostatConfigChangeTestName:
case tests.CryostatReportTestName:
Expand All @@ -114,6 +116,8 @@ func runTests(testNames []string, bundle *apimanifests.Bundle, namespace string,
results = append(results, *tests.OperatorInstallTest(bundle, namespace, openShiftCertManager))
case tests.CryostatCRTestName:
results = append(results, *tests.CryostatCRTest(bundle, namespace, openShiftCertManager))
case tests.CryostatMultiNamespaceTestName:
results = append(results, *tests.CryostatMultiNamespaceTest(bundle, namespace, openShiftCertManager))
case tests.CryostatRecordingTestName:
results = append(results, *tests.CryostatRecordingTest(bundle, namespace, openShiftCertManager))
case tests.CryostatConfigChangeTestName:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,12 @@ rules:
- namespaces
verbs:
- create
- delete
- apiGroups:
- operator.cryostat.io
resources:
- cryostats
verbs:
- create
- delete
- get
18 changes: 9 additions & 9 deletions internal/test/scorecard/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"strings"
"time"

operatorv1beta1 "github.com/cryostatio/cryostat-operator/api/v1beta1"
operatorv1beta2 "github.com/cryostatio/cryostat-operator/api/v1beta2"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/serializer"
Expand Down Expand Up @@ -101,10 +101,10 @@ func newOperatorCRDClient(config *rest.Config) (*OperatorCRDClient, error) {

func newCRDClient(config *rest.Config) (*rest.RESTClient, error) {
scheme := runtime.NewScheme()
if err := operatorv1beta1.AddToScheme(scheme); err != nil {
if err := operatorv1beta2.AddToScheme(scheme); err != nil {
return nil, err
}
return newRESTClientForGV(config, scheme, &operatorv1beta1.GroupVersion)
return newRESTClientForGV(config, scheme, &operatorv1beta2.GroupVersion)
}

func newRESTClientForGV(config *rest.Config, scheme *runtime.Scheme, gv *schema.GroupVersion) (*rest.RESTClient, error) {
Expand All @@ -125,18 +125,18 @@ type CryostatClient struct {
}

// Get returns a Cryostat CR for the given name
func (c *CryostatClient) Get(ctx context.Context, name string) (*operatorv1beta1.Cryostat, error) {
return get(ctx, c.restClient, c.resource, c.namespace, name, &operatorv1beta1.Cryostat{})
func (c *CryostatClient) Get(ctx context.Context, name string) (*operatorv1beta2.Cryostat, error) {
return get(ctx, c.restClient, c.resource, c.namespace, name, &operatorv1beta2.Cryostat{})
}

// Create creates the provided Cryostat CR
func (c *CryostatClient) Create(ctx context.Context, obj *operatorv1beta1.Cryostat) (*operatorv1beta1.Cryostat, error) {
return create(ctx, c.restClient, c.resource, c.namespace, obj, &operatorv1beta1.Cryostat{})
func (c *CryostatClient) Create(ctx context.Context, obj *operatorv1beta2.Cryostat) (*operatorv1beta2.Cryostat, error) {
return create(ctx, c.restClient, c.resource, c.namespace, obj, &operatorv1beta2.Cryostat{})
}

// Update updates the provided Cryostat CR
func (c *CryostatClient) Update(ctx context.Context, obj *operatorv1beta1.Cryostat) (*operatorv1beta1.Cryostat, error) {
return update(ctx, c.restClient, c.resource, c.namespace, obj, &operatorv1beta1.Cryostat{}, obj.Name)
func (c *CryostatClient) Update(ctx context.Context, obj *operatorv1beta2.Cryostat) (*operatorv1beta2.Cryostat, error) {
return update(ctx, c.restClient, c.resource, c.namespace, obj, &operatorv1beta2.Cryostat{}, obj.Name)
}

// Delete deletes the Cryostat CR with the given name
Expand Down
Loading

0 comments on commit 461096c

Please sign in to comment.