Skip to content

Commit

Permalink
cryostat-cr-config test
Browse files Browse the repository at this point in the history
  • Loading branch information
mwangggg committed Mar 1, 2024
1 parent 7f28779 commit 364d5db
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 8 deletions.
10 changes: 10 additions & 0 deletions bundle/tests/scorecard/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@ stages:
storage:
spec:
mountPath: {}
- entrypoint:
- cryostat-scorecard-tests
- cryostat-cr-config
image: quay.io/cryostat/cryostat-operator-scorecard:2.5.0-20231011144522
labels:
suite: cryostat
test: cryostat-cr-config
storage:
spec:
mountPath: {}
storage:
spec:
mountPath: {}
15 changes: 13 additions & 2 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:2.5.0-20231011144522"
image: "quay.io/miwan/cryostat-operator-scorecard:2.5.0-20240301165219"
labels:
suite: cryostat
test: operator-install
Expand All @@ -18,7 +18,18 @@
entrypoint:
- cryostat-scorecard-tests
- cryostat-cr
image: "quay.io/cryostat/cryostat-operator-scorecard:2.5.0-20231011144522"
image: "quay.io/miwan/cryostat-operator-scorecard:2.5.0-20240301165219"
labels:
suite: cryostat
test: cryostat-cr
- op: add
path: /stages/0/tests/-
value:
entrypoint:
- cryostat-scorecard-tests
- cryostat-cr-config
image: "quay.io/miwan/cryostat-operator-scorecard:2.5.0-20240301165219"
labels:
suite: cryostat
test: cryostat-cr-config

11 changes: 11 additions & 0 deletions hack/custom.config.yaml.in
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,14 @@
labels:
suite: cryostat
test: cryostat-cr
- op: add
path: /stages/0/tests/-
value:
entrypoint:
- cryostat-scorecard-tests
- cryostat-cr-config
image: "${CUSTOM_SCORECARD_IMG}"
labels:
suite: cryostat
test: cryostat-cr-config

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.CryostatCRConfigTestName,
}, ","))
result.Errors = append(result.Errors, str)

Expand All @@ -90,6 +91,7 @@ func validateTests(testNames []string) bool {
switch testName {
case tests.OperatorInstallTestName:
case tests.CryostatCRTestName:
case tests.CryostatCRConfigTestName:
default:
return false
}
Expand All @@ -108,6 +110,8 @@ func runTests(testNames []string, bundle *apimanifests.Bundle, namespace string,
results = append(results, tests.OperatorInstallTest(bundle, namespace))
case tests.CryostatCRTestName:
results = append(results, tests.CryostatCRTest(bundle, namespace, openShiftCertManager))
case tests.CryostatCRConfigTestName:
results = append(results, tests.CryostatCRConfigTest(bundle, namespace, openShiftCertManager))
default:
log.Fatalf("unknown test found: %s", testName)
}
Expand Down
13 changes: 7 additions & 6 deletions internal/test/scorecard/tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ import (
)

const (
OperatorInstallTestName string = "operator-install"
CryostatCRTestName string = "cryostat-cr"
OperatorInstallTestName string = "operator-install"
CryostatCRTestName string = "cryostat-cr"
CryostatCRConfigTestName string = "cryostat-cr-config"
)

// OperatorInstallTest checks that the operator installed correctly
Expand Down Expand Up @@ -73,10 +74,12 @@ func CryostatCRTest(bundle *apimanifests.Bundle, namespace string, openShiftCert
return *r
}

func CryostatCRConfigChangeTest(bundle *apimanifests.Bundle, namespace string, openShiftCertManager bool) scapiv1alpha3.TestResult {
tr := newTestResources(CryostatCRTestName)
// CryostatCRConfigTest checks that CryostatCR redeployment due to config changes are successful
func CryostatCRConfigTest(bundle *apimanifests.Bundle, namespace string, openShiftCertManager bool) scapiv1alpha3.TestResult {
tr := newTestResources(CryostatCRConfigTestName)
r := tr.TestResult
client := tr.Client
ctx := context.Background()

err := setupCRTestResources(tr, openShiftCertManager)
if err != nil {
Expand All @@ -97,8 +100,6 @@ func CryostatCRConfigChangeTest(bundle *apimanifests.Bundle, namespace string, o
}

// Switch Cryostat CR to PVC for redeployment
ctx, cancel := context.WithTimeout(context.Background(), testTimeout)
defer cancel()
cr, err = client.OperatorCRDs().Cryostats(namespace).Get(ctx, CryostatCRTestName)
if err != nil {
return fail(*r, fmt.Sprintf("failed to get Cryostat CR: %s", err.Error()))
Expand Down

0 comments on commit 364d5db

Please sign in to comment.