Skip to content

Commit bf90543

Browse files
authored
Merge pull request #1147 from redhat-best-practices-for-k8s/replace_anchore_engine
Replace busted operators
2 parents c1104e4 + 29562eb commit bf90543

18 files changed

+788
-383
lines changed

.github/workflows/pull-images.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ jobs:
4343
podman pull --authfile /home/runner/pull-secret.txt registry.redhat.io/openshift4/dpdk-base-rhel8:v4.9
4444
podman pull --authfile /home/runner/pull-secret.txt registry.connect.redhat.com/cockroachdb/cockroach:v23.1.17
4545
podman pull --authfile /home/runner/pull-secret.txt registry.access.redhat.com/ubi8/nodejs-12:latest
46-
podman pull --authfile /home/runner/pull-secret.txt quay.io/nginx/nginx-ingress-operator@sha256:38bb2a104462808eb800445db354535151fbe2632931b9c2a56da3a526923605
46+
podman pull --authfile /home/runner/pull-secret.txt quay.io/grafana/grafana-operator:v5.18.0
4747
podman pull --authfile /home/runner/pull-secret.txt registry.connect.redhat.com/anchore/engine-operator-bundle@sha256:fbbe7e6c1d75c4de2f47e2c825c930568e85f1134545e9d890a0c9f3d9187a4d
4848
podman pull --authfile /home/runner/pull-secret.txt registry.redhat.io/quay/quay-operator-rhel8@sha256:59c6daa886c01039cb96da04ae250e0e9b89c73dbd7ece934cf8bf9e9f529812

.github/workflows/qe-ocp.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
name: QE OCP Testing (Ubuntu-hosted)
33

44
on:
5-
# pull_request:
6-
# branches: [ main ]
5+
pull_request:
6+
branches: [ main ]
77
workflow_dispatch:
88
# Schedule a daily cron at midnight UTC
99
schedule:
@@ -16,6 +16,7 @@ jobs:
1616
fail-fast: false
1717
matrix:
1818
suite: [accesscontrol, affiliatedcertification, manageability, networking, lifecycle, performance, platformalteration, observability, operator]
19+
# suite: [operator]
1920
env:
2021
SHELL: /bin/bash
2122
KUBECONFIG: '/home/runner/.kube/config'

scripts/run-tests.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function run_tests {
4949
fi
5050
echo "Running tests in the following folders: ${all_default_suites}"
5151
# shellcheck disable=SC2086
52-
ginkgo -timeout=24h -v ${PFLAG} ${FFLAG} --keep-going "${GINKGO_SEED_FLAG}" --require-suite -r $all_default_suites
52+
ginkgo -timeout=24h -v ${PFLAG} ${FFLAG} --keep-going "${GINKGO_SEED_FLAG}" --show-node-events --require-suite -r $all_default_suites
5353
;;
5454
features)
5555
if [ -z "$FEATURES" ]; then
@@ -74,7 +74,7 @@ function run_tests {
7474
fi
7575

7676
# shellcheck disable=SC2086
77-
ginkgo -v ${PFLAG} ${FFLAG} --keep-going ${GINKGO_SEED_FLAG} --output-interceptor-mode=none --timeout=24h --require-suite $command
77+
ginkgo -v ${PFLAG} ${FFLAG} --keep-going ${GINKGO_SEED_FLAG} --output-interceptor-mode=none --timeout=24h --show-node-events --require-suite $command
7878
;;
7979
*)
8080
echo "Unknown case"

tests/affiliatedcertification/parameters/parameters.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ var (
5757
OperatorLabel = map[string]string{"redhat-best-practices-for-k8s.com/operator": "target"}
5858
UncertifiedOperatorPrefixCockroach = "cockroachdb"
5959
CertifiedOperatorPrefixCockroachCertified = "cockroach-operator"
60-
CertifiedOperatorPrefixNginx = "nginx-ingress-operator"
60+
CertifiedOperatorPrefix = "grafana-operator"
6161
UncertifiedOperatorPrefixSriov = "sriov-fec"
6262
UncertifiedOperatorFullSriov = "sriov-fec.v1.2.1"
6363
)

tests/affiliatedcertification/tests/affiliated_certification_invalid_operator.go

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ var _ = Describe("Affiliated-certification invalid operator certification,", Ser
2323
var randomNamespace string
2424
var randomReportDir string
2525
var randomCertsuiteConfigDir string
26+
var grafanaOperatorName string
2627

2728
BeforeEach(func() {
2829
if globalhelper.IsKindCluster() {
@@ -39,35 +40,41 @@ var _ = Describe("Affiliated-certification invalid operator certification,", Ser
3940
randomCertsuiteConfigDir,
4041
)
4142

42-
By("Query the packagemanifest for the default channel")
43-
channel, err := globalhelper.QueryPackageManifestForDefaultChannel(
44-
tsparams.CertifiedOperatorPrefixNginx,
45-
randomNamespace,
46-
)
47-
Expect(err).ToNot(HaveOccurred(), "Error querying package manifest for nginx-ingress-operator")
48-
49-
By("Query the packagemanifest for the " + tsparams.CertifiedOperatorPrefixNginx)
50-
version, err := globalhelper.QueryPackageManifestForVersion(tsparams.CertifiedOperatorPrefixNginx, randomNamespace, channel)
51-
Expect(err).ToNot(HaveOccurred(), "Error querying package manifest for nginx-ingress-operator")
52-
53-
By(fmt.Sprintf("Deploy nginx-ingress-operator%s for testing", "."+version))
54-
// nginx-ingress-operator: in certified-operators group and version is certified
43+
By("Query the packagemanifest for Grafana operator package name and catalog source")
44+
var catalogSource string
45+
var err error
46+
grafanaOperatorName, catalogSource, err = globalhelper.QueryPackageManifestForOperatorNameAndCatalogSource(
47+
"grafana", randomNamespace)
48+
Expect(err).ToNot(HaveOccurred(), "Error querying package manifest for Grafana operator")
49+
Expect(grafanaOperatorName).ToNot(Equal("not found"), "Grafana operator package not found")
50+
Expect(catalogSource).ToNot(Equal("not found"), "Grafana operator catalog source not found")
51+
52+
By("Query the packagemanifest for available channel, version and CSV for " + grafanaOperatorName)
53+
channel, version, csvName, err := globalhelper.QueryPackageManifestForAvailableChannelVersionAndCSV(
54+
grafanaOperatorName, randomNamespace)
55+
Expect(err).ToNot(HaveOccurred(), "Error querying package manifest for "+grafanaOperatorName)
56+
Expect(channel).ToNot(Equal("not found"), "Channel not found")
57+
Expect(version).ToNot(Equal("not found"), "Version not found")
58+
Expect(csvName).ToNot(Equal("not found"), "CSV name not found")
59+
60+
By(fmt.Sprintf("Deploy Grafana operator (channel %s, version %s) for testing", channel, version))
61+
// grafana-operator: in community-operators group
5562
err = tshelper.DeployOperatorSubscription(
56-
tsparams.CertifiedOperatorPrefixNginx,
57-
tsparams.CertifiedOperatorPrefixNginx,
63+
grafanaOperatorName,
64+
grafanaOperatorName,
5865
channel,
5966
randomNamespace,
60-
tsparams.CertifiedOperatorGroup,
67+
catalogSource,
6168
tsparams.OperatorSourceNamespace,
62-
tsparams.CertifiedOperatorPrefixNginx+".v"+version,
69+
csvName,
6370
v1alpha1.ApprovalAutomatic,
6471
)
6572
Expect(err).ToNot(HaveOccurred(), ErrorDeployOperatorStr+
66-
tsparams.CertifiedOperatorPrefixNginx)
73+
grafanaOperatorName)
6774

68-
err = waitUntilOperatorIsReady(tsparams.CertifiedOperatorPrefixNginx,
75+
err = waitUntilOperatorIsReady(grafanaOperatorName,
6976
randomNamespace)
70-
Expect(err).ToNot(HaveOccurred(), "Operator "+tsparams.CertifiedOperatorPrefixNginx+".v"+version+
77+
Expect(err).ToNot(HaveOccurred(), "Operator "+csvName+
7178
" is not ready")
7279

7380
// sriov-fec.v1.1.0 operator : in certified-operators group, version is not certified
@@ -179,11 +186,11 @@ var _ = Describe("Affiliated-certification invalid operator certification,", Ser
179186

180187
Eventually(func() error {
181188
return tshelper.AddLabelToInstalledCSV(
182-
tsparams.CertifiedOperatorPrefixNginx,
189+
grafanaOperatorName,
183190
randomNamespace,
184191
tsparams.OperatorLabel)
185192
}, tsparams.TimeoutLabelCsv, tsparams.PollingInterval).Should(Not(HaveOccurred()),
186-
ErrorLabelingOperatorStr+tsparams.CertifiedOperatorPrefixNginx)
193+
ErrorLabelingOperatorStr+grafanaOperatorName)
187194

188195
By("Start test")
189196
err := globalhelper.LaunchTests(

tests/affiliatedcertification/tests/affiliated_certification_operator.go

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ var _ = Describe("Affiliated-certification operator certification,", Serial, fun
1818
var randomNamespace string
1919
var randomReportDir string
2020
var randomCertsuiteConfigDir string
21+
var grafanaOperatorName string
2122

2223
BeforeEach(func() {
2324
// Create random namespace and keep original report and certsuite config directories
@@ -85,37 +86,41 @@ var _ = Describe("Affiliated-certification operator certification,", Serial, fun
8586
Expect(err).ToNot(HaveOccurred(), "Operator "+tsparams.CertifiedOperatorPrefixCockroachCertified+".v"+version+
8687
" is not ready")
8788

88-
By("Query the packagemanifest for nginx-ingress-operator default channel")
89-
channel, err = globalhelper.QueryPackageManifestForDefaultChannel(
90-
tsparams.CertifiedOperatorPrefixNginx,
91-
randomNamespace,
92-
)
93-
Expect(err).ToNot(HaveOccurred(), "Error querying package manifest for "+tsparams.CertifiedOperatorPrefixNginx)
89+
By("Query the packagemanifest for Grafana operator package name and catalog source")
90+
var catalogSource string
91+
grafanaOperatorName, catalogSource, err = globalhelper.QueryPackageManifestForOperatorNameAndCatalogSource(
92+
"grafana", randomNamespace)
93+
Expect(err).ToNot(HaveOccurred(), "Error querying package manifest for Grafana operator")
94+
Expect(grafanaOperatorName).ToNot(Equal("not found"), "Grafana operator package not found")
95+
Expect(catalogSource).ToNot(Equal("not found"), "Grafana operator catalog source not found")
96+
97+
By("Query the packagemanifest for available channel, version and CSV for " + grafanaOperatorName)
98+
var csvName string
99+
channel, version, csvName, err = globalhelper.QueryPackageManifestForAvailableChannelVersionAndCSV(
100+
grafanaOperatorName, randomNamespace)
101+
Expect(err).ToNot(HaveOccurred(), "Error querying package manifest for "+grafanaOperatorName)
94102
Expect(channel).ToNot(Equal("not found"), "Channel not found")
103+
Expect(version).ToNot(Equal("not found"), "Version not found")
104+
Expect(csvName).ToNot(Equal("not found"), "CSV name not found")
95105

96-
By("Query the packagemanifest for the nginx-ingress-operator")
97-
version, err = globalhelper.QueryPackageManifestForVersion(
98-
tsparams.CertifiedOperatorPrefixNginx, randomNamespace, channel)
99-
Expect(err).ToNot(HaveOccurred(), "Error querying package manifest for "+tsparams.CertifiedOperatorPrefixNginx)
100-
101-
By(fmt.Sprintf("Deploy nginx-ingress-operator.v%s for testing", version))
102-
// nginx-ingress-operator: in certified-operators group and version is certified
106+
By(fmt.Sprintf("Deploy Grafana operator (channel %s, version %s) for testing", channel, version))
107+
// grafana-operator: in community-operators group
103108
err = tshelper.DeployOperatorSubscription(
104-
tsparams.CertifiedOperatorPrefixNginx,
105-
tsparams.CertifiedOperatorPrefixNginx,
109+
grafanaOperatorName,
110+
grafanaOperatorName,
106111
channel,
107112
randomNamespace,
108-
tsparams.CertifiedOperatorGroup,
113+
catalogSource,
109114
tsparams.OperatorSourceNamespace,
110-
tsparams.CertifiedOperatorPrefixNginx+".v"+version,
115+
csvName,
111116
v1alpha1.ApprovalAutomatic,
112117
)
113118
Expect(err).ToNot(HaveOccurred(), ErrorDeployOperatorStr+
114-
tsparams.CertifiedOperatorPrefixNginx)
119+
grafanaOperatorName)
115120

116-
err = waitUntilOperatorIsReady(tsparams.CertifiedOperatorPrefixNginx,
121+
err = waitUntilOperatorIsReady(grafanaOperatorName,
117122
randomNamespace)
118-
Expect(err).ToNot(HaveOccurred(), "Operator "+tsparams.CertifiedOperatorPrefixNginx+
123+
Expect(err).ToNot(HaveOccurred(), "Operator "+csvName+
119124
" is not ready")
120125
})
121126

@@ -198,11 +203,11 @@ var _ = Describe("Affiliated-certification operator certification,", Serial, fun
198203

199204
Eventually(func() error {
200205
return tshelper.AddLabelToInstalledCSV(
201-
tsparams.CertifiedOperatorPrefixNginx,
206+
grafanaOperatorName,
202207
randomNamespace,
203208
tsparams.OperatorLabel)
204209
}, tsparams.TimeoutLabelCsv, tsparams.PollingInterval).Should(Not(HaveOccurred()),
205-
ErrorLabelingOperatorStr+tsparams.CertifiedOperatorPrefixNginx)
210+
ErrorLabelingOperatorStr+grafanaOperatorName)
206211

207212
By("Start test")
208213
err := globalhelper.LaunchTests(
@@ -224,11 +229,11 @@ var _ = Describe("Affiliated-certification operator certification,", Serial, fun
224229
By("Label operators to be certified")
225230
Eventually(func() error {
226231
return tshelper.AddLabelToInstalledCSV(
227-
tsparams.CertifiedOperatorPrefixNginx,
232+
grafanaOperatorName,
228233
randomNamespace,
229234
tsparams.OperatorLabel)
230235
}, tsparams.TimeoutLabelCsv, tsparams.PollingInterval).Should(Not(HaveOccurred()),
231-
ErrorLabelingOperatorStr+tsparams.CertifiedOperatorPrefixNginx)
236+
ErrorLabelingOperatorStr+grafanaOperatorName)
232237

233238
Eventually(func() error {
234239
return tshelper.AddLabelToInstalledCSV(

tests/globalhelper/packagemanifest.go

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package globalhelper
22

33
import (
44
"fmt"
5+
"strings"
56

67
egiClients "github.com/openshift-kni/eco-goinfra/pkg/clients"
78
egiOLM "github.com/openshift-kni/eco-goinfra/pkg/olm"
@@ -59,3 +60,116 @@ func QueryPackageManifestForDefaultChannel(operatorName, operatorNamespace strin
5960

6061
return "not found", nil
6162
}
63+
64+
// QueryPackageManifestForOperatorName searches for packages containing the specified search string
65+
// and returns the first matching package name. This is useful for finding operators whose
66+
// package names may vary between OCP versions (e.g., "cloudbees-ci" vs "cloudbees-ci-rhmp").
67+
func QueryPackageManifestForOperatorName(searchString, operatorNamespace string) (string, error) {
68+
pkgManifest, err := egiOLM.ListPackageManifest(egiClients.New(""), operatorNamespace, client.ListOptions{})
69+
70+
if err != nil {
71+
return "", err
72+
}
73+
74+
for _, item := range pkgManifest {
75+
if strings.Contains(item.Object.GetName(), searchString) {
76+
fmt.Printf("Found package: %s matching search string: %s\n", item.Object.GetName(), searchString)
77+
78+
return item.Object.GetName(), nil
79+
}
80+
}
81+
82+
return "not found", nil
83+
}
84+
85+
// QueryPackageManifestForOperatorNameAndCatalogSource searches for packages containing the specified search string
86+
// and returns both the package name and the catalog source where it was found. This is useful for finding operators whose
87+
// package names and catalog sources may vary between OCP versions (e.g., "ovms-operator" in "certified-operators"
88+
// vs "ovms-operator-rhmp" in "redhat-marketplace").
89+
func QueryPackageManifestForOperatorNameAndCatalogSource(searchString, operatorNamespace string) (string, string, error) {
90+
pkgManifest, err := egiOLM.ListPackageManifest(egiClients.New(""), operatorNamespace, client.ListOptions{})
91+
92+
if err != nil {
93+
return "", "", err
94+
}
95+
96+
for _, item := range pkgManifest {
97+
if strings.Contains(item.Object.GetName(), searchString) {
98+
packageName := item.Object.GetName()
99+
catalogSource := item.Object.Status.CatalogSource
100+
fmt.Printf("Found package: %s in catalog source: %s matching search string: %s\n", packageName, catalogSource, searchString)
101+
102+
return packageName, catalogSource, nil
103+
}
104+
}
105+
106+
return "not found", "not found", nil
107+
}
108+
109+
// QueryPackageManifestForAvailableChannelAndVersion searches for an operator and returns the first available channel
110+
// that has versions, along with a version from that channel. This is more robust than requiring a specific channel.
111+
func QueryPackageManifestForAvailableChannelAndVersion(operatorName, operatorNamespace string) (string, string, error) {
112+
pkgManifest, err := egiOLM.ListPackageManifest(egiClients.New(""), operatorNamespace, client.ListOptions{})
113+
114+
if err != nil {
115+
return "", "", err
116+
}
117+
118+
for _, item := range pkgManifest {
119+
if item.Object.GetName() == operatorName {
120+
// Try the default channel first
121+
defaultChannel := item.Object.Status.DefaultChannel
122+
fmt.Printf("Default channel for %s: %s\n", operatorName, defaultChannel)
123+
124+
for _, chanObj := range item.Object.Status.Channels {
125+
fmt.Printf("Checking channel %s for %s\n", chanObj.Name, operatorName)
126+
127+
// Check if this channel has a version available
128+
if chanObj.CurrentCSVDesc.Version.String() != "" {
129+
channelName := chanObj.Name
130+
version := chanObj.CurrentCSVDesc.Version.String()
131+
fmt.Printf("Found available channel: %s with version: %s for %s\n", channelName, version, operatorName)
132+
133+
return channelName, version, nil
134+
}
135+
}
136+
}
137+
}
138+
139+
return "not found", "not found", nil
140+
}
141+
142+
// QueryPackageManifestForAvailableChannelVersionAndCSV searches for an operator and returns the first available channel
143+
// that has versions, along with the version and the actual CSV name from that channel. This handles cases where
144+
// the CSV name doesn't match the package name pattern (e.g., package "ovms-operator-rhmp" has CSV "openvino-operator.v1.2.0").
145+
func QueryPackageManifestForAvailableChannelVersionAndCSV(operatorName, operatorNamespace string) (string, string, string, error) {
146+
pkgManifest, err := egiOLM.ListPackageManifest(egiClients.New(""), operatorNamespace, client.ListOptions{})
147+
148+
if err != nil {
149+
return "", "", "", err
150+
}
151+
152+
for _, item := range pkgManifest {
153+
if item.Object.GetName() == operatorName {
154+
// Try the default channel first
155+
defaultChannel := item.Object.Status.DefaultChannel
156+
fmt.Printf("Default channel for %s: %s\n", operatorName, defaultChannel)
157+
158+
for _, chanObj := range item.Object.Status.Channels {
159+
fmt.Printf("Checking channel %s for %s\n", chanObj.Name, operatorName)
160+
161+
// Check if this channel has a version available
162+
if chanObj.CurrentCSVDesc.Version.String() != "" && chanObj.CurrentCSV != "" {
163+
channelName := chanObj.Name
164+
version := chanObj.CurrentCSVDesc.Version.String()
165+
csvName := chanObj.CurrentCSV
166+
fmt.Printf("Found available channel: %s with version: %s and CSV: %s for %s\n", channelName, version, csvName, operatorName)
167+
168+
return channelName, version, csvName, nil
169+
}
170+
}
171+
}
172+
}
173+
174+
return "not found", "not found", "not found", nil
175+
}

tests/operator/helper/helper.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,17 @@ func DeployOperatorSubscriptionWithNodeSelector(operatorPackage, channel, namesp
148148
return nil
149149
}
150150

151+
// IsCSVNotSucceeded checks if CSV installation status is not Succeeded.
152+
func IsCSVNotSucceeded(csvPrefix, namespace string) (bool, error) {
153+
csv, err := GetCsvByPrefix(csvPrefix, namespace)
154+
if err != nil {
155+
return false, err
156+
}
157+
158+
// Return true if CSV is NOT in Succeeded phase
159+
return csv.Status.Phase != v1alpha1.CSVPhaseSucceeded, nil
160+
}
161+
151162
func updateCsv(namespace string, csv *v1alpha1.ClusterServiceVersion) error {
152163
_, err := globalhelper.GetAPIClient().ClusterServiceVersions(namespace).Update(
153164
context.TODO(), csv, metav1.UpdateOptions{},

0 commit comments

Comments
 (0)