element_type
stringclasses
4 values
project_name
stringclasses
1 value
uuid
stringlengths
36
36
name
stringlengths
0
346
imports
stringlengths
0
2.67k
structs
stringclasses
761 values
interfaces
stringclasses
22 values
file_location
stringclasses
545 values
code
stringlengths
26
8.07M
global_vars
stringclasses
7 values
package
stringclasses
124 values
tags
stringclasses
1 value
function
openshift/openshift-tests-private
ef4817cc-f15a-4c28-85ed-9594bad08a8f
getCSV
['csvDescription', 'subscriptionDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (sub *subscriptionDescription) getCSV() csvDescription { e2e.Logf("csv is %s, namespace is %s", sub.installedCSV, sub.namespace) return csvDescription{sub.installedCSV, sub.namespace} }
operators
function
openshift/openshift-tests-private
1c255aae-ae07-45b4-8b0b-48e57fc15950
getIP
['"context"', '"fmt"', '"strings"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"']
['subscriptionDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (sub *subscriptionDescription) getIP(oc *exutil.CLI) string { var installPlan string waitErr := wait.PollUntilContextTimeout(context.TODO(), 5*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) { var err error installPlan, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("sub", sub.subName, "-n", sub.namespace, "-o=jsonpath={.status.installPlanRef.name}").Output() if strings.Compare(installPlan, "") == 0 || err != nil { return false, nil } return true, nil }) exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("sub %s has no installplan", sub.subName)) o.Expect(installPlan).NotTo(o.BeEmpty()) return installPlan }
operators
function
openshift/openshift-tests-private
3b028d22-28c2-4cb6-974a-4de4e092801c
getInstanceVersion
['"strings"']
['subscriptionDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (sub *subscriptionDescription) getInstanceVersion(oc *exutil.CLI) string { version := "" output := strings.Split(getResource(oc, asUser, withoutNamespace, "csv", sub.installedCSV, "-n", sub.namespace, "-o=jsonpath={.metadata.annotations.alm-examples}"), "\n") for _, line := range output { if strings.Contains(line, "\"version\"") { version = strings.Trim(strings.Fields(strings.TrimSpace(line))[1], "\"") break } } o.Expect(version).NotTo(o.BeEmpty()) e2e.Logf("sub cr version is %s", version) return version }
operators
function
openshift/openshift-tests-private
7711df8f-4fe8-4efd-88e0-d2011ea3b219
createInstance
['"encoding/json"', '"io/ioutil"', '"path/filepath"']
['subscriptionDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (sub *subscriptionDescription) createInstance(oc *exutil.CLI, instance string) { path := filepath.Join(e2e.TestContext.OutputDir, sub.namespace+"-"+"instance.json") err := ioutil.WriteFile(path, []byte(instance), 0644) o.Expect(err).NotTo(o.HaveOccurred()) err = oc.AsAdmin().WithoutNamespace().Run("apply").Args("-n", sub.namespace, "-f", path).Execute() o.Expect(err).NotTo(o.HaveOccurred()) }
operators
function
openshift/openshift-tests-private
f8cce512-a7b8-4e5f-9711-1934ed101fe0
delete
['subscriptionDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (sub *subscriptionDescription) delete(itName string, dr describerResrouce) { e2e.Logf("remove sub %s, ns is %s", sub.subName, sub.namespace) dr.getIr(itName).remove(sub.subName, "sub", sub.namespace) }
operators
function
openshift/openshift-tests-private
553bd233-55e2-4995-aa09-bb17c352281f
deleteCSV
['subscriptionDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (sub *subscriptionDescription) deleteCSV(itName string, dr describerResrouce) { e2e.Logf("remove csv %s, ns is %s, the subscription is: %s", sub.installedCSV, sub.namespace, sub) dr.getIr(itName).remove(sub.installedCSV, "csv", sub.namespace) }
operators
function
openshift/openshift-tests-private
eda736e4-3a51-490d-8566-09fa665a32fc
patch
['subscriptionDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (sub *subscriptionDescription) patch(oc *exutil.CLI, patch string) { patchResource(oc, asAdmin, withoutNamespace, "sub", sub.subName, "-n", sub.namespace, "--type", "merge", "-p", patch) }
operators
function
openshift/openshift-tests-private
af9ee894-157c-487f-9e5b-97fec4d7f540
createWithoutCheck
['subscriptionDescriptionProxy']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (sub *subscriptionDescriptionProxy) createWithoutCheck(oc *exutil.CLI, itName string, dr describerResrouce) { e2e.Logf("install subscriptionDescriptionProxy") err := applyResourceFromTemplate(oc, "--ignore-unknown-parameters=true", "-f", sub.template, "-p", "SUBNAME="+sub.subName, "SUBNAMESPACE="+sub.namespace, "CHANNEL="+sub.channel, "APPROVAL="+sub.ipApproval, "OPERATORNAME="+sub.operatorPackage, "SOURCENAME="+sub.catalogSourceName, "SOURCENAMESPACE="+sub.catalogSourceNamespace, "STARTINGCSV="+sub.startingCSV, "SUBHTTPPROXY="+sub.httpProxy, "SUBHTTPSPROXY="+sub.httpsProxy, "SUBNOPROXY="+sub.noProxy) o.Expect(err).NotTo(o.HaveOccurred()) dr.getIr(itName).add(newResource(oc, "sub", sub.subName, requireNS, sub.namespace)) e2e.Logf("install subscriptionDescriptionProxy %s SUCCESS", sub.subName) }
operators
function
openshift/openshift-tests-private
ba2c97c9-2967-4909-a1d5-b3f291f46862
create
['"strings"']
['subscriptionDescriptionProxy']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (sub *subscriptionDescriptionProxy) create(oc *exutil.CLI, itName string, dr describerResrouce) { sub.createWithoutCheck(oc, itName, dr) if strings.Compare(sub.ipApproval, "Automatic") == 0 { sub.findInstalledCSVWithSkip(oc, itName, dr, true) } else { newCheck("expect", asAdmin, withoutNamespace, compare, "UpgradePending", ok, []string{"sub", sub.subName, "-n", sub.namespace, "-o=jsonpath={.status.state}"}).check(oc) } }
operators
function
openshift/openshift-tests-private
4bf2340d-12c3-4fad-9553-f52e96354680
create
['crdDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (crd *crdDescription) create(oc *exutil.CLI, itName string, dr describerResrouce) { err := applyResourceFromTemplate(oc, "--ignore-unknown-parameters=true", "-f", crd.template, "-p", "NAME="+crd.name) o.Expect(err).NotTo(o.HaveOccurred()) dr.getIr(itName).add(newResource(oc, "crd", crd.name, notRequireNS, "")) e2e.Logf("create crd %s SUCCESS", crd.name) }
operators
function
openshift/openshift-tests-private
d9b2fbf0-aee6-43bf-b8a3-65996abdb553
delete
['crdDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (crd *crdDescription) delete(oc *exutil.CLI) { e2e.Logf("remove crd %s, withoutNamespace is %v", crd.name, withoutNamespace) removeResource(oc, asAdmin, withoutNamespace, "crd", crd.name) }
operators
function
openshift/openshift-tests-private
5821b4ce-17a5-4918-b14b-d60e01807c2e
create
['configMapDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (cm *configMapDescription) create(oc *exutil.CLI, itName string, dr describerResrouce) { err := applyResourceFromTemplate(oc, "--ignore-unknown-parameters=true", "-f", cm.template, "-p", "NAME="+cm.name, "NAMESPACE="+cm.namespace) o.Expect(err).NotTo(o.HaveOccurred()) dr.getIr(itName).add(newResource(oc, "cm", cm.name, requireNS, cm.namespace)) e2e.Logf("create cm %s SUCCESS", cm.name) }
operators
function
openshift/openshift-tests-private
4f5415db-e5b0-4736-bfb2-f04e62112591
patch
['configMapDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (cm *configMapDescription) patch(oc *exutil.CLI, patch string) { patchResource(oc, asAdmin, withoutNamespace, "cm", cm.name, "-n", cm.namespace, "--type", "merge", "-p", patch) }
operators
function
openshift/openshift-tests-private
37f91432-c036-4a54-ba42-3d90f723d254
delete
['configMapDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (cm *configMapDescription) delete(itName string, dr describerResrouce) { e2e.Logf("remove cm %s, ns is %v", cm.name, cm.namespace) dr.getIr(itName).remove(cm.name, "cm", cm.namespace) }
operators
function
openshift/openshift-tests-private
d14bdbc8-ef21-4f5f-834a-401481d6b217
create
['"strings"']
['catalogSourceDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (catsrc *catalogSourceDescription) create(oc *exutil.CLI, itName string, dr describerResrouce) { if strings.Compare(catsrc.interval, "") == 0 { catsrc.interval = "10m0s" e2e.Logf("set interval to be 10m0s") } applyFn := applyResourceFromTemplate if strings.Compare(catsrc.clusterType, "microshift") == 0 { applyFn = applyResourceFromTemplateOnMicroshift } err := applyFn(oc, "--ignore-unknown-parameters=true", "-f", catsrc.template, "-p", "NAME="+catsrc.name, "NAMESPACE="+catsrc.namespace, "ADDRESS="+catsrc.address, "SECRET="+catsrc.secret, "DISPLAYNAME="+"\""+catsrc.displayName+"\"", "PUBLISHER="+"\""+catsrc.publisher+"\"", "SOURCETYPE="+catsrc.sourceType, "INTERVAL="+catsrc.interval, "IMAGETEMPLATE="+catsrc.imageTemplate) o.Expect(err).NotTo(o.HaveOccurred()) if strings.Compare(catsrc.clusterType, "microshift") != 0 { catsrc.setSCCRestricted(oc) } dr.getIr(itName).add(newResource(oc, "catsrc", catsrc.name, requireNS, catsrc.namespace)) e2e.Logf("create catsrc %s SUCCESS", catsrc.name) }
operators
function
openshift/openshift-tests-private
df806141-8499-405a-a86d-18f13fcc8fe8
setSCCRestricted
['"strings"', '"github.com/tidwall/gjson"']
['catalogSourceDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (catsrc *catalogSourceDescription) setSCCRestricted(oc *exutil.CLI) { if strings.Compare(catsrc.namespace, "openshift-marketplace") == 0 { e2e.Logf("the namespace is openshift-marketplace, skip setting SCC") return } psa := "restricted" if exutil.IsHypershiftHostedCluster(oc) { e2e.Logf("cluster is Hypershift Hosted Cluster, cannot get default PSA setting, use default value restricted") } else { output, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("configmaps", "-n", "openshift-kube-apiserver", "config", `-o=jsonpath={.data.config\.yaml}`).Output() o.Expect(err).NotTo(o.HaveOccurred()) psa = gjson.Get(output, "admission.pluginConfig.PodSecurity.configuration.defaults.enforce").String() e2e.Logf("pod-security.kubernetes.io/enforce is %s", string(psa)) } if strings.Contains(string(psa), "restricted") { originSCC := catsrc.getSCC(oc) e2e.Logf("spec.grpcPodConfig.securityContextConfig is %s", originSCC) if strings.Compare(originSCC, "") == 0 { e2e.Logf("set spec.grpcPodConfig.securityContextConfig to be restricted") err := oc.AsAdmin().WithoutNamespace().Run("patch").Args("catsrc", catsrc.name, "-n", catsrc.namespace, "--type=merge", "-p", `{"spec":{"grpcPodConfig":{"securityContextConfig":"restricted"}}}`).Execute() o.Expect(err).NotTo(o.HaveOccurred()) } else { e2e.Logf("spec.grpcPodConfig.securityContextConfig is %s, skip setting", originSCC) } } }
operators
function
openshift/openshift-tests-private
efeec6be-4f03-4a50-ad21-c56fe66be58a
getSCC
['catalogSourceDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (catsrc *catalogSourceDescription) getSCC(oc *exutil.CLI) string { output, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("catsrc", catsrc.name, "-n", catsrc.namespace, "-o=jsonpath={.spec.grpcPodConfig.securityContextConfig}").Output() o.Expect(err).NotTo(o.HaveOccurred()) return output }
operators
function
openshift/openshift-tests-private
de937233-ad6f-4169-8e5f-6f70b905bb8c
createWithCheck
['"context"', '"fmt"', '"strings"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"']
['catalogSourceDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (catsrc *catalogSourceDescription) createWithCheck(oc *exutil.CLI, itName string, dr describerResrouce) { catsrc.create(oc, itName, dr) err := wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) { status, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("catsrc", catsrc.name, "-n", catsrc.namespace, "-o=jsonpath={.status..lastObservedState}").Output() if strings.Compare(status, "READY") != 0 { e2e.Logf("catsrc %s lastObservedState is %s, not READY", catsrc.name, status) return false, nil } return true, nil }) if err != nil { output, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("catsrc", catsrc.name, "-n", catsrc.namespace, "-o=jsonpath={.status}").Output() e2e.Logf(output) logDebugInfo(oc, catsrc.namespace, "pod", "events") } exutil.AssertWaitPollNoErr(err, fmt.Sprintf("catsrc %s lastObservedState is not READY", catsrc.name)) e2e.Logf("catsrc %s lastObservedState is READY", catsrc.name) }
operators
function
openshift/openshift-tests-private
5db5fc2d-a7fc-4f3b-a20b-4c34bc1bd52a
delete
['catalogSourceDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (catsrc *catalogSourceDescription) delete(itName string, dr describerResrouce) { e2e.Logf("delete carsrc %s, ns is %s", catsrc.name, catsrc.namespace) dr.getIr(itName).remove(catsrc.name, "catsrc", catsrc.namespace) }
operators
function
openshift/openshift-tests-private
8bd1a671-ad42-4423-95e2-e109ba918d28
create
['"context"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"']
['customResourceDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (crinstance *customResourceDescription) create(oc *exutil.CLI, itName string, dr describerResrouce) { errCR := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 60*time.Second, false, func(ctx context.Context) (bool, error) { err := applyResourceFromTemplate(oc, "--ignore-unknown-parameters=true", "-f", crinstance.template, "-p", "NAME="+crinstance.name, "NAMESPACE="+crinstance.namespace) if err != nil { e2e.Logf("met error: %v, try next round ...", err.Error()) return false, nil } return true, nil }) exutil.AssertWaitPollNoErr(errCR, "cr etcdcluster is not created") dr.getIr(itName).add(newResource(oc, crinstance.typename, crinstance.name, requireNS, crinstance.namespace)) e2e.Logf("create CR %s SUCCESS", crinstance.name) }
operators
function
openshift/openshift-tests-private
e98a46ab-bd5d-4482-a926-8d8a2fb3beb5
delete
['customResourceDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (crinstance *customResourceDescription) delete(itName string, dr describerResrouce) { e2e.Logf("delete crinstance %s, type is %s, ns is %s", crinstance.name, crinstance.typename, crinstance.namespace) dr.getIr(itName).remove(crinstance.name, crinstance.typename, crinstance.namespace) }
operators
function
openshift/openshift-tests-private
773e4ce7-9118-48be-9f51-6068cf8276a7
createwithCheck
['"fmt"', '"strings"']
['operatorGroupDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (og *operatorGroupDescription) createwithCheck(oc *exutil.CLI, itName string, dr describerResrouce) { output, err := doAction(oc, "get", asAdmin, false, "operatorgroup") o.Expect(err).NotTo(o.HaveOccurred()) if strings.Contains(output, "No resources found") { e2e.Logf(fmt.Sprintf("No operatorgroup in project: %s, create one: %s", og.namespace, og.name)) og.create(oc, itName, dr) } else { e2e.Logf(fmt.Sprintf("Already exist operatorgroup in project: %s", og.namespace)) } }
operators
function
openshift/openshift-tests-private
48381608-a38d-415f-bf6b-ecd1f5722eca
create
['"strings"']
['operatorGroupDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (og *operatorGroupDescription) create(oc *exutil.CLI, itName string, dr describerResrouce) { var err error applyFn := applyResourceFromTemplate if strings.Compare(og.clusterType, "microshift") == 0 { applyFn = applyResourceFromTemplateOnMicroshift } if strings.Compare(og.multinslabel, "") != 0 && strings.Compare(og.serviceAccountName, "") != 0 { err = applyFn(oc, "--ignore-unknown-parameters=true", "-f", og.template, "-p", "NAME="+og.name, "NAMESPACE="+og.namespace, "MULTINSLABEL="+og.multinslabel, "SERVICE_ACCOUNT_NAME="+og.serviceAccountName) } else if strings.Compare(og.multinslabel, "") == 0 && strings.Compare(og.serviceAccountName, "") == 0 && strings.Compare(og.upgradeStrategy, "") == 0 { err = applyFn(oc, "--ignore-unknown-parameters=true", "-f", og.template, "-p", "NAME="+og.name, "NAMESPACE="+og.namespace) } else if strings.Compare(og.multinslabel, "") != 0 { err = applyFn(oc, "--ignore-unknown-parameters=true", "-f", og.template, "-p", "NAME="+og.name, "NAMESPACE="+og.namespace, "MULTINSLABEL="+og.multinslabel) } else if strings.Compare(og.upgradeStrategy, "") != 0 { err = applyFn(oc, "--ignore-unknown-parameters=true", "-f", og.template, "-p", "NAME="+og.name, "NAMESPACE="+og.namespace, "UPGRADESTRATEGY="+og.upgradeStrategy) } else { err = applyFn(oc, "--ignore-unknown-parameters=true", "-f", og.template, "-p", "NAME="+og.name, "NAMESPACE="+og.namespace, "SERVICE_ACCOUNT_NAME="+og.serviceAccountName) } o.Expect(err).NotTo(o.HaveOccurred()) dr.getIr(itName).add(newResource(oc, "og", og.name, requireNS, og.namespace)) e2e.Logf("create og %s success", og.name) }
operators
function
openshift/openshift-tests-private
8fb75567-9ea6-42c2-b238-702be938d95f
delete
['operatorGroupDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (og *operatorGroupDescription) delete(itName string, dr describerResrouce) { e2e.Logf("delete og %s, ns is %s", og.name, og.namespace) dr.getIr(itName).remove(og.name, "og", og.namespace) }
operators
function
openshift/openshift-tests-private
785e048c-8db2-439b-b4be-de8f5bcc6aab
create
['operatorSourceDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (osrc *operatorSourceDescription) create(oc *exutil.CLI, itName string, dr describerResrouce) { err := applyResourceFromTemplate(oc, "--ignore-unknown-parameters=true", "-f", osrc.template, "-p", "NAME="+osrc.name, "NAMESPACE="+osrc.namespace, "NAMELABEL="+osrc.namelabel, "REGISTRYNAMESPACE="+osrc.registrynamespace, "DISPLAYNAME="+osrc.displayname, "PUBLISHER="+osrc.publisher) o.Expect(err).NotTo(o.HaveOccurred()) dr.getIr(itName).add(newResource(oc, "opsrc", osrc.name, requireNS, osrc.namespace)) e2e.Logf("create operatorSource %s success", osrc.name) }
operators
function
openshift/openshift-tests-private
2905df73-3a3f-47c4-bb49-1d009520a5c2
delete
['operatorSourceDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (osrc *operatorSourceDescription) delete(itName string, dr describerResrouce) { e2e.Logf("delete operatorSource %s, ns is %s", osrc.name, osrc.namespace) dr.getIr(itName).remove(osrc.name, "opsrc", osrc.namespace) }
operators
function
openshift/openshift-tests-private
75ab0e4d-8fdd-4966-a51e-7a811c0ee77b
getRunningNodes
['"fmt"']
['operatorSourceDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (osrc *operatorSourceDescription) getRunningNodes(oc *exutil.CLI) string { nodesNames := getResource(oc, asAdmin, withoutNamespace, "pod", fmt.Sprintf("--selector=marketplace.operatorSource=%s", osrc.name), "-n", osrc.namespace, "-o=jsonpath={.items[*]..nodeName}") o.Expect(nodesNames).NotTo(o.BeEmpty()) e2e.Logf("getRunningNodes: nodesNames %s", nodesNames) return nodesNames }
operators
function
openshift/openshift-tests-private
f1054799-b80d-4ce6-9f0e-dcdc61f8ef31
getDeployment
['"fmt"']
['operatorSourceDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (osrc *operatorSourceDescription) getDeployment(oc *exutil.CLI) { output := getResource(oc, asAdmin, withoutNamespace, "deployment", fmt.Sprintf("--selector=opsrc-owner-name=%s", osrc.name), "-n", osrc.namespace, "-o=jsonpath={.items[0].metadata.name}") o.Expect(output).NotTo(o.BeEmpty()) e2e.Logf("getDeployment: deploymentName %s", output) osrc.deploymentName = output }
operators
function
openshift/openshift-tests-private
e1917b30-b706-404c-9eb6-4278ccffd2d5
patchDeployment
['"strings"']
['operatorSourceDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (osrc *operatorSourceDescription) patchDeployment(oc *exutil.CLI, content string) { if strings.Compare(osrc.deploymentName, "") == 0 { osrc.deploymentName = osrc.name } patchResource(oc, asAdmin, withoutNamespace, "deployment", osrc.deploymentName, "-n", osrc.namespace, "--type", "merge", "-p", content) }
operators
function
openshift/openshift-tests-private
056591bc-3a41-4bf5-b50e-f765acd8a835
getTolerations
['"strings"']
['operatorSourceDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (osrc *operatorSourceDescription) getTolerations(oc *exutil.CLI) string { if strings.Compare(osrc.deploymentName, "") == 0 { osrc.deploymentName = osrc.name } output := getResource(oc, asAdmin, withoutNamespace, "deployment", osrc.deploymentName, "-n", osrc.namespace, "-o=jsonpath={.spec.template.spec.tolerations}") if strings.Compare(output, "") == 0 { e2e.Logf("no tolerations %v", output) return "\"tolerations\": null" } tolerations := "\"tolerations\": " + convertLMtoJSON(output) e2e.Logf("the tolerations:===%v===", tolerations) return tolerations }
operators
function
openshift/openshift-tests-private
6e564b65-7430-4fce-9845-595900b0b0a6
create
['catalogSourceConfigDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (csc *catalogSourceConfigDescription) create(oc *exutil.CLI, itName string, dr describerResrouce) { err := applyResourceFromTemplate(oc, "--ignore-unknown-parameters=true", "-f", csc.template, "-p", "NAME="+csc.name, "NAMESPACE="+csc.namespace, "PACKAGES="+csc.packages, "TARGETNAMESPACE="+csc.targetnamespace, "SOURCE="+csc.source) o.Expect(err).NotTo(o.HaveOccurred()) dr.getIr(itName).add(newResource(oc, "csc", csc.name, requireNS, csc.namespace)) e2e.Logf("create catalogSourceConfig %s success", csc.name) }
operators
function
openshift/openshift-tests-private
8df450e9-72ad-4d77-af3c-5d36288f4ebe
delete
['catalogSourceConfigDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (csc *catalogSourceConfigDescription) delete(itName string, dr describerResrouce) { e2e.Logf("delete catalogSourceConfig %s, ns is %s", csc.name, csc.namespace) dr.getIr(itName).remove(csc.name, "csc", csc.namespace) }
operators
function
openshift/openshift-tests-private
f49abdd7-9f12-457a-9c89-5da1b1558a11
createwithCheck
['"fmt"']
['projectDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (p *projectDescription) createwithCheck(oc *exutil.CLI, itName string, dr describerResrouce) { output, err := doAction(oc, "get", asAdmin, withoutNamespace, "project", p.name) if err != nil { e2e.Logf(fmt.Sprintf("Output: %s, cannot find the %s project, create one", output, p.name)) _, err := doAction(oc, "adm", asAdmin, withoutNamespace, "new-project", p.name) o.Expect(err).NotTo(o.HaveOccurred()) dr.getIr(itName).add(newResource(oc, "project", p.name, notRequireNS, "")) _, err = doAction(oc, "project", asAdmin, withoutNamespace, p.name) o.Expect(err).NotTo(o.HaveOccurred()) } else { e2e.Logf(fmt.Sprintf("project: %s already exist!", p.name)) } }
operators
function
openshift/openshift-tests-private
1f658717-4ce2-4c88-8c17-8f6c6afc36a8
create
['projectDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (p *projectDescription) create(oc *exutil.CLI, itName string, dr describerResrouce) { removeResource(oc, asAdmin, withoutNamespace, "project", p.name) _, err := doAction(oc, "new-project", asAdmin, withoutNamespace, p.name, "--skip-config-write") o.Expect(err).NotTo(o.HaveOccurred()) dr.getIr(itName).add(newResource(oc, "project", p.name, notRequireNS, "")) _, err = doAction(oc, "project", asAdmin, withoutNamespace, p.targetNamespace) o.Expect(err).NotTo(o.HaveOccurred()) }
operators
function
openshift/openshift-tests-private
060b46c9-7ed1-461e-aad3-196890ccaa5f
label
['projectDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (p *projectDescription) label(oc *exutil.CLI, label string) { _, err := doAction(oc, "label", asAdmin, withoutNamespace, "ns", p.name, "env="+label) o.Expect(err).NotTo(o.HaveOccurred()) }
operators
function
openshift/openshift-tests-private
405f22ad-2aa0-48ba-984f-5c0c8e6d008b
delete
['projectDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (p *projectDescription) delete(oc *exutil.CLI) { _, err := doAction(oc, "delete", asAdmin, withoutNamespace, "project", p.name) o.Expect(err).NotTo(o.HaveOccurred()) }
operators
function
openshift/openshift-tests-private
45e4ca17-4b90-4330-8f0b-1f2dc87bdcdf
deleteWithForce
['"k8s.io/apimachinery/pkg/util/wait"']
['projectDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (p *projectDescription) deleteWithForce(oc *exutil.CLI) { // remove Finalizer _, err := doAction(oc, "delete", asAdmin, withoutNamespace, "all", "--all", "-n", p.name, "--force", "--grace-period=0", "--wait=false") o.Expect(err).NotTo(o.HaveOccurred()) _, err = doAction(oc, "delete", asAdmin, withoutNamespace, "csv", "--all", "-n", p.name, "--force", "--grace-period=0", "--wait=false") o.Expect(err).NotTo(o.HaveOccurred()) _, err = doAction(oc, "delete", asAdmin, withoutNamespace, "project", p.name, "--force", "--grace-period=0", "--wait=false") o.Expect(err).NotTo(o.HaveOccurred()) }
operators
function
openshift/openshift-tests-private
7f4e2aca-9bff-4193-ad80-12cc59b3a6b7
newSa
['serviceAccountDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func newSa(name, namespace string) *serviceAccountDescription { return &serviceAccountDescription{ name: name, namespace: namespace, definitionfile: "", } }
operators
function
openshift/openshift-tests-private
5714676c-50f5-45c0-9dba-cdfcf8ea9abc
getDefinition
['"encoding/json"']
['serviceAccountDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (sa *serviceAccountDescription) getDefinition(oc *exutil.CLI) { parameters := []string{"sa", sa.name, "-n", sa.namespace, "-o=json"} definitionfile, err := oc.AsAdmin().WithoutNamespace().Run("get").Args(parameters...).OutputToFile("sa-config.json") o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("getDefinition: definitionfile is %s", definitionfile) sa.definitionfile = definitionfile }
operators
function
openshift/openshift-tests-private
42e60674-b812-4a62-8180-071832824a6c
delete
['serviceAccountDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (sa *serviceAccountDescription) delete(oc *exutil.CLI) { e2e.Logf("delete sa %s, ns is %s", sa.name, sa.namespace) _, err := doAction(oc, "delete", asAdmin, withoutNamespace, "sa", sa.name, "-n", sa.namespace) o.Expect(err).NotTo(o.HaveOccurred()) }
operators
function
openshift/openshift-tests-private
3299a158-b888-4773-930f-a55064f73685
reapply
['serviceAccountDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (sa *serviceAccountDescription) reapply(oc *exutil.CLI) { err := oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", sa.definitionfile).Execute() o.Expect(err).NotTo(o.HaveOccurred()) }
operators
function
openshift/openshift-tests-private
b55cd418-f61f-4f83-bb8f-ae443261a6b4
checkAuth
['"context"', '"fmt"', '"strings"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"']
['serviceAccountDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (sa *serviceAccountDescription) checkAuth(oc *exutil.CLI, expected string, cr string) { err := wait.PollUntilContextTimeout(context.TODO(), 20*time.Second, 420*time.Second, false, func(ctx context.Context) (bool, error) { output, _ := doAction(oc, "auth", asAdmin, withNamespace, "--as", fmt.Sprintf("system:serviceaccount:%s:%s", sa.namespace, sa.name), "can-i", "create", cr) e2e.Logf("the result of checkAuth:%v", output) if strings.Contains(output, expected) { return true, nil } return false, nil }) exutil.AssertWaitPollNoErr(err, fmt.Sprintf("sa %s expects %s permssion to create %s, but no", sa.name, expected, cr)) }
operators
function
openshift/openshift-tests-private
bb4bd499-cdf9-4379-ae32-726d0652c5a0
create
['roleDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (role *roleDescription) create(oc *exutil.CLI) { err := applyResourceFromTemplate(oc, "--ignore-unknown-parameters=true", "-f", role.template, "-p", "NAME="+role.name, "NAMESPACE="+role.namespace) o.Expect(err).NotTo(o.HaveOccurred()) }
operators
function
openshift/openshift-tests-private
7968feb9-f0e8-4c48-ab37-bd6d3cae5484
newRole
['roleDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func newRole(name string, namespace string) *roleDescription { return &roleDescription{ name: name, namespace: namespace, } }
operators
function
openshift/openshift-tests-private
8bb9b7aa-b7dc-428e-857c-79c99b1184e4
patch
['roleDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (role *roleDescription) patch(oc *exutil.CLI, patch string) { patchResource(oc, asAdmin, withoutNamespace, "role", role.name, "-n", role.namespace, "--type", "merge", "-p", patch) }
operators
function
openshift/openshift-tests-private
544455e4-eb16-43d0-ab4a-b26f0b343556
getRules
['roleDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (role *roleDescription) getRules(oc *exutil.CLI) string { return role.getRulesWithDelete(oc, "nodelete") }
operators
function
openshift/openshift-tests-private
e9305cfc-8b8b-4aeb-97d8-ef059677f441
getRulesWithDelete
['"encoding/json"', '"strings"']
['roleDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (role *roleDescription) getRulesWithDelete(oc *exutil.CLI, delete string) string { var roleboday map[string]interface{} output := getResource(oc, asAdmin, withoutNamespace, "role", role.name, "-n", role.namespace, "-o=json") err := json.Unmarshal([]byte(output), &roleboday) o.Expect(err).NotTo(o.HaveOccurred()) rules := roleboday["rules"].([]interface{}) handleRuleAttribute := func(rc *strings.Builder, rt string, r map[string]interface{}) { rc.WriteString("\"" + rt + "\":[") items := r[rt].([]interface{}) e2e.Logf("%s:%v, and the len:%v", rt, items, len(items)) for i, v := range items { vc := v.(string) rc.WriteString("\"" + vc + "\"") if i != len(items)-1 { rc.WriteString(",") } } rc.WriteString("]") if strings.Compare(rt, "verbs") != 0 { rc.WriteString(",") } } var rc strings.Builder rc.WriteString("[") for _, rv := range rules { rule := rv.(map[string]interface{}) if strings.Compare(delete, "nodelete") != 0 && strings.Compare(rule["apiGroups"].([]interface{})[0].(string), delete) == 0 { continue } rc.WriteString("{") handleRuleAttribute(&rc, "apiGroups", rule) handleRuleAttribute(&rc, "resources", rule) handleRuleAttribute(&rc, "verbs", rule) rc.WriteString("},") } result := strings.TrimSuffix(rc.String(), ",") + "]" e2e.Logf("rc:%v", result) return result }
operators
function
openshift/openshift-tests-private
40c89525-a32b-4172-bffc-8d1a5b7c28a5
create
['rolebindingDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (rolebinding *rolebindingDescription) create(oc *exutil.CLI) { err := applyResourceFromTemplate(oc, "--ignore-unknown-parameters=true", "-f", rolebinding.template, "-p", "NAME="+rolebinding.name, "NAMESPACE="+rolebinding.namespace, "SA_NAME="+rolebinding.saname, "ROLE_NAME="+rolebinding.rolename) o.Expect(err).NotTo(o.HaveOccurred()) }
operators
function
openshift/openshift-tests-private
f1658440-e1c5-4723-800d-1cd19e0ebfb8
create
['secretDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (secret *secretDescription) create(oc *exutil.CLI) { err := applyResourceFromTemplate(oc, "--ignore-unknown-parameters=true", "-f", secret.template, "-p", "NAME="+secret.name, "NAMESPACE="+secret.namespace, "SANAME="+secret.saname, "TYPE="+secret.sectype) o.Expect(err).NotTo(o.HaveOccurred()) }
operators
function
openshift/openshift-tests-private
31c1d52a-abdb-4cf8-8c8c-199a8e776256
newCheck
['checkDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func newCheck(method string, executor bool, inlineNamespace bool, expectAction bool, expectContent string, expect bool, resource []string) checkDescription { return checkDescription{ method: method, executor: executor, inlineNamespace: inlineNamespace, expectAction: expectAction, expectContent: expectContent, expect: expect, resource: resource, } }
operators
function
openshift/openshift-tests-private
97f4231a-b65a-4037-b241-8014eb9cf0af
check
['"fmt"']
['checkDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (ck checkDescription) check(oc *exutil.CLI) { switch ck.method { case "present": ok := isPresentResource(oc, ck.executor, ck.inlineNamespace, ck.expectAction, ck.resource...) o.Expect(ok).To(o.BeTrue()) case "expect": err := expectedResource(oc, ck.executor, ck.inlineNamespace, ck.expectAction, ck.expectContent, ck.expect, ck.resource...) if err != nil { getResource(oc, asAdmin, withoutNamespace, "pod", "-n", "openshift-marketplace") getResource(oc, asAdmin, withoutNamespace, "og", "-n", oc.Namespace(), "-o", "yaml") getResource(oc, asAdmin, withoutNamespace, "catalogsource", "-n", oc.Namespace(), "-o", "yaml") getResource(oc, asAdmin, withoutNamespace, "subscription", "-n", oc.Namespace(), "-o", "yaml") getResource(oc, asAdmin, withoutNamespace, "ip", "-n", oc.Namespace()) getResource(oc, asAdmin, withoutNamespace, "csv", "-n", oc.Namespace()) getResource(oc, asAdmin, withoutNamespace, "pods", "-n", oc.Namespace()) } exutil.AssertWaitPollNoErr(err, fmt.Sprintf("expected content %s not found by %v", ck.expectContent, ck.resource)) default: err := fmt.Errorf("unknown method") o.Expect(err).NotTo(o.HaveOccurred()) } }
operators
function
openshift/openshift-tests-private
5a854650-a294-4867-ac2d-dfe9aa4539f0
checkWithoutAssert
['"fmt"']
['checkDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (ck checkDescription) checkWithoutAssert(oc *exutil.CLI) error { switch ck.method { case "present": ok := isPresentResource(oc, ck.executor, ck.inlineNamespace, ck.expectAction, ck.resource...) if ok { return nil } return fmt.Errorf("it is not epxected") case "expect": return expectedResource(oc, ck.executor, ck.inlineNamespace, ck.expectAction, ck.expectContent, ck.expect, ck.resource...) default: return fmt.Errorf("unknown method") } }
operators
function
openshift/openshift-tests-private
25d657ec-bb03-469f-9467-77ea33435a81
add
['checkDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (cl checkList) add(ck checkDescription) checkList { cl = append(cl, ck) return cl }
operators
function
openshift/openshift-tests-private
6af1833b-bbcb-4164-bbff-e5d4a66c9443
empty
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (cl checkList) empty() checkList { cl = cl[0:0] return cl }
operators
function
openshift/openshift-tests-private
4bb7532a-bf2e-4483-9d97-9cec9b9173a0
check
['"sync"']
['checkDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (cl checkList) check(oc *exutil.CLI) { var wg sync.WaitGroup for _, ck := range cl { wg.Add(1) go func(ck checkDescription) { defer g.GinkgoRecover() defer wg.Done() ck.check(oc) }(ck) } wg.Wait() }
operators
function
openshift/openshift-tests-private
a407e724-927f-49c3-8e2c-3fa989d4fffd
newResource
['resourceDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func newResource(oc *exutil.CLI, kind string, name string, nsflag bool, namespace string) resourceDescription { return resourceDescription{ oc: oc, asAdmin: asAdmin, withoutNamespace: withoutNamespace, kind: kind, name: name, requireNS: nsflag, namespace: namespace, } }
operators
function
openshift/openshift-tests-private
a7c34c0f-9289-45e2-acc7-bafd1fb48742
delete
['resourceDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (r resourceDescription) delete() { if r.withoutNamespace && r.requireNS { removeResource(r.oc, r.asAdmin, r.withoutNamespace, r.kind, r.name, "-n", r.namespace) } else { removeResource(r.oc, r.asAdmin, r.withoutNamespace, r.kind, r.name) } }
operators
function
openshift/openshift-tests-private
b47a4980-ee8e-4650-93e5-5269bffb87b1
add
['resourceDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (ir itResource) add(r resourceDescription) { ir[r.name+r.kind+r.namespace] = r }
operators
function
openshift/openshift-tests-private
7fa0394b-013e-4558-8211-303376073558
get
['resourceDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (ir itResource) get(name string, kind string, namespace string) resourceDescription { r, ok := ir[name+kind+namespace] o.Expect(ok).To(o.BeTrue()) return r }
operators
function
openshift/openshift-tests-private
01a5fd7c-3ee6-4915-bef7-cde97d6ee728
remove
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (ir itResource) remove(name string, kind string, namespace string) { rKey := name + kind + namespace if r, ok := ir[rKey]; ok { r.delete() delete(ir, rKey) } }
operators
function
openshift/openshift-tests-private
0091253d-9890-4e5e-abd7-dd54939ea1e4
cleanup
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (ir itResource) cleanup() { for _, r := range ir { e2e.Logf("cleanup resource %s, %s", r.kind, r.name) ir.remove(r.name, r.kind, r.namespace) } }
operators
function
openshift/openshift-tests-private
d4f5771f-2d71-490e-a5c4-5de0eba5973d
addIr
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (dr describerResrouce) addIr(itName string) { dr[itName] = itResource{} }
operators
function
openshift/openshift-tests-private
d1a475b1-eb60-467e-a9b9-bde4f36d0536
getIr
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (dr describerResrouce) getIr(itName string) itResource { ir, ok := dr[itName] if !ok { e2e.Logf("!!! couldn't find the itName:%s, print the describerResrouce:%v", itName, dr) } o.Expect(ok).To(o.BeTrue()) return ir }
operators
function
openshift/openshift-tests-private
6b6736a4-2f19-4011-9d82-f6014daaec55
rmIr
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func (dr describerResrouce) rmIr(itName string) { delete(dr, itName) }
operators
function
openshift/openshift-tests-private
9a181253-9b38-492a-a1f6-c4d322d4b8b4
convertLMtoJSON
['"strings"']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func convertLMtoJSON(content string) string { var jb strings.Builder jb.WriteString("[") items := strings.Split(strings.TrimSuffix(strings.TrimPrefix(content, "["), "]"), "map") for _, item := range items { if strings.Compare(item, "") == 0 { continue } kvs := strings.Fields(strings.TrimSuffix(strings.TrimPrefix(item, "["), "]")) jb.WriteString("{") for ki, kv := range kvs { p := strings.Split(kv, ":") jb.WriteString("\"" + p[0] + "\":") jb.WriteString("\"" + p[1] + "\"") if ki < len(kvs)-1 { jb.WriteString(", ") } } jb.WriteString("},") } return strings.TrimSuffix(jb.String(), ",") + "]" }
operators
function
openshift/openshift-tests-private
531c61fb-6668-4522-b400-3d1370ebf112
getRandomString
['"math/rand"', '"time"']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func getRandomString() string { chars := "abcdefghijklmnopqrstuvwxyz0123456789" seed := rand.New(rand.NewSource(time.Now().UnixNano())) buffer := make([]byte, 8) for index := range buffer { buffer[index] = chars[seed.Intn(len(chars))] } return string(buffer) }
operators
function
openshift/openshift-tests-private
87a4e026-5d53-493b-bb6d-85a737a64146
generateUpdatedKubernatesVersion
['"strconv"', '"strings"']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func generateUpdatedKubernatesVersion(oc *exutil.CLI) string { subKubeVersions := strings.Split(getKubernetesVersion(oc), ".") zVersion, _ := strconv.Atoi(subKubeVersions[1]) subKubeVersions[1] = strconv.Itoa(zVersion + 1) return strings.Join(subKubeVersions[0:2], ".") + ".0" }
operators
function
openshift/openshift-tests-private
1586dfff-0f92-4a0c-9116-0d821b6fed74
getKubernetesVersion
['"encoding/json"', '"strings"']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func getKubernetesVersion(oc *exutil.CLI) string { output, err := doAction(oc, "version", asAdmin, withoutNamespace, "-o=json") o.Expect(err).NotTo(o.HaveOccurred()) var result map[string]interface{} err = json.Unmarshal([]byte(output), &result) o.Expect(err).NotTo(o.HaveOccurred()) gitVersion := result["serverVersion"].(map[string]interface{})["gitVersion"] e2e.Logf("gitVersion is %v", gitVersion) return strings.TrimPrefix(gitVersion.(string), "v") }
operators
function
openshift/openshift-tests-private
bb3ed7da-aad2-4025-9580-0760e27aaa1e
applyResourceFromTemplate
['"context"', '"encoding/json"', '"fmt"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func applyResourceFromTemplate(oc *exutil.CLI, parameters ...string) error { var configFile string err := wait.PollUntilContextTimeout(context.TODO(), 3*time.Second, 15*time.Second, false, func(ctx context.Context) (bool, error) { output, err := oc.AsAdmin().Run("process").Args(parameters...).OutputToFile(getRandomString() + "olm-config.json") if err != nil { e2e.Logf("the err:%v, and try next round", err) return false, nil } configFile = output return true, nil }) exutil.AssertWaitPollNoErr(err, fmt.Sprintf("can not process %v", parameters)) e2e.Logf("the file of resource is %s", configFile) return oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", configFile).Execute() }
operators
function
openshift/openshift-tests-private
48f350fd-fb71-47b9-b2eb-98dd9a603535
isPresentResource
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func isPresentResource(oc *exutil.CLI, asAdmin bool, withoutNamespace bool, present bool, parameters ...string) bool { return checkPresent(oc, 3, 70, asAdmin, withoutNamespace, present, parameters...) }
operators
function
openshift/openshift-tests-private
62a38e49-ead0-41b8-b2a0-500d775c56e9
checkPresent
['"context"', '"strings"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func checkPresent(oc *exutil.CLI, intervalSec int, durationSec int, asAdmin bool, withoutNamespace bool, present bool, parameters ...string) bool { parameters = append(parameters, "--ignore-not-found") err := wait.PollUntilContextTimeout(context.TODO(), time.Duration(intervalSec)*time.Second, time.Duration(durationSec)*time.Second, false, func(ctx context.Context) (bool, error) { output, err := doAction(oc, "get", asAdmin, withoutNamespace, parameters...) if err != nil { e2e.Logf("the get error is %v, and try next", err) return false, nil } if !present && strings.Compare(output, "") == 0 { return true, nil } if present && strings.Compare(output, "") != 0 { return true, nil } return false, nil }) return err == nil }
operators
function
openshift/openshift-tests-private
bf8eb1b1-af71-4a0e-9e3c-bbba645d9503
patchResource
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func patchResource(oc *exutil.CLI, asAdmin bool, withoutNamespace bool, parameters ...string) { _, err := doAction(oc, "patch", asAdmin, withoutNamespace, parameters...) o.Expect(err).NotTo(o.HaveOccurred()) }
operators
function
openshift/openshift-tests-private
9ff9e752-8d86-48b7-8603-b8b31541cf32
execResource
['"context"', '"fmt"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func execResource(oc *exutil.CLI, asAdmin bool, withoutNamespace bool, parameters ...string) string { var result string err := wait.PollUntilContextTimeout(context.TODO(), 3*time.Second, 6*time.Second, false, func(ctx context.Context) (bool, error) { output, err := doAction(oc, "exec", asAdmin, withoutNamespace, parameters...) if err != nil { e2e.Logf("the exec error is %v, and try next", err) return false, nil } result = output return true, nil }) exutil.AssertWaitPollNoErr(err, fmt.Sprintf("can not exec %v", parameters)) e2e.Logf("the result of exec resource:%v", result) return result }
operators
function
openshift/openshift-tests-private
c73198ee-0e93-4007-a9ca-711f5676e138
getResource
['"context"', '"fmt"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func getResource(oc *exutil.CLI, asAdmin bool, withoutNamespace bool, parameters ...string) string { var result string var err error err = wait.PollUntilContextTimeout(context.TODO(), 3*time.Second, 150*time.Second, false, func(ctx context.Context) (bool, error) { result, err = doAction(oc, "get", asAdmin, withoutNamespace, parameters...) if err != nil { e2e.Logf("output is %v, error is %v, and try next", result, err) return false, nil } return true, nil }) exutil.AssertWaitPollNoErr(err, fmt.Sprintf("can not get %v", parameters)) e2e.Logf("$oc get %v, the returned resource:%v", parameters, result) return result }
operators
function
openshift/openshift-tests-private
240e1c8a-305b-4c4b-92e1-492610dff776
getResourceNoEmpty
['"context"', '"fmt"', '"strings"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func getResourceNoEmpty(oc *exutil.CLI, asAdmin bool, withoutNamespace bool, parameters ...string) string { var result string var err error err = wait.PollUntilContextTimeout(context.TODO(), 3*time.Second, 150*time.Second, false, func(ctx context.Context) (bool, error) { result, err = doAction(oc, "get", asAdmin, withoutNamespace, parameters...) if err != nil || strings.TrimSpace(result) == "" { e2e.Logf("output is %v, error is %v, and try next", result, err) return false, nil } return true, nil }) exutil.AssertWaitPollNoErr(err, fmt.Sprintf("can not get %v without empty", parameters)) e2e.Logf("$oc get %v, the returned resource:%v", parameters, result) return result }
operators
function
openshift/openshift-tests-private
79e61d4d-2346-48bd-a85e-c0c19c988698
expectedResource
['"context"', '"strings"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func expectedResource(oc *exutil.CLI, asAdmin bool, withoutNamespace bool, isCompare bool, content string, expect bool, parameters ...string) error { expectMap := map[bool]string{ true: "do", false: "do not", } cc := func(a, b string, ic bool) bool { bs := strings.Split(b, "+2+") ret := false for _, s := range bs { if (ic && strings.Compare(a, s) == 0) || (!ic && strings.Contains(a, s)) { ret = true } } return ret } e2e.Logf("Running: oc get asAdmin(%t) withoutNamespace(%t) %s", asAdmin, withoutNamespace, strings.Join(parameters, " ")) // The detault timeout timeString := "150s" // extract the custom timeout if strings.Contains(content, "-TIME-WAIT-") { timeString = strings.Split(content, "-TIME-WAIT-")[1] content = strings.Split(content, "-TIME-WAIT-")[0] e2e.Logf("! reset the timeout to %s", timeString) } timeout, err := time.ParseDuration(timeString) if err != nil { e2e.Failf("! Fail to parse the timeout value:%s, err:%v", content, err) } return wait.PollUntilContextTimeout(context.TODO(), 3*time.Second, timeout, false, func(ctx context.Context) (bool, error) { output, err := doAction(oc, "get", asAdmin, withoutNamespace, parameters...) if err != nil { e2e.Logf("the get error is %v, and try next", err) return false, nil } e2e.Logf("---> we %v expect value: %s, in returned value: %s", expectMap[expect], content, output) if isCompare && expect && cc(output, content, isCompare) { e2e.Logf("the output %s matches one of the content %s, expected", output, content) return true, nil } if isCompare && !expect && !cc(output, content, isCompare) { e2e.Logf("the output %s does not matche the content %s, expected", output, content) return true, nil } if !isCompare && expect && cc(output, content, isCompare) { e2e.Logf("the output %s contains one of the content %s, expected", output, content) return true, nil } if !isCompare && !expect && !cc(output, content, isCompare) { e2e.Logf("the output %s does not contain the content %s, expected", output, content) return true, nil } e2e.Logf("---> Not as expected! Return false") return false, nil }) }
operators
function
openshift/openshift-tests-private
c7a293f1-c26e-4d72-8142-768a2c0d07dc
removeResource
['"context"', '"fmt"', '"strings"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func removeResource(oc *exutil.CLI, asAdmin bool, withoutNamespace bool, parameters ...string) { output, err := doAction(oc, "delete", asAdmin, withoutNamespace, parameters...) if err != nil && (strings.Contains(output, "NotFound") || strings.Contains(output, "No resources found")) { e2e.Logf("the resource is deleted already") return } o.Expect(err).NotTo(o.HaveOccurred()) err = wait.PollUntilContextTimeout(context.TODO(), 4*time.Second, 160*time.Second, false, func(ctx context.Context) (bool, error) { output, err := doAction(oc, "get", asAdmin, withoutNamespace, parameters...) if err != nil && (strings.Contains(output, "NotFound") || strings.Contains(output, "No resources found")) { e2e.Logf("the resource is delete successfully") return true, nil } return false, nil }) exutil.AssertWaitPollNoErr(err, fmt.Sprintf("can not remove %v", parameters)) }
operators
function
openshift/openshift-tests-private
a7faa2cf-ece1-4f94-a9c2-4d1d33542662
doAction
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func doAction(oc *exutil.CLI, action string, asAdmin bool, withoutNamespace bool, parameters ...string) (string, error) { if asAdmin && withoutNamespace { return oc.AsAdmin().WithoutNamespace().Run(action).Args(parameters...).Output() } if asAdmin && !withoutNamespace { return oc.AsAdmin().Run(action).Args(parameters...).Output() } if !asAdmin && withoutNamespace { return oc.WithoutNamespace().Run(action).Args(parameters...).Output() } if !asAdmin && !withoutNamespace { return oc.Run(action).Args(parameters...).Output() } return "", nil }
operators
function
openshift/openshift-tests-private
caab6e20-fc84-4df4-8342-3bf0a4aedc05
clusterPackageExists
['"strings"']
['subscriptionDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func clusterPackageExists(oc *exutil.CLI, sub subscriptionDescription) (bool, error) { found := false var v []string msg, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("packagemanifest", "-o=jsonpath={range .items[*]}{@.metadata.name}{\",\"}{@.metadata.labels.catalog}{\"\\n\"}{end}").Output() if err == nil { for _, s := range strings.Fields(msg) { v = strings.Split(s, ",") if v[0] == sub.operatorPackage && v[1] == sub.catalogSourceName { found = true e2e.Logf("%v matches: %v", s, sub.operatorPackage) break } } } // add logging on failures if !found { e2e.Logf("%v was not found in \n%v", sub.operatorPackage, msg) } return found, err }
operators
function
openshift/openshift-tests-private
77ed8fb7-a67d-4361-9cdb-5362fe2a4eaf
clusterPackageExistsInNamespace
['"strings"']
['subscriptionDescription']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func clusterPackageExistsInNamespace(oc *exutil.CLI, sub subscriptionDescription, namespace string) (bool, error) { found := false var v []string var msg string var err error if namespace == "all" { msg, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("packagemanifest", "--all-namespaces", "-o=jsonpath={range .items[*]}{@.metadata.name}{\",\"}{@.metadata.labels.catalog}{\"\\n\"}{end}").Output() } else { msg, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("packagemanifest", "-n", namespace, "-o=jsonpath={range .items[*]}{@.metadata.name}{\",\"}{@.metadata.labels.catalog}{\"\\n\"}{end}").Output() } if err == nil { for _, s := range strings.Fields(msg) { v = strings.Split(s, ",") if v[0] == sub.operatorPackage && v[1] == sub.catalogSourceName { found = true e2e.Logf("%v matches: %v", s, sub.operatorPackage) break } } } if !found { e2e.Logf("%v was not found in \n%v", sub.operatorPackage, msg) } return found, err }
operators
function
openshift/openshift-tests-private
090bdc94-375b-4d4d-853a-8a849a1fb53d
githubClient
['"context"', '"net/http"', '"os"', '"golang.org/x/oauth2"']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func githubClient() (context.Context, *http.Client) { ctx := context.Background() ts := oauth2.StaticTokenSource( &oauth2.Token{AccessToken: os.Getenv("GITHUB_TOKEN")}, ) tc := oauth2.NewClient(ctx, ts) return ctx, tc }
operators
function
openshift/openshift-tests-private
acb53dd4-b6e6-4f37-be0f-6cb532bfb9e8
GetDirPath
['"path/filepath"', '"strings"']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func GetDirPath(filePathStr string, filePre string) string { if !strings.Contains(filePathStr, "/") || filePathStr == "/" { return "" } dir, file := filepath.Split(filePathStr) if strings.HasPrefix(file, filePre) { return filePathStr } return GetDirPath(filepath.Dir(dir), filePre) }
operators
function
openshift/openshift-tests-private
0131e342-e608-42ab-a462-1101ea9587ce
DeleteDir
['"os"', '"strings"']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func DeleteDir(filePathStr string, filePre string) bool { filePathToDelete := GetDirPath(filePathStr, filePre) if filePathToDelete == "" || !strings.Contains(filePathToDelete, filePre) { e2e.Logf("there is no such dir %s", filePre) return false } e2e.Logf("remove dir %s", filePathToDelete) os.RemoveAll(filePathToDelete) if _, err := os.Stat(filePathToDelete); err == nil { e2e.Logf("delele dir %s failed", filePathToDelete) return false } return true }
operators
function
openshift/openshift-tests-private
21a27565-aa8a-462e-8934-6ea3ed56c548
CheckUpgradeStatus
['"context"', '"fmt"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func CheckUpgradeStatus(oc *exutil.CLI, expectedStatus string) { e2e.Logf("Check the Upgradeable status of the OLM, expected: %s", expectedStatus) err := wait.PollUntilContextTimeout(context.TODO(), 3*time.Second, 60*time.Second, false, func(ctx context.Context) (bool, error) { upgradeable, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("co", "operator-lifecycle-manager", "-o=jsonpath={.status.conditions[?(@.type==\"Upgradeable\")].status}").Output() if err != nil { e2e.Failf("Fail to get the Upgradeable status of the OLM: %v", err) } if upgradeable != expectedStatus { return false, nil } e2e.Logf("The Upgraableable status should be %s, and get %s", expectedStatus, upgradeable) return true, nil }) exutil.AssertWaitPollNoErr(err, fmt.Sprintf("Upgradeable status of the OLM %s is not expected", expectedStatus)) }
operators
function
openshift/openshift-tests-private
74d2bc06-c309-460d-bd45-6b62d8939ce1
getSAToken
['"strings"']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func getSAToken(oc *exutil.CLI, sa, ns string) (string, error) { e2e.Logf("Getting a token assgined to specific serviceaccount from %s namespace...", ns) token, err := oc.AsAdmin().WithoutNamespace().Run("create").Args("token", sa, "-n", ns).Output() if err != nil { if strings.Contains(token, "unknown command") { // oc client is old version, create token is not supported e2e.Logf("oc create token is not supported by current client, use oc sa get-token instead") token, err = oc.AsAdmin().WithoutNamespace().Run("sa").Args("get-token", sa, "-n", ns).Output() } else { return "", err } } return token, err }
operators
function
openshift/openshift-tests-private
a9dca5e9-3400-481b-acdb-330679bcb93c
notInList
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func notInList(target string, strArray []string) bool { for _, element := range strArray { if target == element { return false } } return true }
operators
function
openshift/openshift-tests-private
82a1014b-9c6f-4ce4-b8e8-ae985c3e329f
logDebugInfo
['"strings"']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func logDebugInfo(oc *exutil.CLI, ns string, resource ...string) { for _, resourceIndex := range resource { e2e.Logf("oc get %s:", resourceIndex) output, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args(resourceIndex, "-n", ns).Output() if strings.Contains(resourceIndex, "event") { var warningEventList []string lines := strings.Split(output, "\n") for _, line := range lines { if strings.Contains(line, "Warning") { warningStr := strings.Split(line, "Warning")[1] if notInList(warningStr, warningEventList) { warningEventList = append(warningEventList, "Warning"+warningStr) } } } e2e.Logf(strings.Join(warningEventList, "\n")) } else { e2e.Logf(output) } } }
operators
function
openshift/openshift-tests-private
2c03ad14-3702-4b86-a6ef-3d914be75d9f
isSNOCluster
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func isSNOCluster(oc *exutil.CLI) bool { //Only 1 master, 1 worker node and with the same hostname. masterNodes, _ := exutil.GetClusterNodesBy(oc, "master") workerNodes, _ := exutil.GetClusterNodesBy(oc, "worker") e2e.Logf("masterNodes:%s, workerNodes:%s", masterNodes, workerNodes) if len(masterNodes) == 1 && len(workerNodes) == 1 && masterNodes[0] == workerNodes[0] { e2e.Logf("This is a SNO cluster") return true } return false }
operators
function
openshift/openshift-tests-private
a82017bc-46c1-4280-9e04-306a6d347432
assertOrCheckMCP
['"context"', '"fmt"', '"strings"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func assertOrCheckMCP(oc *exutil.CLI, mcp string, is int, dm int, skip bool) { var machineCount string err := wait.PollUntilContextTimeout(context.TODO(), time.Duration(is)*time.Second, time.Duration(dm)*time.Minute, false, func(ctx context.Context) (bool, error) { machineCount, _ = oc.AsAdmin().WithoutNamespace().Run("get").Args("mcp", mcp, "-o=jsonpath={.status.machineCount}{\" \"}{.status.readyMachineCount}{\" \"}{.status.unavailableMachineCount}{\" \"}{.status.degradedMachineCount}").Output() indexCount := strings.Fields(machineCount) if strings.Compare(indexCount[0], indexCount[1]) == 0 && strings.Compare(indexCount[2], "0") == 0 && strings.Compare(indexCount[3], "0") == 0 { return true, nil } return false, nil }) e2e.Logf("MachineCount:ReadyMachineCountunavailableMachineCountdegradedMachineCount: %v", machineCount) if err != nil { if skip { g.Skip(fmt.Sprintf("the mcp %v is not correct status, so skip it", machineCount)) } exutil.AssertWaitPollNoErr(err, fmt.Sprintf("macineconfigpool %v update failed", mcp)) } }
operators
function
openshift/openshift-tests-private
a78d00ff-4fbe-4715-a433-01b639166ffb
getAllCSV
['"strings"']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func getAllCSV(oc *exutil.CLI) []string { allCSVs, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("csv", "--all-namespaces", `-o=jsonpath={range .items[*]}{@.metadata.name}{","}{@.metadata.namespace}{","}{@.status.reason}{":"}{end}`).Output() if err != nil { e2e.Failf("!!! Couldn't get all CSVs:%v\n", err) } var csvListOutput []string csvList := strings.Split(allCSVs, ":") for _, csv := range csvList { if strings.Compare(csv, "") == 0 { continue } name := strings.Split(csv, ",")[0] ns := strings.Split(csv, ",")[1] reason := strings.Split(csv, ",")[2] if strings.Compare(reason, "Copied") == 0 { continue } csvListOutput = append(csvListOutput, ns+":"+name) } return csvListOutput }
operators
function
openshift/openshift-tests-private
7e378e70-4a73-4085-b881-b95822a8c448
CreateCatalog
['"context"', '"fmt"', '"strings"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func CreateCatalog(oc *exutil.CLI, catalogName, indexImage, catalogTemplate string) { catalog, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("catalog", catalogName).Output() if err != nil { if strings.Contains(catalog, "not found") { err = applyResourceFromTemplate(oc, "--ignore-unknown-parameters=true", "-f", catalogTemplate, "-p", fmt.Sprintf("NAME=%s", catalogName), fmt.Sprintf("IMAGE=%s", indexImage)) if err != nil { e2e.Logf("Failed to create catalog %s: %s", catalogName, err) // we do not asser it here because it is possible race condition. it means two cases create it at same // time, and the second will raise error } // here we will assert if the catalog is created successfully with checking unpack status. // need to check unpack status before continue to use it err = wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) { phase, errPhase := oc.AsAdmin().WithoutNamespace().Run("get").Args("catalog", catalogName, "-o=jsonpath={.status.phase}").Output() if errPhase != nil { e2e.Logf("%v, next try", errPhase) return false, nil } if strings.Compare(phase, "Unpacked") == 0 { return true, nil } return false, nil }) exutil.AssertWaitPollNoErr(err, "catalog unpack fails") } else { o.Expect(err).NotTo(o.HaveOccurred()) } } }
operators
function
openshift/openshift-tests-private
7315864a-14f8-4fe5-999d-d7f5d13cad22
getCertRotation
['"context"', '"crypto/x509"', '"encoding/base64"', '"encoding/pem"', '"fmt"', '"time"', '"github.com/tidwall/gjson"', '"k8s.io/apimachinery/pkg/util/wait"', 'e2e "k8s.io/kubernetes/test/e2e/framework"']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func getCertRotation(oc *exutil.CLI, secretName, namespace string) (certsLastUpdated, certsRotateAt time.Time) { var certsEncoding string var err error err = wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) { certsEncoding, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("secret", secretName, "-n", namespace, "-o=jsonpath={.data}").Output() if err != nil { return false, nil } return true, nil }) exutil.AssertWaitPollNoErr(err, fmt.Sprintf("Fail to get the certsEncoding, certsEncoding:%v, error:%v", certsEncoding, err)) certs, err := base64.StdEncoding.DecodeString(gjson.Get(certsEncoding, `tls\.crt`).String()) if err != nil { e2e.Failf("Fail to get the certs:%v, error:%v", certs, err) } block, _ := pem.Decode(certs) if block == nil { e2e.Failf("failed to parse certificate PEM") } dates, err := x509.ParseCertificate(block.Bytes) if err != nil { e2e.Failf("Fail to parse certificate:\n%v, error:%v", string(certs), err) } notBefore := dates.NotBefore notAfter := dates.NotAfter // code: https://github.com/jianzhangbjz/operator-framework-olm/commit/7275a55186a59fcb9845cbe3a9a99c56a7afbd1d duration, _ := time.ParseDuration("5m") secondsDifference := notBefore.Add(duration).Sub(notAfter).Seconds() if secondsDifference > 3 || secondsDifference < -3 { e2e.Failf("the duration is incorrect, notBefore:%v, notAfter:%v, secondsDifference:%v", notBefore, notAfter, secondsDifference) } g.By("rotation will be 1 minutes earlier than expiration") certsLastUpdadString, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("csv", "packageserver", "-n", "openshift-operator-lifecycle-manager", "-o=jsonpath={.status.certsLastUpdated}").Output() if err != nil { e2e.Failf("Fail to get certsLastUpdated, error:%v", err) } certsRotateAtString, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("csv", "packageserver", "-n", "openshift-operator-lifecycle-manager", "-o=jsonpath={.status.certsRotateAt}").Output() if err != nil { e2e.Failf("Fail to get certsRotateAt, error:%v", err) } duration2, _ := time.ParseDuration("4m") certsLastUpdated, _ = time.Parse(time.RFC3339, certsLastUpdadString) certsRotateAt, _ = time.Parse(time.RFC3339, certsRotateAtString) // certsLastUpdated:2022-08-23 08:59:45 // certsRotateAt:2022-08-23 09:03:44 // due to https://issues.redhat.com/browse/OCPBUGS-444, there is a 1s difference, so here check if seconds difference in 3s. secondsDifference = certsLastUpdated.Add(duration2).Sub(certsRotateAt).Seconds() if secondsDifference > 3 || secondsDifference < -3 { e2e.Failf("the certsRotateAt beyond 3s than expected, certsLastUpdated:%v, certsRotateAt:%v", certsLastUpdated, certsRotateAt) } return certsLastUpdated, certsRotateAt }
operators
function
openshift/openshift-tests-private
4ca1db53-d9ee-4f73-a916-0a22934b90ba
applyResourceFromTemplateOnMicroshift
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func applyResourceFromTemplateOnMicroshift(oc *exutil.CLI, parameters ...string) error { configFile := exutil.ParameterizedTemplateByReplaceToFile(oc, parameters...) e2e.Logf("the file of resource is %s", configFile) return oc.WithoutNamespace().Run("apply").Args("-f", configFile).Execute() }
operators
function
openshift/openshift-tests-private
54f7fa0a-2178-452f-a7a0-dd87251433b3
GetPodImageAndPolicy
['"fmt"', '"strings"']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func GetPodImageAndPolicy(oc *exutil.CLI, podName, project string) (imageMap map[string]string) { imageMap = make(map[string]string) if podName == "" || project == "" { return imageMap } containers := []string{"initContainers", "containers"} for _, v := range containers { imageNameSlice := []string{} imagePullPolicySlice := []string{} jsonPathImage := fmt.Sprintf("-o=jsonpath={.spec.%s[*].image}", v) jsonPathPolicy := fmt.Sprintf("-o=jsonpath={.spec.%s[*].imagePullPolicy}", v) imageNames, err := oc.AsAdmin().WithoutNamespace().Run("get").Args(podName, jsonPathImage, "-n", project).Output() // sometimes some job's pod maybe deleted so skip it if err != nil { if !strings.Contains(imageNames, "NotFound") { e2e.Failf("Fail to get image(%s), error:%s", podName, imageNames) } } else { imageNameSlice = strings.Split(imageNames, " ") } imagePullPolicys, err := oc.AsAdmin().WithoutNamespace().Run("get").Args(podName, jsonPathPolicy, "-n", project).Output() if err != nil { if !strings.Contains(imagePullPolicys, "NotFound") { e2e.Failf("Fail to get imagePullPolicy(%s), error:%s", podName, imagePullPolicys) } } else { imagePullPolicySlice = strings.Split(imagePullPolicys, " ") } if len(imageNameSlice) < 1 || len(imagePullPolicySlice) < 1 { continue } for i := 0; i < len(imageNameSlice); i++ { if _, ok := imageMap[imageNameSlice[i]]; !ok { imageMap[imageNameSlice[i]] = imagePullPolicySlice[i] } } } return imageMap }
operators
function
openshift/openshift-tests-private
6bfe553f-33a0-4aff-9e4d-1d08d22d322b
getProjectPods
['"strings"']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func getProjectPods(oc *exutil.CLI, project string) (podSlice []string) { podSlice = []string{} if project == "" { return podSlice } pods, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-o", "name", "-n", project).Output() if err != nil { e2e.Failf("Fail to get %s pods, error:%v", project, err) } podSlice = strings.Split(pods, "\n") return podSlice }
operators
function
openshift/openshift-tests-private
069f1efd-b463-4525-b975-66f5e2a28598
ClusterHasEnabledFIPS
['"fmt"', '"strings"']
github.com/openshift/openshift-tests-private/test/extended/operators/olm_utils.go
func ClusterHasEnabledFIPS(oc *exutil.CLI) bool { firstNode, err := exutil.GetFirstMasterNode(oc) msgIfErr := fmt.Sprintf("ERROR Could not get first node to check FIPS '%v' %v", firstNode, err) o.Expect(err).NotTo(o.HaveOccurred(), msgIfErr) o.Expect(firstNode).NotTo(o.BeEmpty(), msgIfErr) // hardcode the default project since its enforce is privileged as default fipsModeStatus, err := oc.AsAdmin().Run("debug").Args("-n", "default", "node/"+firstNode, "--", "chroot", "/host", "fips-mode-setup", "--check").Output() msgIfErr = fmt.Sprintf("ERROR Could not check FIPS on node %v: '%v' %v", firstNode, fipsModeStatus, err) o.Expect(err).NotTo(o.HaveOccurred(), msgIfErr) o.Expect(fipsModeStatus).NotTo(o.BeEmpty(), msgIfErr) // This will be true or false return strings.Contains(fipsModeStatus, "FIPS mode is enabled.") }
operators
test
openshift/openshift-tests-private
786f31b5-c42f-485c-a87b-349925a7c155
olmv1_opeco
import ( "context" "fmt" "os/exec" "path/filepath" "reflect" "regexp" "strings" "time" g "github.com/onsi/ginkgo/v2" o "github.com/onsi/gomega" olmv1util "github.com/openshift/openshift-tests-private/test/extended/operators/olmv1util" exutil "github.com/openshift/openshift-tests-private/test/extended/util" container "github.com/openshift/openshift-tests-private/test/extended/util/container" "k8s.io/apimachinery/pkg/util/wait" e2e "k8s.io/kubernetes/test/e2e/framework" )
github.com/openshift/openshift-tests-private/test/extended/operators/olmv1_opeco.go
package operators import ( "context" "fmt" "os/exec" "path/filepath" "reflect" "regexp" "strings" "time" g "github.com/onsi/ginkgo/v2" o "github.com/onsi/gomega" olmv1util "github.com/openshift/openshift-tests-private/test/extended/operators/olmv1util" exutil "github.com/openshift/openshift-tests-private/test/extended/util" container "github.com/openshift/openshift-tests-private/test/extended/util/container" "k8s.io/apimachinery/pkg/util/wait" e2e "k8s.io/kubernetes/test/e2e/framework" ) var _ = g.Describe("[sig-operators] OLM v1 opeco should", func() { // Hypershift will be supported from 4.19, so add NonHyperShiftHOST Per cases now. defer g.GinkgoRecover() var ( oc = exutil.NewCLI("olmv1-opeco"+getRandomString(), exutil.KubeConfigPath()) ) g.BeforeEach(func() { exutil.SkipNoOLMv1Core(oc) }) // author: [email protected] g.It("Author:xzha-ConnectedOnly-NonHyperShiftHOST-VMonly-High-69758-Catalogd Polling remote registries for update to images content", func() { var ( baseDir = exutil.FixturePath("testdata", "olm", "v1") clustercatalogTemplate = filepath.Join(baseDir, "clustercatalog.yaml") quayCLI = container.NewQuayCLI() imagev1 = "quay.io/olmqe/olmtest-operator-index:nginxolm69758v1" imagev2 = "quay.io/olmqe/olmtest-operator-index:nginxolm69758v2" clustercatalog = olmv1util.ClusterCatalogDescription{ Name: "clustercatalog-69758", Imageref: "quay.io/olmqe/olmtest-operator-index:test69758", Template: clustercatalogTemplate, } ) exutil.By("Get v1 v2 digestID") manifestDigestv1, err := quayCLI.GetImageDigest(strings.Replace(imagev1, "quay.io/", "", 1)) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(manifestDigestv1).NotTo(o.BeEmpty()) manifestDigestv2, err := quayCLI.GetImageDigest(strings.Replace(imagev2, "quay.io/", "", 1)) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(manifestDigestv2).NotTo(o.BeEmpty()) exutil.By("Check default digestID is v1") indexImageDigest, err := quayCLI.GetImageDigest(strings.Replace(clustercatalog.Imageref, "quay.io/", "", 1)) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(indexImageDigest).NotTo(o.BeEmpty()) if indexImageDigest != manifestDigestv1 { //tag v1 to testrun image tagResult, tagErr := quayCLI.ChangeTag(strings.Replace(clustercatalog.Imageref, "quay.io/", "", 1), manifestDigestv1) if !tagResult { e2e.Logf("Error: %v", tagErr) e2e.Failf("Change tag failed on quay.io") } e2e.Logf("Successful init tag v1") } exutil.By("Create clustercatalog") defer clustercatalog.Delete(oc) clustercatalog.Create(oc) exutil.By("Add image pollInterval time") err = oc.AsAdmin().Run("patch").Args("clustercatalog", clustercatalog.Name, "-p", `{"spec":{"source":{"image":{"pollIntervalMinutes": 1}}}}`, "--type=merge").Execute() o.Expect(err).NotTo(o.HaveOccurred()) pollInterval, err := oc.WithoutNamespace().AsAdmin().Run("get").Args("clustercatalog", clustercatalog.Name, "-o=jsonpath={.spec.source.image.pollIntervalMinutes}").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(string(pollInterval)).To(o.ContainSubstring("1")) clustercatalog.WaitCatalogStatus(oc, "true", "Serving", 0) exutil.By("Collect the initial image status information") resolvedRef, err := oc.WithoutNamespace().AsAdmin().Run("get").Args("clustercatalog", clustercatalog.Name, "-o=jsonpath={.status.resolvedSource.image.ref}").Output() o.Expect(err).NotTo(o.HaveOccurred()) v1bundlesDataOut, err := clustercatalog.UnmarshalContent(oc, "bundle") o.Expect(err).NotTo(o.HaveOccurred()) v1bundlesImage := olmv1util.GetBundlesImageTag(v1bundlesDataOut.Bundles) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("Update the image and check for changes") //tag v2 to testrun image tagResult, tagErr := quayCLI.ChangeTag(strings.Replace(clustercatalog.Imageref, "quay.io/", "", 1), manifestDigestv2) if !tagResult { e2e.Logf("Error: %v", tagErr) e2e.Failf("Change tag failed on quay.io") } e2e.Logf("Successful tag v2") errWait := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 90*time.Second, false, func(ctx context.Context) (bool, error) { resolvedRef2, err := oc.WithoutNamespace().AsAdmin().Run("get").Args("clustercatalog", clustercatalog.Name, "-o=jsonpath={.status.resolvedSource.image.ref}").Output() o.Expect(err).NotTo(o.HaveOccurred()) if resolvedRef == resolvedRef2 { e2e.Logf("resolvedRef:%v,resolvedRef2:%v", resolvedRef, resolvedRef2) return false, nil } return true, nil }) exutil.AssertWaitPollNoErr(errWait, "Error resolvedRef are same") exutil.By("check the index content changes") v2bundlesDataOut, err := clustercatalog.UnmarshalContent(oc, "bundle") o.Expect(err).NotTo(o.HaveOccurred()) v2bundlesImage := olmv1util.GetBundlesImageTag(v2bundlesDataOut.Bundles) o.Expect(err).NotTo(o.HaveOccurred()) if reflect.DeepEqual(v1bundlesImage, v2bundlesImage) { e2e.Logf("v1bundlesImage%v, v2bundlesImage%v", v1bundlesImage, v2bundlesImage) e2e.Failf("Failed, The index content no changes") } e2e.Logf("v1bundlesImage%v, v2bundlesImage%v", v1bundlesImage, v2bundlesImage) exutil.By("Update use the digest image and check it") output, err := oc.AsAdmin().Run("patch").Args("clustercatalog", clustercatalog.Name, "-p", `{"spec":{"source":{"image":{"ref":"quay.io/olmqe/olmtest-operator-index@`+manifestDigestv1+`"}}}}`, "--type=merge").Output() o.Expect(err).To(o.HaveOccurred()) o.Expect(string(output)).To(o.ContainSubstring("cannot specify pollIntervalMinutes while using digest-based")) }) // author: [email protected] g.It("Author:xzha-ConnectedOnly-NonHyperShiftHOST-High-69123-Catalogd clustercatalog offer the operator content through http server", func() { var ( baseDir = exutil.FixturePath("testdata", "olm", "v1") clustercatalogTemplate = filepath.Join(baseDir, "clustercatalog.yaml") clustercatalog = olmv1util.ClusterCatalogDescription{ Name: "clustercatalog-69123", Imageref: "quay.io/olmqe/olmtest-operator-index:nginxolm69123", Template: clustercatalogTemplate, } ) exutil.By("Create clustercatalog") defer clustercatalog.Delete(oc) clustercatalog.Create(oc) exutil.By("get the index content through http service on cluster") unmarshalContent, err := clustercatalog.UnmarshalContent(oc, "all") o.Expect(err).NotTo(o.HaveOccurred()) allPackageName := olmv1util.ListPackagesName(unmarshalContent.Packages) o.Expect(allPackageName[0]).To(o.ContainSubstring("nginx69123")) channelData := olmv1util.GetChannelByPakcage(unmarshalContent.Channels, "nginx69123") o.Expect(channelData[0].Name).To(o.ContainSubstring("candidate-v0.0")) bundlesName := olmv1util.GetBundlesNameByPakcage(unmarshalContent.Bundles, "nginx69123") o.Expect(bundlesName[0]).To(o.ContainSubstring("nginx69123.v0.0.1")) }) // author: [email protected] g.It("Author:xzha-DEPRECATED-ConnectedOnly-NonHyperShiftHOST-High-69124-check the clustercatalog source type before created", func() { var ( baseDir = exutil.FixturePath("testdata", "olm", "v1") catalogPollTemplate = filepath.Join(baseDir, "clustercatalog-secret.yaml") clustercatalog = olmv1util.ClusterCatalogDescription{ Name: "clustercatalog-69124", Imageref: "quay.io/olmqe/olmtest-operator-index:nginxolm69124", PollIntervalMinutes: "1", Template: catalogPollTemplate, } ) exutil.By("Create clustercatalog") defer clustercatalog.Delete(oc) clustercatalog.Create(oc) exutil.By("Check image pollInterval time") errMsg, err := oc.AsAdmin().Run("patch").Args("clustercatalog", clustercatalog.Name, "-p", `{"spec":{"source":{"image":{"pollIntervalMinutes":"1mm"}}}}`, "--type=merge").Output() o.Expect(err).To(o.HaveOccurred()) o.Expect(strings.Contains(errMsg, "Invalid value: \"1mm\": spec.source.image.pollIntervalMinutes in body")).To(o.BeTrue()) exutil.By("Check type value") errMsg, err = oc.AsAdmin().Run("patch").Args("clustercatalog", clustercatalog.Name, "-p", `{"spec":{"source":{"type":"redhat"}}}`, "--type=merge").Output() o.Expect(err).To(o.HaveOccurred()) o.Expect(strings.Contains(errMsg, "Unsupported value: \"redhat\": supported values: \"Image\"")).To(o.BeTrue()) }) // author: [email protected] g.It("Author:xzha-ConnectedOnly-NonHyperShiftHOST-High-69242-Catalogd deprecated package/bundlemetadata/catalogmetadata from clustercatalog CR", func() { var ( baseDir = exutil.FixturePath("testdata", "olm", "v1") clustercatalogTemplate = filepath.Join(baseDir, "clustercatalog.yaml") clustercatalog = olmv1util.ClusterCatalogDescription{ Name: "clustercatalog-69242", Imageref: "quay.io/olmqe/olmtest-operator-index:nginxolm69242", Template: clustercatalogTemplate, } ) exutil.By("Create clustercatalog") defer clustercatalog.Delete(oc) clustercatalog.Create(oc) exutil.By("get the old related crd package/bundlemetadata/bundledeployment") packageOutput, err := oc.WithoutNamespace().AsAdmin().Run("get").Args("package").Output() o.Expect(err).To(o.HaveOccurred()) o.Expect(string(packageOutput)).To(o.ContainSubstring("error: the server doesn't have a resource type \"package\"")) bundlemetadata, err := oc.WithoutNamespace().AsAdmin().Run("get").Args("bundlemetadata").Output() o.Expect(err).To(o.HaveOccurred()) o.Expect(string(bundlemetadata)).To(o.ContainSubstring("error: the server doesn't have a resource type \"bundlemetadata\"")) catalogmetadata, err := oc.WithoutNamespace().AsAdmin().Run("get").Args("catalogmetadata").Output() o.Expect(err).To(o.HaveOccurred()) o.Expect(string(catalogmetadata)).To(o.ContainSubstring("error: the server doesn't have a resource type \"catalogmetadata\"")) }) // author: [email protected] g.It("Author:xzha-ConnectedOnly-NonHyperShiftHOST-High-69069-Replace pod-based image unpacker with an image registry client", func() { var ( baseDir = exutil.FixturePath("testdata", "olm", "v1") clustercatalogTemplate = filepath.Join(baseDir, "clustercatalog.yaml") clustercatalog = olmv1util.ClusterCatalogDescription{ Name: "clustercatalog-69069", Imageref: "quay.io/olmqe/olmtest-operator-index:nginxolm69069", Template: clustercatalogTemplate, } ) exutil.By("Create clustercatalog") defer clustercatalog.Delete(oc) clustercatalog.Create(oc) initresolvedRef, err := oc.WithoutNamespace().AsAdmin().Run("get").Args("clustercatalog", clustercatalog.Name, "-o=jsonpath={.status.resolvedSource.image.ref}").Output() o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("Update the index image with different tag , but the same digestID") err = oc.AsAdmin().Run("patch").Args("clustercatalog", clustercatalog.Name, "-p", `{"spec":{"source":{"image":{"ref":"quay.io/olmqe/olmtest-operator-index:nginxolm69069v1"}}}}`, "--type=merge").Execute() o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("Check the image is updated without wait but the resolvedSource is still the same and won't unpack again") jsonpath := fmt.Sprintf(`jsonpath={.status.conditions[?(@.type=="%s")].status}`, "Serving") statusOutput, err := olmv1util.GetNoEmpty(oc, "clustercatalog", clustercatalog.Name, "-o", jsonpath) o.Expect(err).NotTo(o.HaveOccurred()) if !strings.Contains(statusOutput, "True") { e2e.Failf("status is %v, not Serving", statusOutput) } errWait := wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 30*time.Second, false, func(ctx context.Context) (bool, error) { img, err := oc.WithoutNamespace().AsAdmin().Run("get").Args("clustercatalog", clustercatalog.Name, "-o=jsonpath={.status.resolvedSource.image.ref}").Output() if err != nil { return false, err } if strings.Contains(img, initresolvedRef) { return true, nil } e2e.Logf("diff image1: %v, but expect same", img) return false, nil }) if errWait != nil { olmv1util.GetNoEmpty(oc, "clustercatalog", clustercatalog.Name, "-o=jsonpath-as-json={.status}") } exutil.AssertWaitPollNoErr(errWait, "disgest is not same, but should be same") exutil.By("Update the index image with different tag and digestID") err = oc.AsAdmin().Run("patch").Args("clustercatalog", clustercatalog.Name, "-p", `{"spec":{"source":{"image":{"ref":"quay.io/olmqe/olmtest-operator-index:nginxolm69069v2"}}}}`, "--type=merge").Execute() o.Expect(err).NotTo(o.HaveOccurred()) errWait = wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 90*time.Second, false, func(ctx context.Context) (bool, error) { img, err := oc.WithoutNamespace().AsAdmin().Run("get").Args("clustercatalog", clustercatalog.Name, "-o=jsonpath={.status.resolvedSource.image.ref}").Output() if err != nil { return false, err } if strings.Contains(img, initresolvedRef) { e2e.Logf("same image, but expect not same") return false, nil } e2e.Logf("image2: %v", img) return true, nil }) if errWait != nil { olmv1util.GetNoEmpty(oc, "clustercatalog", clustercatalog.Name, "-o=jsonpath-as-json={.status}") } exutil.AssertWaitPollNoErr(errWait, "digest is same, but should be not same") }) // author: [email protected] g.It("Author:xzha-ConnectedOnly-NonHyperShiftHOST-High-69869-Catalogd Add metrics to the Storage implementation", func() { exutil.SkipOnProxyCluster(oc) var ( baseDir = exutil.FixturePath("testdata", "olm", "v1") clustercatalogTemplate = filepath.Join(baseDir, "clustercatalog.yaml") clustercatalog = olmv1util.ClusterCatalogDescription{ Name: "clustercatalog-69869", Imageref: "quay.io/olmqe/olmtest-operator-index:nginxolm69869", Template: clustercatalogTemplate, } metricsMsg string ) exutil.By("Create clustercatalog") defer clustercatalog.Delete(oc) clustercatalog.Create(oc) exutil.By("Get http content") packageDataOut, err := clustercatalog.UnmarshalContent(oc, "package") o.Expect(err).NotTo(o.HaveOccurred()) packageName := olmv1util.ListPackagesName(packageDataOut.Packages) o.Expect(packageName[0]).To(o.ContainSubstring("nginx69869")) exutil.By("Get token and clusterIP") promeEp, err := oc.WithoutNamespace().AsAdmin().Run("get").Args("service", "-n", "openshift-catalogd", "catalogd-service", "-o=jsonpath={.spec.clusterIP}").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(promeEp).NotTo(o.BeEmpty()) metricsToken, err := exutil.GetSAToken(oc) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(metricsToken).NotTo(o.BeEmpty()) clustercatalogPodname, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", "openshift-operator-lifecycle-manager", "--selector=app=catalog-operator", "-o=jsonpath={.items..metadata.name}").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(clustercatalogPodname).NotTo(o.BeEmpty()) errWait := wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 30*time.Second, false, func(ctx context.Context) (bool, error) { queryContent := "https://" + promeEp + ":7443/metrics" metricsMsg, err = oc.AsAdmin().WithoutNamespace().Run("exec").Args("-n", "openshift-operator-lifecycle-manager", clustercatalogPodname, "-i", "--", "curl", "-k", "-H", fmt.Sprintf("Authorization: Bearer %v", metricsToken), queryContent).Output() e2e.Logf("err:%v", err) if strings.Contains(metricsMsg, "catalogd_http_request_duration_seconds_bucket{code=\"200\"") { e2e.Logf("found catalogd_http_request_duration_seconds_bucket{code=\"200\"") return true, nil } return false, nil }) if errWait != nil { e2e.Logf("metricsMsg:%v", metricsMsg) exutil.AssertWaitPollNoErr(errWait, "catalogd_http_request_duration_seconds_bucket{code=\"200\" not found.") } }) // author: [email protected] g.It("Author:xzha-VMonly-DEPRECATED-ConnectedOnly-NonHyperShiftHOST-High-70817-catalogd support setting a pull secret", func() { var ( baseDir = exutil.FixturePath("testdata", "olm", "v1") clustercatalogTemplate = filepath.Join(baseDir, "clustercatalog-secret.yaml") clusterextensionTemplate = filepath.Join(baseDir, "clusterextensionWithoutChannelVersion.yaml") saClusterRoleBindingTemplate = filepath.Join(baseDir, "sa-admin.yaml") ns = "ns-70817" sa = "sa70817" saCrb = olmv1util.SaCLusterRolebindingDescription{ Name: sa, Namespace: ns, Template: saClusterRoleBindingTemplate, } clustercatalog = olmv1util.ClusterCatalogDescription{ Name: "clustercatalog-70817-quay", Imageref: "quay.io/olmqe/olmtest-operator-index-private:nginxolm70817", PullSecret: "fake-secret-70817", PollIntervalMinutes: "1", Template: clustercatalogTemplate, } clusterextension = olmv1util.ClusterExtensionDescription{ Name: "clusterextension-70817", InstallNamespace: ns, PackageName: "nginx70817", SaName: sa, Template: clusterextensionTemplate, } ) exutil.By("Create namespace") defer oc.WithoutNamespace().AsAdmin().Run("delete").Args("ns", ns, "--ignore-not-found").Execute() err := oc.WithoutNamespace().AsAdmin().Run("create").Args("ns", ns).Execute() exutil.By("Create SA for clusterextension") defer saCrb.Delete(oc) saCrb.Create(oc) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("1) Create secret") defer oc.AsAdmin().WithoutNamespace().Run("delete").Args("-n", "openshift-catalogd", "secret", "secret-70817-quay").Output() _, err = oc.AsAdmin().WithoutNamespace().Run("create").Args("-n", "openshift-catalogd", "secret", "generic", "secret-70817-quay", "--from-file=.dockerconfigjson=/home/cloud-user/.docker/config.json", "--type=kubernetes.io/dockerconfigjson").Output() o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("2) Create clustercatalog") defer clustercatalog.Delete(oc) clustercatalog.CreateWithoutCheck(oc) clustercatalog.WaitCatalogStatus(oc, "false", "Serving", 30) conditions, _ := olmv1util.GetNoEmpty(oc, "clustercatalog", clustercatalog.Name, "-o", "jsonpath={.status.conditions}") o.Expect(conditions).To(o.ContainSubstring("error fetching")) o.Expect(conditions).To(o.ContainSubstring("401 Unauthorized")) exutil.By("3) Patch the clustercatalog") patchResource(oc, asAdmin, withoutNamespace, "clustercatalog", clustercatalog.Name, "-p", `{"spec":{"source":{"image":{"pullSecret":"secret-70817-quay"}}}}`, "--type=merge") clustercatalog.WaitCatalogStatus(oc, "true", "Serving", 0) exutil.By("4) install clusterextension") defer clusterextension.Delete(oc) clusterextension.Create(oc) o.Expect(clusterextension.InstalledBundle).To(o.ContainSubstring("v1.0.1")) }) // author: [email protected] g.It("Author:xzha-ConnectedOnly-NonHyperShiftHOST-High-69202-Catalogd clustercatalog offer the operator content through http server off cluster", func() { exutil.SkipOnProxyCluster(oc) var ( baseDir = exutil.FixturePath("testdata", "olm", "v1") clustercatalogTemplate = filepath.Join(baseDir, "clustercatalog.yaml") clustercatalog = olmv1util.ClusterCatalogDescription{ Name: "clustercatalog-69202", Imageref: "quay.io/olmqe/olmtest-operator-index:nginxolm69202", Template: clustercatalogTemplate, } ) exutil.By("Create clustercatalog") defer clustercatalog.Delete(oc) clustercatalog.Create(oc) exutil.By("get the index content through http service off cluster") errWait := wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 100*time.Second, false, func(ctx context.Context) (bool, error) { checkOutput, err := exec.Command("bash", "-c", "curl -k "+clustercatalog.ContentURL).Output() if err != nil { e2e.Logf("failed to execute the curl: %s. Trying again", err) return false, nil } if matched, _ := regexp.MatchString("nginx69202", string(checkOutput)); matched { e2e.Logf("Check the content off cluster success\n") return true, nil } return false, nil }) exutil.AssertWaitPollNoErr(errWait, "Cannot get the result") }) // author: [email protected] g.It("Author:xzha-ConnectedOnly-NonHyperShiftHOST-High-73219-Fetch deprecation data from the catalogd http server", func() { var ( baseDir = exutil.FixturePath("testdata", "olm", "v1") clustercatalogTemplate = filepath.Join(baseDir, "clustercatalog.yaml") clustercatalog = olmv1util.ClusterCatalogDescription{ Name: "clustercatalog-73219", Imageref: "quay.io/olmqe/olmtest-operator-index:nginxolm73219", Template: clustercatalogTemplate, } ) exutil.By("Create clustercatalog") defer clustercatalog.Delete(oc) clustercatalog.Create(oc) exutil.By("get the deprecation content through http service on cluster") unmarshalContent, err := clustercatalog.UnmarshalContent(oc, "deprecations") o.Expect(err).NotTo(o.HaveOccurred()) deprecatedChannel := olmv1util.GetDeprecatedChannelNameByPakcage(unmarshalContent.Deprecations, "nginx73219") o.Expect(deprecatedChannel[0]).To(o.ContainSubstring("candidate-v0.0")) deprecatedBundle := olmv1util.GetDeprecatedBundlesNameByPakcage(unmarshalContent.Deprecations, "nginx73219") o.Expect(deprecatedBundle[0]).To(o.ContainSubstring("nginx73219.v0.0.1")) }) // author: [email protected] g.It("Author:xzha-ConnectedOnly-NonHyperShiftHOST-High-73289-Check the deprecation conditions and messages", func() { var ( baseDir = exutil.FixturePath("testdata", "olm", "v1") clustercatalogTemplate = filepath.Join(baseDir, "clustercatalog.yaml") clusterextensionTemplate = filepath.Join(baseDir, "clusterextension.yaml") saClusterRoleBindingTemplate = filepath.Join(baseDir, "sa-admin.yaml") ns = "ns-73289" sa = "sa73289" saCrb = olmv1util.SaCLusterRolebindingDescription{ Name: sa, Namespace: ns, Template: saClusterRoleBindingTemplate, } clustercatalog = olmv1util.ClusterCatalogDescription{ Name: "clustercatalog-73289", Imageref: "quay.io/olmqe/olmtest-operator-index:nginxolm73289", Template: clustercatalogTemplate, } clusterextension = olmv1util.ClusterExtensionDescription{ Name: "clusterextension-73289", InstallNamespace: ns, PackageName: "nginx73289v1", Channel: "candidate-v1.0", Version: "1.0.1", SaName: sa, Template: clusterextensionTemplate, } ) exutil.By("Create namespace") defer oc.WithoutNamespace().AsAdmin().Run("delete").Args("ns", ns, "--ignore-not-found").Execute() err := oc.WithoutNamespace().AsAdmin().Run("create").Args("ns", ns).Execute() o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("Create SA for clusterextension") defer saCrb.Delete(oc) saCrb.Create(oc) exutil.By("Create clustercatalog") defer clustercatalog.Delete(oc) clustercatalog.Create(oc) exutil.By("Create clusterextension with channel candidate-v1.0, version 1.0.1") defer clusterextension.Delete(oc) clusterextension.Create(oc) o.Expect(clusterextension.InstalledBundle).To(o.ContainSubstring("v1.0.1")) // Test BundleDeprecated exutil.By("Check BundleDeprecated status") clusterextension.WaitClusterExtensionCondition(oc, "Deprecated", "True", 0) clusterextension.WaitClusterExtensionCondition(oc, "BundleDeprecated", "True", 0) exutil.By("Check BundleDeprecated message info") message := clusterextension.GetClusterExtensionMessage(oc, "BundleDeprecated") if !strings.Contains(message, "nginx73289v1.v1.0.1 is deprecated. Uninstall and install v1.0.3 for support.") { e2e.Failf("Info does not meet expectations, message :%v", message) } exutil.By("update version to be >=1.0.2") clusterextension.Patch(oc, `{"spec":{"source":{"catalog":{"version": ">=1.0.2"}}}}`) errWait := wait.PollUntilContextTimeout(context.TODO(), 3*time.Second, 150*time.Second, false, func(ctx context.Context) (bool, error) { installedBundle, _ := olmv1util.GetNoEmpty(oc, "clusterextension", clusterextension.Name, "-o", "jsonpath={.status.install.bundle.name}") if !strings.Contains(installedBundle, "v1.0.3") { e2e.Logf("clusterextension.InstalledBundle is %s, not v1.0.3, and try next", installedBundle) return false, nil } return true, nil }) if errWait != nil { olmv1util.GetNoEmpty(oc, "clusterextension", clusterextension.Name, "-o=jsonpath-as-json={.status}") exutil.AssertWaitPollNoErr(errWait, "clusterextension resolvedBundle is not v1.0.3") } exutil.By("Check if BundleDeprecated status and messages still exist") clusterextension.WaitClusterExtensionCondition(oc, "Deprecated", "False", 0) clusterextension.WaitClusterExtensionCondition(oc, "BundleDeprecated", "False", 0) message = clusterextension.GetClusterExtensionMessage(oc, "BundleDeprecated") if strings.Contains(message, "nginx73289v1.v1.0.1 is deprecated. Uninstall and install v1.0.3 for support.") { e2e.Failf("BundleDeprecated message still exists :%v", message) } clusterextension.Delete(oc) exutil.By("BundleDeprecated test done") // Test ChannelDeprecated exutil.By("update channel to candidate-v3.0") clusterextension.PackageName = "nginx73289v2" clusterextension.Channel = "candidate-v3.0" clusterextension.Version = ">=1.0.0" clusterextension.Template = clusterextensionTemplate clusterextension.Create(oc) o.Expect(clusterextension.InstalledBundle).To(o.ContainSubstring("v3.0.1")) exutil.By("Check ChannelDeprecated status and message") clusterextension.WaitClusterExtensionCondition(oc, "Deprecated", "True", 0) clusterextension.WaitClusterExtensionCondition(oc, "ChannelDeprecated", "True", 0) message = clusterextension.GetClusterExtensionMessage(oc, "ChannelDeprecated") if !strings.Contains(message, "The 'candidate-v3.0' channel is no longer supported. Please switch to the 'candidate-v3.1' channel.") { e2e.Failf("Info does not meet expectations, message :%v", message) } exutil.By("update channel to candidate-v3.1") clusterextension.Patch(oc, `{"spec":{"source":{"catalog":{"channels": ["candidate-v3.1"]}}}}`) exutil.By("Check if ChannelDeprecated status and messages still exist") clusterextension.WaitClusterExtensionCondition(oc, "Deprecated", "False", 0) clusterextension.WaitClusterExtensionCondition(oc, "ChannelDeprecated", "False", 0) message = clusterextension.GetClusterExtensionMessage(oc, "ChannelDeprecated") if strings.Contains(message, "The 'candidate-v3.0' channel is no longer supported. Please switch to the 'candidate-v3.1' channel.") { e2e.Failf("ChannelDeprecated message still exists :%v", message) } clusterextension.CheckClusterExtensionCondition(oc, "Progressing", "reason", "Succeeded", 3, 150, 0) clusterextension.WaitClusterExtensionCondition(oc, "Installed", "True", 0) clusterextension.Delete(oc) exutil.By("ChannelDeprecated test done") // Test PackageDeprecated exutil.By("update Package to 73289v3") clusterextension.PackageName = "nginx73289v3" clusterextension.Channel = "candidate-v1.0" clusterextension.Version = ">=1.0.0" clusterextension.Template = clusterextensionTemplate clusterextension.Create(oc) exutil.By("Check PackageDeprecated status and message") clusterextension.WaitClusterExtensionCondition(oc, "Deprecated", "True", 0) clusterextension.WaitClusterExtensionCondition(oc, "PackageDeprecated", "True", 0) message = clusterextension.GetClusterExtensionMessage(oc, "PackageDeprecated") if !strings.Contains(message, "The nginx73289v3 package is end of life. Please use the another package for support.") { e2e.Failf("Info does not meet expectations, message :%v", message) } exutil.By("PackageDeprecated test done") }) // author: [email protected] g.It("Author:xzha-ConnectedOnly-NonHyperShiftHOST-High-74948-catalog offer the operator content through https server", func() { var ( baseDir = exutil.FixturePath("testdata", "olm", "v1") clustercatalogTemplate = filepath.Join(baseDir, "clustercatalog.yaml") clusterextensionTemplate = filepath.Join(baseDir, "clusterextension.yaml") saClusterRoleBindingTemplate = filepath.Join(baseDir, "sa-admin.yaml") ns = "ns-74948" sa = "sa74948" saCrb = olmv1util.SaCLusterRolebindingDescription{ Name: sa, Namespace: ns, Template: saClusterRoleBindingTemplate, } clustercatalog = olmv1util.ClusterCatalogDescription{ Name: "clustercatalog-74948", Imageref: "quay.io/openshifttest/nginxolm-operator-index:nginxolm74948", Template: clustercatalogTemplate, } clusterextension = olmv1util.ClusterExtensionDescription{ Name: "clusterextension-74948", InstallNamespace: ns, PackageName: "nginx74948", Channel: "candidate-v1.0", Version: "1.0.3", SaName: sa, Template: clusterextensionTemplate, } ) exutil.By("Create clustercatalog") defer clustercatalog.Delete(oc) clustercatalog.Create(oc) exutil.By("Create namespace") defer oc.WithoutNamespace().AsAdmin().Run("delete").Args("ns", ns, "--ignore-not-found").Execute() err := oc.WithoutNamespace().AsAdmin().Run("create").Args("ns", ns).Execute() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(olmv1util.Appearance(oc, exutil.Appear, "ns", ns)).To(o.BeTrue()) exutil.By("Create SA for clusterextension") defer saCrb.Delete(oc) saCrb.Create(oc) exutil.By("Examine the service to confirm that the annotations are present") describe, err := oc.WithoutNamespace().AsAdmin().Run("describe").Args("service", "catalogd-service", "-n", "openshift-catalogd").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(describe).To(o.ContainSubstring("service.beta.openshift.io/serving-cert-secret-name: catalogserver-cert")) exutil.By("Ensure that the service CA bundle has been injected") crt, err := oc.WithoutNamespace().AsAdmin().Run("get").Args("configmap", "openshift-service-ca.crt", "-n", "openshift-catalogd", "-o", "jsonpath={.metadata.annotations}").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(crt).To(o.ContainSubstring("{\"service.beta.openshift.io/inject-cabundle\":\"true\"}")) exutil.By("Check secret data tls.crt tls.key") secretData, err := oc.WithoutNamespace().AsAdmin().Run("get").Args("secret", "catalogserver-cert", "-n", "openshift-catalogd", "-o", "jsonpath={.data}").Output() o.Expect(err).NotTo(o.HaveOccurred()) if !strings.Contains(secretData, "tls.crt") || !strings.Contains(secretData, "tls.key") { e2e.Failf("secret data not found") } exutil.By("Get the index content through https service on cluster") unmarshalContent, err := clustercatalog.UnmarshalContent(oc, "all") o.Expect(err).NotTo(o.HaveOccurred()) allPackageName := olmv1util.ListPackagesName(unmarshalContent.Packages) o.Expect(allPackageName[0]).To(o.ContainSubstring("nginx74948")) exutil.By("Create clusterextension to verify operator-controller has been started, appropriately loaded the CA certs") defer clusterextension.Delete(oc) clusterextension.Create(oc) o.Expect(clusterextension.InstalledBundle).To(o.ContainSubstring("v1.0.3")) }) // author: [email protected] g.It("Author:xzha-ConnectedOnly-NonHyperShiftHOST-OSD_CCS-High-74978-CRD upgrade will be prevented if the Scope is switched between Namespaced and Cluster", func() { var ( baseDir = exutil.FixturePath("testdata", "olm", "v1") clustercatalogTemplate = filepath.Join(baseDir, "clustercatalog.yaml") clusterextensionTemplate = filepath.Join(baseDir, "clusterextension.yaml") saClusterRoleBindingTemplate = filepath.Join(baseDir, "sa-admin.yaml") ns = "ns-74978" sa = "sa74978" saCrb = olmv1util.SaCLusterRolebindingDescription{ Name: sa, Namespace: ns, Template: saClusterRoleBindingTemplate, } clustercatalog = olmv1util.ClusterCatalogDescription{ Name: "clustercatalog-74978", Imageref: "quay.io/openshifttest/nginxolm-operator-index:nginxolm74978", Template: clustercatalogTemplate, } clusterextension = olmv1util.ClusterExtensionDescription{ Name: "clusterextension-74978", InstallNamespace: ns, PackageName: "nginx74978", Channel: "candidate-v1.0", Version: "1.0.1", SaName: sa, Template: clusterextensionTemplate, } ) exutil.By("Create clustercatalog") defer clustercatalog.Delete(oc) clustercatalog.Create(oc) exutil.By("Create namespace") defer oc.WithoutNamespace().AsAdmin().Run("delete").Args("ns", ns, "--ignore-not-found").Execute() err := oc.WithoutNamespace().AsAdmin().Run("create").Args("ns", ns).Execute() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(olmv1util.Appearance(oc, exutil.Appear, "ns", ns)).To(o.BeTrue()) exutil.By("Create SA for clusterextension") defer saCrb.Delete(oc) saCrb.Create(oc) exutil.By("Create clusterextension v1.0.1") defer clusterextension.Delete(oc) clusterextension.Create(oc) o.Expect(clusterextension.InstalledBundle).To(o.ContainSubstring("v1.0.1")) exutil.By("Update the version to 1.0.2, check changed from Namespaced to Cluster") err = oc.AsAdmin().Run("patch").Args("clusterextension", clusterextension.Name, "-p", `{"spec":{"source":{"catalog":{"version":"1.0.2","upgradeConstraintPolicy":"SelfCertified"}}}}`, "--type=merge").Execute() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(clusterextension.InstalledBundle).To(o.ContainSubstring("v1.0.1")) clusterextension.CheckClusterExtensionCondition(oc, "Progressing", "message", `CustomResourceDefinition nginxolm74978s.cache.example.com failed upgrade safety validation. "NoScopeChange" validation failed: scope changed from "Namespaced" to "Cluster"`, 10, 60, 0) clusterextension.Delete(oc) exutil.By("Create clusterextension v1.0.2") clusterextension.Version = "1.0.2" clusterextension.Create(oc) o.Expect(clusterextension.InstalledBundle).To(o.ContainSubstring("v1.0.2")) exutil.By("Update the version to 1.0.3, check changed from Cluster to Namespaced") err = oc.AsAdmin().Run("patch").Args("clusterextension", clusterextension.Name, "-p", `{"spec":{"source":{"catalog":{"version":"1.0.3","upgradeConstraintPolicy":"SelfCertified"}}}}`, "--type=merge").Execute() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(clusterextension.InstalledBundle).To(o.ContainSubstring("v1.0.2")) clusterextension.CheckClusterExtensionCondition(oc, "Progressing", "message", `CustomResourceDefinition nginxolm74978s.cache.example.com failed upgrade safety validation. "NoScopeChange" validation failed: scope changed from "Cluster" to "Namespaced"`, 10, 60, 0) }) // author: [email protected] g.It("Author:xzha-ConnectedOnly-NonHyperShiftHOST-High-75218-Disabling the CRD Upgrade Safety preflight checks", func() { var ( baseDir = exutil.FixturePath("testdata", "olm", "v1") clustercatalogTemplate = filepath.Join(baseDir, "clustercatalog.yaml") clusterextensionTemplate = filepath.Join(baseDir, "clusterextension.yaml") saClusterRoleBindingTemplate = filepath.Join(baseDir, "sa-admin.yaml") ns = "ns-75218" sa = "sa75218" saCrb = olmv1util.SaCLusterRolebindingDescription{ Name: sa, Namespace: ns, Template: saClusterRoleBindingTemplate, } clustercatalog = olmv1util.ClusterCatalogDescription{ Name: "clustercatalog-75218", Imageref: "quay.io/openshifttest/nginxolm-operator-index:nginxolm75218", Template: clustercatalogTemplate, } clusterextension = olmv1util.ClusterExtensionDescription{ Name: "clusterextension-75218", InstallNamespace: ns, PackageName: "nginx75218", Channel: "candidate-v1.0", Version: "1.0.1", SaName: sa, Template: clusterextensionTemplate, } ) exutil.By("Create clustercatalog") defer clustercatalog.Delete(oc) clustercatalog.Create(oc) exutil.By("Create namespace") defer oc.WithoutNamespace().AsAdmin().Run("delete").Args("ns", ns, "--ignore-not-found").Execute() err := oc.WithoutNamespace().AsAdmin().Run("create").Args("ns", ns).Execute() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(olmv1util.Appearance(oc, exutil.Appear, "ns", ns)).To(o.BeTrue()) exutil.By("Create SA for clusterextension") defer saCrb.Delete(oc) saCrb.Create(oc) exutil.By("Create clusterextension v1.0.1") defer clusterextension.Delete(oc) clusterextension.Create(oc) o.Expect(clusterextension.InstalledBundle).To(o.ContainSubstring("v1.0.1")) exutil.By("update the version to 1.0.2, report messages and upgrade safety fail") err = oc.AsAdmin().Run("patch").Args("clusterextension", clusterextension.Name, "-p", `{"spec":{"source":{"catalog":{"version":"1.0.2","upgradeConstraintPolicy":"SelfCertified"}}}}`, "--type=merge").Execute() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(clusterextension.InstalledBundle).To(o.ContainSubstring("v1.0.1")) clusterextension.CheckClusterExtensionCondition(oc, "Progressing", "message", `scope changed from "Namespaced" to "Cluster"`, 10, 60, 0) clusterextension.CheckClusterExtensionCondition(oc, "Progressing", "message", `.spec.field1 may not be removed`, 10, 60, 0) clusterextension.CheckClusterExtensionCondition(oc, "Progressing", "message", `calculating schema diff for CRD version "v1alpha1"`, 10, 60, 0) exutil.By("disabled crd upgrade safety check, it will not affect spec.scope: Invalid value: Cluster") err = oc.AsAdmin().Run("patch").Args("clusterextension", clusterextension.Name, "-p", `{"spec":{"source":{"catalog":{"version":"1.0.2","upgradeConstraintPolicy":"SelfCertified"}}, "install":{"preflight":{"crdUpgradeSafety":{"enforcement":"None"}}}}}`, "--type=merge").Execute() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(clusterextension.InstalledBundle).To(o.ContainSubstring("v1.0.1")) var message string errWait := wait.PollUntilContextTimeout(context.TODO(), 3*time.Second, 18*time.Second, false, func(ctx context.Context) (bool, error) { message = clusterextension.GetClusterExtensionMessage(oc, "Progressing") if !strings.Contains(message, `CustomResourceDefinition.apiextensions.k8s.io "nginxolm75218s.cache.example.com" is invalid: spec.scope: Invalid value: "Cluster": field is immutable`) { return false, nil } return true, nil }) if errWait != nil { olmv1util.GetNoEmpty(oc, "clustercatalog", clustercatalog.Name, "-o=jsonpath-as-json={.status}") } exutil.AssertWaitPollNoErr(errWait, fmt.Sprintf("Unexpected results message: %v", message)) exutil.By("disabled crd upgrade safety check An existing stored version of the CRD is removed") err = oc.AsAdmin().Run("patch").Args("clusterextension", clusterextension.Name, "-p", `{"spec":{"source":{"catalog":{"version":"1.0.3","upgradeConstraintPolicy":"SelfCertified"}}, "install":{"preflight":{"crdUpgradeSafety":{"enforcement":"None"}}}}}`, "--type=merge").Execute() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(clusterextension.InstalledBundle).To(o.ContainSubstring("v1.0.1")) clusterextension.CheckClusterExtensionCondition(oc, "Progressing", "message", `must have exactly one version marked as storage version, status.storedVersions[0]: Invalid value: "v1alpha1": must appear in spec.versions`, 10, 60, 0) exutil.By("disabled crd upgrade safety successfully") err = oc.AsAdmin().Run("patch").Args("clusterextension", clusterextension.Name, "-p", `{"spec":{"source":{"catalog":{"version":"1.0.5","upgradeConstraintPolicy":"SelfCertified"}}, "install":{"preflight":{"crdUpgradeSafety":{"enforcement":"None"}}}}}`, "--type=merge").Execute() o.Expect(err).NotTo(o.HaveOccurred()) clusterextension.CheckClusterExtensionCondition(oc, "Progressing", "reason", "Succeeded", 3, 150, 0) clusterextension.WaitClusterExtensionCondition(oc, "Installed", "True", 0) clusterextension.GetBundleResource(oc) o.Expect(clusterextension.InstalledBundle).To(o.ContainSubstring("v1.0.5")) clusterextension.CheckClusterExtensionCondition(oc, "Installed", "message", "Installed bundle quay.io/openshifttest/nginxolm-operator-bundle:v1.0.5-nginxolm75218 successfully", 10, 60, 0) }) // author: [email protected] g.It("Author:xzha-ConnectedOnly-NonHyperShiftHOST-High-75122-CRD upgrade check Removing an existing stored version and add a new CRD with no modifications to existing versions", func() { exutil.SkipForSNOCluster(oc) var ( caseID = "75122" labelValue = caseID baseDir = exutil.FixturePath("testdata", "olm", "v1") clustercatalogTemplate = filepath.Join(baseDir, "clustercatalog-withlabel.yaml") clusterextensionTemplate = filepath.Join(baseDir, "clusterextension-withselectorlabel.yaml") saClusterRoleBindingTemplate = filepath.Join(baseDir, "sa-admin.yaml") ns = "ns-75122" sa = "sa75122" saCrb = olmv1util.SaCLusterRolebindingDescription{ Name: sa, Namespace: ns, Template: saClusterRoleBindingTemplate, } clustercatalog = olmv1util.ClusterCatalogDescription{ Name: "clustercatalog-75122", Imageref: "quay.io/openshifttest/nginxolm-operator-index:nginxolm75122", LabelValue: labelValue, Template: clustercatalogTemplate, } clusterextension = olmv1util.ClusterExtensionDescription{ Name: "clusterextension-75122", InstallNamespace: ns, PackageName: "nginx75122", Channel: "candidate-v1.0", Version: "1.0.1", SaName: sa, LabelValue: labelValue, Template: clusterextensionTemplate, } ) exutil.By("Create clustercatalog") defer clustercatalog.Delete(oc) clustercatalog.Create(oc) exutil.By("Create namespace") defer oc.WithoutNamespace().AsAdmin().Run("delete").Args("ns", ns, "--ignore-not-found").Execute() err := oc.WithoutNamespace().AsAdmin().Run("create").Args("ns", ns).Execute() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(olmv1util.Appearance(oc, exutil.Appear, "ns", ns)).To(o.BeTrue()) exutil.By("Create SA for clusterextension") defer saCrb.Delete(oc) saCrb.Create(oc) exutil.By("Create clusterextension v1.0.1") defer clusterextension.Delete(oc) clusterextension.Create(oc) o.Expect(clusterextension.InstalledBundle).To(o.ContainSubstring("v1.0.1")) exutil.By("upgrade will be prevented if An existing stored version of the CRD is removed") err = oc.AsAdmin().Run("patch").Args("clusterextension", clusterextension.Name, "-p", `{"spec":{"source":{"catalog":{"version":"1.0.2","upgradeConstraintPolicy":"SelfCertified"}}}}`, "--type=merge").Execute() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(clusterextension.InstalledBundle).To(o.ContainSubstring("v1.0.1")) clusterextension.CheckClusterExtensionCondition(oc, "Progressing", "message", `failed: stored version "v1alpha1" removed for resolved bundle "nginx75122.v1.0.2" with version "1.0.2"`, 10, 60, 0) exutil.By("upgrade will be allowed if A new version of the CRD is added with no modifications to existing versions") err = oc.AsAdmin().Run("patch").Args("clusterextension", clusterextension.Name, "-p", `{"spec":{"source":{"catalog":{"version":"1.0.3","upgradeConstraintPolicy":"SelfCertified"}}}}`, "--type=merge").Execute() o.Expect(err).NotTo(o.HaveOccurred()) clusterextension.CheckClusterExtensionCondition(oc, "Progressing", "reason", "Succeeded", 3, 150, 0) clusterextension.WaitClusterExtensionCondition(oc, "Installed", "True", 0) clusterextension.GetBundleResource(oc) o.Expect(clusterextension.InstalledBundle).To(o.ContainSubstring("v1.0.3")) clusterextension.CheckClusterExtensionCondition(oc, "Installed", "message", "Installed bundle quay.io/openshifttest/nginxolm-operator-bundle:v1.0.3-nginxolm75122 successfully", 10, 60, 0) exutil.By("upgrade will be prevented if An existing served version of the CRD is removed") err = oc.AsAdmin().Run("patch").Args("clusterextension", clusterextension.Name, "-p", `{"spec":{"source":{"catalog":{"version":"1.0.6","upgradeConstraintPolicy":"SelfCertified"}}}}`, "--type=merge").Execute() o.Expect(err).NotTo(o.HaveOccurred()) clusterextension.CheckClusterExtensionCondition(oc, "Installed", "message", "Installed bundle quay.io/openshifttest/nginxolm-operator-bundle:v1.0.6-nginxolm75122 successfully", 10, 60, 0) }) // author: [email protected] // Cover test case: OCP-75123 and OCP-75217 g.It("Author:xzha-ConnectedOnly-NonHyperShiftHOST-High-75123-High-75217-CRD upgrade checks for changes in required field and field type", func() { exutil.SkipForSNOCluster(oc) var ( caseID = "75123" labelValue = caseID baseDir = exutil.FixturePath("testdata", "olm", "v1") clustercatalogTemplate = filepath.Join(baseDir, "clustercatalog-withlabel.yaml") clusterextensionTemplate = filepath.Join(baseDir, "clusterextension-withselectorlabel.yaml") saClusterRoleBindingTemplate = filepath.Join(baseDir, "sa-admin.yaml") ns = "ns-75123" sa = "sa75123" saCrb = olmv1util.SaCLusterRolebindingDescription{ Name: sa, Namespace: ns, Template: saClusterRoleBindingTemplate, } clustercatalog = olmv1util.ClusterCatalogDescription{ Name: "clustercatalog-75123", Imageref: "quay.io/openshifttest/nginxolm-operator-index:nginxolm75123", LabelValue: labelValue, Template: clustercatalogTemplate, } clusterextension = olmv1util.ClusterExtensionDescription{ Name: "clusterextension-75123", InstallNamespace: ns, PackageName: "nginx75123", Channel: "candidate-v1.0", Version: "1.0.1", SaName: sa, LabelValue: labelValue, Template: clusterextensionTemplate, } ) exutil.By("Create clustercatalog") defer clustercatalog.Delete(oc) clustercatalog.Create(oc) exutil.By("Create namespace") defer oc.WithoutNamespace().AsAdmin().Run("delete").Args("ns", ns, "--ignore-not-found").Execute() err := oc.WithoutNamespace().AsAdmin().Run("create").Args("ns", ns).Execute() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(olmv1util.Appearance(oc, exutil.Appear, "ns", ns)).To(o.BeTrue()) exutil.By("Create SA for clusterextension") defer saCrb.Delete(oc) saCrb.Create(oc) exutil.By("Create clusterextension v1.0.1") defer clusterextension.Delete(oc) clusterextension.Create(oc) o.Expect(clusterextension.InstalledBundle).To(o.ContainSubstring("v1.0.1")) exutil.By("upgrade will be prevented if A new required field is added to an existing version of the CRD") err = oc.AsAdmin().Run("patch").Args("clusterextension", clusterextension.Name, "-p", `{"spec":{"source":{"catalog":{"version":"1.0.2","upgradeConstraintPolicy":"SelfCertified"}}}}`, "--type=merge").Execute() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(clusterextension.InstalledBundle).To(o.ContainSubstring("v1.0.1")) // Cover test case: OCP-75217 - [olmv1] Override the unsafe upgrades with the warning message clusterextension.CheckClusterExtensionCondition(oc, "Progressing", "message", `new required fields [requiredfield2] added for resolved bundle`, 10, 60, 0) exutil.By("upgrade will be prevented if An existing field is removed from an existing version of the CRD") err = oc.AsAdmin().Run("patch").Args("clusterextension", clusterextension.Name, "-p", `{"spec":{"source":{"catalog":{"version":"1.0.3","upgradeConstraintPolicy":"SelfCertified"}}}}`, "--type=merge").Execute() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(clusterextension.InstalledBundle).To(o.ContainSubstring("v1.0.1")) clusterextension.CheckClusterExtensionCondition(oc, "Progressing", "message", `CustomResourceDefinition nginxolm75123s.cache.example.com failed upgrade safety validation. "NoExistingFieldRemoved" validation failed: crd/nginxolm75123s.cache.example.com version/v1alpha1 field/^.spec.field may not be removed`, 10, 60, 0) clusterextension.CheckClusterExtensionCondition(oc, "Progressing", "message", `CustomResourceDefinition nginxolm75123s.cache.example.com failed upgrade safety validation. "ChangeValidator" validation failed: calculating schema diff for CRD version "v1alpha1"`, 10, 60, 0) exutil.By("upgrade will be prevented if An existing field type is changed in an existing version of the CRD") err = oc.AsAdmin().Run("patch").Args("clusterextension", clusterextension.Name, "-p", `{"spec":{"source":{"catalog":{"version":"1.0.6","upgradeConstraintPolicy":"SelfCertified"}}}}`, "--type=merge").Execute() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(clusterextension.InstalledBundle).To(o.ContainSubstring("v1.0.1")) clusterextension.CheckClusterExtensionCondition(oc, "Progressing", "message", `field "^.spec.field": type changed from "integer" to "string" for resolved bundle`, 10, 60, 0) exutil.By("upgrade will be allowed if An existing required field is changed to optional in an existing version") err = oc.AsAdmin().Run("patch").Args("clusterextension", clusterextension.Name, "-p", `{"spec":{"source":{"catalog":{"version":"1.0.8","upgradeConstraintPolicy":"SelfCertified"}}}}`, "--type=merge").Execute() o.Expect(err).NotTo(o.HaveOccurred()) clusterextension.CheckClusterExtensionCondition(oc, "Progressing", "reason", "Succeeded", 3, 150, 0) clusterextension.WaitClusterExtensionCondition(oc, "Installed", "True", 0) clusterextension.GetBundleResource(oc) o.Expect(clusterextension.InstalledBundle).To(o.ContainSubstring("v1.0.8")) clusterextension.CheckClusterExtensionCondition(oc, "Installed", "message", "Installed bundle quay.io/openshifttest/nginxolm-operator-bundle:v1.0.8-nginxolm75123 successfully", 10, 60, 0) }) // author: [email protected] g.It("Author:xzha-ConnectedOnly-NonHyperShiftHOST-High-75124-CRD upgrade checks for changes in default values", func() { exutil.SkipForSNOCluster(oc) var ( caseID = "75124" labelValue = caseID baseDir = exutil.FixturePath("testdata", "olm", "v1") clustercatalogTemplate = filepath.Join(baseDir, "clustercatalog-withlabel.yaml") clusterextensionTemplate = filepath.Join(baseDir, "clusterextension-withselectorlabel.yaml") saClusterRoleBindingTemplate = filepath.Join(baseDir, "sa-admin.yaml") ns = "ns-75124" sa = "sa75124" saCrb = olmv1util.SaCLusterRolebindingDescription{ Name: sa, Namespace: ns, Template: saClusterRoleBindingTemplate, } clustercatalog = olmv1util.ClusterCatalogDescription{ Name: "clustercatalog-75124", Imageref: "quay.io/openshifttest/nginxolm-operator-index:nginxolm75124", LabelValue: labelValue, Template: clustercatalogTemplate, } clusterextension = olmv1util.ClusterExtensionDescription{ Name: "clusterextension-75124", InstallNamespace: ns, PackageName: "nginx75124", Channel: "candidate-v1.0", Version: "1.0.1", SaName: sa, LabelValue: labelValue, Template: clusterextensionTemplate, } ) exutil.By("Create clustercatalog") defer clustercatalog.Delete(oc) clustercatalog.Create(oc) exutil.By("Create namespace") defer oc.WithoutNamespace().AsAdmin().Run("delete").Args("ns", ns, "--ignore-not-found").Execute() err := oc.WithoutNamespace().AsAdmin().Run("create").Args("ns", ns).Execute() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(olmv1util.Appearance(oc, exutil.Appear, "ns", ns)).To(o.BeTrue()) exutil.By("Create SA for clusterextension") defer saCrb.Delete(oc) saCrb.Create(oc) exutil.By("Create clusterextension v1.0.1") defer clusterextension.Delete(oc) clusterextension.Create(oc) o.Expect(clusterextension.InstalledBundle).To(o.ContainSubstring("v1.0.1")) exutil.By("upgrade will be prevented if A new default value is added to a field that did not previously have a default value") err = oc.AsAdmin().Run("patch").Args("clusterextension", clusterextension.Name, "-p", `{"spec":{"source":{"catalog":{"version":"1.0.2","upgradeConstraintPolicy":"SelfCertified"}}}}`, "--type=merge").Execute() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(clusterextension.InstalledBundle).To(o.ContainSubstring("v1.0.1")) clusterextension.CheckClusterExtensionCondition(oc, "Progressing", "message", `default value "\"default-string-xzha\"" added when there was no default previously for resolved bundle`, 10, 60, 0) exutil.By("upgrade will be prevented if The default value of a field is changed") err = oc.AsAdmin().Run("patch").Args("clusterextension", clusterextension.Name, "-p", `{"spec":{"source":{"catalog":{"version":"1.0.3","upgradeConstraintPolicy":"SelfCertified"}}}}`, "--type=merge").Execute() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(clusterextension.InstalledBundle).To(o.ContainSubstring("v1.0.1")) clusterextension.CheckClusterExtensionCondition(oc, "Progressing", "message", `failed: version "v1alpha1", field "^.spec.defaultenum": default value changed from "\"value1\"" to "\"value3\"" for resolved bundle`, 10, 60, 0) exutil.By("upgrade will be prevented if An existing default value of a field is removed") err = oc.AsAdmin().Run("patch").Args("clusterextension", clusterextension.Name, "-p", `{"spec":{"source":{"catalog":{"version":"1.0.6","upgradeConstraintPolicy":"SelfCertified"}}}}`, "--type=merge").Execute() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(clusterextension.InstalledBundle).To(o.ContainSubstring("v1.0.1")) clusterextension.CheckClusterExtensionCondition(oc, "Progressing", "message", `field "^.spec.defaultint": default value "9" removed for resolved bundle`, 10, 60, 0) }) // author: [email protected] g.It("Author:xzha-ConnectedOnly-NonHyperShiftHOST-High-75515-CRD upgrade checks for changes in enumeration values", func() { exutil.SkipForSNOCluster(oc) var ( caseID = "75515" labelValue = caseID baseDir = exutil.FixturePath("testdata", "olm", "v1") clustercatalogTemplate = filepath.Join(baseDir, "clustercatalog-withlabel.yaml") clusterextensionTemplate = filepath.Join(baseDir, "clusterextension-withselectorlabel.yaml") saClusterRoleBindingTemplate = filepath.Join(baseDir, "sa-admin.yaml") ns = "ns-75515" sa = "sa75515" saCrb = olmv1util.SaCLusterRolebindingDescription{ Name: sa, Namespace: ns, Template: saClusterRoleBindingTemplate, } clustercatalog = olmv1util.ClusterCatalogDescription{ Name: "clustercatalog-75515", Imageref: "quay.io/openshifttest/nginxolm-operator-index:nginxolm75515", LabelValue: labelValue, Template: clustercatalogTemplate, } clusterextension = olmv1util.ClusterExtensionDescription{ Name: "clusterextension-75515", InstallNamespace: ns, PackageName: "nginx75515", Channel: "candidate-v1.0", Version: "1.0.1", SaName: sa, LabelValue: labelValue, Template: clusterextensionTemplate, } ) exutil.By("Create clustercatalog") defer clustercatalog.Delete(oc) clustercatalog.Create(oc) exutil.By("Create namespace") defer oc.WithoutNamespace().AsAdmin().Run("delete").Args("ns", ns, "--ignore-not-found").Execute() err := oc.WithoutNamespace().AsAdmin().Run("create").Args("ns", ns).Execute() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(olmv1util.Appearance(oc, exutil.Appear, "ns", ns)).To(o.BeTrue()) exutil.By("Create SA for clusterextension") defer saCrb.Delete(oc) saCrb.Create(oc) exutil.By("Create clusterextension v1.0.1") defer clusterextension.Delete(oc) clusterextension.Create(oc) o.Expect(clusterextension.InstalledBundle).To(o.ContainSubstring("v1.0.1")) exutil.By("upgrade will be prevented if New enum restrictions are added to an existing field which did not previously have enum restrictions") err = oc.AsAdmin().Run("patch").Args("clusterextension", clusterextension.Name, "-p", `{"spec":{"source":{"catalog":{"version":"1.0.2","upgradeConstraintPolicy":"SelfCertified"}}}}`, "--type=merge").Execute() o.Expect(err).NotTo(o.HaveOccurred()) clusterextension.CheckClusterExtensionCondition(oc, "Progressing", "message", `field "^.spec.unenumfield": enum constraints ["value1" "value2" "value3"] added when there were no restrictions previously for resolved bundle`, 10, 60, 0) o.Expect(clusterextension.InstalledBundle).To(o.ContainSubstring("v1.0.1")) clusterextension.Delete(oc) exutil.By("Create clusterextension v1.0.3") clusterextension.Version = "1.0.3" clusterextension.Create(oc) o.Expect(clusterextension.InstalledBundle).To(o.ContainSubstring("v1.0.3")) exutil.By("upgrade will be prevented if Existing enum values from an existing field are removed") err = oc.AsAdmin().Run("patch").Args("clusterextension", clusterextension.Name, "-p", `{"spec":{"source":{"catalog":{"version":"1.0.5","upgradeConstraintPolicy":"SelfCertified"}}}}`, "--type=merge").Execute() o.Expect(err).NotTo(o.HaveOccurred()) clusterextension.CheckClusterExtensionCondition(oc, "Progressing", "message", "validation failed", 10, 60, 0) o.Expect(clusterextension.InstalledBundle).To(o.ContainSubstring("v1.0.3")) exutil.By("upgrade will be allowed if Adding new enum values to the list of allowed enum values in a field") err = oc.AsAdmin().Run("patch").Args("clusterextension", clusterextension.Name, "-p", `{"spec":{"source":{"catalog":{"version":"1.0.6","upgradeConstraintPolicy":"SelfCertified"}}}}`, "--type=merge").Execute() o.Expect(err).NotTo(o.HaveOccurred()) clusterextension.WaitClusterExtensionVersion(oc, "v1.0.6") }) // author: [email protected] g.It("Author:xzha-ConnectedOnly-NonHyperShiftHOST-High-75516-CRD upgrade checks for the field maximum minimum changes", func() { exutil.SkipForSNOCluster(oc) var ( caseID = "75516" labelValue = caseID baseDir = exutil.FixturePath("testdata", "olm", "v1") clustercatalogTemplate = filepath.Join(baseDir, "clustercatalog-withlabel.yaml") clusterextensionTemplate = filepath.Join(baseDir, "clusterextension-withselectorlabel.yaml") saClusterRoleBindingTemplate = filepath.Join(baseDir, "sa-admin.yaml") ns = "ns-75516" sa = "sa75516" saCrb = olmv1util.SaCLusterRolebindingDescription{ Name: sa, Namespace: ns, Template: saClusterRoleBindingTemplate, } clustercatalog = olmv1util.ClusterCatalogDescription{ Name: "clustercatalog-75516", Imageref: "quay.io/openshifttest/nginxolm-operator-index:nginxolm75516", LabelValue: labelValue, Template: clustercatalogTemplate, } clusterextension = olmv1util.ClusterExtensionDescription{ Name: "clusterextension-75516", InstallNamespace: ns, PackageName: "nginx75516", Channel: "candidate-v1.0", Version: "1.0.1", SaName: sa, LabelValue: labelValue, Template: clusterextensionTemplate, } ) exutil.By("Create clustercatalog") defer clustercatalog.Delete(oc) clustercatalog.Create(oc) exutil.By("Create namespace") defer oc.WithoutNamespace().AsAdmin().Run("delete").Args("ns", ns, "--ignore-not-found").Execute() err := oc.WithoutNamespace().AsAdmin().Run("create").Args("ns", ns).Execute() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(olmv1util.Appearance(oc, exutil.Appear, "ns", ns)).To(o.BeTrue()) exutil.By("Create SA for clusterextension") defer saCrb.Delete(oc) saCrb.Create(oc) exutil.By("Create clusterextension v1.0.1") defer clusterextension.Delete(oc) clusterextension.Create(oc) o.Expect(clusterextension.InstalledBundle).To(o.ContainSubstring("v1.0.1")) exutil.By("upgrade will be prevented if The minimum value of an existing field is increased in an existing version and The maximum value of an existing field is decreased in an existing version") exutil.By("Check minimum & maximum") err = oc.AsAdmin().Run("patch").Args("clusterextension", clusterextension.Name, "-p", `{"spec":{"source":{"catalog":{"version":"1.0.2","upgradeConstraintPolicy":"SelfCertified"}}}}`, "--type=merge").Execute() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(clusterextension.InstalledBundle).To(o.ContainSubstring("v1.0.1")) clusterextension.CheckClusterExtensionCondition(oc, "Progressing", "message", "maximum: constraint decreased from 100 to 80", 10, 60, 0) clusterextension.CheckClusterExtensionCondition(oc, "Progressing", "message", "minimum: constraint increased from 10 to 20", 10, 60, 0) exutil.By("Check minLength & maxLength") err = oc.AsAdmin().Run("patch").Args("clusterextension", clusterextension.Name, "-p", `{"spec":{"source":{"catalog":{"version":"1.0.3","upgradeConstraintPolicy":"SelfCertified"}}}}`, "--type=merge").Execute() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(clusterextension.InstalledBundle).To(o.ContainSubstring("v1.0.1")) clusterextension.CheckClusterExtensionCondition(oc, "Progressing", "message", "maxLength: constraint decreased from 50 to 30", 10, 60, 0) clusterextension.CheckClusterExtensionCondition(oc, "Progressing", "message", "minLength: constraint increased from 3 to 9", 10, 60, 0) exutil.By("Check minProperties & maxProperties") err = oc.AsAdmin().Run("patch").Args("clusterextension", clusterextension.Name, "-p", `{"spec":{"source":{"catalog":{"version":"1.0.4","upgradeConstraintPolicy":"SelfCertified"}}}}`, "--type=merge").Execute() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(clusterextension.InstalledBundle).To(o.ContainSubstring("v1.0.1")) clusterextension.CheckClusterExtensionCondition(oc, "Progressing", "message", "maxProperties: constraint decreased from 5 to 4", 10, 60, 0) clusterextension.CheckClusterExtensionCondition(oc, "Progressing", "message", "minProperties: constraint increased from 2 to 3", 10, 60, 0) exutil.By("Check minItems & maxItems") err = oc.AsAdmin().Run("patch").Args("clusterextension", clusterextension.Name, "-p", `{"spec":{"source":{"catalog":{"version":"1.0.5","upgradeConstraintPolicy":"SelfCertified"}}}}`, "--type=merge").Execute() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(clusterextension.InstalledBundle).To(o.ContainSubstring("v1.0.1")) clusterextension.CheckClusterExtensionCondition(oc, "Progressing", "message", "maxItems: constraint decreased from 10 to 9", 10, 60, 0) clusterextension.CheckClusterExtensionCondition(oc, "Progressing", "message", "minItems: constraint increased from 2 to 3", 10, 60, 0) exutil.By("upgrade will be prevented if Minimum or maximum field constraints are added to a field that did not previously have constraints") err = oc.AsAdmin().Run("patch").Args("clusterextension", clusterextension.Name, "-p", `{"spec":{"source":{"catalog":{"version":"1.0.6","upgradeConstraintPolicy":"SelfCertified"}}}}`, "--type=merge").Execute() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(clusterextension.InstalledBundle).To(o.ContainSubstring("v1.0.1")) clusterextension.CheckClusterExtensionCondition(oc, "Progressing", "message", `maximum: constraint 100 added when there were no restrictions previously`, 10, 60, 0) clusterextension.CheckClusterExtensionCondition(oc, "Progressing", "message", `minimum: constraint 10 added when there were no restrictions previously`, 10, 60, 0) exutil.By("upgrade will be Allowed if The minimum value of an existing field is decreased in an existing version & The maximum value of an existing field is increased in an existing version") err = oc.AsAdmin().Run("patch").Args("clusterextension", clusterextension.Name, "-p", `{"spec":{"source":{"catalog":{"version":"1.0.7","upgradeConstraintPolicy":"SelfCertified"}}}}`, "--type=merge").Execute() o.Expect(err).NotTo(o.HaveOccurred()) clusterextension.CheckClusterExtensionCondition(oc, "Progressing", "reason", "Succeeded", 3, 150, 0) clusterextension.WaitClusterExtensionCondition(oc, "Installed", "True", 0) clusterextension.GetBundleResource(oc) o.Expect(clusterextension.InstalledBundle).To(o.ContainSubstring("v1.0.7")) clusterextension.CheckClusterExtensionCondition(oc, "Installed", "message", "Installed bundle quay.io/openshifttest/nginxolm-operator-bundle:v1.0.7-nginxolm75516 successfully", 10, 60, 0) }) // author: [email protected] g.It("Author:xzha-ConnectedOnly-NonHyperShiftHOST-Critical-75441-Catalogd supports compression and jsonlines format", func() { var ( baseDir = exutil.FixturePath("testdata", "olm", "v1") clustercatalogTemplate = filepath.Join(baseDir, "clustercatalog.yaml") clustercatalog = olmv1util.ClusterCatalogDescription{ Name: "clustercatalog-75441", Imageref: "quay.io/openshifttest/nginxolm-operator-index:nginxolm75441", Template: clustercatalogTemplate, } clustercatalog1 = olmv1util.ClusterCatalogDescription{ Name: "clustercatalog-75441v2", Imageref: "quay.io/openshifttest/nginxolm-operator-index:nginxolm75441v2", Template: clustercatalogTemplate, } ) exutil.By("Create clustercatalog") defer clustercatalog.Delete(oc) clustercatalog.Create(oc) defer clustercatalog1.Delete(oc) clustercatalog1.Create(oc) exutil.By("Get the gzip response") url1 := clustercatalog.ContentURL exutil.By("Check the url response of clustercatalog-75441") getCmd := fmt.Sprintf("curl -ki %s -H \"Accept-Encoding: gzip\" --output -", url1) stringMessage, err := exec.Command("bash", "-c", getCmd).Output() o.Expect(err).NotTo(o.HaveOccurred()) if !strings.Contains(strings.ToLower(string(stringMessage)), "content-encoding: gzip") { e2e.Logf(string(stringMessage)) e2e.Failf("string Content-Encoding: gzip not in the output") } if !strings.Contains(strings.ToLower(string(stringMessage)), "content-type: application/jsonl") { e2e.Logf(string(stringMessage)) e2e.Failf("string Content-Type: application/jsonl not in the output") } exutil.By("Check the url response of clustercatalog-75441v2") url2 := clustercatalog1.ContentURL getCmd2 := fmt.Sprintf("curl -ki %s -H \"Accept-Encoding: gzip\"", url2) stringMessage2, err := exec.Command("bash", "-c", getCmd2).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(strings.ToLower(string(stringMessage2))).NotTo(o.ContainSubstring("content-encoding: gzip")) o.Expect(strings.ToLower(string(stringMessage2))).To(o.ContainSubstring("content-type: application/jsonl")) }) })
package operators
test case
openshift/openshift-tests-private
eca09ad7-c2da-43ca-a94f-c0473b18b0fe
Author:xzha-ConnectedOnly-NonHyperShiftHOST-VMonly-High-69758-Catalogd Polling remote registries for update to images content
['"context"', '"path/filepath"', '"reflect"', '"strings"', '"time"', 'g "github.com/onsi/ginkgo/v2"', 'olmv1util "github.com/openshift/openshift-tests-private/test/extended/operators/olmv1util"', 'container "github.com/openshift/openshift-tests-private/test/extended/util/container"', '"k8s.io/apimachinery/pkg/util/wait"']
github.com/openshift/openshift-tests-private/test/extended/operators/olmv1_opeco.go
g.It("Author:xzha-ConnectedOnly-NonHyperShiftHOST-VMonly-High-69758-Catalogd Polling remote registries for update to images content", func() { var ( baseDir = exutil.FixturePath("testdata", "olm", "v1") clustercatalogTemplate = filepath.Join(baseDir, "clustercatalog.yaml") quayCLI = container.NewQuayCLI() imagev1 = "quay.io/olmqe/olmtest-operator-index:nginxolm69758v1" imagev2 = "quay.io/olmqe/olmtest-operator-index:nginxolm69758v2" clustercatalog = olmv1util.ClusterCatalogDescription{ Name: "clustercatalog-69758", Imageref: "quay.io/olmqe/olmtest-operator-index:test69758", Template: clustercatalogTemplate, } ) exutil.By("Get v1 v2 digestID") manifestDigestv1, err := quayCLI.GetImageDigest(strings.Replace(imagev1, "quay.io/", "", 1)) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(manifestDigestv1).NotTo(o.BeEmpty()) manifestDigestv2, err := quayCLI.GetImageDigest(strings.Replace(imagev2, "quay.io/", "", 1)) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(manifestDigestv2).NotTo(o.BeEmpty()) exutil.By("Check default digestID is v1") indexImageDigest, err := quayCLI.GetImageDigest(strings.Replace(clustercatalog.Imageref, "quay.io/", "", 1)) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(indexImageDigest).NotTo(o.BeEmpty()) if indexImageDigest != manifestDigestv1 { //tag v1 to testrun image tagResult, tagErr := quayCLI.ChangeTag(strings.Replace(clustercatalog.Imageref, "quay.io/", "", 1), manifestDigestv1) if !tagResult { e2e.Logf("Error: %v", tagErr) e2e.Failf("Change tag failed on quay.io") } e2e.Logf("Successful init tag v1") } exutil.By("Create clustercatalog") defer clustercatalog.Delete(oc) clustercatalog.Create(oc) exutil.By("Add image pollInterval time") err = oc.AsAdmin().Run("patch").Args("clustercatalog", clustercatalog.Name, "-p", `{"spec":{"source":{"image":{"pollIntervalMinutes": 1}}}}`, "--type=merge").Execute() o.Expect(err).NotTo(o.HaveOccurred()) pollInterval, err := oc.WithoutNamespace().AsAdmin().Run("get").Args("clustercatalog", clustercatalog.Name, "-o=jsonpath={.spec.source.image.pollIntervalMinutes}").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(string(pollInterval)).To(o.ContainSubstring("1")) clustercatalog.WaitCatalogStatus(oc, "true", "Serving", 0) exutil.By("Collect the initial image status information") resolvedRef, err := oc.WithoutNamespace().AsAdmin().Run("get").Args("clustercatalog", clustercatalog.Name, "-o=jsonpath={.status.resolvedSource.image.ref}").Output() o.Expect(err).NotTo(o.HaveOccurred()) v1bundlesDataOut, err := clustercatalog.UnmarshalContent(oc, "bundle") o.Expect(err).NotTo(o.HaveOccurred()) v1bundlesImage := olmv1util.GetBundlesImageTag(v1bundlesDataOut.Bundles) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("Update the image and check for changes") //tag v2 to testrun image tagResult, tagErr := quayCLI.ChangeTag(strings.Replace(clustercatalog.Imageref, "quay.io/", "", 1), manifestDigestv2) if !tagResult { e2e.Logf("Error: %v", tagErr) e2e.Failf("Change tag failed on quay.io") } e2e.Logf("Successful tag v2") errWait := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 90*time.Second, false, func(ctx context.Context) (bool, error) { resolvedRef2, err := oc.WithoutNamespace().AsAdmin().Run("get").Args("clustercatalog", clustercatalog.Name, "-o=jsonpath={.status.resolvedSource.image.ref}").Output() o.Expect(err).NotTo(o.HaveOccurred()) if resolvedRef == resolvedRef2 { e2e.Logf("resolvedRef:%v,resolvedRef2:%v", resolvedRef, resolvedRef2) return false, nil } return true, nil }) exutil.AssertWaitPollNoErr(errWait, "Error resolvedRef are same") exutil.By("check the index content changes") v2bundlesDataOut, err := clustercatalog.UnmarshalContent(oc, "bundle") o.Expect(err).NotTo(o.HaveOccurred()) v2bundlesImage := olmv1util.GetBundlesImageTag(v2bundlesDataOut.Bundles) o.Expect(err).NotTo(o.HaveOccurred()) if reflect.DeepEqual(v1bundlesImage, v2bundlesImage) { e2e.Logf("v1bundlesImage%v, v2bundlesImage%v", v1bundlesImage, v2bundlesImage) e2e.Failf("Failed, The index content no changes") } e2e.Logf("v1bundlesImage%v, v2bundlesImage%v", v1bundlesImage, v2bundlesImage) exutil.By("Update use the digest image and check it") output, err := oc.AsAdmin().Run("patch").Args("clustercatalog", clustercatalog.Name, "-p", `{"spec":{"source":{"image":{"ref":"quay.io/olmqe/olmtest-operator-index@`+manifestDigestv1+`"}}}}`, "--type=merge").Output() o.Expect(err).To(o.HaveOccurred()) o.Expect(string(output)).To(o.ContainSubstring("cannot specify pollIntervalMinutes while using digest-based")) })
test case
openshift/openshift-tests-private
f3f6fb69-bcb8-44e1-aca3-258ce3cf4893
Author:xzha-ConnectedOnly-NonHyperShiftHOST-High-69123-Catalogd clustercatalog offer the operator content through http server
['"path/filepath"', 'olmv1util "github.com/openshift/openshift-tests-private/test/extended/operators/olmv1util"']
github.com/openshift/openshift-tests-private/test/extended/operators/olmv1_opeco.go
g.It("Author:xzha-ConnectedOnly-NonHyperShiftHOST-High-69123-Catalogd clustercatalog offer the operator content through http server", func() { var ( baseDir = exutil.FixturePath("testdata", "olm", "v1") clustercatalogTemplate = filepath.Join(baseDir, "clustercatalog.yaml") clustercatalog = olmv1util.ClusterCatalogDescription{ Name: "clustercatalog-69123", Imageref: "quay.io/olmqe/olmtest-operator-index:nginxolm69123", Template: clustercatalogTemplate, } ) exutil.By("Create clustercatalog") defer clustercatalog.Delete(oc) clustercatalog.Create(oc) exutil.By("get the index content through http service on cluster") unmarshalContent, err := clustercatalog.UnmarshalContent(oc, "all") o.Expect(err).NotTo(o.HaveOccurred()) allPackageName := olmv1util.ListPackagesName(unmarshalContent.Packages) o.Expect(allPackageName[0]).To(o.ContainSubstring("nginx69123")) channelData := olmv1util.GetChannelByPakcage(unmarshalContent.Channels, "nginx69123") o.Expect(channelData[0].Name).To(o.ContainSubstring("candidate-v0.0")) bundlesName := olmv1util.GetBundlesNameByPakcage(unmarshalContent.Bundles, "nginx69123") o.Expect(bundlesName[0]).To(o.ContainSubstring("nginx69123.v0.0.1")) })
test case
openshift/openshift-tests-private
4ef8bdd3-1f6e-4f0c-90b0-29131cb99e50
Author:xzha-DEPRECATED-ConnectedOnly-NonHyperShiftHOST-High-69124-check the clustercatalog source type before created
['"path/filepath"', '"strings"', '"time"', 'olmv1util "github.com/openshift/openshift-tests-private/test/extended/operators/olmv1util"']
github.com/openshift/openshift-tests-private/test/extended/operators/olmv1_opeco.go
g.It("Author:xzha-DEPRECATED-ConnectedOnly-NonHyperShiftHOST-High-69124-check the clustercatalog source type before created", func() { var ( baseDir = exutil.FixturePath("testdata", "olm", "v1") catalogPollTemplate = filepath.Join(baseDir, "clustercatalog-secret.yaml") clustercatalog = olmv1util.ClusterCatalogDescription{ Name: "clustercatalog-69124", Imageref: "quay.io/olmqe/olmtest-operator-index:nginxolm69124", PollIntervalMinutes: "1", Template: catalogPollTemplate, } ) exutil.By("Create clustercatalog") defer clustercatalog.Delete(oc) clustercatalog.Create(oc) exutil.By("Check image pollInterval time") errMsg, err := oc.AsAdmin().Run("patch").Args("clustercatalog", clustercatalog.Name, "-p", `{"spec":{"source":{"image":{"pollIntervalMinutes":"1mm"}}}}`, "--type=merge").Output() o.Expect(err).To(o.HaveOccurred()) o.Expect(strings.Contains(errMsg, "Invalid value: \"1mm\": spec.source.image.pollIntervalMinutes in body")).To(o.BeTrue()) exutil.By("Check type value") errMsg, err = oc.AsAdmin().Run("patch").Args("clustercatalog", clustercatalog.Name, "-p", `{"spec":{"source":{"type":"redhat"}}}`, "--type=merge").Output() o.Expect(err).To(o.HaveOccurred()) o.Expect(strings.Contains(errMsg, "Unsupported value: \"redhat\": supported values: \"Image\"")).To(o.BeTrue()) })