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
test case
openshift/openshift-tests-private
dc1f2bde-be57-42e5-804a-622cd8c0b82a
Author:jitli-ConnectedOnly-VMonly-High-44295-Ensure that Go type Operators creation is working [Slow]
['"context"', '"fmt"', '"os"', '"os/exec"', '"strings"', '"time"', '"github.com/openshift/openshift-tests-private/test/extended/util/architecture"', '"path/filepath"', '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/operatorsdk/operatorsdk.go
g.It("Author:jitli-ConnectedOnly-VMonly-High-44295-Ensure that Go type Operators creation is working [Slow]", func() { if os.Getenv("HTTP_PROXY") != "" || os.Getenv("http_proxy") != "" { g.Skip("HTTP_PROXY is not empty - skipping test ...") } architecture.SkipNonAmd64SingleArch(oc) buildPruningBaseDir := exutil.FixturePath("testdata", "operatorsdk") dataPath := filepath.Join(buildPruningBaseDir, "ocp-44295-data") quayCLI := container.NewQuayCLI() imageTag := "quay.io/olmqe/memcached-operator:44295-" + getRandomString() tmpBasePath := "/tmp/ocp-44295-" + getRandomString() tmpPath := filepath.Join(tmpBasePath, "memcached-operator-44295") nsSystem := "system-ocp44295" + getRandomString() nsOperator := "memcached-operator-system-ocp44295" + getRandomString() defer os.RemoveAll(tmpBasePath) defer quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1)) err := os.MkdirAll(tmpPath, 0o755) o.Expect(err).NotTo(o.HaveOccurred()) operatorsdkCLI.ExecCommandPath = tmpPath makeCLI.ExecCommandPath = tmpPath exutil.By("step: generate go type operator") defer func() { _, err = makeCLI.Run("undeploy").Args().Output() o.Expect(err).NotTo(o.HaveOccurred()) }() output, err := operatorsdkCLI.Run("init").Args("--domain=example.com", "--repo=github.com/example-inc/memcached-operator-44295").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("Writing scaffold for you to edit")) o.Expect(output).To(o.ContainSubstring("Next: define a resource with")) exutil.By("step: Create a Memcached API.") output, err = operatorsdkCLI.Run("create").Args("api", "--resource=true", "--controller=true", "--group=cache", "--version=v1alpha1", "--kind=Memcached44295").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("Update dependencies")) o.Expect(output).To(o.ContainSubstring("Next")) exutil.By("step: update API") err = copy(filepath.Join(dataPath, "memcached_types.go"), filepath.Join(tmpPath, "api", "v1alpha1", "memcached44295_types.go")) o.Expect(err).NotTo(o.HaveOccurred()) _, err = makeCLI.Run("generate").Args().Output() o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("step: make manifests") _, err = makeCLI.Run("manifests").Args().Output() o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("step: modify namespace and controllers") crFilePath := filepath.Join(tmpPath, "config", "samples", "cache_v1alpha1_memcached44295.yaml") exec.Command("bash", "-c", fmt.Sprintf("sed -i '$d' %s", crFilePath)).Output() exec.Command("bash", "-c", fmt.Sprintf("sed -i '$a\\ size: 3' %s", crFilePath)).Output() exec.Command("bash", "-c", fmt.Sprintf("sed -i 's/name: system/name: system-ocp44295/g' `grep -rl \"name: system\" %s`", tmpPath)).Output() exec.Command("bash", "-c", fmt.Sprintf("sed -i 's/namespace: system/namespace: %s/g' `grep -rl \"namespace: system\" %s`", nsSystem, tmpPath)).Output() exec.Command("bash", "-c", fmt.Sprintf("sed -i 's/namespace: memcached-operator-44295-system/namespace: %s/g' `grep -rl \"namespace: memcached-operator-44295-system\" %s`", nsOperator, tmpPath)).Output() err = copy(filepath.Join(dataPath, "memcached_controller.go"), filepath.Join(tmpPath, "internal", "controller", "memcached44295_controller.go")) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("step: Build the operator image") dockerFilePath := filepath.Join(tmpPath, "Dockerfile") replaceContent(dockerFilePath, "golang:", "quay.io/olmqe/golang:") output, err = makeCLI.Run("docker-build").Args("IMG=" + imageTag).Output() if (err != nil) && strings.Contains(output, "go mod tidy") { e2e.Logf("execute go mod tidy") exec.Command("bash", "-c", fmt.Sprintf("cd %s; go mod tidy", tmpPath)).Output() output, err = makeCLI.Run("docker-build").Args("IMG=" + imageTag).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("docker build -t")) } else { o.Expect(output).To(o.ContainSubstring("docker build -t")) } exutil.By("step: Push the operator image") _, err = makeCLI.Run("docker-push").Args("IMG=" + imageTag).Output() o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("step: Install kustomize") kustomizePath := "/root/kustomize" binPath := filepath.Join(tmpPath, "bin") exec.Command("bash", "-c", fmt.Sprintf("cp %s %s", kustomizePath, binPath)).Output() exutil.By("step: Install the CRD") output, err = makeCLI.Run("install").Args().Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("memcached44295s.cache.example.com")) exutil.By("step: Deploy the operator") output, err = makeCLI.Run("deploy").Args("IMG=" + imageTag).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("deployment.apps/memcached-operator-44295-controller-manager")) waitErr := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) { podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output() o.Expect(err).NotTo(o.HaveOccurred()) lines := strings.Split(podList, "\n") for _, line := range lines { if strings.Contains(line, "memcached-operator-44295-controller-manager") { e2e.Logf("found pod memcached-operator-44295-controller-manager") if strings.Contains(line, "Running") { e2e.Logf("the status of pod memcached-operator-44295-controller-manager is Running") return true, nil } e2e.Logf("the status of pod memcached-operator-44295-controller-manager is not Running") return false, nil } } return false, nil }) if waitErr != nil { logDebugInfo(oc, nsOperator, "events", "pod") } exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("No memcached-operator-44295-controller-manager in project %s", nsOperator)) msg, err := oc.AsAdmin().WithoutNamespace().Run("logs").Args("deployment.apps/memcached-operator-44295-controller-manager", "-c", "manager", "-n", nsOperator).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(msg).To(o.ContainSubstring("Starting workers")) exutil.By("step: Create the resource") _, err = oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", crFilePath, "-n", nsOperator).Output() o.Expect(err).NotTo(o.HaveOccurred()) waitErr = wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) { msg, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output() o.Expect(err).NotTo(o.HaveOccurred()) if strings.Contains(msg, "memcached44295-sample") { e2e.Logf("found pod memcached44295-sample") return true, nil } return false, nil }) if waitErr != nil { logDebugInfo(oc, nsOperator, "events", "pod") } exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("No memcached44295-sample in project %s", nsOperator)) waitErr = wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) { msg, err = oc.AsAdmin().WithoutNamespace().Run("describe").Args("deployment/memcached44295-sample", "-n", nsOperator).Output() o.Expect(err).NotTo(o.HaveOccurred()) if strings.Contains(msg, "3 desired | 3 updated | 3 total | 3 available | 0 unavailable") { e2e.Logf("deployment/memcached44295-sample is created successfully") return true, nil } return false, nil }) if waitErr != nil { msg, err = oc.AsAdmin().WithoutNamespace().Run("describe").Args("deployment/memcached44295-sample", "-n", nsOperator).Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf(msg) msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("events", "-n", nsOperator).Output() e2e.Logf(msg) } exutil.AssertWaitPollNoErr(waitErr, "the status of deployment/memcached44295-sample is wrong") exutil.By("OCP 44295 SUCCESS") })
test case
openshift/openshift-tests-private
e8e342e4-d709-4549-afa9-eeddf5eafffd
Author:jitli-ConnectedOnly-VMonly-High-52371-Enable Micrometer Metrics from java operator plugins
['"context"', '"fmt"', '"os"', '"strings"', '"time"', '"github.com/openshift/openshift-tests-private/test/extended/util/architecture"', '"path/filepath"', '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/operatorsdk/operatorsdk.go
g.It("Author:jitli-ConnectedOnly-VMonly-High-52371-Enable Micrometer Metrics from java operator plugins", func() { g.Skip("OperatorSDK Java plugin unavailable and no plan to fix it, so skip it") if os.Getenv("HTTP_PROXY") != "" || os.Getenv("http_proxy") != "" { g.Skip("HTTP_PROXY is not empty - skipping test ...") } architecture.SkipNonAmd64SingleArch(oc) var ( buildPruningBaseDir = exutil.FixturePath("testdata", "operatorsdk") dataPath = filepath.Join(buildPruningBaseDir, "ocp-52371-data") clusterrolebindingtemplate = filepath.Join(buildPruningBaseDir, "cluster-role-binding.yaml") quayCLI = container.NewQuayCLI() imageTag = "quay.io/olmqe/memcached-quarkus-operator:52371-" + getRandomString() tmpBasePath = "/tmp/ocp-52371-" + getRandomString() tmpOperatorPath = filepath.Join(tmpBasePath, "memcached-quarkus-operator-52371") kubernetesYamlFilePath = filepath.Join(tmpOperatorPath, "target", "kubernetes", "kubernetes.yml") ) operatorsdkCLI.ExecCommandPath = tmpOperatorPath makeCLI.ExecCommandPath = tmpOperatorPath mvnCLI.ExecCommandPath = tmpOperatorPath err := os.MkdirAll(tmpOperatorPath, 0o755) o.Expect(err).NotTo(o.HaveOccurred()) defer os.RemoveAll(tmpBasePath) exutil.By("step: generate java type operator") output, err := operatorsdkCLI.Run("init").Args("--plugins=quarkus", "--domain=example.com").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("operator-sdk create api")) exutil.By("step: Create API.") _, err = operatorsdkCLI.Run("create").Args("api", "--plugins=quarkus", "--group=cache", "--version=v1", "--kind=Memcached52371").Output() o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("step: update API and Controller") examplePath := filepath.Join(tmpOperatorPath, "src", "main", "java", "com", "example") err = copy(filepath.Join(dataPath, "Memcached52371Reconciler.java"), filepath.Join(examplePath, "Memcached52371Reconciler.java")) o.Expect(err).NotTo(o.HaveOccurred()) err = copy(filepath.Join(dataPath, "Memcached52371Spec.java"), filepath.Join(examplePath, "Memcached52371Spec.java")) o.Expect(err).NotTo(o.HaveOccurred()) err = copy(filepath.Join(dataPath, "Memcached52371Status.java"), filepath.Join(examplePath, "Memcached52371Status.java")) o.Expect(err).NotTo(o.HaveOccurred()) err = copy(filepath.Join(dataPath, "pom.xml"), filepath.Join(tmpOperatorPath, "pom.xml")) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("step:mvn clean install") output, err = mvnCLI.Run("clean").Args("install").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("BUILD SUCCESS")) exutil.By("step: Build and push the operator image") defer quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1)) output, err = makeCLI.Run("docker-build").Args("docker-push", "IMG="+imageTag).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("BUILD SUCCESS")) exutil.By("step: Deploy the operator") oc.SetupProject() ns := oc.Namespace() exutil.By("step: Install the CRD") defer func() { exutil.By("step: delete crd.") _, err = oc.AsAdmin().WithoutNamespace().Run("delete").Args("-f", filepath.Join(tmpOperatorPath, "target", "kubernetes", "memcached52371s.cache.example.com-v1.yml")).Output() o.Expect(err).NotTo(o.HaveOccurred()) }() _, err = oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", filepath.Join(tmpOperatorPath, "target", "kubernetes", "memcached52371s.cache.example.com-v1.yml")).Output() o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("step: Create rcbc file") insertContent(kubernetesYamlFilePath, "- kind: ServiceAccount", " namespace: "+ns) exutil.By("step: Deploy the operator") defer func() { exutil.By("step: delete operator.") _, err := oc.AsAdmin().WithoutNamespace().Run("delete").Args("-f", kubernetesYamlFilePath, "-n", ns).Output() o.Expect(err).NotTo(o.HaveOccurred()) }() _, err = oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", kubernetesYamlFilePath, "-n", ns).Output() o.Expect(err).NotTo(o.HaveOccurred()) clusterrolebinding := clusterrolebindingDescription{ name: "memcached52371-operator-admin", namespace: ns, saname: "memcached-quarkus-operator-52371-operator", template: clusterrolebindingtemplate, } clusterrolebinding.create(oc) waitErr := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) { podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", ns).Output() o.Expect(err).NotTo(o.HaveOccurred()) lines := strings.Split(podList, "\n") for _, line := range lines { if strings.Contains(line, "memcached-quarkus-operator-52371-operator") { e2e.Logf("found pod memcached-quarkus-operator-52371-operator") if strings.Contains(line, "Running") { e2e.Logf("the status of pod memcached-quarkus-operator-52371-operator is Running") return true, nil } e2e.Logf("the status of pod memcached-quarkus-operator-52371-operator is not Running") return false, nil } } return false, nil }) if waitErr != nil { logDebugInfo(oc, ns, "events", "pod") } exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("No memcached-quarkus-operator-52371-operator in project %s", ns)) label := `app.kubernetes.io/name=memcached-quarkus-operator-52371-operator` podName, err := oc.AsAdmin().Run("get").Args("-n", ns, "pod", "-l", label, "-ojsonpath={..metadata.name}").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(podName).NotTo(o.BeEmpty()) exutil.By("step: Create CR") crFilePath := filepath.Join(dataPath, "memcached-sample.yaml") defer func() { exutil.By("step: delete cr.") _, err := oc.AsAdmin().WithoutNamespace().Run("delete").Args("-f", crFilePath, "-n", ns).Output() o.Expect(err).NotTo(o.HaveOccurred()) }() _, err = oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", crFilePath, "-n", ns).Output() o.Expect(err).NotTo(o.HaveOccurred()) waitErr = wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) { podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", ns).Output() o.Expect(err).NotTo(o.HaveOccurred()) lines := strings.Split(podList, "\n") for _, line := range lines { if strings.Contains(line, "memcached52371-sample") { e2e.Logf("found pod memcached52371-sample") if strings.Contains(line, "Running") { e2e.Logf("the status of pod memcached52371-sample is Running") return true, nil } e2e.Logf("the status of pod memcached52371-sample is not Running") return false, nil } } return false, nil }) if waitErr != nil { output, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("Memcached52371", "-n", ns).Output() e2e.Logf(output) output, _ = oc.AsAdmin().WithoutNamespace().Run("get").Args("pod", "-n", ns).Output() e2e.Logf(output) output, _ = oc.AsAdmin().WithoutNamespace().Run("logs").Args("-n", ns, podName).Output() e2e.Logf(output) } exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("No memcached52371-sample in project %s or the pod is not running", ns)) exutil.By("check Micrometer Metrics is enable") clusterIP, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("-n", ns, "service", "memcached-quarkus-operator-52371-operator", "-o=jsonpath={.spec.clusterIP}").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(clusterIP).NotTo(o.BeEmpty()) url := fmt.Sprintf("http://%s/q/metrics", clusterIP) output, err = oc.AsAdmin().WithoutNamespace().Run("rsh").Args("-n", ns, podName, "curl", url).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).NotTo(o.BeEmpty()) o.Expect(output).To(o.ContainSubstring("system_cpu_count")) exutil.By("OCP 52371 SUCCESS") })
test case
openshift/openshift-tests-private
93e1456e-5d4f-4fc8-beef-ac6c4265b2e7
Author:jitli-ConnectedOnly-VMonly-High-52377-operatorSDK support java plugin
['"context"', '"fmt"', '"os"', '"strings"', '"time"', '"github.com/openshift/openshift-tests-private/test/extended/util/architecture"', '"path/filepath"', '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/operatorsdk/operatorsdk.go
g.It("Author:jitli-ConnectedOnly-VMonly-High-52377-operatorSDK support java plugin", func() { g.Skip("OperatorSDK Java plugin unavailable and no plan to fix it, so skip it") if os.Getenv("HTTP_PROXY") != "" || os.Getenv("http_proxy") != "" { g.Skip("HTTP_PROXY is not empty - skipping test ...") } exutil.SkipOnProxyCluster(oc) architecture.SkipNonAmd64SingleArch(oc) var ( buildPruningBaseDir = exutil.FixturePath("testdata", "operatorsdk") dataPath = filepath.Join(buildPruningBaseDir, "ocp-52377-data") clusterrolebindingtemplate = filepath.Join(buildPruningBaseDir, "cluster-role-binding.yaml") quayCLI = container.NewQuayCLI() imageTag = "quay.io/olmqe/memcached-quarkus-operator:52377-" + getRandomString() bundleImage = "quay.io/olmqe/memcached-quarkus-bundle:52377-" + getRandomString() tmpBasePath = "/tmp/ocp-52377-" + getRandomString() tmpOperatorPath = filepath.Join(tmpBasePath, "memcached-quarkus-operator-52377") ) operatorsdkCLI.ExecCommandPath = tmpOperatorPath makeCLI.ExecCommandPath = tmpOperatorPath mvnCLI.ExecCommandPath = tmpOperatorPath err := os.MkdirAll(tmpOperatorPath, 0o755) o.Expect(err).NotTo(o.HaveOccurred()) defer os.RemoveAll(tmpBasePath) exutil.By("step: generate java type operator") output, err := operatorsdkCLI.Run("init").Args("--plugins=quarkus", "--domain=example.com").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("operator-sdk create api")) exutil.By("step: Create API.") _, err = operatorsdkCLI.Run("create").Args("api", "--plugins=quarkus", "--group=cache", "--version=v1", "--kind=Memcached52377").Output() o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("step: update API and Controller") examplePath := filepath.Join(tmpOperatorPath, "src", "main", "java", "com", "example") err = copy(filepath.Join(dataPath, "Memcached52377Reconciler.java"), filepath.Join(examplePath, "Memcached52377Reconciler.java")) o.Expect(err).NotTo(o.HaveOccurred()) err = copy(filepath.Join(dataPath, "Memcached52377Spec.java"), filepath.Join(examplePath, "Memcached52377Spec.java")) o.Expect(err).NotTo(o.HaveOccurred()) err = copy(filepath.Join(dataPath, "Memcached52377Status.java"), filepath.Join(examplePath, "Memcached52377Status.java")) o.Expect(err).NotTo(o.HaveOccurred()) err = copy(filepath.Join(dataPath, "pom.xml"), filepath.Join(tmpOperatorPath, "pom.xml")) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("step:mvn clean install") output, err = mvnCLI.Run("clean").Args("install").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("BUILD SUCCESS")) exutil.By("step: Build and push the operator image") defer quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1)) output, err = makeCLI.Run("docker-build").Args("docker-push", "IMG="+imageTag).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("BUILD SUCCESS")) exutil.By("step: make bundle.") output, err = makeCLI.Run("bundle").Args().Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("operator-sdk bundle validate")) exutil.By("step: update csv file") csvFile := filepath.Join(tmpOperatorPath, "bundle", "manifests", "memcached-quarkus-operator-52377.clusterserviceversion.yaml") replaceContent(csvFile, "supported: false", "supported: true") exutil.By("step: build and push bundle image.") defer quayCLI.DeleteTag(strings.Replace(bundleImage, "quay.io/", "", 1)) _, err = makeCLI.Run("bundle-build").Args("bundle-push", "BUNDLE_IMG="+bundleImage).Output() o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("step: create new project") oc.SetupProject() ns := oc.Namespace() exutil.By("step: run bundle") defer func() { output, err = operatorsdkCLI.Run("cleanup").Args("memcached-quarkus-operator-52377", "-n", ns).Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } }() output, err = operatorsdkCLI.Run("run").Args("bundle", bundleImage, "-n", ns, "--timeout", "5m", "--security-context-config=restricted").Output() if err != nil { logDebugInfo(oc, ns, "csv", "pod", "ip") } o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("OLM has successfully installed")) exutil.By("step: create clusterrolebinding") clusterrolebinding := clusterrolebindingDescription{ name: "memcached52377-operator-admin", namespace: ns, saname: "memcached-quarkus-operator-52377-operator", template: clusterrolebindingtemplate, } clusterrolebinding.create(oc) waitErr := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) { podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", ns).Output() o.Expect(err).NotTo(o.HaveOccurred()) lines := strings.Split(podList, "\n") for _, line := range lines { if strings.Contains(line, "memcached-quarkus-operator-52377-operator") { e2e.Logf("found pod memcached-quarkus-operator-52377-operator") if strings.Contains(line, "Running") { e2e.Logf("the status of pod memcached-quarkus-operator-52377-operator is Running") return true, nil } e2e.Logf("the status of pod memcached-quarkus-operator-52377-operator is not Running") return false, nil } } return false, nil }) if waitErr != nil { logDebugInfo(oc, ns, "pod", "csv", "catsrc") } exutil.By("step: Create CR") crFilePath := filepath.Join(dataPath, "memcached-sample.yaml") defer func() { exutil.By("step: delete cr.") _, err := oc.AsAdmin().WithoutNamespace().Run("delete").Args("-f", crFilePath, "-n", ns).Output() o.Expect(err).NotTo(o.HaveOccurred()) }() _, err = oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", crFilePath, "-n", ns).Output() o.Expect(err).NotTo(o.HaveOccurred()) waitErr = wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) { podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", ns).Output() o.Expect(err).NotTo(o.HaveOccurred()) lines := strings.Split(podList, "\n") for _, line := range lines { if strings.Contains(line, "memcached52377-sample") { e2e.Logf("found pod memcached52377-sample") if strings.Contains(line, "Running") { e2e.Logf("the status of pod memcached52377-sample is Running") return true, nil } e2e.Logf("the status of pod memcached52377-sample is not Running") return false, nil } } return false, nil }) if waitErr != nil { logDebugInfo(oc, ns, "Memcached52377", "pod", "events") } exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("No memcached52377-sample in project %s or the pod is not running", ns)) exutil.By("OCP 52377 SUCCESS") })
test case
openshift/openshift-tests-private
5f3cd95b-c7c8-4185-9163-07b9bef0835b
VMonly-ConnectedOnly-Author:chuo-High-40341-Ansible operator needs a way to pass vars as unsafe
['"context"', '"fmt"', '"os"', '"os/exec"', '"strings"', '"time"', '"github.com/openshift/openshift-tests-private/test/extended/util/architecture"', '"path/filepath"', '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/operatorsdk/operatorsdk.go
g.It("VMonly-ConnectedOnly-Author:chuo-High-40341-Ansible operator needs a way to pass vars as unsafe ", func() { imageTag := "quay.io/olmqe/memcached-operator-pass-unsafe:v" + ocpversion + getRandomString() clusterArchitecture := architecture.SkipArchitectures(oc, architecture.MULTI, architecture.PPC64LE, architecture.S390X) if clusterArchitecture == architecture.ARM64 { imageTag = "quay.io/olmqe/memcached-operator-pass-unsafe:v" + ocpversion + "-40341" } nsSystem := "system-40341-" + getRandomString() nsOperator := "memcached-operator-40341-system-" + getRandomString() tmpBasePath := "/tmp/ocp-40341-" + getRandomString() tmpPath := filepath.Join(tmpBasePath, "memcached-operator-40341") err := os.MkdirAll(tmpPath, 0o755) o.Expect(err).NotTo(o.HaveOccurred()) defer os.RemoveAll(tmpBasePath) operatorsdkCLI.ExecCommandPath = tmpPath makeCLI.ExecCommandPath = tmpPath defer func() { if imageTag != "quay.io/olmqe/memcached-operator-pass-unsafe:v"+ocpversion+"-40341" { quayCLI := container.NewQuayCLI() quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1)) } }() defer func() { deployfilepath := filepath.Join(tmpPath, "config", "samples", "cache_v1alpha1_memcached40341.yaml") _, err = oc.AsAdmin().WithoutNamespace().Run("delete").Args("-f", deployfilepath, "-n", nsOperator).Output() exutil.By("step: undeploy") _, err = makeCLI.Run("undeploy").Args().Output() o.Expect(err).NotTo(o.HaveOccurred()) }() exutil.By("step: init Ansible Based Operator") output, err := operatorsdkCLI.Run("init").Args("--plugins=ansible", "--domain", "example.com").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("Next")) exutil.By("step: Create API.") output, err = operatorsdkCLI.Run("create").Args("api", "--group", "cache", "--version", "v1alpha1", "--kind", "Memcached40341", "--generate-role").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("Writing kustomize manifests")) if !upstream { exutil.By("step: modify Dockerfile.") dockerFile := filepath.Join(tmpPath, "Dockerfile") content := getContent(dockerFile) o.Expect(content).To(o.ContainSubstring("registry.redhat.io/openshift4/ose-ansible-rhel9-operator:v" + ocpversion)) replaceContent(dockerFile, "registry.redhat.io/openshift4/ose-ansible-rhel9-operator:v"+ocpversion, "brew.registry.redhat.io/rh-osbs/openshift-ose-ansible-rhel9-operator:v"+ocpversion) } deployfilepath := filepath.Join(tmpPath, "config", "samples", "cache_v1alpha1_memcached40341.yaml") exec.Command("bash", "-c", fmt.Sprintf("sed -i '$d' %s", deployfilepath)).Output() exec.Command("bash", "-c", fmt.Sprintf("sed -i '$a\\ size: 3' %s", deployfilepath)).Output() exec.Command("bash", "-c", fmt.Sprintf("sed -i '$a\\ testKey: testVal' %s", deployfilepath)).Output() exec.Command("bash", "-c", fmt.Sprintf("sed -i 's/name: system/name: %s/g' `grep -rl \"name: system\" %s`", nsSystem, tmpPath)).Output() exec.Command("bash", "-c", fmt.Sprintf("sed -i 's/namespace: system/namespace: %s/g' `grep -rl \"namespace: system\" %s`", nsSystem, tmpPath)).Output() exec.Command("bash", "-c", fmt.Sprintf("sed -i 's/namespace: memcached-operator-40341-system/namespace: %s/g' `grep -rl \"namespace: memcached-operator-40341-system\" %s`", nsOperator, tmpPath)).Output() exutil.By("step: build and Push the operator image") dockerFilePath := filepath.Join(tmpPath, "Dockerfile") replaceContent(dockerFilePath, "RUN ansible-galaxy collection install -r ${HOME}/requirements.yml", "RUN ansible-galaxy collection install -r ${HOME}/requirements.yml --force") tokenDir := "/tmp/ocp-34426" + getRandomString() err = os.MkdirAll(tokenDir, os.ModePerm) defer os.RemoveAll(tokenDir) if err != nil { e2e.Failf("fail to create the token folder:%s", tokenDir) } _, err = oc.AsAdmin().WithoutNamespace().Run("extract").Args("secret/pull-secret", "-n", "openshift-config", fmt.Sprintf("--to=%s", tokenDir), "--confirm").Output() if err != nil { e2e.Failf("Fail to get the cluster auth %v", err) } // TODO[aleskandro,chuo]: this is a workaround: https://issues.redhat.com/browse/ARMOCP-531 architecture.SkipArchitectures(oc, architecture.MULTI, architecture.PPC64LE, architecture.S390X) switch clusterArchitecture { case architecture.AMD64: buildPushOperatorImage(clusterArchitecture, tmpPath, imageTag, tokenDir) case architecture.ARM64: e2e.Logf(fmt.Sprintf("platform is %s, IMG is %s", clusterArchitecture, imageTag)) } exutil.By("step: Install the CRD") output, err = makeCLI.Run("install").Args().Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("memcached40341s.cache.example.com created")) output, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("crd", "memcached40341s.cache.example.com").Output() e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).NotTo(o.ContainSubstring("NotFound")) exutil.By("step: Deploy the operator") output, err = makeCLI.Run("deploy").Args("IMG=" + imageTag).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("deployment.apps/memcached-operator-40341-controller-manager")) waitErr := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) { podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output() o.Expect(err).NotTo(o.HaveOccurred()) lines := strings.Split(podList, "\n") for _, line := range lines { if strings.Contains(line, "memcached-operator-40341-controller-manager") { e2e.Logf("found pod memcached-operator-40341-controller-manager") if strings.Contains(line, "Running") { e2e.Logf("the status of pod memcached-operator-40341-controller-manager is Running") return true, nil } e2e.Logf("the status of pod memcached-operator-40341-controller-manager is not Running") return false, nil } } return false, nil }) if waitErr != nil { logDebugInfo(oc, nsOperator, "events", "pod") } exutil.AssertWaitPollNoErr(waitErr, "No memcached-operator-40341-controller-manager") exutil.By("step: Create the resource") _, err = oc.AsAdmin().WithoutNamespace().Run("create").Args("-f", deployfilepath, "-n", nsOperator).Output() o.Expect(err).NotTo(o.HaveOccurred()) waitErr = wait.PollUntilContextTimeout(context.TODO(), 5*time.Second, 10*time.Second, false, func(ctx context.Context) (bool, error) { output, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("memcached40341s.cache.example.com", "-n", nsOperator).Output() o.Expect(err).NotTo(o.HaveOccurred()) if strings.Contains(output, "memcached40341-sample") { e2e.Logf("cr memcached40341-sample is created") return true, nil } return false, nil }) if waitErr != nil { logDebugInfo(oc, nsOperator, "events", "pod") } exutil.AssertWaitPollNoErr(waitErr, "No cr memcached40341-sample") exutil.By("step: check vars") output, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("memcached40341s.cache.example.com/memcached40341-sample", "-n", nsOperator, "-o=jsonpath={.spec.size}").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.Equal("3")) output, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("memcached40341s.cache.example.com/memcached40341-sample", "-n", nsOperator, "-o=jsonpath={.spec.testKey}").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.Equal("testVal")) exutil.By("40341 SUCCESS") })
test case
openshift/openshift-tests-private
e1ab1be3-b526-4c3f-854d-d4e962e7802e
Author:jfan-Critical-49960-verify an empty CRD description
['"path/filepath"']
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/operatorsdk.go
g.It("Author:jfan-Critical-49960-verify an empty CRD description", func() { tmpBasePath := exutil.FixturePath("testdata", "operatorsdk", "ocp-49960-data") exutil.By("step: validate CRD description success") output, err := operatorsdkCLI.Run("bundle").Args("validate", tmpBasePath+"/bundle", "--select-optional", "name=good-practices").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("All validation tests have completed successfully")) exutil.By("step: validate empty CRD description") csvFilePath := filepath.Join(tmpBasePath, "bundle", "manifests", "k8sevent.clusterserviceversion.yaml") replaceContent(csvFilePath, "description: test", "description:") output, err = operatorsdkCLI.Run("bundle").Args("validate", tmpBasePath+"/bundle", "--select-optional", "name=good-practices").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("has an empty description")) exutil.By("step: validate olm unsupported resource") crdFilePath := filepath.Join(tmpBasePath, "bundle", "manifests", "k8s.k8sevent.com_k8sevents.yaml") replaceContent(crdFilePath, "CustomResourceDefinition", "CustomResource") output, _ = operatorsdkCLI.Run("bundle").Args("validate", tmpBasePath+"/bundle", "--select-optional", "name=good-practices").Output() o.Expect(output).To(o.ContainSubstring("unsupported media type")) exutil.By("SUCCESS 49960") })
test case
openshift/openshift-tests-private
d302bbd7-cb24-4846-b907-7908f74ef630
VMonly-ConnectedOnly-Author:jfan-High-48885-SDK generate digest type bundle of ansible
['"context"', '"os"', '"strings"', '"time"', '"github.com/openshift/openshift-tests-private/test/extended/util/architecture"', '"path/filepath"', '"k8s.io/apimachinery/pkg/util/wait"']
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/operatorsdk.go
g.It("VMonly-ConnectedOnly-Author:jfan-High-48885-SDK generate digest type bundle of ansible", func() { architecture.SkipArchitectures(oc, architecture.MULTI, architecture.PPC64LE, architecture.S390X) buildPruningBaseDir := exutil.FixturePath("testdata", "operatorsdk") dataPath := filepath.Join(buildPruningBaseDir, "ocp-48885-data") tmpBasePath := "/tmp/ocp-48885-" + getRandomString() tmpPath := filepath.Join(tmpBasePath, "memcached-operator-48885") err := os.MkdirAll(tmpPath, 0o755) o.Expect(err).NotTo(o.HaveOccurred()) defer os.RemoveAll(tmpBasePath) operatorsdkCLI.ExecCommandPath = tmpPath makeCLI.ExecCommandPath = tmpPath exutil.By("step: init Ansible Based Operator") output, err := operatorsdkCLI.Run("init").Args("--plugins=ansible", "--domain", "example.com").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("Next")) exutil.By("step: Create API.") output, err = operatorsdkCLI.Run("create").Args("api", "--group", "cache", "--version", "v1", "--kind", "Memcached48885", "--generate-role").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("Writing kustomize manifests")) exutil.By("step: modify files to get the quay.io/olmqe images.") // copy task main.yml err = copy(filepath.Join(dataPath, "main.yml"), filepath.Join(tmpPath, "roles", "memcached48885", "tasks", "main.yml")) o.Expect(err).NotTo(o.HaveOccurred()) // copy manager.yaml err = copy(filepath.Join(dataPath, "manager.yaml"), filepath.Join(tmpPath, "config", "manager", "manager.yaml")) o.Expect(err).NotTo(o.HaveOccurred()) // update the Makefile makefileFilePath := filepath.Join(tmpPath, "Makefile") replaceContent(makefileFilePath, "controller:latest", "quay.io/olmqe/ansibledisconnected:v4.11") replaceContent(makefileFilePath, "operator-sdk generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)", "operator-sdk generate bundle $(BUNDLE_GEN_FLAGS)") exutil.By("step: make bundle.") // copy manifests manifestsPath := filepath.Join(tmpPath, "config", "manifests", "bases") err = os.MkdirAll(manifestsPath, 0o755) o.Expect(err).NotTo(o.HaveOccurred()) manifestsFile := filepath.Join(manifestsPath, "memcached-operator-48885.clusterserviceversion.yaml") _, err = os.Create(manifestsFile) o.Expect(err).NotTo(o.HaveOccurred()) err = copy(filepath.Join(dataPath, "memcached-operator-48885.clusterserviceversion.yaml"), filepath.Join(manifestsFile)) o.Expect(err).NotTo(o.HaveOccurred()) // make bundle use image digests waitErr := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 120*time.Second, false, func(ctx context.Context) (bool, error) { msg, err := makeCLI.Run("bundle").Args("USE_IMAGE_DIGESTS=true").Output() if err != nil { e2e.Logf("make bundle failed, try again") return false, nil } if strings.Contains(msg, "operator-sdk bundle validate ./bundle") { return true, nil } return false, nil }) exutil.AssertWaitPollNoErr(waitErr, "operator-sdk bundle generate failed") csvFile := filepath.Join(tmpPath, "bundle", "manifests", "memcached-operator-48885.clusterserviceversion.yaml") content := getContent(csvFile) if !strings.Contains(content, "quay.io/olmqe/memcached@sha256:") || !strings.Contains(content, "quay.io/olmqe/ansibledisconnected@sha256:") { e2e.Failf("Fail to get the image info with digest type") } })
test case
openshift/openshift-tests-private
b1660a57-9f24-464d-839e-3e66e7013c52
VMonly-ConnectedOnly-Author:jfan-High-52813-SDK generate digest type bundle of helm
['"context"', '"fmt"', '"os"', '"strings"', '"time"', '"github.com/openshift/openshift-tests-private/test/extended/util/architecture"', '"path/filepath"', '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/operatorsdk/operatorsdk.go
g.It("VMonly-ConnectedOnly-Author:jfan-High-52813-SDK generate digest type bundle of helm", func() { if os.Getenv("HTTP_PROXY") != "" || os.Getenv("http_proxy") != "" { g.Skip("HTTP_PROXY is not empty - skipping test ...") } clusterArchitecture := architecture.SkipNonAmd64SingleArch(oc) buildPruningBaseDir := exutil.FixturePath("testdata", "operatorsdk") dataPath := filepath.Join(buildPruningBaseDir, "ocp-52813-data") tmpBasePath := "/tmp/ocp-52813-" + getRandomString() tmpPath := filepath.Join(tmpBasePath, "memcached-operator-52813") imageTag := "quay.io/olmqe/memcached-operator:52813-" + getRandomString() err := os.MkdirAll(tmpPath, 0o755) o.Expect(err).NotTo(o.HaveOccurred()) defer os.RemoveAll(tmpBasePath) operatorsdkCLI.ExecCommandPath = tmpPath makeCLI.ExecCommandPath = tmpPath defer func() { quayCLI := container.NewQuayCLI() quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1)) }() exutil.By("step: init Helm Based Operator") output, err := operatorsdkCLI.Run("init").Args("--plugins=helm", "--domain=disconnected.com", "--group=test", "--version=v1", "--kind=Nginx").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("Created helm-charts")) exutil.By("step: modify files to get the quay.io/olmqe images.") // copy watches.yaml err = copy(filepath.Join(dataPath, "watches.yaml"), filepath.Join(tmpPath, "watches.yaml")) o.Expect(err).NotTo(o.HaveOccurred()) // copy helm-charts/nginx/values.yaml err = copy(filepath.Join(dataPath, "values.yaml"), filepath.Join(tmpPath, "helm-charts", "nginx", "values.yaml")) o.Expect(err).NotTo(o.HaveOccurred()) // update the file helm-charts/nginx/templates/deployment.yaml deployFilepath := filepath.Join(tmpPath, "helm-charts", "nginx", "templates", "deployment.yaml") replaceContent(deployFilepath, ".Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion", ".Values.relatedImage") // update the Dockerfile dockerFile := filepath.Join(tmpPath, "Dockerfile") replaceContent(dockerFile, "registry.redhat.io/openshift4/ose-helm-rhel9-operator:v"+ocpversion, "brew.registry.redhat.io/rh-osbs/openshift-ose-helm-operator-rhel9:v"+ocpversion) // copy the manager err = copy(filepath.Join(dataPath, "manager.yaml"), filepath.Join(tmpPath, "config", "manager", "manager.yaml")) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("step: Build and push the operator image") tokenDir := "/tmp/ocp-52813" + getRandomString() err = os.MkdirAll(tokenDir, os.ModePerm) defer os.RemoveAll(tokenDir) if err != nil { e2e.Failf("fail to create the token folder:%s", tokenDir) } _, err = oc.AsAdmin().WithoutNamespace().Run("extract").Args("secret/pull-secret", "-n", "openshift-config", fmt.Sprintf("--to=%s", tokenDir), "--confirm").Output() if err != nil { e2e.Failf("Fail to get the cluster auth %v", err) } buildPushOperatorImage(clusterArchitecture, tmpPath, imageTag, tokenDir) // update the Makefile makefileFilePath := filepath.Join(tmpPath, "Makefile") replaceContent(makefileFilePath, "controller:latest", imageTag) replaceContent(makefileFilePath, "operator-sdk generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)", "operator-sdk generate bundle $(BUNDLE_GEN_FLAGS)") exutil.By("step: make bundle.") // copy manifests manifestsPath := filepath.Join(tmpPath, "config", "manifests", "bases") err = os.MkdirAll(manifestsPath, 0o755) o.Expect(err).NotTo(o.HaveOccurred()) manifestsFile := filepath.Join(manifestsPath, "memcached-operator-52813.clusterserviceversion.yaml") _, err = os.Create(manifestsFile) o.Expect(err).NotTo(o.HaveOccurred()) err = copy(filepath.Join(dataPath, "memcached-operator-52813.clusterserviceversion.yaml"), filepath.Join(manifestsFile)) o.Expect(err).NotTo(o.HaveOccurred()) // make bundle use image digests waitErr := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 120*time.Second, false, func(ctx context.Context) (bool, error) { msg, err := makeCLI.Run("bundle").Args("USE_IMAGE_DIGESTS=true").Output() if err != nil { e2e.Logf("make bundle failed, try again") return false, nil } if strings.Contains(msg, "operator-sdk bundle validate ./bundle") { return true, nil } return false, nil }) exutil.AssertWaitPollNoErr(waitErr, "operator-sdk bundle generate failed") csvFile := filepath.Join(tmpPath, "bundle", "manifests", "memcached-operator-52813.clusterserviceversion.yaml") content := getContent(csvFile) if !strings.Contains(content, "quay.io/olmqe/nginx@sha256:") || !strings.Contains(content, "quay.io/olmqe/memcached-operator@sha256:") { e2e.Failf("Fail to get the image info with digest type") } })
test case
openshift/openshift-tests-private
de248d9a-2d22-4137-85e4-34ef3c78d9a2
VMonly-ConnectedOnly-Author:jfan-High-52814-SDK generate digest type bundle of go
['"context"', '"fmt"', '"os"', '"os/exec"', '"strings"', '"time"', '"github.com/openshift/openshift-tests-private/test/extended/util/architecture"', '"path/filepath"', '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/operatorsdk/operatorsdk.go
g.It("VMonly-ConnectedOnly-Author:jfan-High-52814-SDK generate digest type bundle of go", func() { if os.Getenv("HTTP_PROXY") != "" || os.Getenv("http_proxy") != "" { g.Skip("HTTP_PROXY is not empty - skipping test ...") } clusterArchitecture := architecture.SkipArchitectures(oc, architecture.MULTI, architecture.PPC64LE, architecture.S390X) buildPruningBaseDir := exutil.FixturePath("testdata", "operatorsdk") dataPath := filepath.Join(buildPruningBaseDir, "ocp-52814-data") tmpBasePath := "/tmp/ocp-52814-" + getRandomString() tmpPath := filepath.Join(tmpBasePath, "memcached-operator-52814") imageTag := "quay.io/olmqe/memcached-operator:52814-" + getRandomString() err := os.MkdirAll(tmpPath, 0o755) o.Expect(err).NotTo(o.HaveOccurred()) defer os.RemoveAll(tmpBasePath) operatorsdkCLI.ExecCommandPath = tmpPath makeCLI.ExecCommandPath = tmpPath defer func() { quayCLI := container.NewQuayCLI() quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1)) }() exutil.By("step: init Go Based Operator") output, err := operatorsdkCLI.Run("init").Args("--domain=disconnected.com", "--repo=github.com/example-inc/memcached-operator").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("Next")) exutil.By("step: create api") output, err = operatorsdkCLI.Run("create").Args("api", "--group=test", "--version=v1", "--kind=Memcached52814", "--controller", "--resource").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("make manifests")) exutil.By("step: modify files to get the quay.io/olmqe images.") // copy api/v1/memcached52814_types.go err = copy(filepath.Join(dataPath, "memcached52814_types.go"), filepath.Join(tmpPath, "api", "v1", "memcached52814_types.go")) o.Expect(err).NotTo(o.HaveOccurred()) // copy controllers/memcached52814_controller.go err = copy(filepath.Join(dataPath, "memcached52814_controller.go"), filepath.Join(tmpPath, "internal", "controller", "memcached52814_controller.go")) o.Expect(err).NotTo(o.HaveOccurred()) // copy the manager err = copy(filepath.Join(dataPath, "manager.yaml"), filepath.Join(tmpPath, "config", "manager", "manager.yaml")) o.Expect(err).NotTo(o.HaveOccurred()) // update the Dockerfile dockerfileFilePath := filepath.Join(tmpPath, "Dockerfile") replaceContent(dockerfileFilePath, "golang", "quay.io/olmqe/golang") exutil.By("step: Build and push the operator image") tokenDir := "/tmp/ocp-52814" + getRandomString() err = os.MkdirAll(tokenDir, os.ModePerm) defer os.RemoveAll(tokenDir) if err != nil { e2e.Failf("fail to create the token folder:%s", tokenDir) } _, err = oc.AsAdmin().WithoutNamespace().Run("extract").Args("secret/pull-secret", "-n", "openshift-config", fmt.Sprintf("--to=%s", tokenDir), "--confirm").Output() if err != nil { e2e.Failf("Fail to get the cluster auth %v", err) } buildPushOperatorImage(clusterArchitecture, tmpPath, imageTag, tokenDir) // update the Makefile makefileFilePath := filepath.Join(tmpPath, "Makefile") replaceContent(makefileFilePath, "controller:latest", imageTag) exutil.By("step: Install kustomize") kustomizePath := "/root/kustomize" binPath := filepath.Join(tmpPath, "bin") exec.Command("bash", "-c", fmt.Sprintf("cp %s %s", kustomizePath, binPath)).Output() exutil.By("step: make bundle.") // copy manifests manifestsPath := filepath.Join(tmpPath, "config", "manifests", "bases") err = os.MkdirAll(manifestsPath, 0o755) o.Expect(err).NotTo(o.HaveOccurred()) manifestsFile := filepath.Join(manifestsPath, "memcached-operator-52814.clusterserviceversion.yaml") _, err = os.Create(manifestsFile) o.Expect(err).NotTo(o.HaveOccurred()) err = copy(filepath.Join(dataPath, "memcached-operator-52814.clusterserviceversion.yaml"), filepath.Join(manifestsFile)) o.Expect(err).NotTo(o.HaveOccurred()) // make bundle use image digests waitErr := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 120*time.Second, false, func(ctx context.Context) (bool, error) { msg, err := makeCLI.Run("bundle").Args("USE_IMAGE_DIGESTS=true").Output() if err != nil { e2e.Logf("make bundle failed, try again") return false, nil } if strings.Contains(msg, "operator-sdk bundle validate ./bundle") { return true, nil } return false, nil }) exutil.AssertWaitPollNoErr(waitErr, "operator-sdk bundle generate failed") csvFile := filepath.Join(tmpPath, "bundle", "manifests", "memcached-operator-52814.clusterserviceversion.yaml") content := getContent(csvFile) if !strings.Contains(content, "quay.io/olmqe/memcached@sha256:") || !strings.Contains(content, "quay.io/olmqe/memcached-operator@sha256:") { e2e.Failf("Fail to get the image info with digest type") } })
test case
openshift/openshift-tests-private
3037aa9a-fd7f-42cc-9eda-4bbdcf7bc2b7
VMonly-ConnectedOnly-Author:jfan-High-44550-SDK support ansible type operator for http_proxy env
['"context"', '"fmt"', '"os"', '"strings"', '"time"', '"github.com/openshift/openshift-tests-private/test/extended/util/architecture"', '"path/filepath"', '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/operatorsdk/operatorsdk.go
g.It("VMonly-ConnectedOnly-Author:jfan-High-44550-SDK support ansible type operator for http_proxy env", func() { g.By("Check if it is a proxy platform") proxySet, _ := oc.WithoutNamespace().AsAdmin().Run("get").Args("proxy/cluster", "-o=jsonpath={.spec.httpProxy}").Output() if proxySet == " " { g.Skip("Skip for no-proxy platform") } clusterArchitecture := architecture.SkipNonAmd64SingleArch(oc) tmpBasePath := "/tmp/ocp-44550-" + getRandomString() tmpPath := filepath.Join(tmpBasePath, "memcached-operator-44550") err := os.MkdirAll(tmpPath, 0o755) o.Expect(err).NotTo(o.HaveOccurred()) defer os.RemoveAll(tmpBasePath) operatorsdkCLI.ExecCommandPath = tmpPath makeCLI.ExecCommandPath = tmpPath nsOperator := "memcached-operator-44550-system" imageTag := "quay.io/olmqe/memcached-operator:44550-" + getRandomString() buildPruningBaseDir := exutil.FixturePath("testdata", "operatorsdk") dataPath := filepath.Join(buildPruningBaseDir, "ocp-44550-data") crFilePath := filepath.Join(dataPath, "cache_v1_memcached44550.yaml") quayCLI := container.NewQuayCLI() defer quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1)) defer func() { _, err = oc.AsAdmin().WithoutNamespace().Run("delete").Args("-f", crFilePath, "-n", nsOperator).Output() exutil.By("step: undeploy") _, err = makeCLI.Run("undeploy").Args().Output() o.Expect(err).NotTo(o.HaveOccurred()) }() exutil.By("step: init Ansible Based Operator") output, err := operatorsdkCLI.Run("init").Args("--plugins=ansible", "--domain", "example.com").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("Next")) exutil.By("step: Create API.") output, err = operatorsdkCLI.Run("create").Args("api", "--group", "cache", "--version", "v1", "--kind", "Memcached44550", "--generate-role").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("Writing kustomize manifests")) exutil.By("step: modify files to get the quay.io/olmqe images.") // copy task main.yml err = copy(filepath.Join(dataPath, "main.yml"), filepath.Join(tmpPath, "roles", "memcached44550", "tasks", "main.yml")) o.Expect(err).NotTo(o.HaveOccurred()) // copy manager.yaml err = copy(filepath.Join(dataPath, "manager.yaml"), filepath.Join(tmpPath, "config", "manager", "manager.yaml")) o.Expect(err).NotTo(o.HaveOccurred()) // update the Makefile makefileFilePath := filepath.Join(tmpPath, "Makefile") replaceContent(makefileFilePath, "controller:latest", imageTag) replaceContent(makefileFilePath, "build config/default | kubectl apply -f -", "build config/default | CLUSTER_PROXY=$(shell kubectl get proxies.config.openshift.io cluster -o json | jq '.spec.httpProxy') envsubst | kubectl apply -f -") // update the Dockerfile dockerFile := filepath.Join(tmpPath, "Dockerfile") replaceContent(dockerFile, "registry.redhat.io/openshift4/ose-ansible-rhel9-operator:v"+ocpversion, "brew.registry.redhat.io/rh-osbs/openshift-ose-ansible-rhel9-operator:v"+ocpversion) replaceContent(dockerFile, "install -r ${HOME}/requirements.yml", "install -r ${HOME}/requirements.yml --force") exutil.By("step: Build and push the operator image") tokenDir := "/tmp/ocp-44550" + getRandomString() err = os.MkdirAll(tokenDir, os.ModePerm) defer os.RemoveAll(tokenDir) if err != nil { e2e.Failf("fail to create the token folder:%s", tokenDir) } _, err = oc.AsAdmin().WithoutNamespace().Run("extract").Args("secret/pull-secret", "-n", "openshift-config", fmt.Sprintf("--to=%s", tokenDir), "--confirm").Output() if err != nil { e2e.Failf("Fail to get the cluster auth %v", err) } buildPushOperatorImage(clusterArchitecture, tmpPath, imageTag, tokenDir) exutil.By("step: Install the CRD") output, err = makeCLI.Run("install").Args().Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("memcached44550s.cache.example.com")) exutil.By("step: Deploy the operator") output, err = makeCLI.Run("deploy").Args("IMG=" + imageTag).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("deployment.apps/memcached-operator-44550-controller-manager")) waitErr := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) { podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output() o.Expect(err).NotTo(o.HaveOccurred()) lines := strings.Split(podList, "\n") for _, line := range lines { if strings.Contains(line, "memcached-operator-44550-controller-manager") { e2e.Logf("found pod memcached-operator-44550-controller-manager") if strings.Contains(line, "1/1") { e2e.Logf("the status of pod memcached-operator-44550-controller-manager is Running") return true, nil } e2e.Logf("the status of pod memcached-operator-44550-controller-manager is not Running") return false, nil } } return false, nil }) if waitErr != nil { logDebugInfo(oc, nsOperator, "events", "pod") } exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("No memcached-operator-44550-controller-manager in project %s", nsOperator)) msg, err := oc.AsAdmin().WithoutNamespace().Run("logs").Args("deployment.apps/memcached-operator-44550-controller-manager", "-c", "manager", "-n", nsOperator).Output() o.Expect(err).NotTo(o.HaveOccurred()) if !strings.Contains(msg, "Starting workers") { e2e.Failf("Starting workers failed") } exutil.By("step: Create the resource") _, err = oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", crFilePath, "-n", nsOperator).Output() o.Expect(err).NotTo(o.HaveOccurred()) waitErr = wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) { msg, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output() o.Expect(err).NotTo(o.HaveOccurred()) if strings.Contains(msg, "memcached44550-sample-ansiblehttp") { e2e.Logf("found pod memcached44550-sample-ansiblehttp") return true, nil } return false, nil }) if waitErr != nil { logDebugInfo(oc, nsOperator, "events", "pod") } exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("No memcached44550-sample in project %s", nsOperator)) waitErr = wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) { proxyMsg, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("proxies.config.openshift.io", "cluster", "-o=jsonpath={.spec.httpProxy}").Output() o.Expect(err).NotTo(o.HaveOccurred()) msg, err = oc.AsAdmin().WithoutNamespace().Run("describe").Args("deployment/memcached44550-sample-ansiblehttp", "-n", nsOperator).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(msg).To(o.ContainSubstring("HTTP_PROXY: " + proxyMsg)) if strings.Contains(msg, "3 desired | 3 updated | 3 total | 3 available | 0 unavailable") { e2e.Logf("deployment/memcach44550-sample is created successfully") return true, nil } return false, nil }) if waitErr != nil { logDebugInfo(oc, nsOperator, "events") } exutil.AssertWaitPollNoErr(waitErr, "the status of deployment/memcached44550-sample-ansiblehttp is wrong") })
test case
openshift/openshift-tests-private
81baf4ef-eda8-4dd8-ba2b-7c5a5631b6b0
VMonly-ConnectedOnly-Author:jfan-High-44551-SDK support helm type operator for http_proxy env
['"context"', '"fmt"', '"os"', '"strings"', '"time"', '"github.com/openshift/openshift-tests-private/test/extended/util/architecture"', '"path/filepath"', '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/operatorsdk/operatorsdk.go
g.It("VMonly-ConnectedOnly-Author:jfan-High-44551-SDK support helm type operator for http_proxy env", func() { clusterArchitecture := architecture.SkipNonAmd64SingleArch(oc) tmpBasePath := "/tmp/ocp-44551-" + getRandomString() tmpPath := filepath.Join(tmpBasePath, "memcached-operator-44551") err := os.MkdirAll(tmpPath, 0o755) o.Expect(err).NotTo(o.HaveOccurred()) defer os.RemoveAll(tmpBasePath) operatorsdkCLI.ExecCommandPath = tmpPath makeCLI.ExecCommandPath = tmpPath nsOperator := "memcached-operator-44551-system" imageTag := "quay.io/olmqe/memcached-operator:44551-" + getRandomString() dataPath := "test/extended/testdata/operatorsdk/ocp-44551-data/" crFilePath := filepath.Join(dataPath, "kakademo_v1_nginx.yaml") quayCLI := container.NewQuayCLI() defer quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1)) defer func() { oc.AsAdmin().WithoutNamespace().Run("delete").Args("-f", crFilePath, "-n", nsOperator).Output() exutil.By("step: undeploy") _, err = makeCLI.Run("undeploy").Args().Output() o.Expect(err).NotTo(o.HaveOccurred()) }() exutil.By("step: init Helm Based Operator") output, err := operatorsdkCLI.Run("init").Args("--plugins=helm", "--domain=httpproxy.com", "--group=kakademo", "--version=v1", "--kind=Nginx").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("Created helm-charts")) exutil.By("step: modify files to generate the quay.io/olmqe images.") // update the Dockerfile dockerFile := filepath.Join(tmpPath, "Dockerfile") replaceContent(dockerFile, "registry.redhat.io/openshift4/ose-helm-rhel9-operator:v"+ocpversion, "brew.registry.redhat.io/rh-osbs/openshift-ose-helm-operator-rhel9:v"+ocpversion) // update the Makefile makefileFilePath := filepath.Join(tmpPath, "Makefile") replaceContent(makefileFilePath, "controller:latest", imageTag) replaceContent(makefileFilePath, "build config/default | kubectl apply -f -", "build config/default | CLUSTER_PROXY=$(shell kubectl get proxies.config.openshift.io cluster -o json | jq '.spec.httpProxy') envsubst | kubectl apply -f -") // copy watches.yaml err = copy(filepath.Join(dataPath, "watches.yaml"), filepath.Join(tmpPath, "watches.yaml")) o.Expect(err).NotTo(o.HaveOccurred()) // copy helm-charts/nginx/values.yaml err = copy(filepath.Join(dataPath, "values.yaml"), filepath.Join(tmpPath, "helm-charts", "nginx", "values.yaml")) o.Expect(err).NotTo(o.HaveOccurred()) // copy helm-charts/nginx/templates/deployment.yaml err = copy(filepath.Join(dataPath, "deployment.yaml"), filepath.Join(tmpPath, "helm-charts", "nginx", "templates", "deployment.yaml")) o.Expect(err).NotTo(o.HaveOccurred()) // copy config/manager/manager.yaml err = copy(filepath.Join(dataPath, "manager.yaml"), filepath.Join(tmpPath, "config", "manager", "manager.yaml")) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("step: Build and push the operator image") tokenDir := "/tmp/ocp-44551" + getRandomString() err = os.MkdirAll(tokenDir, os.ModePerm) defer os.RemoveAll(tokenDir) if err != nil { e2e.Failf("fail to create the token folder:%s", tokenDir) } _, err = oc.AsAdmin().WithoutNamespace().Run("extract").Args("secret/pull-secret", "-n", "openshift-config", fmt.Sprintf("--to=%s", tokenDir), "--confirm").Output() if err != nil { e2e.Failf("Fail to get the cluster auth %v", err) } buildPushOperatorImage(clusterArchitecture, tmpPath, imageTag, tokenDir) exutil.By("step: Install the CRD") output, err = makeCLI.Run("install").Args().Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("kakademo")) exutil.By("step: Deploy the operator") output, err = makeCLI.Run("deploy").Args("IMG=" + imageTag).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("deployment.apps/memcached-operator-44551-controller-manager")) waitErr := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) { podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output() o.Expect(err).NotTo(o.HaveOccurred()) lines := strings.Split(podList, "\n") for _, line := range lines { if strings.Contains(line, "memcached-operator-44551-controller-manager") { e2e.Logf("found pod memcached-operator-44551-controller-manager") if strings.Contains(line, "1/1") { e2e.Logf("the status of pod memcached-operator-44551-controller-manager is Running") return true, nil } e2e.Logf("the status of pod memcached-operator-44551-controller-manager is not Running") return false, nil } } return false, nil }) if waitErr != nil { logDebugInfo(oc, nsOperator, "events", "pod") } exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("No memcached-operator-44551-controller-manager in project %s", nsOperator)) waitErr = wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) { msg, err := oc.AsAdmin().WithoutNamespace().Run("logs").Args("deployment.apps/memcached-operator-44551-controller-manager", "-c", "manager", "-n", nsOperator).Output() o.Expect(err).NotTo(o.HaveOccurred()) if strings.Contains(msg, "Starting workers") { e2e.Logf("Starting workers successfully") return true, nil } return false, nil }) exutil.AssertWaitPollNoErr(waitErr, "container manager doesn't work") exutil.By("step: Create the resource") _, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("policy", "add-scc-to-user", "anyuid", fmt.Sprintf("system:serviceaccount:%s:nginx-sample", nsOperator)).Output() o.Expect(err).NotTo(o.HaveOccurred()) _, err = oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", crFilePath, "-n", nsOperator).Output() o.Expect(err).NotTo(o.HaveOccurred()) waitErr = wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) { msg, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output() o.Expect(err).NotTo(o.HaveOccurred()) if strings.Contains(msg, "nginx-sample") { e2e.Logf("found pod nginx-sample") return true, nil } return false, nil }) if waitErr != nil { logDebugInfo(oc, nsOperator, "events", "pod") } exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("No memcached44551-sample in project %s", nsOperator)) waitErr = wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) { proxyMsg, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("proxies.config.openshift.io", "cluster", "-o=jsonpath={.spec.httpProxy}").Output() o.Expect(err).NotTo(o.HaveOccurred()) msg, err := oc.AsAdmin().WithoutNamespace().Run("describe").Args("deployment/nginx-sample", "-n", nsOperator).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(msg).To(o.ContainSubstring("HTTP_PROXY: " + proxyMsg)) if strings.Contains(msg, "HTTP_PROXY: "+proxyMsg) { e2e.Logf("deployment/nginx-sample is created successfully") return true, nil } return false, nil }) if waitErr != nil { logDebugInfo(oc, nsOperator, "events") } exutil.AssertWaitPollNoErr(waitErr, "the status of deployment/memcached44551-sample-ansiblehttp is wrong") })
test case
openshift/openshift-tests-private
8d3d9dad-258c-4461-8434-a9260cf6d29e
NonPreRelease-Longduration-VMonly-ConnectedOnly-Author:jitli-High-50065-SDK Add file based catalog support to run bundle
['"context"', '"strings"']
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/operatorsdk.go
g.It("NonPreRelease-Longduration-VMonly-ConnectedOnly-Author:jitli-High-50065-SDK Add file based catalog support to run bundle", func() { exutil.SkipOnProxyCluster(oc) operatorsdkCLI.showInfo = true oc.SetupProject() exutil.By("Run bundle without index") defer operatorsdkCLI.Run("cleanup").Args("k8sevent", "-n", oc.Namespace()).Output() output, err := operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/k8sevent-bundle:v4.11", "-n", oc.Namespace(), "--timeout", "5m", "--security-context-config=restricted").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("Generated a valid File-Based Catalog")) o.Expect(output).To(o.ContainSubstring("OLM has successfully installed")) exutil.By("Run bundle with FBC index") defer operatorsdkCLI.Run("cleanup").Args("blacklist", "-n", oc.Namespace()).Output() output, err = operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/blacklist-bundle:v4.11", "--index-image", "quay.io/olmqe/nginxolm-operator-index:v1", "-n", oc.Namespace(), "--timeout", "5m", "--security-context-config=restricted").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring(`Creating a File-Based Catalog of the bundle \"quay.io/olmqe/blacklist-bundle`)) o.Expect(output).To(o.ContainSubstring(`Rendering a File-Based Catalog of the Index Image \"quay.io/olmqe/nginxolm-operator-index:v1\"`)) o.Expect(output).To(o.ContainSubstring("OLM has successfully installed")) exutil.By("Run bundle with SQLite index") defer operatorsdkCLI.Run("cleanup").Args("k8sstatus", "-n", oc.Namespace()).Output() output, err = operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/k8sstatus-bundle:v4.11", "--index-image", "quay.io/olmqe/ditto-index:50065", "-n", oc.Namespace(), "--timeout", "5m", "--security-context-config=restricted").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("SQLite based index images are being deprecated and will be removed in a future release")) o.Expect(output).To(o.ContainSubstring("OLM has successfully installed")) exutil.By("Run bundle with index that contains the bundle message") defer operatorsdkCLI.Run("cleanup").Args("upgradeindex", "-n", oc.Namespace()).Output() _, err = operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/upgradeindex-bundle:v0.1", "--index-image", "quay.io/olmqe/upgradeindex-index:v0.1", "-n", oc.Namespace(), "--timeout", "5m", "--security-context-config=restricted").Output() o.Expect(err).To(o.HaveOccurred()) output, _ = oc.AsAdmin().WithoutNamespace().Run("logs").Args("-n", oc.Namespace(), "quay-io-olmqe-upgradeindex-bundle-v0-1").Output() if !strings.Contains(output, "Bundle quay.io/olmqe/upgradeindex-bundle:v0.1 already exists, Bundle already added that provides package and csv") { e2e.Failf("Cannot get log Bundle quay.io/olmqe/upgradeindex-bundle:v0.1 already exists, Bundle already added that provides package and csv") } })
test case
openshift/openshift-tests-private
def26b3a-c699-4a61-aeb3-a63130c4db0b
Author:jitli-VMonly-ConnectedOnly-High-52364-SDK Run bundle not support large FBC index since OCP4.14 [Serial]
['"context"']
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/operatorsdk.go
g.It("Author:jitli-VMonly-ConnectedOnly-High-52364-SDK Run bundle not support large FBC index since OCP4.14 [Serial]", func() { exutil.SkipOnProxyCluster(oc) operatorsdkCLI.showInfo = true oc.SetupProject() exutil.By("Run bundle with large FBC index (size >3M)") defer operatorsdkCLI.Run("cleanup").Args("upgradefbc", "-n", oc.Namespace()).Output() output, err := operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/upgradefbc-bundle:v0.1", "--index-image", "quay.io/operatorhubio/catalog:latest", "-n", oc.Namespace(), "--timeout", "5m", "--security-context-config=restricted").Output() o.Expect(err).To(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("Too long: must have at most 1048576 bytes")) })
test case
openshift/openshift-tests-private
ed4eaf58-c503-4028-b1ea-168ae140d03b
VMonly-ConnectedOnly-Author:jitli-High-51295-SDK-Run bundle-upgrade from bundle installation without index image [Serial]
['"context"']
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/operatorsdk.go
g.It("VMonly-ConnectedOnly-Author:jitli-High-51295-SDK-Run bundle-upgrade from bundle installation without index image [Serial]", func() { exutil.SkipOnProxyCluster(oc) operatorsdkCLI.showInfo = true oc.SetupProject() exutil.By("Run bundle install operator without index image v0.1") defer operatorsdkCLI.Run("cleanup").Args("upgradeindex", "-n", oc.Namespace()).Output() output, err := operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/upgradeindex-bundle:v0.1", "-n", oc.Namespace(), "--timeout", "5m", "--security-context-config=restricted").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("OLM has successfully installed")) exutil.By("Run bundle-upgrade from the csv v.0.1->v0.2") output, err = operatorsdkCLI.Run("run").Args("bundle-upgrade", "quay.io/olmqe/upgradeindex-bundle:v0.2", "-n", oc.Namespace(), "--timeout", "5m", "--security-context-config=restricted").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("Generated a valid Upgraded File-Based Catalog")) o.Expect(output).To(o.ContainSubstring("Successfully upgraded to")) })
test case
openshift/openshift-tests-private
29925976-cb1a-4a9b-b68e-b2eb783c225a
VMonly-ConnectedOnly-Author:jitli-High-51296-SDK-Run bundle-upgrade from bundle installation with index image [Serial]
['"context"']
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/operatorsdk.go
g.It("VMonly-ConnectedOnly-Author:jitli-High-51296-SDK-Run bundle-upgrade from bundle installation with index image [Serial]", func() { exutil.SkipOnProxyCluster(oc) operatorsdkCLI.showInfo = true oc.SetupProject() exutil.By("Run bundle install operator with SQLite index image csv 0.1") defer operatorsdkCLI.Run("cleanup").Args("upgradeoperator", "-n", oc.Namespace()).Output() output, err := operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/upgradeoperator-bundle:v0.1", "--index-image", "quay.io/olmqe/upgradeindex-index:v0.1", "-n", oc.Namespace(), "--timeout", "5m", "--security-context-config=restricted").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("OLM has successfully installed")) exutil.By("Run bundle-upgrade from the csv v.0.1->v0.2") output, err = operatorsdkCLI.Run("run").Args("bundle-upgrade", "quay.io/olmqe/upgradeoperator-bundle:v0.2", "-n", oc.Namespace(), "--timeout", "5m", "--security-context-config=restricted").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("Updated catalog source upgradeoperator-catalog")) o.Expect(output).To(o.ContainSubstring("Successfully upgraded")) exutil.By("Run bundle install operator with FBC index image") defer operatorsdkCLI.Run("cleanup").Args("upgradeindex", "-n", oc.Namespace()).Output() output, err = operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/upgradeindex-bundle:v0.1", "--index-image", "quay.io/olmqe/nginxolm-operator-index:v1", "-n", oc.Namespace(), "--timeout", "5m", "--security-context-config=restricted").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("Generated a valid File-Based Catalog")) o.Expect(output).To(o.ContainSubstring("OLM has successfully installed")) exutil.By("Run bundle-upgrade from the csv v.0.1->v0.2") output, err = operatorsdkCLI.Run("run").Args("bundle-upgrade", "quay.io/olmqe/upgradeindex-bundle:v0.2", "-n", oc.Namespace(), "--timeout", "5m", "--security-context-config=restricted").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("Generated a valid Upgraded File-Based Catalog")) o.Expect(output).To(o.ContainSubstring("Successfully upgraded")) })
test case
openshift/openshift-tests-private
50aec5b3-1a4f-44e1-95ba-839da6cb5bfc
VMonly-ConnectedOnly-Author:jfan-High-44553-SDK support go type operator for http_proxy env [Slow]
['"context"', '"fmt"', '"os"', '"strings"', '"time"', '"github.com/openshift/openshift-tests-private/test/extended/util/architecture"', '"path/filepath"', '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/operatorsdk/operatorsdk.go
g.It("VMonly-ConnectedOnly-Author:jfan-High-44553-SDK support go type operator for http_proxy env [Slow]", func() { architecture.SkipNonAmd64SingleArch(oc) tmpBasePath := "/tmp/ocp-44553-" + getRandomString() tmpPath := filepath.Join(tmpBasePath, "memcached-operator-44553") err := os.MkdirAll(tmpPath, 0o755) o.Expect(err).NotTo(o.HaveOccurred()) defer os.RemoveAll(tmpBasePath) operatorsdkCLI.ExecCommandPath = tmpPath makeCLI.ExecCommandPath = tmpPath nsOperator := "memcached-operator-44553-system" imageTag := "quay.io/olmqe/memcached-operator:44553-" + getRandomString() dataPath := "test/extended/testdata/operatorsdk/ocp-44553-data/" crFilePath := filepath.Join(dataPath, "cache_v1_memcached44553.yaml") quayCLI := container.NewQuayCLI() exutil.By("step: clear unnecessary tokens") githubToken := os.Getenv("GITHUB_TOKEN") if githubToken != "" { defer os.Setenv("GITHUB_TOKEN", githubToken) os.Setenv("GITHUB_TOKEN", "") } defer quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1)) defer func() { oc.AsAdmin().WithoutNamespace().Run("delete").Args("-f", crFilePath, "-n", nsOperator).Output() exutil.By("step: undeploy") _, err = makeCLI.Run("undeploy").Args().Output() o.Expect(err).NotTo(o.HaveOccurred()) }() exutil.By("step: init Go Based Operator") output, err := operatorsdkCLI.Run("init").Args("--domain=httpproxy.com", "--repo=github.com/example-inc/memcached-operator", "--plugins=go/v4").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("create api")) exutil.By("step: Create API.") output, err = operatorsdkCLI.Run("create").Args("api", "--group=cache", "--version=v1", "--kind=Memcached44553", "--resource", "--controller").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("make manifests")) exutil.By("step: modify files to generate the quay.io/olmqe images.") // update the Dockerfile dockerFilePath := filepath.Join(tmpPath, "Dockerfile") replaceContent(dockerFilePath, "golang:", "quay.io/olmqe/golang:") // update the Makefile makefileFilePath := filepath.Join(tmpPath, "Makefile") replaceContent(makefileFilePath, "controller:latest", imageTag) replaceContent(makefileFilePath, "build config/default | kubectl apply -f -", "build config/default | CLUSTER_PROXY=$(shell kubectl get proxies.config.openshift.io cluster -o json | jq '.spec.httpProxy') envsubst | kubectl apply -f -") // copy config/manager/manager.yaml err = copy(filepath.Join(dataPath, "manager.yaml"), filepath.Join(tmpPath, "config", "manager", "manager.yaml")) o.Expect(err).NotTo(o.HaveOccurred()) // copy controllers/memcached44553_controller.go err = copy(filepath.Join(dataPath, "memcached44553_controller.go"), filepath.Join(tmpPath, "internal", "controller", "memcached44553_controller.go")) o.Expect(err).NotTo(o.HaveOccurred()) // copy api/v1/memcached44553_types.go err = copy(filepath.Join(dataPath, "memcached44553_types.go"), filepath.Join(tmpPath, "api", "v1", "memcached44553_types.go")) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("step: Build and push the operator image") tokenDir := "/tmp/ocp-44553" + getRandomString() err = os.MkdirAll(tokenDir, os.ModePerm) defer os.RemoveAll(tokenDir) if err != nil { e2e.Failf("fail to create the token folder:%s", tokenDir) } _, err = oc.AsAdmin().WithoutNamespace().Run("extract").Args("secret/pull-secret", "-n", "openshift-config", fmt.Sprintf("--to=%s", tokenDir), "--confirm").Output() if err != nil { e2e.Failf("Fail to get the cluster auth %v", err) } // replace the go.sum & go.mod err = copy(filepath.Join(dataPath, "44553gosum"), filepath.Join(tmpPath, "go.sum")) o.Expect(err).NotTo(o.HaveOccurred()) err = copy(filepath.Join(dataPath, "44553gomod"), filepath.Join(tmpPath, "go.mod")) o.Expect(err).NotTo(o.HaveOccurred()) podmanCLI := container.NewPodmanCLI() podmanCLI.ExecCommandPath = tmpPath output, err = podmanCLI.Run("build").Args(tmpPath, "--arch", "amd64", "--tag", imageTag, "--authfile", fmt.Sprintf("%s/.dockerconfigjson", tokenDir)).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("Successfully")) output, err = podmanCLI.Run("push").Args(imageTag).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("Writing manifest to image destination")) exutil.By("step: Deploy the operator") output, err = makeCLI.Run("deploy").Args("IMG=" + imageTag).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("deployment.apps/memcached-operator-44553-controller-manager")) waitErr := wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) { podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output() o.Expect(err).NotTo(o.HaveOccurred()) lines := strings.Split(podList, "\n") for _, line := range lines { if strings.Contains(line, "memcached-operator-44553-controller-manager") { e2e.Logf("found pod memcached-operator-44553-controller-manager") if strings.Contains(line, "2/2") { e2e.Logf("the status of pod memcached-operator-44553-controller-manager is Running") return true, nil } e2e.Logf("the status of pod memcached-operator-44553-controller-manager is not Running") return false, nil } } return false, nil }) if waitErr != nil { logDebugInfo(oc, nsOperator, "events", "pod") } exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("No memcached-operator-44553-controller-manager in project %s", nsOperator)) waitErr = wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) { msg, err := oc.AsAdmin().WithoutNamespace().Run("logs").Args("deployment.apps/memcached-operator-44553-controller-manager", "-c", "manager", "-n", nsOperator).Output() o.Expect(err).NotTo(o.HaveOccurred()) if strings.Contains(msg, "Starting workers") { e2e.Logf("Starting workers successfully") return true, nil } return false, nil }) exutil.AssertWaitPollNoErr(waitErr, "container manager doesn't work") exutil.By("step: Create the resource") _, err = oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", crFilePath, "-n", nsOperator).Output() o.Expect(err).NotTo(o.HaveOccurred()) waitErr = wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) { msg, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output() o.Expect(err).NotTo(o.HaveOccurred()) if strings.Contains(msg, "memcached44553-sample") { e2e.Logf("found pod memcached44553-sample") return true, nil } return false, nil }) if waitErr != nil { logDebugInfo(oc, nsOperator, "events", "pod") } exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("No memcached44553-sample in project %s", nsOperator)) waitErr = wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) { proxyMsg, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("proxies.config.openshift.io", "cluster", "-o=jsonpath={.spec.httpProxy}").Output() o.Expect(err).NotTo(o.HaveOccurred()) msg, err := oc.AsAdmin().WithoutNamespace().Run("describe").Args("deployment/memcached44553-sample", "-n", nsOperator).Output() o.Expect(err).NotTo(o.HaveOccurred()) if strings.Contains(msg, "HTTP_PROXY: "+proxyMsg) { e2e.Logf("deployment/memcached44553-sample is created successfully") return true, nil } return false, nil }) if waitErr != nil { logDebugInfo(oc, nsOperator, "events") } exutil.AssertWaitPollNoErr(waitErr, "the status of deployment/memcached44553-sample is wrong") })
test case
openshift/openshift-tests-private
6e342919-546d-41d0-b32a-aa1730a958ef
VMonly-ConnectedOnly-Author:jitli-High-51300-SDK Run bundle upgrade from bundle installation with multi bundles index image
['"context"', '"fmt"', '"strings"', '"time"', '"path/filepath"', '"k8s.io/apimachinery/pkg/util/wait"']
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/operatorsdk.go
g.It("VMonly-ConnectedOnly-Author:jitli-High-51300-SDK Run bundle upgrade from bundle installation with multi bundles index image", func() { exutil.SkipOnProxyCluster(oc) operatorsdkCLI.showInfo = true oc.SetupProject() var ( dr = make(describerResrouce) itName = g.CurrentSpecReport().FullText() buildPruningBaseDir = exutil.FixturePath("testdata", "olm") ogSingleTemplate = filepath.Join(buildPruningBaseDir, "operatorgroup.yaml") catsrcImageTemplate = filepath.Join(buildPruningBaseDir, "catalogsource-image.yaml") subTemplate = filepath.Join(buildPruningBaseDir, "olm-subscription.yaml") og = operatorGroupDescription{ name: "test-og-51300", namespace: oc.Namespace(), template: ogSingleTemplate, } catsrc = catalogSourceDescription{ name: "upgradefbc-index-51300", namespace: oc.Namespace(), displayName: "Test 51300 Operators", publisher: "OperatorSDK QE", sourceType: "grpc", address: "quay.io/olmqe/upgradefbcmuli-index:v0.1", interval: "15m", template: catsrcImageTemplate, } sub = subscriptionDescription{ subName: "upgradefbc-index-51300", namespace: oc.Namespace(), catalogSourceName: catsrc.name, catalogSourceNamespace: oc.Namespace(), channel: "alpha", ipApproval: "Automatic", operatorPackage: "upgradefbc", template: subTemplate, } ) dr.addIr(itName) exutil.By("Install the OperatorGroup") og.createwithCheck(oc, itName, dr) exutil.By("Create catalog source") catsrc.createWithCheck(oc, itName, dr) exutil.By("Install operator") sub.create(oc, itName, dr) exutil.By("Check Operator is Succeeded") newCheck("expect", asAdmin, withoutNamespace, compare, "Succeeded", ok, []string{"csv", sub.installedCSV, "-n", oc.Namespace(), "-o=jsonpath={.status.phase}"}).check(oc) exutil.By("Run bundle-upgrade operator") output, err := operatorsdkCLI.Run("run").Args("bundle-upgrade", "quay.io/olmqe/upgradefbc-bundle:v0.0.2", "-n", oc.Namespace(), "--timeout", "5m", "--security-context-config=restricted").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("Successfully upgraded to")) waitErr := wait.PollUntilContextTimeout(context.TODO(), 15*time.Second, 360*time.Second, false, func(ctx context.Context) (bool, error) { msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("csv", "upgradefbc.v0.0.2", "-n", oc.Namespace()).Output() if strings.Contains(msg, "Succeeded") { e2e.Logf("upgrade to 0.0.2 success") return true, nil } return false, nil }) exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("upgradefbc upgrade failed in %s ", oc.Namespace())) })
test case
openshift/openshift-tests-private
0ac5ae98-8f5e-46da-9e45-31dedc80af55
VMonly-ConnectedOnly-Author:jitli-High-50141-SDK Run bundle upgrade from OLM installed operator [Slow]
['"context"', '"fmt"', '"strings"', '"time"', '"path/filepath"', '"k8s.io/apimachinery/pkg/util/wait"']
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/operatorsdk.go
g.It("VMonly-ConnectedOnly-Author:jitli-High-50141-SDK Run bundle upgrade from OLM installed operator [Slow]", func() { exutil.SkipOnProxyCluster(oc) operatorsdkCLI.showInfo = true oc.SetupProject() var ( dr = make(describerResrouce) itName = g.CurrentSpecReport().FullText() buildPruningBaseDir = exutil.FixturePath("testdata", "olm") ogSingleTemplate = filepath.Join(buildPruningBaseDir, "operatorgroup.yaml") catsrcImageTemplate = filepath.Join(buildPruningBaseDir, "catalogsource-image.yaml") subTemplate = filepath.Join(buildPruningBaseDir, "olm-subscription.yaml") og = operatorGroupDescription{ name: "test-og-50141", namespace: oc.Namespace(), template: ogSingleTemplate, } catsrcfbc = catalogSourceDescription{ name: "upgradefbc-index-50141", namespace: oc.Namespace(), displayName: "Test 50141 Operators FBC", publisher: "OperatorSDK QE", sourceType: "grpc", address: "quay.io/olmqe/upgradefbc-index:v0.1", interval: "15m", template: catsrcImageTemplate, } subfbc = subscriptionDescription{ subName: "upgradefbc-index-50141", namespace: oc.Namespace(), catalogSourceName: catsrcfbc.name, catalogSourceNamespace: oc.Namespace(), channel: "alpha", ipApproval: "Automatic", operatorPackage: "upgradefbc", template: subTemplate, } catsrcsqlite = catalogSourceDescription{ name: "upgradeindex-sqlite-50141", namespace: oc.Namespace(), displayName: "Test 50141 Operators SQLite", publisher: "OperatorSDK QE", sourceType: "grpc", address: "quay.io/olmqe/upgradeindex-index:v0.1", interval: "15m", template: catsrcImageTemplate, } subsqlite = subscriptionDescription{ subName: "upgradesqlite-index-50141", namespace: oc.Namespace(), catalogSourceName: catsrcsqlite.name, catalogSourceNamespace: oc.Namespace(), channel: "alpha", ipApproval: "Automatic", operatorPackage: "upgradeindex", startingCSV: "upgradeindex.v0.0.1", template: subTemplate, } ) dr.addIr(itName) exutil.By("Install the OperatorGroup") og.createwithCheck(oc, itName, dr) exutil.By("Create catalog source") catsrcfbc.createWithCheck(oc, itName, dr) exutil.By("Install operator through OLM and the index iamge is kind of FBC") subfbc.create(oc, itName, dr) exutil.By("Check Operator is Succeeded") newCheck("expect", asAdmin, withoutNamespace, compare, "Succeeded", ok, []string{"csv", subfbc.installedCSV, "-n", oc.Namespace(), "-o=jsonpath={.status.phase}"}).check(oc) exutil.By("Run bundle-upgrade operator") output, err := operatorsdkCLI.Run("run").Args("bundle-upgrade", "quay.io/olmqe/upgradefbc-bundle:v0.0.2", "-n", oc.Namespace(), "--timeout", "5m", "--security-context-config=restricted").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("Successfully upgraded to")) waitErr := wait.PollUntilContextTimeout(context.TODO(), 15*time.Second, 360*time.Second, false, func(ctx context.Context) (bool, error) { msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("csv", "upgradefbc.v0.0.2", "-n", oc.Namespace()).Output() if strings.Contains(msg, "Succeeded") { e2e.Logf("upgrade to 0.0.2 success") return true, nil } return false, nil }) exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("upgradefbc upgrade failed in %s ", oc.Namespace())) exutil.By("Create catalog source") catsrcsqlite.createWithCheck(oc, itName, dr) exutil.By("Install operator through OLM and the index iamge is kind of SQLITE") subsqlite.createWithoutCheck(oc, itName, dr) exutil.By("Check Operator is Succeeded") subsqlite.findInstalledCSV(oc, itName, dr) newCheck("expect", asAdmin, withoutNamespace, compare, "Succeeded", ok, []string{"csv", subsqlite.installedCSV, "-n", oc.Namespace(), "-o=jsonpath={.status.phase}"}).check(oc) exutil.By("Run bundle-upgrade operator") output, err = operatorsdkCLI.Run("run").Args("bundle-upgrade", "quay.io/olmqe/upgradeindex-bundle:v0.2", "-n", oc.Namespace(), "--timeout", "5m", "--security-context-config=restricted").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("Successfully upgraded to")) waitErr = wait.PollUntilContextTimeout(context.TODO(), 15*time.Second, 360*time.Second, false, func(ctx context.Context) (bool, error) { msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("csv", "upgradeindex.v0.0.2", "-n", oc.Namespace()).Output() if strings.Contains(msg, "Succeeded") { e2e.Logf("upgrade to 0.0.2 success") return true, nil } return false, nil }) exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("upgradeindex upgrade failed in %s ", oc.Namespace())) })
test case
openshift/openshift-tests-private
16eea960-8696-4c3e-9d4b-8e34027f38d6
VMonly-DisconnectedOnly-Author:jitli-High-52571-Disconnected test for ansible type operator
['"context"', '"fmt"', '"os"', '"strings"', '"time"', '"github.com/openshift/openshift-tests-private/test/extended/util/architecture"', '"path/filepath"', '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/operatorsdk/operatorsdk.go
g.It("VMonly-DisconnectedOnly-Author:jitli-High-52571-Disconnected test for ansible type operator", func() { exutil.SkipOnProxyCluster(oc) clusterArchitecture := architecture.SkipNonAmd64SingleArch(oc) var ( buildPruningBaseDir = exutil.FixturePath("testdata", "operatorsdk") dataPath = filepath.Join(buildPruningBaseDir, "ocp-48885-data") tmpBasePath = "/tmp/ocp-52571-" + getRandomString() tmpPath = filepath.Join(tmpBasePath, "memcached-operator-52571") imageTag = "quay.io/olmqe/memcached-operator:52571-" + getRandomString() quayCLI = container.NewQuayCLI() bundleImage = "quay.io/olmqe/memcached-operator-bundle:52571-" + getRandomString() ) err := os.MkdirAll(tmpPath, 0o755) o.Expect(err).NotTo(o.HaveOccurred()) defer os.RemoveAll(tmpBasePath) operatorsdkCLI.ExecCommandPath = tmpPath makeCLI.ExecCommandPath = tmpPath defer quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1)) exutil.By("step: init Ansible Based Operator") output, err := operatorsdkCLI.Run("init").Args("--plugins=ansible", "--domain=disconnected.com").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("Next")) exutil.By("step: Create API.") output, err = operatorsdkCLI.Run("create").Args("api", "--group=test", "--version=v1", "--kind", "Memcached52571", "--generate-role").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("Writing kustomize manifests")) exutil.By("step: modify files to get the quay.io/olmqe images.") // copy task main.yml err = copy(filepath.Join(dataPath, "main.yml"), filepath.Join(tmpPath, "roles", "memcached52571", "tasks", "main.yml")) o.Expect(err).NotTo(o.HaveOccurred()) // copy manager.yaml err = copy(filepath.Join(dataPath, "manager.yaml"), filepath.Join(tmpPath, "config", "manager", "manager.yaml")) o.Expect(err).NotTo(o.HaveOccurred()) // update the Dockerfile dockerFile := filepath.Join(tmpPath, "Dockerfile") replaceContent(dockerFile, "registry.redhat.io/openshift4/ose-ansible-rhel9-operator:v"+ocpversion, "brew.registry.redhat.io/rh-osbs/openshift-ose-ansible-rhel9-operator:v"+ocpversion) replaceContent(dockerFile, "install -r ${HOME}/requirements.yml", "install -r ${HOME}/requirements.yml --force") exutil.By("step: Build and push the operator image") tokenDir := "/tmp/ocp-52571" + getRandomString() err = os.MkdirAll(tokenDir, os.ModePerm) defer os.RemoveAll(tokenDir) if err != nil { e2e.Failf("fail to create the token folder:%s", tokenDir) } _, err = oc.AsAdmin().WithoutNamespace().Run("extract").Args("secret/pull-secret", "-n", "openshift-config", fmt.Sprintf("--to=%s", tokenDir), "--confirm").Output() if err != nil { e2e.Failf("Fail to get the cluster auth %v", err) } // update the Makefile makefileFilePath := filepath.Join(tmpPath, "Makefile") replaceContent(makefileFilePath, "controller:latest", imageTag) replaceContent(makefileFilePath, "operator-sdk generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)", "operator-sdk generate bundle $(BUNDLE_GEN_FLAGS)") // copy manifests manifestsPath := filepath.Join(tmpPath, "config", "manifests", "bases") err = os.MkdirAll(manifestsPath, 0o755) o.Expect(err).NotTo(o.HaveOccurred()) manifestsFile := filepath.Join(manifestsPath, "memcached-operator-52571.clusterserviceversion.yaml") _, err = os.Create(manifestsFile) o.Expect(err).NotTo(o.HaveOccurred()) err = copy(filepath.Join(dataPath, "memcached-operator-52571.clusterserviceversion.yaml"), filepath.Join(manifestsFile)) o.Expect(err).NotTo(o.HaveOccurred()) buildPushOperatorImage(clusterArchitecture, tmpPath, imageTag, tokenDir) exutil.By("step: make bundle use image digests") waitErr := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 120*time.Second, false, func(ctx context.Context) (bool, error) { msg, err := makeCLI.Run("bundle").Args("USE_IMAGE_DIGESTS=true").Output() if err != nil { e2e.Logf("make bundle failed, try again") return false, nil } if strings.Contains(msg, "operator-sdk bundle validate ./bundle") { return true, nil } return false, nil }) exutil.AssertWaitPollNoErr(waitErr, "operator-sdk bundle generate failed") csvFile := filepath.Join(tmpPath, "bundle", "manifests", "memcached-operator-52571.clusterserviceversion.yaml") content := getContent(csvFile) if !strings.Contains(content, "quay.io/olmqe/memcached@sha256:") || !strings.Contains(content, "quay.io/olmqe/memcached-operator@sha256:") { e2e.Failf("Fail to get the image info with digest type") } exutil.By("step: build and push bundle image.") defer quayCLI.DeleteTag(strings.Replace(bundleImage, "quay.io/", "", 1)) _, err = makeCLI.Run("bundle-build").Args("BUNDLE_IMG=" + bundleImage).Output() o.Expect(err).NotTo(o.HaveOccurred()) podmanCLI := container.NewPodmanCLI() waitErr = wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 60*time.Second, false, func(ctx context.Context) (bool, error) { output, _ = podmanCLI.Run("push").Args(bundleImage).Output() if strings.Contains(output, "Writing manifest to image destination") { return true, nil } return false, nil }) exutil.AssertWaitPollNoErr(waitErr, "Podman push bundle image failed.") exutil.By("step: create new project") oc.SetupProject() ns := oc.Namespace() exutil.By("step: get digestID") bundleImageDigest, err := quayCLI.GetImageDigest(strings.Replace(bundleImage, "quay.io/", "", 1)) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(bundleImageDigest).NotTo(o.BeEmpty()) indexImage := "quay.io/olmqe/nginxolm-operator-index:v1" indexImageDigest, err := quayCLI.GetImageDigest(strings.Replace(indexImage, "quay.io/", "", 1)) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(indexImageDigest).NotTo(o.BeEmpty()) exutil.By("step: run bundle") defer func() { output, err = operatorsdkCLI.Run("cleanup").Args("memcached-operator-52571", "-n", ns).Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } }() output, err = operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/memcached-operator-bundle@"+bundleImageDigest, "--index-image", "quay.io/olmqe/nginxolm-operator-index@"+indexImageDigest, "-n", ns, "--timeout", "5m", "--security-context-config=restricted", "--decompression-image", "quay.io/olmqe/busybox@sha256:e39d9c8ac4963d0b00a5af08678757b44c35ea8eb6be0cdfbeb1282e7f7e6003").Output() if err != nil { logDebugInfo(oc, ns, "csv", "pod", "ip") } o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("OLM has successfully installed")) waitErr = wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 120*time.Second, false, func(ctx context.Context) (bool, error) { podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", ns).Output() o.Expect(err).NotTo(o.HaveOccurred()) lines := strings.Split(podList, "\n") for _, line := range lines { if strings.Contains(line, "memcached-operator-52571-controller-manager") { e2e.Logf("found pod memcached-operator-52571-controller-manager") if strings.Contains(line, "Running") { e2e.Logf("the status of pod memcached-operator-52571-controller-manager is Running") return true, nil } e2e.Logf("the status of pod memcached-operator-52571-controller-manager is not Running") return false, nil } } return false, nil }) if waitErr != nil { logDebugInfo(oc, ns, "pod", "csv", "catsrc") } output, err = oc.WithoutNamespace().AsAdmin().Run("get").Args("pods", "-o=jsonpath={.items[*].spec.containers[*].image}", "-n", ns).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("quay.io/olmqe/memcached-operator@sha256:")) exutil.By("step: Create CR") err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("policy", "add-scc-to-user", "anyuid", fmt.Sprintf("system:serviceaccount:%s:memcached52571-sample-nginx", ns)).Execute() o.Expect(err).NotTo(o.HaveOccurred()) crFilePath := filepath.Join(dataPath, "memcached-sample.yaml") defer func() { exutil.By("step: delete cr.") _, err := oc.AsAdmin().WithoutNamespace().Run("delete").Args("-f", crFilePath, "-n", ns).Output() o.Expect(err).NotTo(o.HaveOccurred()) }() _, err = oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", crFilePath, "-n", ns).Output() o.Expect(err).NotTo(o.HaveOccurred()) waitErr = wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 120*time.Second, false, func(ctx context.Context) (bool, error) { podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", ns).Output() o.Expect(err).NotTo(o.HaveOccurred()) lines := strings.Split(podList, "\n") for _, line := range lines { if strings.Contains(line, "memcached52571-sample") { e2e.Logf("found pod memcached52571-sample") if strings.Contains(line, "Running") { e2e.Logf("the status of pod memcached52571-sample is Running") return true, nil } e2e.Logf("the status of pod memcached52571-sample is not Running") return false, nil } } return false, nil }) if waitErr != nil { logDebugInfo(oc, ns, "Memcached52571", "pod", "events") } exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("No memcached52571-sample in project %s or the pod is not running", ns)) })
test case
openshift/openshift-tests-private
b705d6ab-1fc4-4167-9d0d-6a8b9fae2b6e
VMonly-DisconnectedOnly-Author:jitli-High-52572-Disconnected test for helm type operator
['"context"', '"fmt"', '"os"', '"strings"', '"time"', '"github.com/openshift/openshift-tests-private/test/extended/util/architecture"', '"path/filepath"', '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/operatorsdk/operatorsdk.go
g.It("VMonly-DisconnectedOnly-Author:jitli-High-52572-Disconnected test for helm type operator", func() { exutil.SkipOnProxyCluster(oc) clusterArchitecture := architecture.SkipArchitectures(oc, architecture.MULTI, architecture.PPC64LE, architecture.S390X) var ( buildPruningBaseDir = exutil.FixturePath("testdata", "operatorsdk") dataPath = filepath.Join(buildPruningBaseDir, "ocp-52813-data") tmpBasePath = "/tmp/ocp-52572-" + getRandomString() tmpPath = filepath.Join(tmpBasePath, "memcached-operator-52572") imageTag = "quay.io/olmqe/memcached-operator:52572-" + getRandomString() quayCLI = container.NewQuayCLI() bundleImage = "quay.io/olmqe/memcached-operator-bundle:52572-" + getRandomString() ) err := os.MkdirAll(tmpPath, 0o755) o.Expect(err).NotTo(o.HaveOccurred()) defer os.RemoveAll(tmpBasePath) operatorsdkCLI.ExecCommandPath = tmpPath makeCLI.ExecCommandPath = tmpPath defer quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1)) exutil.By("step: init Helm Based Operator") output, err := operatorsdkCLI.Run("init").Args("--plugins=helm", "--domain=disconnected.com", "--group=test", "--version=v1", "--kind=Nginx").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("Created helm-charts")) exutil.By("step: modify files to get the quay.io/olmqe images.") // copy watches.yaml err = copy(filepath.Join(dataPath, "watches.yaml"), filepath.Join(tmpPath, "watches.yaml")) o.Expect(err).NotTo(o.HaveOccurred()) // copy helm-charts/nginx/values.yaml err = copy(filepath.Join(dataPath, "values.yaml"), filepath.Join(tmpPath, "helm-charts", "nginx", "values.yaml")) o.Expect(err).NotTo(o.HaveOccurred()) // update the file helm-charts/nginx/templates/deployment.yaml deployFilepath := filepath.Join(tmpPath, "helm-charts", "nginx", "templates", "deployment.yaml") replaceContent(deployFilepath, ".Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion", ".Values.relatedImage") // update the Dockerfile dockerFile := filepath.Join(tmpPath, "Dockerfile") replaceContent(dockerFile, "registry.redhat.io/openshift4/ose-helm-rhel9-operator:v"+ocpversion, "brew.registry.redhat.io/rh-osbs/openshift-ose-helm-operator-rhel9:v"+ocpversion) // copy the manager err = copy(filepath.Join(dataPath, "manager.yaml"), filepath.Join(tmpPath, "config", "manager", "manager.yaml")) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("step: Build and push the operator image") tokenDir := "/tmp/ocp-52572" + getRandomString() err = os.MkdirAll(tokenDir, os.ModePerm) defer os.RemoveAll(tokenDir) if err != nil { e2e.Failf("fail to create the token folder:%s", tokenDir) } _, err = oc.AsAdmin().WithoutNamespace().Run("extract").Args("secret/pull-secret", "-n", "openshift-config", fmt.Sprintf("--to=%s", tokenDir), "--confirm").Output() if err != nil { e2e.Failf("Fail to get the cluster auth %v", err) } buildPushOperatorImage(clusterArchitecture, tmpPath, imageTag, tokenDir) // update the Makefile makefileFilePath := filepath.Join(tmpPath, "Makefile") replaceContent(makefileFilePath, "controller:latest", imageTag) replaceContent(makefileFilePath, "operator-sdk generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)", "operator-sdk generate bundle $(BUNDLE_GEN_FLAGS)") exutil.By("step: make bundle.") // copy manifests manifestsPath := filepath.Join(tmpPath, "config", "manifests", "bases") err = os.MkdirAll(manifestsPath, 0o755) o.Expect(err).NotTo(o.HaveOccurred()) manifestsFile := filepath.Join(manifestsPath, "memcached-operator-52572.clusterserviceversion.yaml") _, err = os.Create(manifestsFile) o.Expect(err).NotTo(o.HaveOccurred()) err = copy(filepath.Join(dataPath, "memcached-operator-52572.clusterserviceversion.yaml"), filepath.Join(manifestsFile)) o.Expect(err).NotTo(o.HaveOccurred()) // make bundle use image digests waitErr := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 120*time.Second, false, func(ctx context.Context) (bool, error) { msg, err := makeCLI.Run("bundle").Args("USE_IMAGE_DIGESTS=true").Output() if err != nil { e2e.Logf("make bundle failed, try again") return false, nil } if strings.Contains(msg, "operator-sdk bundle validate ./bundle") { return true, nil } return false, nil }) exutil.AssertWaitPollNoErr(waitErr, "operator-sdk bundle generate failed") csvFile := filepath.Join(tmpPath, "bundle", "manifests", "memcached-operator-52572.clusterserviceversion.yaml") content := getContent(csvFile) if !strings.Contains(content, "quay.io/olmqe/nginx@sha256:") || !strings.Contains(content, "quay.io/olmqe/memcached-operator@sha256:") { e2e.Failf("Fail to get the image info with digest type") } exutil.By("step: build and push bundle image.") defer quayCLI.DeleteTag(strings.Replace(bundleImage, "quay.io/", "", 1)) _, err = makeCLI.Run("bundle-build").Args("BUNDLE_IMG=" + bundleImage).Output() o.Expect(err).NotTo(o.HaveOccurred()) podmanCLI := container.NewPodmanCLI() waitErr = wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 60*time.Second, false, func(ctx context.Context) (bool, error) { output, _ = podmanCLI.Run("push").Args(bundleImage).Output() if strings.Contains(output, "Writing manifest to image destination") { return true, nil } return false, nil }) exutil.AssertWaitPollNoErr(waitErr, "Podman push bundle image failed.") exutil.By("step: create new project") oc.SetupProject() ns := oc.Namespace() exutil.By("step: get digestID") bundleImageDigest, err := quayCLI.GetImageDigest(strings.Replace(bundleImage, "quay.io/", "", 1)) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(bundleImageDigest).NotTo(o.BeEmpty()) indexImage := "quay.io/olmqe/nginxolm-operator-index:v1" indexImageDigest, err := quayCLI.GetImageDigest(strings.Replace(indexImage, "quay.io/", "", 1)) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(indexImageDigest).NotTo(o.BeEmpty()) exutil.By("step: run bundle") defer func() { output, err = operatorsdkCLI.Run("cleanup").Args("memcached-operator-52572", "-n", ns).Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } }() output, err = operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/memcached-operator-bundle@"+bundleImageDigest, "--index-image", "quay.io/olmqe/nginxolm-operator-index@"+indexImageDigest, "-n", ns, "--timeout", "5m", "--security-context-config=restricted", "--decompression-image", "quay.io/olmqe/busybox@sha256:e39d9c8ac4963d0b00a5af08678757b44c35ea8eb6be0cdfbeb1282e7f7e6003").Output() if err != nil { logDebugInfo(oc, ns, "csv", "pod", "ip") } o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("OLM has successfully installed")) waitErr = wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 120*time.Second, false, func(ctx context.Context) (bool, error) { podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", ns).Output() o.Expect(err).NotTo(o.HaveOccurred()) lines := strings.Split(podList, "\n") for _, line := range lines { if strings.Contains(line, "memcached-operator-52572-controller-manager") { e2e.Logf("found pod memcached-operator-52572-controller-manager") if strings.Contains(line, "Running") { e2e.Logf("the status of pod memcached-operator-52572-controller-manager is Running") return true, nil } e2e.Logf("the status of pod memcached-operator-52572-controller-manager is not Running") return false, nil } } return false, nil }) if waitErr != nil { logDebugInfo(oc, ns, "pod", "csv", "catsrc") } output, err = oc.WithoutNamespace().AsAdmin().Run("get").Args("pods", "-o=jsonpath={.items[*].spec.containers[*].image}", "-n", ns).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("quay.io/olmqe/memcached-operator@sha256:")) exutil.By("step: Create CR") err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("policy", "add-scc-to-user", "anyuid", fmt.Sprintf("system:serviceaccount:%s:memcached52572-sample-nginx", ns)).Execute() o.Expect(err).NotTo(o.HaveOccurred()) crFilePath := filepath.Join(dataPath, "memcached-sample.yaml") defer func() { exutil.By("step: delete cr.") _, err := oc.AsAdmin().WithoutNamespace().Run("delete").Args("-f", crFilePath, "-n", ns).Output() o.Expect(err).NotTo(o.HaveOccurred()) }() _, err = oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", crFilePath, "-n", ns).Output() o.Expect(err).NotTo(o.HaveOccurred()) waitErr = wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) { podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", ns).Output() o.Expect(err).NotTo(o.HaveOccurred()) lines := strings.Split(podList, "\n") for _, line := range lines { if strings.Contains(line, "memcached52572-sample") { e2e.Logf("found pod memcached52572-sample") if strings.Contains(line, "Running") { e2e.Logf("the status of pod memcached52572-sample is Running") return true, nil } e2e.Logf("the status of pod memcached52572-sample is not Running") return false, nil } } return false, nil }) if waitErr != nil { logDebugInfo(oc, ns, "Memcached52572", "pod", "events") } exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("No memcached52572-sample in project %s or the pod is not running", ns)) })
test case
openshift/openshift-tests-private
a32a350f-88ca-44f5-a2d3-51fe06a8484b
VMonly-DisconnectedOnly-Author:jitli-High-52305-Disconnected test for go type operator [Slow]
['"context"', '"fmt"', '"os"', '"os/exec"', '"strings"', '"time"', '"github.com/openshift/openshift-tests-private/test/extended/util/architecture"', '"path/filepath"', '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/operatorsdk/operatorsdk.go
g.It("VMonly-DisconnectedOnly-Author:jitli-High-52305-Disconnected test for go type operator [Slow]", func() { exutil.SkipOnProxyCluster(oc) clusterArchitecture := architecture.SkipArchitectures(oc, architecture.MULTI, architecture.PPC64LE, architecture.S390X) var ( buildPruningBaseDir = exutil.FixturePath("testdata", "operatorsdk") dataPath = filepath.Join(buildPruningBaseDir, "ocp-52814-data") tmpBasePath = "/tmp/ocp-52305-" + getRandomString() tmpPath = filepath.Join(tmpBasePath, "memcached-operator-52814") imageTag = "quay.io/olmqe/memcached-operator:52305-" + getRandomString() quayCLI = container.NewQuayCLI() bundleImage = "quay.io/olmqe/memcached-operator-bundle:52305-" + getRandomString() ) err := os.MkdirAll(tmpPath, 0o755) o.Expect(err).NotTo(o.HaveOccurred()) defer os.RemoveAll(tmpBasePath) operatorsdkCLI.ExecCommandPath = tmpPath makeCLI.ExecCommandPath = tmpPath defer quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1)) exutil.By("step: init Go Based Operator") output, err := operatorsdkCLI.Run("init").Args("--domain=disconnected.com", "--repo=github.com/example-inc/memcached-operator").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("Next")) exutil.By("step: create api") output, err = operatorsdkCLI.Run("create").Args("api", "--group=test", "--version=v1", "--kind=Memcached52814", "--controller", "--resource").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("make manifests")) exutil.By("step: modify files to get the quay.io/olmqe images.") // copy api/v1/memcached52814_types.go err = copy(filepath.Join(dataPath, "memcached52814_types.go"), filepath.Join(tmpPath, "api", "v1", "memcached52814_types.go")) o.Expect(err).NotTo(o.HaveOccurred()) // copy internal/controller/memcached52814_controller.go err = copy(filepath.Join(dataPath, "memcached52814_controller.go"), filepath.Join(tmpPath, "internal", "controller", "memcached52814_controller.go")) o.Expect(err).NotTo(o.HaveOccurred()) // copy the manager err = copy(filepath.Join(dataPath, "manager.yaml"), filepath.Join(tmpPath, "config", "manager", "manager.yaml")) o.Expect(err).NotTo(o.HaveOccurred()) // update the Dockerfile dockerfileFilePath := filepath.Join(tmpPath, "Dockerfile") replaceContent(dockerfileFilePath, "golang", "quay.io/olmqe/golang") exutil.By("step: Build and push the operator image") tokenDir := "/tmp/ocp-52305" + getRandomString() err = os.MkdirAll(tokenDir, os.ModePerm) defer os.RemoveAll(tokenDir) if err != nil { e2e.Failf("fail to create the token folder:%s", tokenDir) } _, err = oc.AsAdmin().WithoutNamespace().Run("extract").Args("secret/pull-secret", "-n", "openshift-config", fmt.Sprintf("--to=%s", tokenDir), "--confirm").Output() if err != nil { e2e.Failf("Fail to get the cluster auth %v", err) } buildPushOperatorImage(clusterArchitecture, tmpPath, imageTag, tokenDir) // update the Makefile makefileFilePath := filepath.Join(tmpPath, "Makefile") replaceContent(makefileFilePath, "controller:latest", imageTag) exutil.By("step: Install kustomize") kustomizePath := "/root/kustomize" binPath := filepath.Join(tmpPath, "bin") exec.Command("bash", "-c", fmt.Sprintf("cp %s %s", kustomizePath, binPath)).Output() exutil.By("step: make bundle.") // copy manifests manifestsPath := filepath.Join(tmpPath, "config", "manifests", "bases") err = os.MkdirAll(manifestsPath, 0o755) o.Expect(err).NotTo(o.HaveOccurred()) manifestsFile := filepath.Join(manifestsPath, "memcached-operator-52814.clusterserviceversion.yaml") _, err = os.Create(manifestsFile) o.Expect(err).NotTo(o.HaveOccurred()) err = copy(filepath.Join(dataPath, "memcached-operator-52814.clusterserviceversion.yaml"), filepath.Join(manifestsFile)) o.Expect(err).NotTo(o.HaveOccurred()) // make bundle use image digests waitErr := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 120*time.Second, false, func(ctx context.Context) (bool, error) { msg, err := makeCLI.Run("bundle").Args("USE_IMAGE_DIGESTS=true").Output() if err != nil { e2e.Logf("make bundle failed, try again") return false, nil } if strings.Contains(msg, "operator-sdk bundle validate ./bundle") { return true, nil } return false, nil }) exutil.AssertWaitPollNoErr(waitErr, "operator-sdk bundle generate failed") csvFile := filepath.Join(tmpPath, "bundle", "manifests", "memcached-operator-52814.clusterserviceversion.yaml") content := getContent(csvFile) if !strings.Contains(content, "quay.io/olmqe/memcached@sha256:") || !strings.Contains(content, "quay.io/olmqe/memcached-operator@sha256:") { e2e.Failf("Fail to get the image info with digest type") } exutil.By("step: build and push bundle image.") defer quayCLI.DeleteTag(strings.Replace(bundleImage, "quay.io/", "", 1)) _, err = makeCLI.Run("bundle-build").Args("BUNDLE_IMG=" + bundleImage).Output() o.Expect(err).NotTo(o.HaveOccurred()) podmanCLI := container.NewPodmanCLI() waitErr = wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 60*time.Second, false, func(ctx context.Context) (bool, error) { output, _ = podmanCLI.Run("push").Args(bundleImage).Output() if strings.Contains(output, "Writing manifest to image destination") { return true, nil } return false, nil }) exutil.AssertWaitPollNoErr(waitErr, "Podman push bundle image failed.") exutil.By("step: create new project") oc.SetupProject() ns := oc.Namespace() exutil.By("step: get digestID") bundleImageDigest, err := quayCLI.GetImageDigest(strings.Replace(bundleImage, "quay.io/", "", 1)) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(bundleImageDigest).NotTo(o.BeEmpty()) indexImage := "quay.io/olmqe/nginxolm-operator-index:v1" indexImageDigest, err := quayCLI.GetImageDigest(strings.Replace(indexImage, "quay.io/", "", 1)) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(indexImageDigest).NotTo(o.BeEmpty()) exutil.By("step: run bundle") defer func() { output, err = operatorsdkCLI.Run("cleanup").Args("memcached-operator-52814", "-n", ns).Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } }() output, err = operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/memcached-operator-bundle@"+bundleImageDigest, "--index-image", "quay.io/olmqe/nginxolm-operator-index@"+indexImageDigest, "-n", ns, "--timeout", "5m", "--security-context-config=restricted", "--decompression-image", "quay.io/olmqe/busybox@sha256:e39d9c8ac4963d0b00a5af08678757b44c35ea8eb6be0cdfbeb1282e7f7e6003").Output() if err != nil { logDebugInfo(oc, ns, "csv", "pod", "ip") } o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("OLM has successfully installed")) waitErr = wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 120*time.Second, false, func(ctx context.Context) (bool, error) { podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", ns).Output() o.Expect(err).NotTo(o.HaveOccurred()) lines := strings.Split(podList, "\n") for _, line := range lines { if strings.Contains(line, "memcached-operator-52814-controller-manager") { e2e.Logf("found pod memcached-operator-52814-controller-manager") if strings.Contains(line, "Running") { e2e.Logf("the status of pod memcached-operator-52814-controller-manager is Running") return true, nil } e2e.Logf("the status of pod memcached-operator-52814-controller-manager is not Running") return false, nil } } return false, nil }) if waitErr != nil { logDebugInfo(oc, ns, "pod", "csv", "catsrc") } output, err = oc.WithoutNamespace().AsAdmin().Run("get").Args("pods", "-o=jsonpath={.items[*].spec.containers[*].image}", "-n", ns).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("quay.io/olmqe/memcached-operator@sha256:")) exutil.By("step: Create CR") err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("policy", "add-scc-to-user", "anyuid", fmt.Sprintf("system:serviceaccount:%s:memcached52305-sample", ns)).Execute() o.Expect(err).NotTo(o.HaveOccurred()) crFilePath := filepath.Join(dataPath, "memcached-sample.yaml") defer func() { exutil.By("step: delete cr.") _, err := oc.AsAdmin().WithoutNamespace().Run("delete").Args("-f", crFilePath, "-n", ns).Output() o.Expect(err).NotTo(o.HaveOccurred()) }() _, err = oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", crFilePath, "-n", ns).Output() o.Expect(err).NotTo(o.HaveOccurred()) waitErr = wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 120*time.Second, false, func(ctx context.Context) (bool, error) { podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", ns).Output() o.Expect(err).NotTo(o.HaveOccurred()) lines := strings.Split(podList, "\n") for _, line := range lines { if strings.Contains(line, "memcached52305-sample") { e2e.Logf("found pod memcached52305-sample") if strings.Contains(line, "Running") { e2e.Logf("the status of pod memcached52305-sample is Running") return true, nil } e2e.Logf("the status of pod memcached52305-sample is not Running") return false, nil } } return false, nil }) if waitErr != nil { logDebugInfo(oc, ns, "Memcached52814", "pod", "events") } exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("No memcached52305-sample in project %s or the pod is not running", ns)) })
test case
openshift/openshift-tests-private
3bb54f72-ce21-4bd5-95b6-1ea0ea1db549
VMonly-ConnectedOnly-Author:jfan-High-45141-High-41497-High-34292-High-29374-High-28157-High-27977-ansible k8sevent k8sstatus maxConcurrentReconciles modules to a collect blacklist [Slow]
['"context"', '"fmt"', '"os"', '"os/exec"', '"strings"', '"time"', '"github.com/openshift/openshift-tests-private/test/extended/util/architecture"', '"path/filepath"', '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/operatorsdk/operatorsdk.go
g.It("VMonly-ConnectedOnly-Author:jfan-High-45141-High-41497-High-34292-High-29374-High-28157-High-27977-ansible k8sevent k8sstatus maxConcurrentReconciles modules to a collect blacklist [Slow]", func() { clusterArchitecture := architecture.SkipNonAmd64SingleArch(oc) // test data buildPruningBaseDir := exutil.FixturePath("testdata", "operatorsdk") dataPath := filepath.Join(buildPruningBaseDir, "ocp-27977-data") crFilePath := filepath.Join(dataPath, "ansiblebase_v1_basetest.yaml") // exec dir tmpBasePath := "/tmp/ocp-27977-" + getRandomString() tmpPath := filepath.Join(tmpBasePath, "ansibletest") operatorsdkCLI.ExecCommandPath = tmpPath makeCLI.ExecCommandPath = tmpPath // exec ns & image tag nsOperator := "ansibletest-system" imageTag := "quay.io/olmqe/ansibletest:" + ocpversion + "-" + getRandomString() // cleanup the test data err := os.MkdirAll(tmpPath, 0o755) o.Expect(err).NotTo(o.HaveOccurred()) defer os.RemoveAll(tmpBasePath) quayCLI := container.NewQuayCLI() defer quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1)) defer func() { _, err = oc.AsAdmin().WithoutNamespace().Run("delete").Args("-f", crFilePath, "-n", nsOperator).Output() exutil.By("step: undeploy") _, err = makeCLI.Run("undeploy").Args().Output() o.Expect(err).NotTo(o.HaveOccurred()) }() exutil.By("step: init Ansible Based Operator") output, err := operatorsdkCLI.Run("init").Args("--plugins=ansible", "--domain", "qetest.com").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("Next")) exutil.By("step: Create API.") output, err = operatorsdkCLI.Run("create").Args("api", "--group", "ansiblebase", "--version", "v1", "--kind", "Basetest", "--generate-role").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("Writing kustomize manifests")) exutil.By("step: modify files to get the quay.io/olmqe images.") // copy task main.yml err = copy(filepath.Join(dataPath, "main.yml"), filepath.Join(tmpPath, "roles", "basetest", "tasks", "main.yml")) o.Expect(err).NotTo(o.HaveOccurred()) // copy Dockerfile dockerfileFilePath := filepath.Join(dataPath, "Dockerfile") err = copy(dockerfileFilePath, filepath.Join(tmpPath, "Dockerfile")) o.Expect(err).NotTo(o.HaveOccurred()) replaceContent(filepath.Join(tmpPath, "Dockerfile"), "brew.registry.redhat.io/rh-osbs/openshift-ose-ansible-operator:vocpversion", "brew.registry.redhat.io/rh-osbs/openshift-ose-ansible-rhel9-operator:v"+ocpversion) // copy manager.yaml err = copy(filepath.Join(dataPath, "manager.yaml"), filepath.Join(tmpPath, "config", "manager", "manager.yaml")) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("step: Build and push the operator image") tokenDir := "/tmp/ocp-27977" + getRandomString() err = os.MkdirAll(tokenDir, os.ModePerm) defer os.RemoveAll(tokenDir) if err != nil { e2e.Failf("fail to create the token folder:%s", tokenDir) } _, err = oc.AsAdmin().WithoutNamespace().Run("extract").Args("secret/pull-secret", "-n", "openshift-config", fmt.Sprintf("--to=%s", tokenDir), "--confirm").Output() if err != nil { e2e.Failf("Fail to get the cluster auth %v", err) } buildPushOperatorImage(clusterArchitecture, tmpPath, imageTag, tokenDir) exutil.By("step: Install the CRD") output, err = makeCLI.Run("install").Args().Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("basetests.ansiblebase.qetest.com")) exutil.By("step: Deploy the operator") output, err = makeCLI.Run("deploy").Args("IMG=" + imageTag).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("deployment.apps/ansibletest-controller-manager")) waitErr := wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 300*time.Second, false, func(ctx context.Context) (bool, error) { podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output() o.Expect(err).NotTo(o.HaveOccurred()) lines := strings.Split(podList, "\n") for _, line := range lines { if strings.Contains(line, "ansibletest-controller-manager") { e2e.Logf("found pod ansibletest-controller-manager") if strings.Contains(line, "2/2") { e2e.Logf("the status of pod ansibletest-controller-manager is Running") return true, nil } e2e.Logf("the status of pod ansibletest-controller-manager is not Running") return false, nil } } return false, nil }) if waitErr != nil { logDebugInfo(oc, nsOperator, "events", "pod") } exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("No ansibletest-controller-manager in project %s", nsOperator)) msg, err := oc.AsAdmin().WithoutNamespace().Run("logs").Args("deployment.apps/ansibletest-controller-manager", "-c", "manager", "-n", nsOperator).Output() o.Expect(err).NotTo(o.HaveOccurred()) if !strings.Contains(msg, "Starting workers") { e2e.Failf("Starting workers failed") } // OCP-34292 waitErr = wait.PollUntilContextTimeout(context.TODO(), 5*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) { msg, _ := oc.AsAdmin().WithoutNamespace().Run("logs").Args("deploy/ansibletest-controller-manager", "-c", "manager", "-n", nsOperator).Output() if strings.Contains(msg, "\"worker count\":1") { e2e.Logf("found worker count:1") return true, nil } return false, nil }) exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("log of deploy/ansibletest-controller-manager of %s doesn't have worker count:4", nsOperator)) // add the admin policy err = oc.AsAdmin().Run("adm").Args("policy", "add-cluster-role-to-user", "cluster-admin", "system:serviceaccount:"+nsOperator+":ansibletest-controller-manager").Execute() o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("step: Create the resource") _, err = oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", crFilePath, "-n", nsOperator).Output() o.Expect(err).NotTo(o.HaveOccurred()) waitErr = wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 300*time.Second, false, func(ctx context.Context) (bool, error) { msg, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output() o.Expect(err).NotTo(o.HaveOccurred()) if strings.Contains(msg, "basetest-sample") { e2e.Logf("found pod basetest-sample") return true, nil } return false, nil }) if waitErr != nil { logDebugInfo(oc, nsOperator, "events", "pod") } exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("No basetest-sample in project %s", nsOperator)) // OCP-27977 waitErr = wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) { msg, err = oc.AsAdmin().WithoutNamespace().Run("describe").Args("deployment/basetest-sample", "-n", nsOperator).Output() o.Expect(err).NotTo(o.HaveOccurred()) if strings.Contains(msg, "2 desired | 2 updated | 2 total | 2 available | 0 unavailable") { e2e.Logf("deployment/basetest-sample is created successfully") return true, nil } return false, nil }) if waitErr != nil { logDebugInfo(oc, nsOperator, "events") } exutil.AssertWaitPollNoErr(waitErr, "the status of deployment/basetest-sample is wrong") // OCP-45141 waitErr = wait.PollUntilContextTimeout(context.TODO(), 5*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) { msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("event", "-n", nsOperator).Output() if strings.Contains(msg, "test-reason") { e2e.Logf("k8s_event test") return true, nil } return false, nil }) exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("can't get k8s event test-name in %s", nsOperator)) // OCP-41497 waitErr = wait.PollUntilContextTimeout(context.TODO(), 5*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) { msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("basetest.ansiblebase.qetest.com/basetest-sample", "-n", nsOperator, "-o", "yaml").Output() if strings.Contains(msg, "hello world") { e2e.Logf("k8s_status test hello world") return true, nil } return false, nil }) exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("can't get basetest-sample hello world in %s", nsOperator)) // OCP-29374 waitErr = wait.PollUntilContextTimeout(context.TODO(), 5*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) { msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("secret", "-n", nsOperator).Output() if strings.Contains(msg, "test-secret") { e2e.Logf("found secret test-secret") return true, nil } return false, nil }) exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("doesn't get secret test-secret %s", nsOperator)) msg, err = oc.AsAdmin().WithoutNamespace().Run("describe").Args("secret", "test-secret", "-n", nsOperator).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(msg).To(o.ContainSubstring("test: 6 bytes")) // OCP-28157 waitErr = wait.PollUntilContextTimeout(context.TODO(), 5*time.Second, 300*time.Second, false, func(ctx context.Context) (bool, error) { msg, _ := oc.AsAdmin().WithoutNamespace().Run("describe").Args("configmap", "test-blacklist-watches", "-n", nsOperator).Output() if strings.Contains(msg, "afdasdfsajsafj") { e2e.Logf("Skipping the blacklist") return true, nil } return false, nil }) exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("log of deploy/ansibletest-controller-manager of %s doesn't work the blacklist", nsOperator)) })
test case
openshift/openshift-tests-private
75fee0a5-a015-4522-9828-41a98d666886
VMonly-ConnectedOnly-Author:jfan-High-28586-ansible Content Collections Support in watches.yaml
['"context"', '"fmt"', '"os"', '"os/exec"', '"strings"', '"time"', '"github.com/openshift/openshift-tests-private/test/extended/util/architecture"', '"path/filepath"', '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/operatorsdk/operatorsdk.go
g.It("VMonly-ConnectedOnly-Author:jfan-High-28586-ansible Content Collections Support in watches.yaml", func() { clusterArchitecture := architecture.SkipNonAmd64SingleArch(oc) // test data buildPruningBaseDir := exutil.FixturePath("testdata", "operatorsdk") dataPath := filepath.Join(buildPruningBaseDir, "ocp-28586-data") crFilePath := filepath.Join(dataPath, "cache5_v1_collectiontest.yaml") // exec dir tmpBasePath := "/tmp/ocp-28586-" + getRandomString() tmpPath := filepath.Join(tmpBasePath, "contentcollections") operatorsdkCLI.ExecCommandPath = tmpPath makeCLI.ExecCommandPath = tmpPath // exec ns & image tag nsOperator := "contentcollections-system" imageTag := "quay.io/olmqe/contentcollections:" + ocpversion + "-" + getRandomString() // cleanup the test data err := os.MkdirAll(tmpPath, 0o755) o.Expect(err).NotTo(o.HaveOccurred()) defer os.RemoveAll(tmpBasePath) quayCLI := container.NewQuayCLI() defer quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1)) defer func() { _, err = oc.AsAdmin().WithoutNamespace().Run("delete").Args("-f", crFilePath, "-n", nsOperator).Output() exutil.By("step: undeploy") _, err = makeCLI.Run("undeploy").Args().Output() o.Expect(err).NotTo(o.HaveOccurred()) }() exutil.By("step: init Ansible Based Operator") output, err := operatorsdkCLI.Run("init").Args("--plugins=ansible", "--domain", "cotentcollect.com").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("Next")) exutil.By("step: Create API.") output, err = operatorsdkCLI.Run("create").Args("api", "--group", "cache5", "--version", "v1", "--kind", "CollectionTest", "--generate-role").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("Writing kustomize manifests")) exutil.By("step: modify files to get the quay.io/olmqe images.") // mkdir fixture_collection collectionFilePath := filepath.Join(tmpPath, "fixture_collection", "roles", "dummy", "tasks") err = os.MkdirAll(collectionFilePath, 0o755) o.Expect(err).NotTo(o.HaveOccurred()) // copy galaxy.yml & main.yml err = copy(filepath.Join(dataPath, "galaxy.yml"), filepath.Join(tmpPath, "fixture_collection", "galaxy.yml")) o.Expect(err).NotTo(o.HaveOccurred()) err = copy(filepath.Join(dataPath, "main.yml"), filepath.Join(collectionFilePath, "main.yml")) o.Expect(err).NotTo(o.HaveOccurred()) // copy Dockerfile dockerfileFilePath := filepath.Join(dataPath, "Dockerfile") err = copy(dockerfileFilePath, filepath.Join(tmpPath, "Dockerfile")) o.Expect(err).NotTo(o.HaveOccurred()) replaceContent(filepath.Join(tmpPath, "Dockerfile"), "brew.registry.redhat.io/rh-osbs/openshift-ose-ansible-operator:vocpversion", "brew.registry.redhat.io/rh-osbs/openshift-ose-ansible-rhel9-operator:v"+ocpversion) // copy the watches.yaml err = copy(filepath.Join(dataPath, "watches.yaml"), filepath.Join(tmpPath, "watches.yaml")) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("step: Build and push the operator image") tokenDir := "/tmp/ocp-28586" + getRandomString() err = os.MkdirAll(tokenDir, os.ModePerm) defer os.RemoveAll(tokenDir) if err != nil { e2e.Failf("fail to create the token folder:%s", tokenDir) } _, err = oc.AsAdmin().WithoutNamespace().Run("extract").Args("secret/pull-secret", "-n", "openshift-config", fmt.Sprintf("--to=%s", tokenDir), "--confirm").Output() if err != nil { e2e.Failf("Fail to get the cluster auth %v", err) } buildPushOperatorImage(clusterArchitecture, tmpPath, imageTag, tokenDir) exutil.By("step: Install the CRD") output, err = makeCLI.Run("install").Args().Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("collectiontests.cache5.cotentcollect.com")) exutil.By("step: Deploy the operator") output, err = makeCLI.Run("deploy").Args("IMG=" + imageTag).Output() o.Expect(output).To(o.ContainSubstring("deployment.apps/contentcollections-controller-manager")) waitErr := wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 240*time.Second, false, func(ctx context.Context) (bool, error) { podMsg, _ := oc.AsAdmin().WithoutNamespace().Run("describe").Args("pods", "-n", nsOperator).Output() if !strings.Contains(podMsg, "Started container manager") { e2e.Logf("Started container manager failed") logDebugInfo(oc, nsOperator, "events", "pod") return false, nil } return true, nil }) if waitErr != nil { logDebugInfo(oc, nsOperator, "events", "pod") } waitErr = wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 240*time.Second, false, func(ctx context.Context) (bool, error) { msg, _ := oc.AsAdmin().WithoutNamespace().Run("logs").Args("deployment.apps/contentcollections-controller-manager", "-c", "manager", "-n", nsOperator).Output() if !strings.Contains(msg, "Starting workers") { e2e.Logf("Starting workers failed") return false, nil } return true, nil }) if waitErr != nil { logDebugInfo(oc, nsOperator, "events", "pod") } exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("No contentcollections-controller-manager in project %s", nsOperator)) exutil.By("step: Create the resource") msg, err := oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", crFilePath, "-n", nsOperator).Output() o.Expect(err).NotTo(o.HaveOccurred()) if !strings.Contains(msg, "collectiontest-sample created") { e2e.Failf("collectiontest-sample created failed") } // check the dummy task waitErr = wait.PollUntilContextTimeout(context.TODO(), 15*time.Second, 360*time.Second, false, func(ctx context.Context) (bool, error) { msg, _ := oc.AsAdmin().WithoutNamespace().Run("logs").Args("deploy/contentcollections-controller-manager", "-c", "manager", "-n", nsOperator).Output() if strings.Contains(msg, "dummy : Create ConfigMap") { e2e.Logf("found dummy : Create ConfigMap") return true, nil } return false, nil }) exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("miss log dummy : Create ConfigMap in %s", nsOperator)) })
test case
openshift/openshift-tests-private
7584ad0b-bf2b-4f76-b282-24c20e0b3313
VMonly-ConnectedOnly-Author:jfan-High-48366-add ansible prometheus metrics
['"context"', '"fmt"', '"os"', '"os/exec"', '"strings"', '"time"', '"github.com/openshift/openshift-tests-private/test/extended/util/architecture"', '"path/filepath"', '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/operatorsdk/operatorsdk.go
g.It("VMonly-ConnectedOnly-Author:jfan-High-48366-add ansible prometheus metrics", func() { clusterArchitecture := architecture.SkipNonAmd64SingleArch(oc) // test data buildPruningBaseDir := exutil.FixturePath("testdata", "operatorsdk") dataPath := filepath.Join(buildPruningBaseDir, "ocp-48366-data") crFilePath := filepath.Join(dataPath, "metrics_v1_testmetrics.yaml") // exec dir tmpBasePath := "/tmp/ocp-48366-" + getRandomString() tmpPath := filepath.Join(tmpBasePath, "ansiblemetrics") operatorsdkCLI.ExecCommandPath = tmpPath makeCLI.ExecCommandPath = tmpPath // exec ns & image tag nsOperator := "ansiblemetrics-system" imageTag := "quay.io/olmqe/testmetrics:" + ocpversion + "-" + getRandomString() // cleanup the test data err := os.MkdirAll(tmpPath, 0o755) o.Expect(err).NotTo(o.HaveOccurred()) defer os.RemoveAll(tmpBasePath) quayCLI := container.NewQuayCLI() defer quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1)) defer func() { _, err = oc.AsAdmin().WithoutNamespace().Run("delete").Args("-f", crFilePath, "-n", nsOperator).Output() exutil.By("step: undeploy") _, err = makeCLI.Run("undeploy").Args().Output() o.Expect(err).NotTo(o.HaveOccurred()) }() exutil.By("step: init Ansible metrics Operator") output, err := operatorsdkCLI.Run("init").Args("--plugins=ansible", "--domain", "testmetrics.com").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("Next")) exutil.By("step: Create API.") output, err = operatorsdkCLI.Run("create").Args("api", "--group", "metrics", "--version", "v1", "--kind", "Testmetrics", "--generate-role").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("Writing kustomize manifests")) exutil.By("step: modify files to get the quay.io/olmqe images.") // copy Dockerfile dockerfileFilePath := filepath.Join(tmpPath, "Dockerfile") err = copy(filepath.Join(dataPath, "Dockerfile"), dockerfileFilePath) o.Expect(err).NotTo(o.HaveOccurred()) replaceContent(dockerfileFilePath, "brew.registry.redhat.io/rh-osbs/openshift-ose-ansible-operator:vocpversion", "brew.registry.redhat.io/rh-osbs/openshift-ose-ansible-rhel9-operator:v"+ocpversion) // copy the roles/testmetrics/tasks/main.yml err = copy(filepath.Join(dataPath, "main.yml"), filepath.Join(tmpPath, "roles", "testmetrics", "tasks", "main.yml")) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("step: Build and push the operator image") tokenDir := "/tmp/ocp-48366" + getRandomString() err = os.MkdirAll(tokenDir, os.ModePerm) defer os.RemoveAll(tokenDir) if err != nil { e2e.Failf("fail to create the token folder:%s", tokenDir) } _, err = oc.AsAdmin().WithoutNamespace().Run("extract").Args("secret/pull-secret", "-n", "openshift-config", fmt.Sprintf("--to=%s", tokenDir), "--confirm").Output() if err != nil { e2e.Failf("Fail to get the cluster auth %v", err) } buildPushOperatorImage(clusterArchitecture, tmpPath, imageTag, tokenDir) exutil.By("step: Install the CRD") output, err = makeCLI.Run("install").Args().Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("metrics")) exutil.By("step: Deploy the operator") output, err = makeCLI.Run("deploy").Args("IMG=" + imageTag).Output() o.Expect(output).To(o.ContainSubstring("deployment.apps/ansiblemetrics-controller-manager")) waitErr := wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 300*time.Second, false, func(ctx context.Context) (bool, error) { podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output() o.Expect(err).NotTo(o.HaveOccurred()) lines := strings.Split(podList, "\n") for _, line := range lines { if strings.Contains(line, "ansiblemetrics-controller-manager") { if strings.Contains(line, "2/2") { e2e.Logf("the status of pod ansiblemetrics-controller-manager is Running") return true, nil } e2e.Logf("the status of pod ansiblemetrics-controller-manager is not Running") return false, nil } } return false, nil }) if waitErr != nil { logDebugInfo(oc, nsOperator, "events", "pod") } waitErr = wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 300*time.Second, false, func(ctx context.Context) (bool, error) { msg, _ := oc.AsAdmin().WithoutNamespace().Run("logs").Args("deployment.apps/ansiblemetrics-controller-manager", "-c", "manager", "-n", nsOperator).Output() if !strings.Contains(msg, "Starting workers") { e2e.Logf("Starting workers failed") return false, nil } return true, nil }) if waitErr != nil { logDebugInfo(oc, nsOperator, "events", "pod") } exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("No ansiblemetrics-controller-manager in project %s", nsOperator)) exutil.By("step: Create the resource") err = oc.AsAdmin().WithoutNamespace().Run("create").Args("-f", crFilePath, "-n", nsOperator).Execute() o.Expect(err).NotTo(o.HaveOccurred()) waitErr = wait.PollUntilContextTimeout(context.TODO(), 15*time.Second, 360*time.Second, false, func(ctx context.Context) (bool, error) { msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output() if strings.Contains(msg, "metrics-sample") { e2e.Logf("metrics created success") return true, nil } return false, nil }) exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("can't get metrics samples in %s", nsOperator)) metricsToken, _ := exutil.GetSAToken(oc) o.Expect(metricsToken).NotTo(o.BeEmpty()) promeEp, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("ep", "ansiblemetrics-controller-manager-metrics-service", "-o=jsonpath={.subsets[0].addresses[0].ip}", "-n", nsOperator).Output() o.Expect(err).NotTo(o.HaveOccurred()) metricsMsg, err := exec.Command("bash", "-c", "oc exec deployment/ansiblemetrics-controller-manager -n "+nsOperator+" -- curl -k -H \"Authorization: Bearer "+metricsToken+"\" 'https://["+promeEp+"]:8443/metrics'").Output() //Depending on the environment, the IP address may sometimes switch between ipv4 and ipv6. if err != nil { metricsMsg, err = exec.Command("bash", "-c", "oc exec deployment/ansiblemetrics-controller-manager -n "+nsOperator+" -- curl -k -H \"Authorization: Bearer "+metricsToken+"\" 'https://"+promeEp+":8443/metrics'").Output() o.Expect(err).NotTo(o.HaveOccurred()) } var strMetricsMsg string strMetricsMsg = string(metricsMsg) if !strings.Contains(strMetricsMsg, "my gague and set it to 2") { e2e.Logf("%s", strMetricsMsg) e2e.Failf("my gague and set it to 2 failed") } if !strings.Contains(strMetricsMsg, "counter") { e2e.Logf("%s", strMetricsMsg) e2e.Failf("counter failed") } if !strings.Contains(strMetricsMsg, "Observe my histogram") { e2e.Logf("%s", strMetricsMsg) e2e.Failf("Observe my histogram failed") } if !strings.Contains(strMetricsMsg, "Observe my summary") { e2e.Logf("%s", strMetricsMsg) e2e.Failf("Observe my summary failed") } })
test case
openshift/openshift-tests-private
042a4c70-6e13-4c1f-a4db-aa4481454185
VMonly-ConnectedOnly-Author:jfan-Medium-48359-SDK init plugin about hybird helm operator [Slow]
['"context"', '"fmt"', '"os"', '"strings"', '"time"', '"github.com/openshift/openshift-tests-private/test/extended/util/architecture"', '"path/filepath"', '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/operatorsdk/operatorsdk.go
g.It("VMonly-ConnectedOnly-Author:jfan-Medium-48359-SDK init plugin about hybird helm operator [Slow]", func() { g.Skip("OperatorSDK Hybrid Helm plugin unavailable and no plan to fix it, so skip it") clusterArchitecture := architecture.SkipNonAmd64SingleArch(oc) tmpBasePath := "/tmp/ocp-48359-" + getRandomString() tmpPath := filepath.Join(tmpBasePath, "memcached-operator-48359") err := os.MkdirAll(tmpPath, 0o755) o.Expect(err).NotTo(o.HaveOccurred()) defer os.RemoveAll(tmpBasePath) operatorsdkCLI.ExecCommandPath = tmpPath makeCLI.ExecCommandPath = tmpPath nsOperator := "memcached-operator-48359-system" imageTag := "quay.io/olmqe/memcached-operator:48359-" + getRandomString() dataPath := "test/extended/testdata/operatorsdk/ocp-48359-data/" crFilePath := filepath.Join(dataPath, "cache6_v1_memcachedbackup.yaml") quayCLI := container.NewQuayCLI() defer quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1)) defer func() { oc.AsAdmin().WithoutNamespace().Run("delete").Args("-f", crFilePath, "-n", nsOperator).Output() exutil.By("step: undeploy") _, err = makeCLI.Run("undeploy").Args().Output() o.Expect(err).NotTo(o.HaveOccurred()) }() exutil.By("step: init Helm Based Operator") output, err := operatorsdkCLI.Run("init").Args("--plugins=hybrid.helm.sdk.operatorframework.io", "--domain=hybird.com", "--project-version=3", "--repo=github.com/example/memcached-operator").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("go mod tidy")) exutil.By("step: create the apis") // Create helm api output, err = operatorsdkCLI.Run("create").Args("api", "--plugins=helm.sdk.operatorframework.io/v1", "--group=cache6", "--version=v1", "--kind=Memcached").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("Created helm-charts")) // Create go api output, err = operatorsdkCLI.Run("create").Args("api", "--group=cache6", "--version=v1", "--kind=MemcachedBackup", "--resource", "--controller", "--plugins=go/v4").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("make manifests")) exutil.By("step: modify files to generate the operator image.") // update the Dockerfile dockerFilePath := filepath.Join(tmpPath, "Dockerfile") replaceContent(dockerFilePath, "golang:", "quay.io/olmqe/golang:") replaceContent(dockerFilePath, "COPY controllers/ controllers/", "COPY internal/controller/ internal/controller/") replaceContent(dockerFilePath, "RUN GOOS=linux GOARCH=amd64 go build -a -o manager cmd/main.go", "RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go") // update the Makefile makefileFilePath := filepath.Join(tmpPath, "Makefile") replaceContent(makefileFilePath, "controller:latest", imageTag) // copy memcachedbackup_types.go err = copy(filepath.Join(dataPath, "memcachedbackup_types.go"), filepath.Join(tmpPath, "api", "v1", "memcachedbackup_types.go")) o.Expect(err).NotTo(o.HaveOccurred()) // copy memcachedbackup_controller.go ./controllers/memcachedbackup_controller.go err = copy(filepath.Join(dataPath, "memcachedbackup_controller.go"), filepath.Join(tmpPath, "internal", "controller", "memcachedbackup_controller.go")) o.Expect(err).NotTo(o.HaveOccurred()) // copy kubmize exutil.By("step: Install kustomize") kustomizePath := "/root/kustomize" binPath := filepath.Join(tmpPath, "bin", "kustomize") err = copy(filepath.Join(kustomizePath), filepath.Join(binPath)) o.Expect(err).NotTo(o.HaveOccurred()) // chmod 644 watches.yaml err = os.Chmod(filepath.Join(tmpPath, "watches.yaml"), 0o644) exutil.By("step: Build and push the operator image") tokenDir := "/tmp/ocp-48359" + getRandomString() err = os.MkdirAll(tokenDir, os.ModePerm) defer os.RemoveAll(tokenDir) if err != nil { e2e.Failf("fail to create the token folder:%s", tokenDir) } _, err = oc.AsAdmin().WithoutNamespace().Run("extract").Args("secret/pull-secret", "-n", "openshift-config", fmt.Sprintf("--to=%s", tokenDir), "--confirm").Output() if err != nil { e2e.Failf("Fail to get the cluster auth %v", err) } buildPushOperatorImage(clusterArchitecture, tmpPath, imageTag, tokenDir) exutil.By("step: Deploy the operator") output, err = makeCLI.Run("deploy").Args("IMG=" + imageTag).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("deployment.apps/memcached-operator-48359-controller-manager")) waitErr := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) { podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output() o.Expect(err).NotTo(o.HaveOccurred()) lines := strings.Split(podList, "\n") for _, line := range lines { if strings.Contains(line, "memcached-operator-48359-controller-manager") { e2e.Logf("found pod memcached-operator-48359-controller-manager") if strings.Contains(line, "2/2") { e2e.Logf("the status of pod memcached-operator-48359-controller-manager is Running") return true, nil } e2e.Logf("the status of pod memcached-operator-48359-controller-manager is not Running") return false, nil } } return false, nil }) if waitErr != nil { logDebugInfo(oc, nsOperator, "events", "pod") } exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("No memcached-operator-48359-controller-manager in project %s", nsOperator)) waitErr = wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) { msg, err := oc.AsAdmin().WithoutNamespace().Run("logs").Args("deployment.apps/memcached-operator-48359-controller-manager", "-c", "manager", "-n", nsOperator).Output() o.Expect(err).NotTo(o.HaveOccurred()) if strings.Contains(msg, "Starting workers") { e2e.Logf("Starting workers successfully") return true, nil } return false, nil }) exutil.AssertWaitPollNoErr(waitErr, "container manager doesn't work") if waitErr != nil { logDebugInfo(oc, nsOperator, "events", "pod") } exutil.By("step: Create the resource") _, err = oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", crFilePath, "-n", nsOperator).Output() o.Expect(err).NotTo(o.HaveOccurred()) waitErr = wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) { msg, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output() o.Expect(err).NotTo(o.HaveOccurred()) if strings.Contains(msg, "memcachedbackup-sample") { e2e.Logf("found pod memcachedbackup-sample") return true, nil } return false, nil }) if waitErr != nil { logDebugInfo(oc, nsOperator, "events", "pod") } exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("hybird test: No memcachedbackup-sample in project %s", nsOperator)) })
test case
openshift/openshift-tests-private
3b993bb4-3675-4298-b6ee-e9d0143a3af5
VMonly-ConnectedOnly-Author:jitli-High-40964-migrate packagemanifest to bundle
['"context"', '"os"', '"strings"', '"github.com/openshift/openshift-tests-private/test/extended/util/architecture"', '"path/filepath"', 'container "github.com/openshift/openshift-tests-private/test/extended/util/container"']
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/operatorsdk.go
g.It("VMonly-ConnectedOnly-Author:jitli-High-40964-migrate packagemanifest to bundle", func() { exutil.SkipOnProxyCluster(oc) architecture.SkipNonAmd64SingleArch(oc) var ( tmpBasePath = "/tmp/ocp-40964-" + getRandomString() pacakagemanifestsPath = exutil.FixturePath("testdata", "operatorsdk", "ocp-40964-data", "manifests", "etcd") quayCLI = container.NewQuayCLI() containerCLI = container.NewPodmanCLI() bundleImage = "quay.io/olmqe/etcd-operatorsdk:0.9.4" bundleImageTag = "quay.io/olmqe/etcd-operatorsdk:0.9.4-" + getRandomString() ) oc.SetupProject() operatorsdkCLI.showInfo = true defer os.RemoveAll(tmpBasePath) err := os.MkdirAll(tmpBasePath, 0o755) o.Expect(err).NotTo(o.HaveOccurred()) operatorsdkCLI.ExecCommandPath = tmpBasePath exutil.By("transfer the packagemanifest to bundle dir") output, err := operatorsdkCLI.Run("pkgman-to-bundle").Args(pacakagemanifestsPath, "--output-dir=test-40964-bundle").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("Bundle metadata generated successfully")) bundleDir := filepath.Join(tmpBasePath, "test-40964-bundle", "bundle-0.9.4", "bundle") if _, err := os.Stat(bundleDir); os.IsNotExist(err) { e2e.Failf("bundle dir not found") } exutil.By("generate the bundle image") output, err = operatorsdkCLI.Run("pkgman-to-bundle").Args(pacakagemanifestsPath, "--image-tag-base", "quay.io/olmqe/etcd-operatorsdk", "--output-dir=test-40964-bundle-image").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("Successfully built image quay.io/olmqe/etcd-operatorsdk:0.9.4")) exutil.By("run the generated bundle") defer quayCLI.DeleteTag(strings.Replace(bundleImageTag, "quay.io/", "", 1)) defer containerCLI.RemoveImage(bundleImage) if output, err := containerCLI.Run("tag").Args(bundleImage, bundleImageTag).Output(); err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } if output, err = containerCLI.Run("push").Args(bundleImageTag).Output(); err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } defer func() { output, err := operatorsdkCLI.Run("cleanup").Args("etcd", "-n", oc.Namespace()).Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } }() output, _ = operatorsdkCLI.Run("run").Args("bundle", bundleImageTag, "-n", oc.Namespace(), "--timeout", "5m", "--security-context-config=restricted").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("OLM has successfully installed")) })
test case
openshift/openshift-tests-private
c399cef5-25bb-458b-98f4-9b4023e60e06
VMonly-Author:jitli-Critical-49884-Add support for external bundle validators
['"context"', '"os"', '"time"', '"path/filepath"', '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/operatorsdk/operatorsdk.go
g.It("VMonly-Author:jitli-Critical-49884-Add support for external bundle validators", func() { tmpPath := "/tmp/ocp-49884-" + getRandomString() err := os.MkdirAll(tmpPath, 0o755) o.Expect(err).NotTo(o.HaveOccurred()) defer os.RemoveAll(tmpPath) tmpBasePath := exutil.FixturePath("testdata", "operatorsdk", "ocp-49960-data") exutil.By("Get the external bundle validator from container image") podmanCLI := container.NewPodmanCLI() podmanCLI.ExecCommandPath = tmpPath podmanOutput, err := podmanCLI.Run("run").Args("--rm", "-v", tmpPath+":/tmp:z", "quay.io/openshifttest/validator-poc:v1", "cp", "/opt/validator-poc", "/tmp/validator-poc").Output() if err != nil { e2e.Logf(string(podmanOutput)) e2e.Failf("Fail to get the validator-poc from container image %v", err) } exvalidator := filepath.Join(tmpPath, "validator-poc") waitErr := wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 30*time.Second, false, func(ctx context.Context) (bool, error) { if _, err := os.Stat(exvalidator); os.IsNotExist(err) { e2e.Logf("get validator-poc Failed") return false, nil } return true, nil }) exutil.AssertWaitPollNoErr(waitErr, "get validator-poc Failed") err = os.Chmod(exvalidator, os.FileMode(0o755)) o.Expect(err).NotTo(o.HaveOccurred()) updatedFileInfo, err := os.Stat(exvalidator) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(updatedFileInfo.Mode().Perm()).To(o.Equal(os.FileMode(0o755)), "File permissions not set correctly") exutil.By("bundle validate with external validater") output, _ := operatorsdkCLI.Run("bundle").Args("validate", tmpBasePath+"/bundle", "--alpha-select-external", exvalidator).Output() o.Expect(output).To(o.ContainSubstring("csv.Spec.Icon elements should contain both data and mediatype")) exutil.By("bundle validate with 2 external validater") output, _ = operatorsdkCLI.Run("bundle").Args("validate", tmpBasePath+"/bundle", "--alpha-select-external", exvalidator+":"+exvalidator).Output() o.Expect(output).To(o.ContainSubstring("csv.Spec.Icon elements should contain both data and mediatype")) })
test case
openshift/openshift-tests-private
38eaaa15-262b-441a-b068-4390b1f6b1ea
VMonly-ConnectedOnly-Author:jitli-Critical-59885-Run bundle on different security level namespaces [Serial]
['"context"', '"strings"']
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/operatorsdk.go
g.It("VMonly-ConnectedOnly-Author:jitli-Critical-59885-Run bundle on different security level namespaces [Serial]", func() { exutil.SkipOnProxyCluster(oc) operatorsdkCLI.showInfo = true oc.SetupProject() defer func() { output, err := operatorsdkCLI.Run("cleanup").Args("upgradeoperator", "-n", oc.Namespace()).Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } }() exutil.By("Run bundle without options --security-context-config=restricted") output, _ := operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/upgradeoperator-bundle:v0.1", "-n", oc.Namespace(), "--timeout", "5m").Output() if strings.Contains(output, "violates PodSecurity") { e2e.Logf("violates PodSecurity, need add label to decrease namespace safety factor") output, err := operatorsdkCLI.Run("cleanup").Args("upgradeoperator", "-n", oc.Namespace()).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("uninstalled")) exutil.By("Add label to decrease namespace safety factor") _, err = oc.AsAdmin().WithoutNamespace().Run("label").Args("ns", oc.Namespace(), "security.openshift.io/scc.podSecurityLabelSync=false", "pod-security.kubernetes.io/enforce=privileged", "pod-security.kubernetes.io/audit=privileged", "pod-security.kubernetes.io/warn=privileged", "--overwrite").Output() o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("Run bundle without options --security-context-config=restricted again") output, _ = operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/upgradeoperator-bundle:v0.1", "-n", oc.Namespace(), "--timeout", "5m").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("OLM has successfully installed")) } else { o.Expect(output).To(o.ContainSubstring("OLM has successfully installed")) } })
test case
openshift/openshift-tests-private
7547e442-c011-420b-9798-6ce3e35283b1
ConnectedOnly-VMonly-Author:jitli-High-69005-helm operator recoilne the different namespaces
['"context"', '"fmt"', '"os"', '"os/exec"', '"strings"', '"time"', '"github.com/openshift/openshift-tests-private/test/extended/util/architecture"', '"path/filepath"', '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/operatorsdk/operatorsdk.go
g.It("ConnectedOnly-VMonly-Author:jitli-High-69005-helm operator recoilne the different namespaces", func() { clusterArchitecture := architecture.SkipArchitectures(oc, architecture.MULTI, architecture.PPC64LE, architecture.S390X) imageTag := "quay.io/olmqe/nginx-operator-base:v" + ocpversion + "-69005" + getRandomString() nsSystem := "system-69005-" + getRandomString() nsOperator := "nginx-operator-69005-system" tmpBasePath := "/tmp/ocp-69005-" + getRandomString() tmpPath := filepath.Join(tmpBasePath, "nginx-operator-69005") err := os.MkdirAll(tmpPath, 0o755) o.Expect(err).NotTo(o.HaveOccurred()) defer os.RemoveAll(tmpBasePath) operatorsdkCLI.ExecCommandPath = tmpPath makeCLI.ExecCommandPath = tmpPath defer func() { quayCLI := container.NewQuayCLI() quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1)) }() exutil.By("init Helm Based Operators") output, err := operatorsdkCLI.Run("init").Args("--plugins=helm").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("Next: define a resource with")) exutil.By("Create API.") output, err = operatorsdkCLI.Run("create").Args("api", "--group", "demo", "--version", "v1", "--kind", "Nginx69005").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("nginx")) if !upstream { dockerFile := filepath.Join(tmpPath, "Dockerfile") content := getContent(dockerFile) o.Expect(content).To(o.ContainSubstring("registry.redhat.io/openshift4/ose-helm-rhel9-operator:v" + ocpversion)) replaceContent(dockerFile, "registry.redhat.io/openshift4/ose-helm-rhel9-operator:v"+ocpversion, "brew.registry.redhat.io/rh-osbs/openshift-ose-helm-operator-rhel9:v"+ocpversion) } exutil.By("modify namespace") exec.Command("bash", "-c", fmt.Sprintf("sed -i 's/name: system/name: %s/g' `grep -rl \"name: system\" %s`", nsSystem, tmpPath)).Output() exec.Command("bash", "-c", fmt.Sprintf("sed -i 's/namespace: system/namespace: %s/g' `grep -rl \"namespace: system\" %s`", nsSystem, tmpPath)).Output() exec.Command("bash", "-c", fmt.Sprintf("sed -i 's/namespace: nginx-operator-69005-system/namespace: %s/g' `grep -rl \"namespace: nginx-operator-system\" %s`", nsOperator, tmpPath)).Output() exutil.By("build and Push the operator image") tokenDir := "/tmp/ocp-69005" + getRandomString() err = os.MkdirAll(tokenDir, os.ModePerm) defer os.RemoveAll(tokenDir) if err != nil { e2e.Failf("fail to create the token folder:%s", tokenDir) } _, err = oc.AsAdmin().WithoutNamespace().Run("extract").Args("secret/pull-secret", "-n", "openshift-config", fmt.Sprintf("--to=%s", tokenDir), "--confirm").Output() if err != nil { e2e.Failf("Fail to get the cluster auth %v", err) } buildPushOperatorImage(clusterArchitecture, tmpPath, imageTag, tokenDir) defer func() { exutil.By("run make undeploy") _, err = makeCLI.Run("undeploy").Args().Output() o.Expect(err).NotTo(o.HaveOccurred()) }() exutil.By("Edit manager.yaml to add the multiple namespaces") managerFilePath := filepath.Join(tmpPath, "config", "manager", "manager.yaml") replaceContent(managerFilePath, "name: manager", "name: manager\n env:\n - name: \"WATCH_NAMESPACE\"\n value: default,nginx-operator-69005-system") exutil.By("Deploy the operator") output, err = makeCLI.Run("deploy").Args("IMG=" + imageTag).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("deployment.apps/nginx-operator-69005-controller-manager created")) waitErr := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) { podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output() o.Expect(err).NotTo(o.HaveOccurred()) lines := strings.Split(podList, "\n") for _, line := range lines { if strings.Contains(line, "nginx-operator-69005-controller-manager") { e2e.Logf("found pod nginx-operator-69005-controller-manager") if strings.Contains(line, "Running") { e2e.Logf("the status of pod nginx-operator-69005-controller-manager is Running") return true, nil } e2e.Logf("the status of pod nginx-operator-69005-controller-manager is not Running") return false, nil } } return false, nil }) if err != nil { logDebugInfo(oc, nsOperator, "events", "pod") } exutil.AssertWaitPollNoErr(waitErr, "No nginx-operator-69005-controller-manager") exutil.By("Check the namespaces watching") podName, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator, "-o=jsonpath={.items..metadata.name}").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(podName).NotTo(o.BeEmpty()) podLogs, err := oc.AsAdmin().WithoutNamespace().Run("logs").Args(podName, "-n", nsOperator, "--limit-bytes", "50000").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(podLogs).To(o.ContainSubstring(`"msg":"Watching namespaces","namespaces":["default","nginx-operator-69005-system"]`)) exutil.By("run make undeploy") _, err = makeCLI.Run("undeploy").Args().Output() o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("Edit manager.yaml to add the single namespaces") managerFilePath = filepath.Join(tmpPath, "config", "manager", "manager.yaml") replaceContent(managerFilePath, "default,nginx-operator-69005-system", "nginx-operator-69005-system") exutil.By("Deploy the operator") output, err = makeCLI.Run("deploy").Args("IMG=" + imageTag).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("deployment.apps/nginx-operator-69005-controller-manager created")) waitErr = wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) { podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output() o.Expect(err).NotTo(o.HaveOccurred()) lines := strings.Split(podList, "\n") for _, line := range lines { if strings.Contains(line, "nginx-operator-69005-controller-manager") { e2e.Logf("found pod nginx-operator-69005-controller-manager") if strings.Contains(line, "Running") { e2e.Logf("the status of pod nginx-operator-69005-controller-manager is Running") return true, nil } e2e.Logf("the status of pod nginx-operator-69005-controller-manager is not Running") return false, nil } } return false, nil }) if err != nil { logDebugInfo(oc, nsOperator, "events", "pod") } exutil.AssertWaitPollNoErr(waitErr, "No nginx-operator-69005-controller-manager") exutil.By("Check the namespaces watching") podName, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator, "-o=jsonpath={.items..metadata.name}").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(podName).NotTo(o.BeEmpty()) podLogs, err = oc.AsAdmin().WithoutNamespace().Run("logs").Args(podName, "-n", nsOperator, "--limit-bytes", "50000").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(podLogs).To(o.ContainSubstring(`"msg":"Watching namespaces","namespaces":["nginx-operator-69005-system"]`)) })
test case
openshift/openshift-tests-private
913e29e7-4224-4497-9869-426df3b1feb7
VMonly-ConnectedOnly-Author:jitli-Medium-69118-Run bundle init image choosable [Serial]
['"context"']
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/operatorsdk.go
g.It("VMonly-ConnectedOnly-Author:jitli-Medium-69118-Run bundle init image choosable [Serial]", func() { exutil.SkipOnProxyCluster(oc) operatorsdkCLI.showInfo = true oc.SetupProject() defer func() { output, err := operatorsdkCLI.Run("cleanup").Args("upgradeoperator", "-n", oc.Namespace()).Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } }() exutil.By("Run bundle") output, err := operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/upgradeoperator-bundle:v0.1", "-n", oc.Namespace(), "--timeout", "5m", "--security-context-config=restricted").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("OLM has successfully installed")) exutil.By("Check the default init image") output, err = oc.WithoutNamespace().AsAdmin().Run("get").Args("pod", "quay-io-olmqe-upgradeoperator-bundle-v0-1", "-o=jsonpath={.spec.initContainers[*].image}", "-n", oc.Namespace()).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("registry.access.redhat.com/ubi9/ubi:9.4")) output, err = operatorsdkCLI.Run("cleanup").Args("upgradeoperator", "-n", oc.Namespace()).Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } exutil.By("Customize the initialization image to run the bundle") output, err = operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/upgradeoperator-bundle:v0.1", "-n", oc.Namespace(), "--timeout", "5m", "--security-context-config=restricted", "--decompression-image", "quay.io/olmqe/busybox:latest").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("OLM has successfully installed")) exutil.By("Check the custom init image") output, err = oc.WithoutNamespace().AsAdmin().Run("get").Args("pod", "quay-io-olmqe-upgradeoperator-bundle-v0-1", "-o=jsonpath={.spec.initContainers[*].image}", "-n", oc.Namespace()).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("quay.io/olmqe/busybox:latest")) })
file
openshift/openshift-tests-private
72303ca9-10b7-4e44-bd01-0c2cd69b4b2d
client
import ( "bytes" "fmt" "io" "math/rand" "os" "os/exec" "path/filepath" "runtime/debug" "strings" "time" g "github.com/onsi/ginkgo/v2" e2e "k8s.io/kubernetes/test/e2e/framework" )
github.com/openshift/openshift-tests-private/test/extended/opm/client.go
package opm import ( "bytes" "fmt" "io" "math/rand" "os" "os/exec" "path/filepath" "runtime/debug" "strings" "time" g "github.com/onsi/ginkgo/v2" e2e "k8s.io/kubernetes/test/e2e/framework" ) // CLI provides function to call the CLI type CLI struct { execPath string ExecCommandPath string verb string username string globalArgs []string commandArgs []string finalArgs []string stdin *bytes.Buffer stdout io.Writer stderr io.Writer verbose bool showInfo bool skipTLS bool podmanAuthfile string } // NewOpmCLI initialize the OPM framework func NewOpmCLI() *CLI { client := &CLI{} client.username = "admin" client.execPath = "opm" client.showInfo = true return client } func NewInitializer() *CLI { client := &CLI{} client.username = "admin" client.execPath = "initializer" client.showInfo = true return client } // Run executes given command verb func (c *CLI) Run(commands ...string) *CLI { in, out, errout := &bytes.Buffer{}, &bytes.Buffer{}, &bytes.Buffer{} client := &CLI{ execPath: c.execPath, verb: commands[0], username: c.username, ExecCommandPath: c.ExecCommandPath, podmanAuthfile: c.podmanAuthfile, } if c.skipTLS { client.globalArgs = append([]string{"--skip-tls=true"}, commands...) } else { client.globalArgs = commands } client.stdin, client.stdout, client.stderr = in, out, errout return client.setOutput(c.stdout) } // setOutput allows to override the default command output func (c *CLI) setOutput(out io.Writer) *CLI { c.stdout = out return c } // Args sets the additional arguments for the OpenShift CLI command func (c *CLI) Args(args ...string) *CLI { c.commandArgs = args c.finalArgs = append(c.globalArgs, c.commandArgs...) return c } func (c *CLI) printCmd() string { return strings.Join(c.finalArgs, " ") } // ExitError returns the error info type ExitError struct { Cmd string StdErr string *exec.ExitError } // FatalErr exits the test in case a fatal error has occurred. func FatalErr(msg interface{}) { // the path that leads to this being called isn't always clear... fmt.Fprintln(g.GinkgoWriter, string(debug.Stack())) e2e.Failf("%v", msg) } func (c *CLI) SetAuthFile(authfile string) *CLI { c.podmanAuthfile = authfile return c } // Output executes the command and returns stdout/stderr combined into one string func (c *CLI) Output() (string, error) { if c.verbose { e2e.Logf("DEBUG: %s %s\n", c.execPath, c.printCmd()) } cmd := exec.Command(c.execPath, c.finalArgs...) if c.podmanAuthfile != "" { cmd.Env = append(os.Environ(), "REGISTRY_AUTH_FILE="+c.podmanAuthfile) } if c.ExecCommandPath != "" { e2e.Logf("set exec command path is %s\n", c.ExecCommandPath) cmd.Dir = c.ExecCommandPath } cmd.Stdin = c.stdin if c.showInfo { e2e.Logf("Running '%s %s'", c.execPath, strings.Join(c.finalArgs, " ")) } out, err := cmd.CombinedOutput() trimmed := strings.TrimSpace(string(out)) switch err.(type) { case nil: c.stdout = bytes.NewBuffer(out) return trimmed, nil case *exec.ExitError: e2e.Logf("Error running %v:\n%s", cmd, trimmed) return trimmed, &ExitError{ExitError: err.(*exec.ExitError), Cmd: c.execPath + " " + strings.Join(c.finalArgs, " "), StdErr: trimmed} default: FatalErr(fmt.Errorf("unable to execute %q: %v", c.execPath, err)) // unreachable code return "", nil } } 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 } else { return GetDirPath(filepath.Dir(dir), filePre) } } 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 } else { 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 } } 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) }
package opm
function
openshift/openshift-tests-private
5df1e232-928b-4166-83b3-679ea6646b96
NewOpmCLI
['CLI']
github.com/openshift/openshift-tests-private/test/extended/opm/client.go
func NewOpmCLI() *CLI { client := &CLI{} client.username = "admin" client.execPath = "opm" client.showInfo = true return client }
opm
function
openshift/openshift-tests-private
6f7fe914-3327-49c7-82c7-0caa626db2c8
NewInitializer
['CLI']
github.com/openshift/openshift-tests-private/test/extended/opm/client.go
func NewInitializer() *CLI { client := &CLI{} client.username = "admin" client.execPath = "initializer" client.showInfo = true return client }
opm
function
openshift/openshift-tests-private
56b77498-6a31-4725-b7f4-75aa2abefed7
Run
['"bytes"']
['CLI']
github.com/openshift/openshift-tests-private/test/extended/opm/client.go
func (c *CLI) Run(commands ...string) *CLI { in, out, errout := &bytes.Buffer{}, &bytes.Buffer{}, &bytes.Buffer{} client := &CLI{ execPath: c.execPath, verb: commands[0], username: c.username, ExecCommandPath: c.ExecCommandPath, podmanAuthfile: c.podmanAuthfile, } if c.skipTLS { client.globalArgs = append([]string{"--skip-tls=true"}, commands...) } else { client.globalArgs = commands } client.stdin, client.stdout, client.stderr = in, out, errout return client.setOutput(c.stdout) }
opm
function
openshift/openshift-tests-private
8da62279-179f-41e6-bf66-27becd4f312c
setOutput
['"io"']
['CLI']
github.com/openshift/openshift-tests-private/test/extended/opm/client.go
func (c *CLI) setOutput(out io.Writer) *CLI { c.stdout = out return c }
opm
function
openshift/openshift-tests-private
e2b535e1-417d-434f-b504-0ccfa98dca12
Args
['CLI']
github.com/openshift/openshift-tests-private/test/extended/opm/client.go
func (c *CLI) Args(args ...string) *CLI { c.commandArgs = args c.finalArgs = append(c.globalArgs, c.commandArgs...) return c }
opm
function
openshift/openshift-tests-private
88425e60-045d-4c4f-b672-dc235caeefbd
printCmd
['"strings"']
['CLI']
github.com/openshift/openshift-tests-private/test/extended/opm/client.go
func (c *CLI) printCmd() string { return strings.Join(c.finalArgs, " ") }
opm
function
openshift/openshift-tests-private
c8f09d67-8b49-475d-a7bc-7608ff1111ec
FatalErr
['"fmt"', '"runtime/debug"']
github.com/openshift/openshift-tests-private/test/extended/opm/client.go
func FatalErr(msg interface{}) { // the path that leads to this being called isn't always clear... fmt.Fprintln(g.GinkgoWriter, string(debug.Stack())) e2e.Failf("%v", msg) }
opm
function
openshift/openshift-tests-private
8ae0e1b1-428c-4988-98c2-0b141123cf88
SetAuthFile
['CLI']
github.com/openshift/openshift-tests-private/test/extended/opm/client.go
func (c *CLI) SetAuthFile(authfile string) *CLI { c.podmanAuthfile = authfile return c }
opm
function
openshift/openshift-tests-private
b178e950-63f2-4763-a6c4-363fd63ba25a
Output
['"bytes"', '"fmt"', '"os"', '"os/exec"', '"strings"']
['CLI', 'ExitError']
github.com/openshift/openshift-tests-private/test/extended/opm/client.go
func (c *CLI) Output() (string, error) { if c.verbose { e2e.Logf("DEBUG: %s %s\n", c.execPath, c.printCmd()) } cmd := exec.Command(c.execPath, c.finalArgs...) if c.podmanAuthfile != "" { cmd.Env = append(os.Environ(), "REGISTRY_AUTH_FILE="+c.podmanAuthfile) } if c.ExecCommandPath != "" { e2e.Logf("set exec command path is %s\n", c.ExecCommandPath) cmd.Dir = c.ExecCommandPath } cmd.Stdin = c.stdin if c.showInfo { e2e.Logf("Running '%s %s'", c.execPath, strings.Join(c.finalArgs, " ")) } out, err := cmd.CombinedOutput() trimmed := strings.TrimSpace(string(out)) switch err.(type) { case nil: c.stdout = bytes.NewBuffer(out) return trimmed, nil case *exec.ExitError: e2e.Logf("Error running %v:\n%s", cmd, trimmed) return trimmed, &ExitError{ExitError: err.(*exec.ExitError), Cmd: c.execPath + " " + strings.Join(c.finalArgs, " "), StdErr: trimmed} default: FatalErr(fmt.Errorf("unable to execute %q: %v", c.execPath, err)) // unreachable code return "", nil } }
opm
function
openshift/openshift-tests-private
1c58e7c5-8c1e-478d-9966-db0a1ea639eb
GetDirPath
['"path/filepath"', '"strings"']
github.com/openshift/openshift-tests-private/test/extended/opm/client.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 } else { return GetDirPath(filepath.Dir(dir), filePre) } }
opm
function
openshift/openshift-tests-private
87521270-52ce-46d8-bf6f-51d992f8610b
DeleteDir
['"os"', '"strings"']
github.com/openshift/openshift-tests-private/test/extended/opm/client.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 } else { 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 } }
opm
function
openshift/openshift-tests-private
839a1959-e746-464b-aa51-e2ac8cd1d44d
getRandomString
['"math/rand"', '"time"']
github.com/openshift/openshift-tests-private/test/extended/opm/client.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) }
opm
test
openshift/openshift-tests-private
4bfc13ca-3d31-48d1-a538-d638b07c1b99
opm
import ( "context" "fmt" "io/ioutil" "os" "os/exec" "path" "path/filepath" "regexp" "strings" "time" g "github.com/onsi/ginkgo/v2" o "github.com/onsi/gomega" exutil "github.com/openshift/openshift-tests-private/test/extended/util" container "github.com/openshift/openshift-tests-private/test/extended/util/container" db "github.com/openshift/openshift-tests-private/test/extended/util/db" "k8s.io/apimachinery/pkg/util/wait" e2e "k8s.io/kubernetes/test/e2e/framework" )
github.com/openshift/openshift-tests-private/test/extended/opm/opm.go
package opm import ( "context" "fmt" "io/ioutil" "os" "os/exec" "path" "path/filepath" "regexp" "strings" "time" g "github.com/onsi/ginkgo/v2" o "github.com/onsi/gomega" exutil "github.com/openshift/openshift-tests-private/test/extended/util" container "github.com/openshift/openshift-tests-private/test/extended/util/container" db "github.com/openshift/openshift-tests-private/test/extended/util/db" "k8s.io/apimachinery/pkg/util/wait" e2e "k8s.io/kubernetes/test/e2e/framework" ) var _ = g.Describe("[sig-operators] OLM opm should", func() { defer g.GinkgoRecover() var opmCLI = NewOpmCLI() // author: [email protected] g.It("Author:scolange-Medium-43769-Remove opm alpha add command", func() { exutil.By("step: opm alpha --help") output1, err := opmCLI.Run("alpha").Args("--help").Output() e2e.Logf(output1) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output1).NotTo(o.ContainSubstring("add")) exutil.By("test case 43769 SUCCESS") }) // author: [email protected] g.It("Author:kuiwang-Medium-43185-DC based opm subcommands out of alpha", func() { exutil.By("check init, serve, render and validate under opm") output, err := opmCLI.Run("").Args("--help").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf(output) o.Expect(output).To(o.ContainSubstring("init ")) o.Expect(output).To(o.ContainSubstring("serve ")) o.Expect(output).To(o.ContainSubstring("render ")) o.Expect(output).To(o.ContainSubstring("validate ")) exutil.By("check init, serve, render and validate not under opm alpha") output, err = opmCLI.Run("alpha").Args("--help").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf(output) o.Expect(output).NotTo(o.ContainSubstring("init ")) o.Expect(output).NotTo(o.ContainSubstring("serve ")) o.Expect(output).NotTo(o.ContainSubstring("render ")) o.Expect(output).NotTo(o.ContainSubstring("validate ")) }) // author: [email protected] g.It("ConnectedOnly-Author:kuiwang-Medium-43171-opm render blob from bundle, db based index, dc based index, db file and directory", func() { exutil.By("render db-based index image") output, err := opmCLI.Run("render").Args("quay.io/olmqe/olm-index:OLM-2199").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("\"name\": \"cockroachdb\"")) o.Expect(output).To(o.ContainSubstring("\"name\": \"cockroachdb.v5.0.3\"")) o.Expect(output).To(o.ContainSubstring("\"image\": \"quay.io/olmqe/cockroachdb-operator:5.0.3-2199\"")) o.Expect(output).To(o.ContainSubstring("quay.io/helmoperators/cockroachdb:v5.0.3")) o.Expect(output).To(o.ContainSubstring("\"name\": \"cockroachdb.v5.0.4\"")) o.Expect(output).To(o.ContainSubstring("\"replaces\": \"cockroachdb.v5.0.3\"")) o.Expect(output).To(o.ContainSubstring("quay.io/helmoperators/cockroachdb:v5.0.4")) o.Expect(output).To(o.ContainSubstring("\"name\": \"windup-operator.0.0.4\"")) o.Expect(output).To(o.ContainSubstring("quay.io/windupeng/windup-operator-native:0.0.4")) o.Expect(output).To(o.ContainSubstring("\"name\": \"windup-operator.0.0.5\"")) o.Expect(output).To(o.ContainSubstring("quay.io/windupeng/windup-operator-native:0.0.5")) exutil.By("render dc-based index image with one file") output, err = opmCLI.Run("render").Args("quay.io/olmqe/olm-index:OLM-2199-DC-example").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("\"name\": \"cockroachdb\"")) o.Expect(output).To(o.ContainSubstring("\"name\": \"cockroachdb.v5.0.3\"")) o.Expect(output).To(o.ContainSubstring("\"image\": \"quay.io/olmqe/cockroachdb-operator:5.0.3-2199\"")) o.Expect(output).To(o.ContainSubstring("quay.io/helmoperators/cockroachdb:v5.0.3")) o.Expect(output).To(o.ContainSubstring("\"name\": \"cockroachdb.v5.0.4\"")) o.Expect(output).To(o.ContainSubstring("\"replaces\": \"cockroachdb.v5.0.3\"")) o.Expect(output).To(o.ContainSubstring("quay.io/helmoperators/cockroachdb:v5.0.4")) o.Expect(output).To(o.ContainSubstring("\"name\": \"windup-operator.0.0.4\"")) o.Expect(output).To(o.ContainSubstring("quay.io/windupeng/windup-operator-native:0.0.4")) o.Expect(output).To(o.ContainSubstring("\"name\": \"windup-operator.0.0.5\"")) o.Expect(output).To(o.ContainSubstring("quay.io/windupeng/windup-operator-native:0.0.5")) exutil.By("render dc-based index image with different files") output, err = opmCLI.Run("render").Args("quay.io/olmqe/olm-index:OLM-2199-DC-example-Df").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("\"name\": \"cockroachdb\"")) o.Expect(output).To(o.ContainSubstring("\"name\": \"cockroachdb.v5.0.3\"")) o.Expect(output).To(o.ContainSubstring("\"image\": \"quay.io/olmqe/cockroachdb-operator:5.0.3-2199\"")) o.Expect(output).To(o.ContainSubstring("quay.io/helmoperators/cockroachdb:v5.0.3")) o.Expect(output).To(o.ContainSubstring("\"name\": \"cockroachdb.v5.0.4\"")) o.Expect(output).To(o.ContainSubstring("\"replaces\": \"cockroachdb.v5.0.3\"")) o.Expect(output).To(o.ContainSubstring("quay.io/helmoperators/cockroachdb:v5.0.4")) o.Expect(output).To(o.ContainSubstring("\"name\": \"windup-operator.0.0.4\"")) o.Expect(output).To(o.ContainSubstring("quay.io/windupeng/windup-operator-native:0.0.4")) o.Expect(output).To(o.ContainSubstring("\"name\": \"windup-operator.0.0.5\"")) o.Expect(output).To(o.ContainSubstring("quay.io/windupeng/windup-operator-native:0.0.5")) exutil.By("render dc-based index image with different directory") output, err = opmCLI.Run("render").Args("quay.io/olmqe/olm-index:OLM-2199-DC-example-Dd").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("\"name\": \"cockroachdb\"")) o.Expect(output).To(o.ContainSubstring("\"name\": \"cockroachdb.v5.0.3\"")) o.Expect(output).To(o.ContainSubstring("\"image\": \"quay.io/olmqe/cockroachdb-operator:5.0.3-2199\"")) o.Expect(output).To(o.ContainSubstring("quay.io/helmoperators/cockroachdb:v5.0.3")) o.Expect(output).To(o.ContainSubstring("\"name\": \"cockroachdb.v5.0.4\"")) o.Expect(output).To(o.ContainSubstring("\"replaces\": \"cockroachdb.v5.0.3\"")) o.Expect(output).To(o.ContainSubstring("quay.io/helmoperators/cockroachdb:v5.0.4")) o.Expect(output).To(o.ContainSubstring("\"name\": \"windup-operator.0.0.4\"")) o.Expect(output).To(o.ContainSubstring("quay.io/windupeng/windup-operator-native:0.0.4")) o.Expect(output).To(o.ContainSubstring("\"name\": \"windup-operator.0.0.5\"")) o.Expect(output).To(o.ContainSubstring("quay.io/windupeng/windup-operator-native:0.0.5")) exutil.By("render bundle image") output, err = opmCLI.Run("render").Args("quay.io/olmqe/cockroachdb-operator:5.0.4-2199", "quay.io/olmqe/cockroachdb-operator:5.0.3-2199").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).NotTo(o.ContainSubstring("\"name\": \"cockroachdb\"")) o.Expect(output).To(o.ContainSubstring("\"name\": \"cockroachdb.v5.0.4\"")) o.Expect(output).To(o.ContainSubstring("\"name\": \"cockroachdb.v5.0.3\"")) o.Expect(output).To(o.ContainSubstring("\"package\": \"cockroachdb\"")) o.Expect(output).To(o.ContainSubstring("quay.io/helmoperators/cockroachdb:v5.0.4")) o.Expect(output).To(o.ContainSubstring("quay.io/helmoperators/cockroachdb:v5.0.3")) o.Expect(output).To(o.ContainSubstring("\"group\": \"charts.operatorhub.io\"")) o.Expect(output).To(o.ContainSubstring("\"version\": \"5.0.4\"")) o.Expect(output).To(o.ContainSubstring("\"version\": \"5.0.3\"")) exutil.By("render directory") opmBaseDir := exutil.FixturePath("testdata", "opm") configDir := filepath.Join(opmBaseDir, "render", "configs") output, err = opmCLI.Run("render").Args(configDir).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("\"name\": \"cockroachdb\"")) o.Expect(output).To(o.ContainSubstring("\"name\": \"cockroachdb.v5.0.3\"")) o.Expect(output).To(o.ContainSubstring("\"image\": \"quay.io/olmqe/cockroachdb-operator:5.0.3-2199\"")) o.Expect(output).To(o.ContainSubstring("quay.io/helmoperators/cockroachdb:v5.0.3")) o.Expect(output).To(o.ContainSubstring("\"name\": \"cockroachdb.v5.0.4\"")) o.Expect(output).To(o.ContainSubstring("\"replaces\": \"cockroachdb.v5.0.3\"")) o.Expect(output).To(o.ContainSubstring("quay.io/helmoperators/cockroachdb:v5.0.4")) o.Expect(output).To(o.ContainSubstring("\"name\": \"windup-operator.0.0.4\"")) o.Expect(output).To(o.ContainSubstring("quay.io/windupeng/windup-operator-native:0.0.4")) o.Expect(output).To(o.ContainSubstring("\"name\": \"windup-operator.0.0.5\"")) o.Expect(output).To(o.ContainSubstring("quay.io/windupeng/windup-operator-native:0.0.5")) }) // author: [email protected] g.It("Author:kuiwang-Medium-43180-opm init dc configuration package", func() { exutil.By("init package") opmBaseDir := exutil.FixturePath("testdata", "opm") readme := filepath.Join(opmBaseDir, "render", "init", "readme.md") testpng := filepath.Join(opmBaseDir, "render", "init", "test.png") output, err := opmCLI.Run("init").Args("--default-channel=alpha", "-d", readme, "-i", testpng, "mta-operator").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf(output) o.Expect(output).To(o.ContainSubstring("\"schema\": \"olm.package\"")) o.Expect(output).To(o.ContainSubstring("\"name\": \"mta-operator\"")) o.Expect(output).To(o.ContainSubstring("\"defaultChannel\": \"alpha\"")) o.Expect(output).To(o.ContainSubstring("zcfHkVw9GfpbJmeev9F08WW8uDkaslwX6avlWGU6N")) o.Expect(output).To(o.ContainSubstring("\"description\": \"it is testing\"")) }) // author: [email protected] g.It("Author:kuiwang-Medium-43248-Support ignoring files when loading declarative configs", func() { opmBaseDir := exutil.FixturePath("testdata", "opm") correctIndex := path.Join(opmBaseDir, "render", "validate", "configs") wrongIndex := path.Join(opmBaseDir, "render", "validate", "configs-wrong") wrongIgnoreIndex := path.Join(opmBaseDir, "render", "validate", "configs-wrong-ignore") exutil.By("validate correct index") output, err := opmCLI.Run("validate").Args(correctIndex).Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf(output) exutil.By("validate wrong index") output, err = opmCLI.Run("validate").Args(wrongIndex).Output() o.Expect(err).To(o.HaveOccurred()) e2e.Logf(output) exutil.By("validate index with ignore wrong json") output, err = opmCLI.Run("validate").Args(wrongIgnoreIndex).Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf(output) }) // author: [email protected] g.It("Author:jitli-Medium-43768-Improve formatting of opm alpha validate", func() { opmBase := exutil.FixturePath("testdata", "opm") catalogdir := path.Join(opmBase, "render", "validate", "catalog") catalogerrdir := path.Join(opmBase, "render", "validate", "catalog-error") exutil.By("step: opm validate -h") output1, err := opmCLI.Run("validate").Args("--help").Output() e2e.Logf(output1) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output1).To(o.ContainSubstring("opm validate ")) exutil.By("opm validate catalog") output, err := opmCLI.Run("validate").Args(catalogdir).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.BeEmpty()) exutil.By("opm validate catalog-error") output, err = opmCLI.Run("validate").Args(catalogerrdir).Output() o.Expect(err).To(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("invalid package \\\"operator-1\\\"")) o.Expect(output).To(o.ContainSubstring("invalid channel \\\"alpha\\\"")) o.Expect(output).To(o.ContainSubstring("invalid bundle \\\"operator-1.v0.3.0\\\"")) e2e.Logf(output) }) // author: [email protected] g.It("Author:xzha-Medium-45401-opm validate should detect cycles in channels", func() { opmBase := exutil.FixturePath("testdata", "opm") catalogerrdir := path.Join(opmBase, "render", "validate", "catalog-error", "operator-1") exutil.By("opm validate catalog-error/operator-1") output, err := opmCLI.Run("validate").Args(catalogerrdir).Output() if err != nil { e2e.Logf(output) } o.Expect(err).To(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("invalid channel \\\"45401-1\\\"")) o.Expect(output).To(o.ContainSubstring("invalid channel \\\"45401-2\\\"")) o.Expect(output).To(o.ContainSubstring("invalid channel \\\"45401-3\\\"")) channelInfoList := strings.Split(output, "invalid channel") for _, channelInfo := range channelInfoList { if strings.Contains(channelInfo, "45401-1") { o.Expect(channelInfo).To(o.ContainSubstring("detected cycle in replaces chain of upgrade graph")) } if strings.Contains(channelInfo, "45401-2") { o.Expect(output).To(o.ContainSubstring("multiple channel heads found in graph")) } if strings.Contains(channelInfo, "45401-3") { o.Expect(output).To(o.ContainSubstring("no channel head found in graph")) } } exutil.By("45401 SUCCESS") }) // author: [email protected] g.It("ConnectedOnly-Author:xzha-Medium-45402-opm render should automatically pulling in the image(s) used in the deployments", func() { exutil.By("render bundle image") output, err := opmCLI.Run("render").Args("quay.io/olmqe/mta-operator:v0.0.4-45402", "quay.io/olmqe/eclipse-che:7.32.2-45402", "-oyaml").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("---")) bundleConfigBlobs := strings.Split(output, "---") for _, bundleConfigBlob := range bundleConfigBlobs { if strings.Contains(bundleConfigBlob, "packageName: mta-operator") { exutil.By("check putput of render bundle image which has no relatedimages defined in csv") o.Expect(bundleConfigBlob).To(o.ContainSubstring("relatedImages")) relatedImages := strings.Split(bundleConfigBlob, "relatedImages")[1] o.Expect(relatedImages).To(o.ContainSubstring("quay.io/olmqe/mta-operator:v0.0.4-45402")) o.Expect(relatedImages).To(o.ContainSubstring("quay.io/windupeng/windup-operator-native:0.0.4")) continue } if strings.Contains(bundleConfigBlob, "packageName: eclipse-che") { exutil.By("check putput of render bundle image which has relatedimages defined in csv") o.Expect(bundleConfigBlob).To(o.ContainSubstring("relatedImages")) relatedImages := strings.Split(bundleConfigBlob, "relatedImages")[1] o.Expect(relatedImages).To(o.ContainSubstring("index.docker.io/codercom/code-server")) o.Expect(relatedImages).To(o.ContainSubstring("quay.io/olmqe/eclipse-che:7.32.2-45402")) } } }) // author: [email protected] g.It("ConnectedOnly-Author:xzha-Medium-48438-opm render should support olm.constraint which is defined in dependencies", func() { exutil.By("render bundle image") output, err := opmCLI.Run("render").Args("quay.io/olmqe/etcd-bundle:v0.9.2-48438", "-oyaml").Output() o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("check output of render bundle image contain olm.constraint which is defined in dependencies.yaml") if !strings.Contains(output, "olm.constraint") { e2e.Failf("output doesn't contain olm.constraint") } //exutil.By("check output of render bundle image contain olm.csv.metadata") //if !strings.Contains(output, "olm.csv.metadata") { // e2e.Failf("output doesn't contain olm.csv.metadata") //} }) // author: [email protected] g.It("ConnectedOnly-VMonly-Author:xzha-High-30189-OPM can pull and unpack bundle images in a container", func() { imageTag := "quay.io/openshift/origin-operator-registry" containerCLI := container.NewPodmanCLI() containerName := "test-30189-" + getRandomString() e2e.Logf("create container with image %s", imageTag) id, err := containerCLI.ContainerCreate(imageTag, containerName, "/bin/sh", true) defer func() { e2e.Logf("stop container %s", id) containerCLI.ContainerStop(id) e2e.Logf("remove container %s", id) err := containerCLI.ContainerRemove(id) if err != nil { e2e.Failf("Defer: fail to remove container %s", id) } }() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("container id is %s", id) e2e.Logf("start container %s", id) err = containerCLI.ContainerStart(id) o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("start container %s successful", id) e2e.Logf("get grpcurl") _, err = containerCLI.Exec(id, []string{"wget", "https://github.com/fullstorydev/grpcurl/releases/download/v1.6.0/grpcurl_1.6.0_linux_x86_64.tar.gz"}) o.Expect(err).NotTo(o.HaveOccurred()) _, err = containerCLI.Exec(id, []string{"tar", "xzf", "grpcurl_1.6.0_linux_x86_64.tar.gz"}) o.Expect(err).NotTo(o.HaveOccurred()) _, err = containerCLI.Exec(id, []string{"chmod", "a+rx", "grpcurl"}) o.Expect(err).NotTo(o.HaveOccurred()) opmPath, err := exec.LookPath("opm") o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(opmPath).NotTo(o.BeEmpty()) err = containerCLI.CopyFile(id, opmPath, "/tmp/opm") o.Expect(err).NotTo(o.HaveOccurred()) commandStr := []string{"/tmp/opm", "version"} e2e.Logf("run command %s", commandStr) output, err := containerCLI.Exec(id, commandStr) o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("opm version is: %s", output) commandStr = []string{"/tmp/opm", "index", "add", "--bundles", "quay.io/olmqe/ditto-operator:0.1.0", "--from-index", "quay.io/olmqe/etcd-index:30189", "--generate"} e2e.Logf("run command %s", commandStr) output, err = containerCLI.Exec(id, commandStr) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("Pulling previous image")) o.Expect(output).To(o.ContainSubstring("writing dockerfile: index.Dockerfile")) commandStr = []string{"ls"} e2e.Logf("run command %s", commandStr) output, err = containerCLI.Exec(id, commandStr) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("database")) o.Expect(output).To(o.ContainSubstring("index.Dockerfile")) commandStr = []string{"/tmp/opm", "index", "export", "-i", "quay.io/olmqe/etcd-index:0.9.0-30189", "-f", "tmp", "-o", "etcd"} e2e.Logf("run command %s", commandStr) output, err = containerCLI.Exec(id, commandStr) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("Pulling previous image")) o.Expect(output).To(o.ContainSubstring("Preparing to pull bundles map")) commandStr = []string{"mv", "tmp/etcd", "."} e2e.Logf("run command %s", commandStr) _, err = containerCLI.Exec(id, commandStr) o.Expect(err).NotTo(o.HaveOccurred()) commandStr = []string{"ls", "-R", "etcd"} e2e.Logf("run command %s", commandStr) output, err = containerCLI.Exec(id, commandStr) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("etcdoperator.v0.9.0.clusterserviceversion.yaml")) commandStr = []string{"mkdir", "test"} e2e.Logf("run command %s", commandStr) _, err = containerCLI.Exec(id, commandStr) o.Expect(err).NotTo(o.HaveOccurred()) commandStr = []string{"/tmp/opm", "alpha", "bundle", "generate", "--directory", "etcd", "--package", "test-operator", "--channels", "stable,beta", "-u", "test"} e2e.Logf("run command %s", commandStr) output, err = containerCLI.Exec(id, commandStr) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("Writing bundle.Dockerfile")) commandStr = []string{"ls", "-R", "test"} e2e.Logf("run command %s", commandStr) output, err = containerCLI.Exec(id, commandStr) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("annotations.yaml")) o.Expect(output).To(o.ContainSubstring("etcdoperator.v0.9.0.clusterserviceversion.yaml")) commandStr = []string{"initializer", "-m", "test"} e2e.Logf("run command %s", commandStr) output, err = containerCLI.Exec(id, commandStr) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("loading Packages and Entries")) commandStr = []string{"/tmp/opm", "registry", "serve", "-p", "50050"} e2e.Logf("run command %s", commandStr) _, err = containerCLI.ExecBackgroud(id, commandStr) o.Expect(err).NotTo(o.HaveOccurred()) commandGRP := "podman exec " + id + " ./grpcurl -plaintext localhost:50050 api.Registry/ListBundles | jq '{csvName}'" outputGRP, err := exec.Command("bash", "-c", commandGRP).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(outputGRP).NotTo(o.ContainSubstring("etcdoperator.v0.9.2")) o.Expect(outputGRP).To(o.ContainSubstring("etcdoperator.v0.9.0")) commandStr = []string{"/tmp/opm", "registry", "add", "-b", "quay.io/olmqe/etcd-bundle:0.9.2"} e2e.Logf("run command %s", commandStr) output, err = containerCLI.Exec(id, commandStr) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("adding to the registry")) commandStr = []string{"/tmp/opm", "registry", "serve", "-p", "50051"} e2e.Logf("run command %s", commandStr) _, err = containerCLI.ExecBackgroud(id, commandStr) o.Expect(err).NotTo(o.HaveOccurred()) commandGRP = "podman exec " + id + " ./grpcurl -plaintext localhost:50051 api.Registry/ListBundles | jq '{csvName}'" outputGRP, err = exec.Command("bash", "-c", commandGRP).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(outputGRP).To(o.ContainSubstring("etcdoperator.v0.9.2")) o.Expect(outputGRP).To(o.ContainSubstring("etcdoperator.v0.9.0")) commandStr = []string{"/tmp/opm", "registry", "rm", "-o", "etcd"} e2e.Logf("run command %s", commandStr) output, err = containerCLI.Exec(id, commandStr) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("removing from the registry")) commandStr = []string{"/tmp/opm", "registry", "serve", "-p", "50052"} e2e.Logf("run command %s", commandStr) _, err = containerCLI.ExecBackgroud(id, commandStr) o.Expect(err).NotTo(o.HaveOccurred()) commandGRP = "podman exec " + id + " ./grpcurl -plaintext localhost:50052 api.Registry/ListBundles | jq '{csvName}'" outputGRP, err = exec.Command("bash", "-c", commandGRP).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(outputGRP).NotTo(o.ContainSubstring("etcd")) e2e.Logf("OCP 30189 SUCCESS") }) // author: [email protected] g.It("ConnectedOnly-VMonly-Author:xzha-Medium-47335-opm should validate the constraint type for bundle", func() { opmBaseDir := exutil.FixturePath("testdata", "opm") tmpPath := filepath.Join(opmBaseDir, "temp"+getRandomString()) defer DeleteDir(tmpPath, "fixture-testdata") exutil.By("step: mkdir with mode 0755") err := os.MkdirAll(tmpPath, 0755) o.Expect(err).NotTo(o.HaveOccurred()) opmCLI.ExecCommandPath = tmpPath exutil.By("opm validate quay.io/olmqe/etcd-bundle:v0.9.2-47335-1") output, err := opmCLI.Run("alpha").Args("bundle", "validate", "-t", "quay.io/olmqe/etcd-bundle:v0.9.2-47335-1", "-b", "podman").Output() if err != nil { e2e.Logf(output) } o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("opm validate quay.io/olmqe/etcd-bundle:v0.9.2-47335-2") output, err = opmCLI.Run("alpha").Args("bundle", "validate", "-t", "quay.io/olmqe/etcd-bundle:v0.9.2-47335-2", "-b", "podman").Output() o.Expect(err).To(o.HaveOccurred()) o.Expect(string(output)).To(o.ContainSubstring("Bundle validation errors: Invalid CEL expression: ERROR")) o.Expect(string(output)).To(o.ContainSubstring("Syntax error: missing")) exutil.By("opm validate quay.io/olmqe/etcd-bundle:v0.9.2-47335-3") output, err = opmCLI.Run("alpha").Args("bundle", "validate", "-t", "quay.io/olmqe/etcd-bundle:v0.9.2-47335-3", "-b", "podman").Output() o.Expect(err).To(o.HaveOccurred()) o.Expect(string(output)).To(o.ContainSubstring("Bundle validation errors: The CEL expression is missing")) exutil.By("opm validate quay.io/olmqe/etcd-bundle:v0.9.2-47335-4") output, err = opmCLI.Run("alpha").Args("bundle", "validate", "-t", "quay.io/olmqe/etcd-bundle:v0.9.2-47335-4", "-b", "podman").Output() if err != nil { e2e.Logf(output) } o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("opm validate quay.io/olmqe/etcd-bundle:v0.9.2-47335-5") output, err = opmCLI.Run("alpha").Args("bundle", "validate", "-t", "quay.io/olmqe/etcd-bundle:v0.9.2-47335-5", "-b", "podman").Output() o.Expect(err).To(o.HaveOccurred()) o.Expect(string(output)).To(o.ContainSubstring("Bundle validation errors: Invalid CEL expression: ERROR")) o.Expect(string(output)).To(o.ContainSubstring("undeclared reference to 'semver_compares'")) exutil.By("opm validate quay.io/olmqe/etcd-bundle:v0.9.2-47335-6") output, err = opmCLI.Run("alpha").Args("bundle", "validate", "-t", "quay.io/olmqe/etcd-bundle:v0.9.2-47335-6", "-b", "podman").Output() o.Expect(err).To(o.HaveOccurred()) o.Expect(string(output)).To(o.ContainSubstring("Bundle validation errors: Invalid CEL expression: cel expressions must have type Bool")) exutil.By("47335 SUCCESS") }) // author: [email protected] g.It("ConnectedOnly-Author:xzha-Medium-70013-opm support deprecated channel", func() { opmBaseDir := exutil.FixturePath("testdata", "opm", "70013") opmCLI.ExecCommandPath = opmBaseDir exutil.By("opm validate catalog") output, err := opmCLI.Run("validate").Args("catalog-valid").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.BeEmpty()) exutil.By("opm validate catalog") output, err = opmCLI.Run("validate").Args("catalog-invalid").Output() o.Expect(err).To(o.HaveOccurred()) o.Expect(string(output)).To(o.ContainSubstring("message must be set")) exutil.By("opm render") output, err = opmCLI.Run("render").Args("quay.io/olmqe/olmtest-operator-index:nginx70050", "-o", "yaml").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(strings.Contains(string(output), "schema: olm.deprecations")).To(o.BeTrue()) exutil.By("70013 SUCCESS") }) // author: [email protected] g.It("Author:bandrade-Medium-34016-opm can prune operators from catalog", func() { opmBaseDir := exutil.FixturePath("testdata", "opm") indexDB := filepath.Join(opmBaseDir, "index_34016.db") output, err := opmCLI.Run("registry").Args("prune", "-d", indexDB, "-p", "lib-bucket-provisioner").Output() o.Expect(err).NotTo(o.HaveOccurred()) if !strings.Contains(output, "deleting packages") || !strings.Contains(output, "pkg=planetscale") { e2e.Failf(fmt.Sprintf("Failed to obtain the removed packages from prune : %s", output)) } }) // author: [email protected] g.It("ConnectedOnly-Author:bandrade-Medium-54168-opm support '--use-http' global flag", func() { if os.Getenv("HTTP_PROXY") != "" || os.Getenv("http_proxy") != "" { g.Skip("HTTP_PROXY is not empty - skipping test ...") } opmBaseDir := exutil.FixturePath("testdata", "opm", "53869") opmCLI.ExecCommandPath = opmBaseDir defer DeleteDir(opmBaseDir, "fixture-testdata") exutil.By("1) checking alpha list") output, err := opmCLI.Run("alpha").Args("list", "bundles", "quay.io/openshifttest/nginxolm-operator-index:v1", "--use-http").Output() o.Expect(err).NotTo(o.HaveOccurred()) if !strings.Contains(output, "nginx-operator") { e2e.Failf(fmt.Sprintf("Failed to obtain the packages from alpha list : %s", output)) } exutil.By("2) checking render") output, err = opmCLI.Run("render").Args("quay.io/openshifttest/nginxolm-operator-index:v1", "--use-http").Output() o.Expect(err).NotTo(o.HaveOccurred()) if !strings.Contains(output, "nginx-operator") { e2e.Failf(fmt.Sprintf("Failed run render command : %s", output)) } exutil.By("3) checking index add") output, err = opmCLI.Run("index").Args("add", "-b", "quay.io/openshifttest/nginxolm-operator-bundle:v0.0.1", "-t", "quay.io/olmqe/nginxolm-operator-index:v54168", "--use-http", "--generate").Output() o.Expect(err).NotTo(o.HaveOccurred()) if !strings.Contains(output, "writing dockerfile") { e2e.Failf(fmt.Sprintf("Failed run render command : %s", output)) } exutil.By("4) checking render-veneer semver") output, err = opmCLI.Run("alpha").Args("render-template", "--use-http", "basic", filepath.Join(opmBaseDir, "catalog-basic-template.yaml"), "-o", "yaml").Output() o.Expect(err).NotTo(o.HaveOccurred()) if !strings.Contains(output, "nginx-operator") { e2e.Failf(fmt.Sprintf("Failed run render command : %s", output)) } exutil.By("5) checking render-graph") output, err = opmCLI.Run("alpha").Args("render-graph", "quay.io/openshifttest/nginxolm-operator-index:v1", "--use-http").Output() o.Expect(err).NotTo(o.HaveOccurred()) if !strings.Contains(output, "nginx-operator") { e2e.Failf(fmt.Sprintf("Failed run render-graph command : %s", output)) } }) // author: [email protected] g.It("Author:bandrade-VMonly-Low-30318-Bundle build understands packages", func() { opmBaseDir := exutil.FixturePath("testdata", "opm") testDataPath := filepath.Join(opmBaseDir, "learn_operator") opmCLI.ExecCommandPath = testDataPath defer DeleteDir(testDataPath, "fixture-testdata") exutil.By("step: opm alpha bundle generate") output, err := opmCLI.Run("alpha").Args("bundle", "generate", "-d", "package/0.0.1", "-p", "25955-operator", "-c", "alpha", "-e", "alpha").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf(output) if !strings.Contains(output, "Writing annotations.yaml") || !strings.Contains(output, "Writing bundle.Dockerfile") { e2e.Failf("Failed to execute opm alpha bundle generate : %s", output) } }) }) var _ = g.Describe("[sig-operators] OLM opm with podman", func() { defer g.GinkgoRecover() var opmCLI = NewOpmCLI() var oc = exutil.NewCLI("vmonly-"+getRandomString(), exutil.KubeConfigPath()) // OCP-43641 author: [email protected] g.It("Author:jitli-ConnectedOnly-VMonly-Medium-43641-opm index add fails during image extraction", func() { bundleImage := "quay.io/olmqe/etcd:0.9.4-43641" indexImage := "quay.io/olmqe/etcd-index:v1-4.8" opmBaseDir := exutil.FixturePath("testdata", "opm") TestDataPath := filepath.Join(opmBaseDir, "temp") opmCLI.ExecCommandPath = TestDataPath defer DeleteDir(TestDataPath, "fixture-testdata") err := os.Mkdir(TestDataPath, 0755) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("step: checking user account is no-root") user, err := exec.Command("bash", "-c", "whoami").Output() e2e.Logf("User:%s", user) o.Expect(err).NotTo(o.HaveOccurred()) if strings.Compare(string(user), "root") == -1 { exutil.By("step: opm index add") output1, err := opmCLI.Run("index").Args("add", "--generate", "--bundles", bundleImage, "--from-index", indexImage, "--overwrite-latest").Output() e2e.Logf(output1) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("test case 43641 SUCCESS") } else { e2e.Logf("User is %s. the case should login as no-root account", user) } }) // author: [email protected] g.It("Author:xzha-ConnectedOnly-VMonly-Medium-25955-opm Ability to generate scaffolding for Operator Bundle", func() { var podmanCLI = container.NewPodmanCLI() opmBaseDir := exutil.FixturePath("testdata", "opm") TestDataPath := filepath.Join(opmBaseDir, "learn_operator") opmCLI.ExecCommandPath = TestDataPath defer DeleteDir(TestDataPath, "fixture-testdata") imageTag := "quay.io/olmqe/25955-operator-" + getRandomString() + ":v0.0.1" exutil.By("step: opm alpha bundle generate") output, err := opmCLI.Run("alpha").Args("bundle", "generate", "-d", "package/0.0.1", "-p", "25955-operator", "-c", "alpha", "-e", "alpha").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf(output) if !strings.Contains(output, "Writing annotations.yaml") || !strings.Contains(output, "Writing bundle.Dockerfile") { e2e.Failf("Failed to execute opm alpha bundle generate : %s", output) } exutil.By("step: opm alpha bundle build") e2e.Logf("clean test data") DeleteDir(TestDataPath, "fixture-testdata") opmBaseDir = exutil.FixturePath("testdata", "opm") TestDataPath = filepath.Join(opmBaseDir, "learn_operator") opmCLI.ExecCommandPath = TestDataPath _, err = podmanCLI.RemoveImage(imageTag) o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("run opm alpha bundle build") defer podmanCLI.RemoveImage(imageTag) output, _ = opmCLI.Run("alpha").Args("bundle", "build", "-d", "package/0.0.1", "-b", "podman", "--tag", imageTag, "-p", "25955-operator", "-c", "alpha", "-e", "alpha", "--overwrite").Output() e2e.Logf(output) if !strings.Contains(output, "COMMIT "+imageTag) { e2e.Failf("Failed to execute opm alpha bundle build : %s", output) } e2e.Logf("step: check image %s exist", imageTag) existFlag, err := podmanCLI.CheckImageExist(imageTag) o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("check image exist is %v", existFlag) o.Expect(existFlag).To(o.BeTrue()) }) // author: [email protected] g.It("Author:xzha-ConnectedOnly-VMonly-Medium-37294-OPM can strand packages with prune stranded", func() { var sqlit = db.NewSqlit() quayCLI := container.NewQuayCLI() containerTool := "podman" containerCLI := container.NewPodmanCLI() opmBaseDir := exutil.FixturePath("testdata", "opm") TestDataPath := filepath.Join(opmBaseDir, "temp") opmCLI.ExecCommandPath = TestDataPath defer DeleteDir(TestDataPath, "fixture-testdata") indexImage := "quay.io/olmqe/etcd-index:test-37294" indexImageSemver := "quay.io/olmqe/etcd-index:test-37294-semver" exutil.By("step: check etcd-index:test-37294, operatorbundle has two records, channel_entry has one record") indexdbpath1 := filepath.Join(TestDataPath, getRandomString()) err := os.Mkdir(TestDataPath, 0755) o.Expect(err).NotTo(o.HaveOccurred()) err = os.Mkdir(indexdbpath1, 0755) o.Expect(err).NotTo(o.HaveOccurred()) _, err = oc.AsAdmin().WithoutNamespace().Run("image").Args("extract", indexImage, "--path", "/database/index.db:"+indexdbpath1).Output() e2e.Logf("get index.db SUCCESS, path is %s", path.Join(indexdbpath1, "index.db")) o.Expect(err).NotTo(o.HaveOccurred()) result, err := sqlit.DBMatch(path.Join(indexdbpath1, "index.db"), "operatorbundle", "name", []string{"etcdoperator.v0.9.0", "etcdoperator.v0.9.2"}) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(result).To(o.BeTrue()) result, err = sqlit.DBMatch(path.Join(indexdbpath1, "index.db"), "channel_entry", "operatorbundle_name", []string{"etcdoperator.v0.9.2"}) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(result).To(o.BeTrue()) exutil.By("step: prune-stranded this index image") indexImageTmp1 := indexImage + getRandomString() defer containerCLI.RemoveImage(indexImageTmp1) output, err := opmCLI.Run("index").Args("prune-stranded", "-f", indexImage, "--tag", indexImageTmp1, "-c", containerTool).Output() if err != nil { e2e.Logf(output) } o.Expect(err).NotTo(o.HaveOccurred()) output, err = containerCLI.Run("push").Args(indexImageTmp1).Output() if err != nil { e2e.Logf(output) } defer quayCLI.DeleteTag(strings.Replace(indexImageTmp1, "quay.io/", "", 1)) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("step: check index image operatorbundle has one record") indexdbpath2 := filepath.Join(TestDataPath, getRandomString()) err = os.Mkdir(indexdbpath2, 0755) o.Expect(err).NotTo(o.HaveOccurred()) _, err = oc.AsAdmin().WithoutNamespace().Run("image").Args("extract", indexImageTmp1, "--path", "/database/index.db:"+indexdbpath2).Output() e2e.Logf("get index.db SUCCESS, path is %s", path.Join(indexdbpath2, "index.db")) o.Expect(err).NotTo(o.HaveOccurred()) result, err = sqlit.DBMatch(path.Join(indexdbpath2, "index.db"), "operatorbundle", "name", []string{"etcdoperator.v0.9.2"}) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(result).To(o.BeTrue()) result, err = sqlit.DBMatch(path.Join(indexdbpath2, "index.db"), "channel_entry", "operatorbundle_name", []string{"etcdoperator.v0.9.2"}) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(result).To(o.BeTrue()) exutil.By("test 2") exutil.By("step: step: check etcd-index:test-37294-semver, operatorbundle has two records, channel_entry has two records") indexdbpath3 := filepath.Join(TestDataPath, getRandomString()) err = os.Mkdir(indexdbpath3, 0755) o.Expect(err).NotTo(o.HaveOccurred()) _, err = oc.AsAdmin().WithoutNamespace().Run("image").Args("extract", indexImageSemver, "--path", "/database/index.db:"+indexdbpath3).Output() e2e.Logf("get index.db SUCCESS, path is %s", path.Join(indexdbpath3, "index.db")) o.Expect(err).NotTo(o.HaveOccurred()) result, err = sqlit.DBMatch(path.Join(indexdbpath3, "index.db"), "operatorbundle", "name", []string{"etcdoperator.v0.9.0", "etcdoperator.v0.9.2"}) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(result).To(o.BeTrue()) result, err = sqlit.DBMatch(path.Join(indexdbpath3, "index.db"), "channel_entry", "operatorbundle_name", []string{"etcdoperator.v0.9.0", "etcdoperator.v0.9.2"}) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(result).To(o.BeTrue()) exutil.By("step: prune-stranded this index image") indexImageTmp2 := indexImage + getRandomString() defer containerCLI.RemoveImage(indexImageTmp2) output, err = opmCLI.Run("index").Args("prune-stranded", "-f", indexImageSemver, "--tag", indexImageTmp2, "-c", containerTool).Output() if err != nil { e2e.Logf(output) } o.Expect(err).NotTo(o.HaveOccurred()) output, err = containerCLI.Run("push").Args(indexImageTmp2).Output() if err != nil { e2e.Logf(output) } defer quayCLI.DeleteTag(strings.Replace(indexImageTmp2, "quay.io/", "", 1)) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("step: check index image has both v0.9.2 and v0.9.2") indexdbpath4 := filepath.Join(TestDataPath, getRandomString()) err = os.Mkdir(indexdbpath4, 0755) o.Expect(err).NotTo(o.HaveOccurred()) _, err = oc.AsAdmin().WithoutNamespace().Run("image").Args("extract", indexImageTmp2, "--path", "/database/index.db:"+indexdbpath4).Output() e2e.Logf("get index.db SUCCESS, path is %s", path.Join(indexdbpath4, "index.db")) o.Expect(err).NotTo(o.HaveOccurred()) result, err = sqlit.DBMatch(path.Join(indexdbpath4, "index.db"), "operatorbundle", "name", []string{"etcdoperator.v0.9.0", "etcdoperator.v0.9.2"}) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(result).To(o.BeTrue()) result, err = sqlit.DBMatch(path.Join(indexdbpath4, "index.db"), "channel_entry", "operatorbundle_name", []string{"etcdoperator.v0.9.0", "etcdoperator.v0.9.2"}) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(result).To(o.BeTrue()) e2e.Logf("step: check index image has both v0.9.2 and v0.9.2 SUCCESS") }) // author: [email protected] g.It("Author:kuiwang-ConnectedOnly-VMonly-Medium-40167-bundle image is missed in index db of index image", func() { node, errNode := oc.AsAdmin().WithoutNamespace().Run("get").Args("node", "-o=jsonpath={.items[0].metadata.name}").Output() o.Expect(errNode).NotTo(o.HaveOccurred()) errSet := exutil.SetNamespacePrivileged(oc, oc.Namespace()) o.Expect(errSet).NotTo(o.HaveOccurred()) efips, errFips := oc.AsAdmin().WithoutNamespace().Run("debug").Args("node/"+node, "--to-namespace="+oc.Namespace(), "--", "chroot", "/host", "fips-mode-setup", "--check").Output() if errFips != nil || strings.Contains(efips, "FIPS mode is enabled") { g.Skip("skip it without impacting function") } exutil.SkipBaselineCaps(oc, "None") exutil.SkipForSNOCluster(oc) platform := exutil.CheckPlatform(oc) proxy, errProxy := oc.AsAdmin().WithoutNamespace().Run("get").Args("proxy", "cluster", "-o=jsonpath={.status.httpProxy}{.status.httpsProxy}").Output() o.Expect(errProxy).NotTo(o.HaveOccurred()) if proxy != "" || strings.Contains(platform, "openstack") || strings.Contains(platform, "baremetal") || strings.Contains(platform, "vsphere") || strings.Contains(platform, "none") { g.Skip("it is not supported") } var ( opmBaseDir = exutil.FixturePath("testdata", "opm") TestDataPath = filepath.Join(opmBaseDir, "temp") opmCLI = NewOpmCLI() quayCLI = container.NewQuayCLI() sqlit = db.NewSqlit() containerTool = "podman" containerCLI = container.NewPodmanCLI() // it is shared image. could not need to remove it. indexImage = "quay.io/olmqe/cockroachdb-index:2.1.11-40167" // it is generated by case. need to remove it after case exist normally or abnormally customIndexImage = "quay.io/olmqe/cockroachdb-index:2.1.11-40167-custome-" + getRandomString() ) defer DeleteDir(TestDataPath, "fixture-testdata") defer containerCLI.RemoveImage(customIndexImage) defer quayCLI.DeleteTag(strings.Replace(customIndexImage, "quay.io/", "", 1)) err := os.Mkdir(TestDataPath, 0755) o.Expect(err).NotTo(o.HaveOccurred()) opmCLI.ExecCommandPath = TestDataPath exutil.By("prune redhat index image to get custom index image") if output, err := opmCLI.Run("index").Args("prune", "-f", indexImage, "-p", "cockroachdb", "-t", customIndexImage, "-c", containerTool).Output(); err != nil { e2e.Logf(output) if strings.Contains(output, "error unmounting container") { g.Skip("skip case because we can not prepare data") } o.Expect(err).NotTo(o.HaveOccurred()) } if output, err := containerCLI.Run("push").Args(customIndexImage).Output(); err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } exutil.By("extract db file") indexdbpath1 := filepath.Join(TestDataPath, getRandomString()) err = os.Mkdir(indexdbpath1, 0755) o.Expect(err).NotTo(o.HaveOccurred()) _, err = oc.AsAdmin().WithoutNamespace().Run("image").Args("extract", customIndexImage, "--path", "/database/index.db:"+indexdbpath1).Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("get index.db SUCCESS, path is %s", path.Join(indexdbpath1, "index.db")) exutil.By("check if the bunld image is in db index") rows, err := sqlit.QueryDB(path.Join(indexdbpath1, "index.db"), "select image from related_image where operatorbundle_name like 'cockroachdb%';") o.Expect(err).NotTo(o.HaveOccurred()) defer rows.Close() var imageList string var image string for rows.Next() { rows.Scan(&image) imageList = imageList + image } e2e.Logf("imageList is %v", imageList) o.Expect(imageList).To(o.ContainSubstring("cockroachdb-operator")) }) // author: [email protected] g.It("Author:xzha-ConnectedOnly-VMonly-Medium-40530-The index image generated by opm index prune should not leave unrelated images", func() { quayCLI := container.NewQuayCLI() var sqlit = db.NewSqlit() containerCLI := container.NewPodmanCLI() containerTool := "podman" opmBaseDir := exutil.FixturePath("testdata", "opm") TestDataPath := filepath.Join(opmBaseDir, "temp") opmCLI.ExecCommandPath = TestDataPath defer DeleteDir(TestDataPath, "fixture-testdata") indexImage := "quay.io/olmqe/redhat-operator-index:40530" defer containerCLI.RemoveImage(indexImage) exutil.By("step: check the index image has other bundles except cluster-logging") indexTmpPath1 := filepath.Join(TestDataPath, getRandomString()) err := os.MkdirAll(indexTmpPath1, 0755) o.Expect(err).NotTo(o.HaveOccurred()) _, err = oc.AsAdmin().WithoutNamespace().Run("image").Args("extract", indexImage, "--path", "/database/index.db:"+indexTmpPath1).Output() e2e.Logf("get index.db SUCCESS, path is %s", path.Join(indexTmpPath1, "index.db")) o.Expect(err).NotTo(o.HaveOccurred()) rows, err := sqlit.QueryDB(path.Join(indexTmpPath1, "index.db"), "select distinct(operatorbundle_name) from related_image where operatorbundle_name not in (select operatorbundle_name from channel_entry)") o.Expect(err).NotTo(o.HaveOccurred()) defer rows.Close() var OperatorBundles []string var name string for rows.Next() { rows.Scan(&name) OperatorBundles = append(OperatorBundles, name) } o.Expect(OperatorBundles).NotTo(o.BeEmpty()) exutil.By("step: Prune the index image to keep cluster-logging only") indexImage1 := indexImage + getRandomString() defer containerCLI.RemoveImage(indexImage1) output, err := opmCLI.Run("index").Args("prune", "-f", indexImage, "-p", "cluster-logging", "-t", indexImage1, "-c", containerTool).Output() if err != nil { e2e.Logf(output) } o.Expect(err).NotTo(o.HaveOccurred()) output, err = containerCLI.Run("push").Args(indexImage1).Output() if err != nil { e2e.Logf(output) } defer quayCLI.DeleteTag(strings.Replace(indexImage1, "quay.io/", "", 1)) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("step: check database, there is no related images") indexTmpPath2 := filepath.Join(TestDataPath, getRandomString()) err = os.MkdirAll(indexTmpPath2, 0755) o.Expect(err).NotTo(o.HaveOccurred()) _, err = oc.AsAdmin().WithoutNamespace().Run("image").Args("extract", indexImage1, "--path", "/database/index.db:"+indexTmpPath2).Output() e2e.Logf("get index.db SUCCESS, path is %s", path.Join(indexTmpPath2, "index.db")) o.Expect(err).NotTo(o.HaveOccurred()) rows2, err := sqlit.QueryDB(path.Join(indexTmpPath2, "index.db"), "select distinct(operatorbundle_name) from related_image where operatorbundle_name not in (select operatorbundle_name from channel_entry)") o.Expect(err).NotTo(o.HaveOccurred()) OperatorBundles = nil defer rows2.Close() for rows2.Next() { rows2.Scan(&name) OperatorBundles = append(OperatorBundles, name) } o.Expect(OperatorBundles).To(o.BeEmpty()) exutil.By("step: check the image mirroring mapping") manifestsPath := filepath.Join(TestDataPath, getRandomString()) output, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("catalog", "mirror", indexImage1, "localhost:5000", "--manifests-only", "--to-manifests="+manifestsPath).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("/database/index.db")) result, err := exec.Command("bash", "-c", "cat "+manifestsPath+"/mapping.txt").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(result).NotTo(o.BeEmpty()) result, _ = exec.Command("bash", "-c", "cat "+manifestsPath+"/mapping.txt|grep -v ose-cluster-logging|grep -v ose-logging|grep -v redhat-operator-index:40530").Output() o.Expect(result).To(o.BeEmpty()) exutil.By("step: 40530 SUCCESS") }) // author: [email protected] g.It("Author:bandrade-ConnectedOnly-VMonly-Medium-34049-opm can prune operators from index", func() { var sqlit = db.NewSqlit() quayCLI := container.NewQuayCLI() podmanCLI := container.NewPodmanCLI() opmBaseDir := exutil.FixturePath("testdata", "opm") TestDataPath := filepath.Join(opmBaseDir, "temp") indexTmpPath := filepath.Join(TestDataPath, getRandomString()) defer DeleteDir(TestDataPath, indexTmpPath) err := os.MkdirAll(indexTmpPath, 0755) o.Expect(err).NotTo(o.HaveOccurred()) containerCLI := container.NewPodmanCLI() containerTool := "podman" sourceImageTag := "quay.io/olmqe/multi-index:2.0" imageTag := "quay.io/olmqe/multi-index:3.0." + getRandomString() defer podmanCLI.RemoveImage(imageTag) defer podmanCLI.RemoveImage(sourceImageTag) output, err := opmCLI.Run("index").Args("prune", "-f", sourceImageTag, "-p", "planetscale", "-t", imageTag, "-c", containerTool).Output() o.Expect(err).NotTo(o.HaveOccurred()) if !strings.Contains(output, "deleting packages") || !strings.Contains(output, "pkg=lib-bucket-provisioner") { e2e.Failf(fmt.Sprintf("Failed to obtain the removed packages from prune : %s", output)) } output, err = containerCLI.Run("push").Args(imageTag).Output() if err != nil { e2e.Logf(output) } defer quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1)) o.Expect(err).NotTo(o.HaveOccurred()) _, err = oc.AsAdmin().WithoutNamespace().Run("image").Args("extract", imageTag, "--path", "/database/index.db:"+indexTmpPath).Output() e2e.Logf("get index.db SUCCESS, path is %s", path.Join(indexTmpPath, "index.db")) o.Expect(err).NotTo(o.HaveOccurred()) result, err := sqlit.DBMatch(path.Join(indexTmpPath, "index.db"), "channel_entry", "operatorbundle_name", []string{"lib-bucket-provisioner.v1.0.0"}) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(result).To(o.BeFalse()) }) g.It("Author:xzha-ConnectedOnly-VMonly-Medium-26594-Related Images", func() { var sqlit = db.NewSqlit() quayCLI := container.NewQuayCLI() containerCLI := container.NewPodmanCLI() containerTool := "podman" opmBaseDir := exutil.FixturePath("testdata", "opm") TestDataPath := filepath.Join(opmBaseDir, "eclipse-che") TmpDataPath := filepath.Join(opmBaseDir, "tmp") err := os.MkdirAll(TmpDataPath, 0755) o.Expect(err).NotTo(o.HaveOccurred()) bundleImageTag := "quay.io/olmqe/eclipse-che:7.32.2-" + getRandomString() defer exec.Command("kill", "-9", "$(lsof -t -i:26594)").Output() defer DeleteDir(TestDataPath, "fixture-testdata") defer containerCLI.RemoveImage(bundleImageTag) defer quayCLI.DeleteTag(strings.Replace(bundleImageTag, "quay.io/", "", 1)) exutil.By("step: build bundle image ") opmCLI.ExecCommandPath = TestDataPath output, err := opmCLI.Run("alpha").Args("bundle", "build", "-d", "7.32.2", "-b", containerTool, "-t", bundleImageTag, "-p", "eclipse-che", "-c", "alpha", "-e", "alpha", "--overwrite").Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("Writing annotations.yaml")) o.Expect(string(output)).To(o.ContainSubstring("Writing bundle.Dockerfile")) if output, err = containerCLI.Run("push").Args(bundleImageTag).Output(); err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } exutil.By("step: build bundle.db") dbFilePath := TmpDataPath + "bundles.db" if output, err := opmCLI.Run("registry").Args("add", "-b", bundleImageTag, "-d", dbFilePath, "-c", containerTool, "--mode", "semver").Output(); err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } exutil.By("step: Check if the related images stores in this database") image := "quay.io/che-incubator/configbump@sha256:175ff2ba1bd74429de192c0a9facf39da5699c6da9f151bd461b3dc8624dd532" result, err := sqlit.DBMatch(dbFilePath, "package", "name", []string{"eclipse-che"}) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(result).To(o.BeTrue()) result, err = sqlit.DBHas(dbFilePath, "related_image", "image", []string{image}) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(result).To(o.BeTrue()) exutil.By("step: Run the opm registry server binary to load manifest and serves a grpc API to query it.") e2e.Logf("step: Run the registry-server ") cmd := exec.Command("opm", "registry", "serve", "-d", dbFilePath, "-t", filepath.Join(TmpDataPath, "26594.log"), "-p", "26594") cmd.Dir = TmpDataPath err = cmd.Start() o.Expect(err).NotTo(o.HaveOccurred()) time.Sleep(time.Second * 1) e2e.Logf("step: check api.Registry/ListPackages") outputCurl, err := exec.Command("grpcurl", "-plaintext", "localhost:26594", "api.Registry/ListPackages").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(string(outputCurl)).To(o.ContainSubstring("eclipse-che")) e2e.Logf("step: check api.Registry/GetBundleForChannel") outputCurl, err = exec.Command("grpcurl", "-plaintext", "-d", "{\"pkgName\":\"eclipse-che\",\"channelName\":\"alpha\"}", "localhost:26594", "api.Registry/GetBundleForChannel").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(string(outputCurl)).To(o.ContainSubstring(image)) cmd.Process.Kill() exutil.By("step: SUCCESS") }) g.It("Author:xzha-ConnectedOnly-Medium-43409-opm can list catalog contents", func() { dbimagetag := "quay.io/olmqe/community-operator-index:v4.8" dcimagetag := "quay.io/olmqe/community-operator-index:v4.8-dc" exutil.By("1, testing with index.db image ") exutil.By("1.1 list packages") output, err := opmCLI.Run("alpha").Args("list", "packages", dbimagetag).Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("3scale-community-operator")) o.Expect(string(output)).To(o.ContainSubstring("3scale API Management")) o.Expect(string(output)).To(o.ContainSubstring("threescale-2.10")) exutil.By("1.2 list channels") output, err = opmCLI.Run("alpha").Args("list", "channels", dbimagetag).Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("3scale-community-operator")) o.Expect(string(output)).To(o.ContainSubstring("threescale-2.10")) o.Expect(string(output)).To(o.ContainSubstring("3scale-community-operator.v0.7.0")) exutil.By("1.3 list channels in a package") output, err = opmCLI.Run("alpha").Args("list", "channels", dbimagetag, "3scale-community-operator").Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("threescale-2.10")) o.Expect(string(output)).To(o.ContainSubstring("threescale-2.9")) exutil.By("1.4 list bundles") output, err = opmCLI.Run("alpha").Args("list", "bundles", dbimagetag).Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("3scale-community-operator.v0.6.0")) o.Expect(string(output)).To(o.ContainSubstring("3scale-community-operator.v0.7.0")) exutil.By("1.5 list bundles in a package") output, err = opmCLI.Run("alpha").Args("list", "bundles", dbimagetag, "wso2am-operator").Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("wso2am-operator.v1.0.0")) o.Expect(string(output)).To(o.ContainSubstring("wso2am-operator.v1.0.1")) o.Expect(string(output)).To(o.ContainSubstring("wso2am-operator.v1.1.0")) exutil.By("2, testing with dc format index image") exutil.By("2.1 list packages") output, err = opmCLI.Run("alpha").Args("list", "packages", dcimagetag).Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("3scale-community-operator")) o.Expect(string(output)).To(o.ContainSubstring("3scale API Management")) o.Expect(string(output)).To(o.ContainSubstring("threescale-2.10")) exutil.By("2.2 list channels") output, err = opmCLI.Run("alpha").Args("list", "channels", dcimagetag).Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("3scale-community-operator")) o.Expect(string(output)).To(o.ContainSubstring("threescale-2.10")) o.Expect(string(output)).To(o.ContainSubstring("3scale-community-operator.v0.7.0")) exutil.By("2.3 list channels in a package") output, err = opmCLI.Run("alpha").Args("list", "channels", dcimagetag, "3scale-community-operator").Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("threescale-2.10")) o.Expect(string(output)).To(o.ContainSubstring("threescale-2.9")) exutil.By("2.4 list bundles") output, err = opmCLI.Run("alpha").Args("list", "bundles", dcimagetag).Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("3scale-community-operator.v0.6.0")) o.Expect(string(output)).To(o.ContainSubstring("3scale-community-operator.v0.7.0")) exutil.By("2.5 list bundles in a package") output, err = opmCLI.Run("alpha").Args("list", "bundles", dcimagetag, "wso2am-operator").Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("wso2am-operator.v1.0.0")) o.Expect(string(output)).To(o.ContainSubstring("wso2am-operator.v1.0.1")) o.Expect(string(output)).To(o.ContainSubstring("wso2am-operator.v1.1.0")) exutil.By("3, testing with index.db file") opmBaseDir := exutil.FixturePath("testdata", "opm") TmpDataPath := filepath.Join(opmBaseDir, "tmp") indexdbFilePath := filepath.Join(TmpDataPath, "index.db") err = os.MkdirAll(TmpDataPath, 0755) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("get index.db") _, err = oc.AsAdmin().WithoutNamespace().Run("image").Args("extract", dbimagetag, "--path", "/database/index.db:"+TmpDataPath).Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("get index.db SUCCESS, path is %s", indexdbFilePath) if _, err := os.Stat(indexdbFilePath); os.IsNotExist(err) { e2e.Logf("get index.db Failed") } exutil.By("3.1 list packages") output, err = opmCLI.Run("alpha").Args("list", "packages", indexdbFilePath).Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("3scale-community-operator")) o.Expect(string(output)).To(o.ContainSubstring("3scale API Management")) o.Expect(string(output)).To(o.ContainSubstring("threescale-2.10")) exutil.By("3.2 list channels") output, err = opmCLI.Run("alpha").Args("list", "channels", indexdbFilePath).Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("3scale-community-operator")) o.Expect(string(output)).To(o.ContainSubstring("threescale-2.10")) o.Expect(string(output)).To(o.ContainSubstring("3scale-community-operator.v0.7.0")) exutil.By("3.3 list channels in a package") output, err = opmCLI.Run("alpha").Args("list", "channels", indexdbFilePath, "3scale-community-operator").Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("threescale-2.10")) o.Expect(string(output)).To(o.ContainSubstring("threescale-2.9")) exutil.By("3.4 list bundles") output, err = opmCLI.Run("alpha").Args("list", "bundles", indexdbFilePath).Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("3scale-community-operator.v0.6.0")) o.Expect(string(output)).To(o.ContainSubstring("3scale-community-operator.v0.7.0")) exutil.By("3.5 list bundles in a package") output, err = opmCLI.Run("alpha").Args("list", "bundles", indexdbFilePath, "wso2am-operator").Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("wso2am-operator.v1.0.0")) o.Expect(string(output)).To(o.ContainSubstring("wso2am-operator.v1.0.1")) o.Expect(string(output)).To(o.ContainSubstring("wso2am-operator.v1.1.0")) exutil.By("step: SUCCESS") }) // author: [email protected] g.It("Author:xzha-ConnectedOnly-VMonly-Medium-43147-opm support rebuild index if any bundles have been truncated", func() { quayCLI := container.NewQuayCLI() containerCLI := container.NewPodmanCLI() containerTool := "podman" indexImage := "quay.io/olmqe/ditto-index:43147" indexImageDep := "quay.io/olmqe/ditto-index:43147-dep" + getRandomString() indexImageOW := "quay.io/olmqe/ditto-index:43147-ow" + getRandomString() defer containerCLI.RemoveImage(indexImage) defer containerCLI.RemoveImage(indexImageDep) defer containerCLI.RemoveImage(indexImageOW) defer quayCLI.DeleteTag(strings.Replace(indexImageDep, "quay.io/", "", 1)) exutil.By("step: run deprecatetruncate") output, err := opmCLI.Run("index").Args("deprecatetruncate", "-b", "quay.io/olmqe/ditto-operator:0.1.1", "-f", indexImage, "-t", indexImageDep, "-c", containerTool).Output() if err != nil { e2e.Logf(output) } o.Expect(err).NotTo(o.HaveOccurred()) output, err = containerCLI.Run("push").Args(indexImageDep).Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } exutil.By("check there is no channel alpha") output, err = opmCLI.Run("alpha").Args("list", "channels", indexImageDep).Output() if err != nil { e2e.Logf(output) } o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(string(output)).NotTo(o.ContainSubstring("alpha")) o.Expect(string(output)).To(o.ContainSubstring("beta")) o.Expect(string(output)).NotTo(o.ContainSubstring("ditto-operator.v0.1.0")) exutil.By("re-adding the bundle") output, err = opmCLI.Run("index").Args("add", "-b", "quay.io/olmqe/ditto-operator:0.2.0-43147", "-f", indexImageDep, "-t", indexImageOW, "--overwrite-latest", "-c", containerTool).Output() if err != nil { e2e.Logf(output) } o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(string(output)).NotTo(o.ContainSubstring("ERRO")) exutil.By("step: 43147 SUCCESS") }) // author: [email protected] g.It("Author:xzha-ConnectedOnly-VMonly-Medium-43562-opm should raise error when adding an bundle whose version is higher than the bundle being added", func() { containerCLI := container.NewPodmanCLI() containerTool := "podman" indexImage := "quay.io/olmqe/ditto-index:43562" indexImage1 := "quay.io/olmqe/ditto-index:43562-1" + getRandomString() indexImage2 := "quay.io/olmqe/ditto-index:43562-2" + getRandomString() defer containerCLI.RemoveImage(indexImage) defer containerCLI.RemoveImage(indexImage1) defer containerCLI.RemoveImage(indexImage2) exutil.By("step: run add ditto-operator.v0.1.0 replace ditto-operator.v0.1.1") output1, err := opmCLI.Run("index").Args("add", "-b", "quay.io/olmqe/ditto-operator:43562-0.1.0", "-f", indexImage, "-t", indexImage1, "-c", containerTool).Output() o.Expect(err).To(o.HaveOccurred()) o.Expect(string(output1)).To(o.ContainSubstring("error")) o.Expect(string(output1)).To(o.ContainSubstring("permissive mode disabled")) o.Expect(string(output1)).To(o.ContainSubstring("this may be due to incorrect channel head")) output2, err := opmCLI.Run("index").Args("add", "-b", "quay.io/olmqe/ditto-operator:43562-0.1.2", "-f", indexImage, "-t", indexImage1, "-c", containerTool).Output() o.Expect(err).To(o.HaveOccurred()) o.Expect(string(output2)).To(o.ContainSubstring("error")) o.Expect(string(output2)).To(o.ContainSubstring("permissive mode disabled")) o.Expect(string(output2)).To(o.ContainSubstring("this may be due to incorrect channel head")) exutil.By("test case 43562 SUCCESS") }) // author: [email protected] g.It("ConnectedOnly-Author:xzha-VMonly-High-30786-Bundle addition commutativity", func() { var sqlit = db.NewSqlit() opmBaseDir := exutil.FixturePath("testdata", "opm") defer DeleteDir(opmBaseDir, "fixture-testdata") TestDataPath := filepath.Join(opmBaseDir, "temp") opmCLI.ExecCommandPath = TestDataPath var ( bundles [3]string bundleName [3]string indexName = "index30786" matched bool sqlResults []db.Channel ) exutil.By("Setup environment") // see OCP-30786 for creation of these images bundles[0] = "quay.io/olmqe/etcd-bundle:0.9.0-39795" bundles[1] = "quay.io/olmqe/etcd-bundle:0.9.2-39795" bundles[2] = "quay.io/olmqe/etcd-bundle:0.9.4-39795" bundleName[0] = "etcdoperator.v0.9.0" bundleName[1] = "etcdoperator.v0.9.2" bundleName[2] = "etcdoperator.v0.9.4" podmanCLI := container.NewPodmanCLI() containerCLI := podmanCLI indexTmpPath1 := filepath.Join(TestDataPath, "database") err := os.MkdirAll(indexTmpPath1, 0755) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("Create index image with a,b") index := 1 a := 0 b := 1 order := "a,b" s := fmt.Sprintf("%v,%v", bundles[a], bundles[b]) t1 := fmt.Sprintf("%v:%v", indexName, index) defer podmanCLI.RemoveImage(t1) msg, err := opmCLI.Run("index").Args("add", "-b", s, "-t", t1).Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf(msg) matched, _ = regexp.MatchString(fmt.Sprintf("bundles=.*%v %v", bundles[a], bundles[b]), msg) o.Expect(matched).To(o.BeTrue()) msg, err = containerCLI.Run("images").Args("-n", t1).Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("IMAGES in %v: %v", order, msg) o.Expect(msg).NotTo(o.BeEmpty()) podmanCLI.RemoveImage(t1) exutil.By("Generate db with a,b & check with sqlite") msg, err = opmCLI.Run("index").Args("add", "-b", s, "--generate").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf(msg) matched, _ = regexp.MatchString(fmt.Sprintf("bundles=.*%v %v", bundles[a], bundles[b]), msg) o.Expect(matched).To(o.BeTrue()) sqlResults, err = sqlit.QueryOperatorChannel(path.Join(indexTmpPath1, "index.db")) // force string compare o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("sqlite contents %v: %v", order, sqlResults) o.Expect(fmt.Sprintf("%v", sqlResults[0])).To(o.ContainSubstring(bundleName[1])) o.Expect(fmt.Sprintf("%v", sqlResults[1])).To(o.ContainSubstring(bundleName[0])) os.Remove(path.Join(indexTmpPath1, "index.db")) exutil.By("Create index image with b,a") index++ a = 1 b = 0 order = "b,a" s = fmt.Sprintf("%v,%v", bundles[a], bundles[b]) t2 := fmt.Sprintf("%v:%v", indexName, index) defer podmanCLI.RemoveImage(t2) msg, err = opmCLI.Run("index").Args("add", "-b", s, "-t", t2).Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf(msg) matched, _ = regexp.MatchString(fmt.Sprintf("bundles=.*%v %v", bundles[a], bundles[b]), msg) o.Expect(matched).To(o.BeTrue()) msg, err = containerCLI.Run("images").Args("-n", t2).Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("IMAGES in %v: %v", order, msg) o.Expect(msg).NotTo(o.BeEmpty()) podmanCLI.RemoveImage(t2) exutil.By("Generate db with b,a & check with sqlite") msg, err = opmCLI.Run("index").Args("add", "-b", s, "--generate").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf(msg) matched, _ = regexp.MatchString(fmt.Sprintf("bundles=.*%v %v", bundles[a], bundles[b]), msg) o.Expect(matched).To(o.BeTrue()) sqlResults, err = sqlit.QueryOperatorChannel(path.Join(indexTmpPath1, "index.db")) // force string compare o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("sqlite contents %v: %v", order, sqlResults) o.Expect(fmt.Sprintf("%v", sqlResults[0])).To(o.ContainSubstring(bundleName[1])) o.Expect(fmt.Sprintf("%v", sqlResults[1])).To(o.ContainSubstring(bundleName[0])) os.Remove(path.Join(indexTmpPath1, "index.db")) exutil.By("Create index image with a,b,c") index++ a = 0 b = 1 c := 2 order = "a,b,c" s = fmt.Sprintf("%v,%v,%v", bundles[a], bundles[b], bundles[c]) t3 := fmt.Sprintf("%v:%v", indexName, index) defer podmanCLI.RemoveImage(t3) msg, err = opmCLI.Run("index").Args("add", "-b", s, "-t", t3).Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf(msg) matched, _ = regexp.MatchString(fmt.Sprintf("bundles=.*%v %v %v", bundles[a], bundles[b], bundles[c]), msg) o.Expect(matched).To(o.BeTrue()) msg, err = containerCLI.Run("images").Args("-n", t3).Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("IMAGES in %v: %v", order, msg) o.Expect(msg).NotTo(o.BeEmpty()) podmanCLI.RemoveImage(t3) exutil.By("Generate db with a,b,c & check with sqlite") msg, err = opmCLI.Run("index").Args("add", "-b", s, "--generate").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf(msg) matched, _ = regexp.MatchString(fmt.Sprintf("bundles=.*%v %v %v", bundles[a], bundles[b], bundles[c]), msg) o.Expect(matched).To(o.BeTrue()) sqlResults, err = sqlit.QueryOperatorChannel(path.Join(indexTmpPath1, "index.db")) // force string compare o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("sqlite contents %v: %v", order, sqlResults) o.Expect(fmt.Sprintf("%v", sqlResults[0])).To(o.ContainSubstring(bundleName[2])) o.Expect(fmt.Sprintf("%v", sqlResults[1])).To(o.ContainSubstring(bundleName[1])) o.Expect(fmt.Sprintf("%v", sqlResults[2])).To(o.ContainSubstring(bundleName[0])) os.Remove(path.Join(indexTmpPath1, "index.db")) exutil.By("Create index image with b,c,a") index++ a = 1 b = 2 c = 0 order = "b,c,a" s = fmt.Sprintf("%v,%v,%v", bundles[a], bundles[b], bundles[c]) t4 := fmt.Sprintf("%v:%v", indexName, index) defer podmanCLI.RemoveImage(t4) msg, err = opmCLI.Run("index").Args("add", "-b", s, "-t", t4).Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf(msg) matched, _ = regexp.MatchString(fmt.Sprintf("bundles=.*%v %v %v", bundles[a], bundles[b], bundles[c]), msg) o.Expect(matched).To(o.BeTrue()) msg, err = containerCLI.Run("images").Args("-n", t4).Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("IMAGES in %v: %v", order, msg) o.Expect(msg).NotTo(o.BeEmpty()) podmanCLI.RemoveImage(t4) // no db check exutil.By("Create index image with c,a,b") index++ a = 2 b = 0 c = 1 order = "c,a,b" s = fmt.Sprintf("%v,%v,%v", bundles[a], bundles[b], bundles[c]) t5 := fmt.Sprintf("%v:%v", indexName, index) defer podmanCLI.RemoveImage(t5) msg, err = opmCLI.Run("index").Args("add", "-b", s, "-t", t5).Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf(msg) matched, _ = regexp.MatchString(fmt.Sprintf("bundles=.*%v %v %v", bundles[a], bundles[b], bundles[c]), msg) o.Expect(matched).To(o.BeTrue()) msg, err = containerCLI.Run("images").Args("-n", t5).Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("IMAGES in %v: %v", order, msg) o.Expect(msg).NotTo(o.BeEmpty()) podmanCLI.RemoveImage(t5) // no db check exutil.By("Generate db with b,a,c & check with sqlite") a = 1 b = 0 c = 2 order = "b,a,c" s = fmt.Sprintf("%v,%v,%v", bundles[a], bundles[b], bundles[c]) // no image check, just db msg, err = opmCLI.Run("index").Args("add", "-b", s, "--generate").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf(msg) matched, _ = regexp.MatchString(fmt.Sprintf("bundles=.*%v %v %v", bundles[a], bundles[b], bundles[c]), msg) o.Expect(matched).To(o.BeTrue()) sqlResults, err = sqlit.QueryOperatorChannel(path.Join(indexTmpPath1, "index.db")) // force string compare o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("sqlite contents %v: %v", order, sqlResults) o.Expect(fmt.Sprintf("%v", sqlResults[0])).To(o.ContainSubstring(bundleName[2])) o.Expect(fmt.Sprintf("%v", sqlResults[1])).To(o.ContainSubstring(bundleName[1])) o.Expect(fmt.Sprintf("%v", sqlResults[2])).To(o.ContainSubstring(bundleName[0])) os.Remove(path.Join(indexTmpPath1, "index.db")) exutil.By("Finished") }) // author: [email protected] g.It("ConnectedOnly-Author:scolange-VMonly-Medium-25935-Ability to modify the contents of an existing registry database", func() { containerCLI := container.NewPodmanCLI() containerTool := "podman" opmBaseDir := exutil.FixturePath("testdata", "opm") TmpDataPath := filepath.Join(opmBaseDir, "tmp") defer DeleteDir(TmpDataPath, "fixture-testdata") bundleImageTag1 := "quay.io/operator-framework/operator-bundle-prometheus:0.14.0" bundleImageTag2 := "quay.io/operator-framework/operator-bundle-prometheus:0.15.0" bundleImageTag3 := "quay.io/operator-framework/operator-bundle-prometheus:0.22.2" defer containerCLI.RemoveImage(bundleImageTag1) defer containerCLI.RemoveImage(bundleImageTag2) defer containerCLI.RemoveImage(bundleImageTag3) exutil.By("step: build bundle.db") dbFilePath := TmpDataPath + "bundles.db" if output, err := opmCLI.Run("registry").Args("add", "-b", bundleImageTag1, "-d", dbFilePath, "-c", containerTool, "--mode", "semver").Output(); err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } exutil.By("step1: modified the bundle.db already created") if output, err := opmCLI.Run("registry").Args("add", "-b", bundleImageTag2, "-d", dbFilePath, "-c", containerTool, "--mode", "semver").Output(); err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } exutil.By("step2: modified the bundle.db already created") if output, err := opmCLI.Run("registry").Args("add", "-b", bundleImageTag3, "-d", dbFilePath, "-c", containerTool, "--mode", "semver").Output(); err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } exutil.By("step: SUCCESS 25935") }) // author: [email protected] g.It("Author:xzha-Medium-45407-opm and oc should print sqlite deprecation warnings", func() { exutil.By("opm render --help") output, err := opmCLI.Run("render").Args("--help").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("DEPRECATION NOTICE:")) exutil.By("opm index --help") output, err = opmCLI.Run("index").Args("--help").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("DEPRECATION NOTICE:")) exutil.By("opm registry --help") output, err = opmCLI.Run("registry").Args("--help").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("DEPRECATION NOTICE:")) exutil.By("oc adm catalog mirror --help") output, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("catalog", "mirror", "--help").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("DEPRECATION NOTICE:")) exutil.By("45407 SUCCESS") }) // author: [email protected] g.It("Author:xzha-ConnectedOnly-VMonly-Medium-45403-opm index prune should report error if the working directory does not have write permissions", func() { podmanCLI := container.NewPodmanCLI() opmBaseDir := exutil.FixturePath("testdata", "opm") tmpPath := filepath.Join(opmBaseDir, "temp"+getRandomString()) defer DeleteDir(tmpPath, "fixture-testdata") exutil.By("step: mkdir with mode 0555") err := os.MkdirAll(tmpPath, 0555) o.Expect(err).NotTo(o.HaveOccurred()) opmCLI.ExecCommandPath = tmpPath exutil.By("step: opm index prune") containerTool := "podman" sourceImageTag := "quay.io/olmqe/multi-index:2.0" imageTag := "quay.io/olmqe/multi-index:45403-" + getRandomString() defer podmanCLI.RemoveImage(imageTag) output, err := opmCLI.Run("index").Args("prune", "-f", sourceImageTag, "-p", "planetscale", "-t", imageTag, "-c", containerTool).Output() o.Expect(err).To(o.HaveOccurred()) o.Expect(output).To(o.MatchRegexp("(?i)mkdir .* permission denied(?i)")) exutil.By("45403 SUCCESS") }) // author: [email protected] g.It("Author:xzha-ConnectedOnly-Medium-53869-opm supports creating a catalog using basic veneer", func() { if os.Getenv("HTTP_PROXY") != "" || os.Getenv("http_proxy") != "" { g.Skip("HTTP_PROXY is not empty - skipping test ...") } opmBaseDir := exutil.FixturePath("testdata", "opm", "53869") opmCLI.ExecCommandPath = opmBaseDir defer DeleteDir(opmBaseDir, "fixture-testdata") exutil.By("step: create dir catalog") catsrcPathYaml := filepath.Join(opmBaseDir, "catalog-yaml") err := os.MkdirAll(catsrcPathYaml, 0755) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("step: create a catalog using basic veneer with yaml format") output, err := opmCLI.Run("alpha").Args("render-template", "basic", filepath.Join(opmBaseDir, "catalog-basic-template.yaml"), "-o", "yaml").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(string(output)).To(o.ContainSubstring("nginx-operator")) indexFilePath := filepath.Join(catsrcPathYaml, "index.yaml") if err = ioutil.WriteFile(indexFilePath, []byte(output), 0644); err != nil { e2e.Failf(fmt.Sprintf("Writefile %s Error: %v", indexFilePath, err)) } output, err = opmCLI.Run("validate").Args(catsrcPathYaml).Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } output, err = opmCLI.Run("alpha").Args("list", "bundles", catsrcPathYaml).Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("quay.io/olmqe/nginxolm-operator-bundle:v0.0.1")) o.Expect(string(output)).To(o.ContainSubstring("quay.io/olmqe/nginxolm-operator-bundle:v1.0.1")) exutil.By("step: create dir catalog") catsrcPathJSON := filepath.Join(opmBaseDir, "catalog-json") err = os.MkdirAll(catsrcPathJSON, 0755) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("step: create a catalog using basic veneer with json format") output, err = opmCLI.Run("alpha").Args("render-template", "basic", filepath.Join(opmBaseDir, "catalog-basic-template.yaml"), "-o", "json").Output() o.Expect(err).NotTo(o.HaveOccurred()) indexFilePath = filepath.Join(catsrcPathJSON, "index.json") if err = ioutil.WriteFile(indexFilePath, []byte(output), 0644); err != nil { e2e.Failf(fmt.Sprintf("Writefile %s Error: %v", indexFilePath, err)) } output, err = opmCLI.Run("validate").Args(catsrcPathJSON).Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } output, err = opmCLI.Run("alpha").Args("list", "bundles", catsrcPathJSON, "nginx-operator").Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("quay.io/olmqe/nginxolm-operator-bundle:v0.0.1")) o.Expect(string(output)).To(o.ContainSubstring("quay.io/olmqe/nginxolm-operator-bundle:v1.0.1")) }) // author: [email protected] g.It("Author:xzha-ConnectedOnly-Medium-53871-Medium-53915-Medium-53996-opm supports creating a catalog using semver veneer", func() { if os.Getenv("HTTP_PROXY") != "" || os.Getenv("http_proxy") != "" { g.Skip("HTTP_PROXY is not empty - skipping test ...") } opmBaseDir := exutil.FixturePath("testdata", "opm", "53871") opmCLI.ExecCommandPath = opmBaseDir defer DeleteDir(opmBaseDir, "fixture-testdata") exutil.By("step: create dir catalog-1") catsrcPath1 := filepath.Join(opmBaseDir, "catalog-1") err := os.MkdirAll(catsrcPath1, 0755) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("step: GenerateMajorChannels: true GenerateMinorChannels: false") output, err := opmCLI.Run("alpha").Args("render-template", "semver", filepath.Join(opmBaseDir, "catalog-semver-veneer-1.yaml"), "-o", "yaml").Output() o.Expect(err).NotTo(o.HaveOccurred()) indexFilePath := filepath.Join(catsrcPath1, "index.yaml") if err = ioutil.WriteFile(indexFilePath, []byte(output), 0644); err != nil { e2e.Failf(fmt.Sprintf("Writefile %s Error: %v", indexFilePath, err)) } output, err = opmCLI.Run("validate").Args(catsrcPath1).Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } output, err = opmCLI.Run("alpha").Args("list", "channels", catsrcPath1, "nginx-operator").Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("candidate-v0 nginx-operator.v0.0.1")) o.Expect(string(output)).To(o.ContainSubstring("candidate-v1 nginx-operator.v1.0.2")) o.Expect(string(output)).To(o.ContainSubstring("candidate-v2 nginx-operator.v2.1.0")) o.Expect(string(output)).To(o.ContainSubstring("fast-v0 nginx-operator.v0.0.1")) o.Expect(string(output)).To(o.ContainSubstring("fast-v2 nginx-operator.v2.1.0")) o.Expect(string(output)).To(o.ContainSubstring("stable-v1 nginx-operator.v1.0.2")) o.Expect(string(output)).To(o.ContainSubstring("stable-v2 nginx-operator.v2.1.0")) exutil.By("step: create dir catalog-2") catsrcPath2 := filepath.Join(opmBaseDir, "catalog-2") err = os.MkdirAll(catsrcPath2, 0755) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("step: GenerateMajorChannels: true GenerateMinorChannels: true") output, err = opmCLI.Run("alpha").Args("render-template", "semver", filepath.Join(opmBaseDir, "catalog-semver-veneer-2.yaml"), "-o", "yaml").Output() o.Expect(err).NotTo(o.HaveOccurred()) indexFilePath = filepath.Join(catsrcPath2, "index.yaml") if err = ioutil.WriteFile(indexFilePath, []byte(output), 0644); err != nil { e2e.Failf(fmt.Sprintf("Writefile %s Error: %v", indexFilePath, err)) } output, err = opmCLI.Run("validate").Args(catsrcPath2).Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } output, err = opmCLI.Run("alpha").Args("list", "channels", catsrcPath2, "nginx-operator").Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("candidate-v0 nginx-operator.v0.0.1")) o.Expect(string(output)).To(o.ContainSubstring("candidate-v0.0 nginx-operator.v0.0.1")) o.Expect(string(output)).To(o.ContainSubstring("candidate-v1 nginx-operator.v1.0.1")) o.Expect(string(output)).To(o.ContainSubstring("candidate-v1.0 nginx-operator.v1.0.1")) o.Expect(string(output)).To(o.ContainSubstring("fast-v1 nginx-operator.v1.0.1-beta")) o.Expect(string(output)).To(o.ContainSubstring("fast-v1.0 nginx-operator.v1.0.1-beta")) o.Expect(string(output)).To(o.ContainSubstring("stable-v1 nginx-operator.v1.0.1")) o.Expect(string(output)).To(o.ContainSubstring("stable-v1.0 nginx-operator.v1.0.1")) exutil.By("step: create dir catalog-3") catsrcPath3 := filepath.Join(opmBaseDir, "catalog-3") err = os.MkdirAll(catsrcPath3, 0755) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("step: not set GenerateMajorChannels and GenerateMinorChannels") output, err = opmCLI.Run("alpha").Args("render-template", "semver", filepath.Join(opmBaseDir, "catalog-semver-veneer-3.yaml")).Output() o.Expect(err).NotTo(o.HaveOccurred()) indexFilePath = filepath.Join(catsrcPath3, "index.json") if err = ioutil.WriteFile(indexFilePath, []byte(output), 0644); err != nil { e2e.Failf(fmt.Sprintf("Writefile %s Error: %v", indexFilePath, err)) } output, err = opmCLI.Run("validate").Args(catsrcPath3).Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } output, err = opmCLI.Run("alpha").Args("list", "channels", catsrcPath3, "nginx-operator").Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).NotTo(o.ContainSubstring("candidate-v0 ")) o.Expect(string(output)).To(o.ContainSubstring("candidate-v0.0 nginx-operator.v0.0.1")) o.Expect(string(output)).NotTo(o.ContainSubstring("candidate-v1 ")) o.Expect(string(output)).To(o.ContainSubstring("candidate-v1.0 nginx-operator.v1.0.2")) o.Expect(string(output)).NotTo(o.ContainSubstring("fast-v0 ")) o.Expect(string(output)).To(o.ContainSubstring("fast-v0.0 nginx-operator.v0.0.1")) o.Expect(string(output)).NotTo(o.ContainSubstring("fast-v2 ")) o.Expect(string(output)).To(o.ContainSubstring("fast-v2.0 nginx-operator.v2.0.1")) o.Expect(string(output)).To(o.ContainSubstring("fast-v2.1 nginx-operator.v2.1.0")) o.Expect(string(output)).NotTo(o.ContainSubstring("stable-v2 ")) o.Expect(string(output)).To(o.ContainSubstring("stable-v2.1 nginx-operator.v2.1.0")) exutil.By("step: generate mermaid graph data for generated-channels") output, err = opmCLI.Run("alpha").Args("render-template", "semver", filepath.Join(opmBaseDir, "catalog-semver-veneer-4.yaml"), "-o", "mermaid").Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("channel \"fast-v2.0\"")) o.Expect(string(output)).To(o.ContainSubstring("subgraph nginx-operator-fast-v2.0[\"fast-v2.0\"]")) o.Expect(string(output)).To(o.ContainSubstring("nginx-operator-fast-v2.0-nginx-operator.v2.0.1[\"nginx-operator.v2.0.1\"]")) exutil.By("step: semver veneer should validate bundle versions") output, err = opmCLI.Run("alpha").Args("render-template", "semver", filepath.Join(opmBaseDir, "catalog-semver-veneer-5.yaml")).Output() o.Expect(err).To(o.HaveOccurred()) o.Expect(string(output)).To(o.ContainSubstring("encountered bundle versions which differ only by build metadata, which cannot be ordered")) o.Expect(string(output)).To(o.ContainSubstring("cannot be compared to \"1.0.1-alpha\"")) exutil.By("OCP-53996") filePath := filepath.Join(opmBaseDir, "catalog-semver-veneer-1.yaml") exutil.By("step: create dir catalog") catsrcPath53996 := filepath.Join(opmBaseDir, "catalog-53996") err = os.MkdirAll(catsrcPath53996, 0755) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("step: generate index.yaml with yaml format") command := "cat " + filePath + "| opm alpha render-template semver -o yaml - " contentByte, err := exec.Command("bash", "-c", command).Output() o.Expect(err).NotTo(o.HaveOccurred()) indexFilePath = filepath.Join(catsrcPath53996, "index.yaml") if err = ioutil.WriteFile(indexFilePath, contentByte, 0644); err != nil { e2e.Failf(fmt.Sprintf("Writefile %s Error: %v", indexFilePath, err)) } output, err = opmCLI.Run("validate").Args(catsrcPath53996).Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } output, err = opmCLI.Run("alpha").Args("list", "channels", catsrcPath53996, "nginx-operator").Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("candidate-v0 nginx-operator.v0.0.1")) o.Expect(string(output)).To(o.ContainSubstring("candidate-v1 nginx-operator.v1.0.2")) o.Expect(string(output)).To(o.ContainSubstring("candidate-v2 nginx-operator.v2.1.0")) o.Expect(string(output)).To(o.ContainSubstring("fast-v0 nginx-operator.v0.0.1")) o.Expect(string(output)).To(o.ContainSubstring("fast-v2 nginx-operator.v2.1.0")) o.Expect(string(output)).To(o.ContainSubstring("stable-v1 nginx-operator.v1.0.2")) o.Expect(string(output)).To(o.ContainSubstring("stable-v2 nginx-operator.v2.1.0")) exutil.By("step: generate json format file") command = "cat " + filePath + `| opm alpha render-template semver - | jq 'select(.schema=="olm.channel")'| jq '{name,entries}'` contentByte, err = exec.Command("bash", "-c", command).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(string(contentByte)).To(o.ContainSubstring("nginx-operator.v1.0.2")) o.Expect(string(contentByte)).To(o.ContainSubstring("candidate-v1")) exutil.By("step: generate mermaid graph data for generated-channels") command = "cat " + filePath + "| opm alpha render-template semver -o mermaid -" contentByte, err = exec.Command("bash", "-c", command).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(string(contentByte)).To(o.ContainSubstring("package \"nginx-operator\"")) o.Expect(string(contentByte)).To(o.ContainSubstring("nginx-operator-candidate-v1-nginx-operator.v1.0.1")) }) // author: [email protected] g.It("Author:xzha-ConnectedOnly-Medium-53917-opm can visualize the update graph for a given Operator from an arbitrary version", func() { if os.Getenv("HTTP_PROXY") != "" || os.Getenv("http_proxy") != "" { g.Skip("HTTP_PROXY is not empty - skipping test ...") } exutil.By("step: check help message") output, err := opmCLI.Run("alpha").Args("render-graph", "-h").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(string(output)).To(o.ContainSubstring("--minimum-edge")) o.Expect(string(output)).To(o.ContainSubstring("--use-http")) exutil.By("step: opm alpha render-graph index-image") output, err = opmCLI.Run("alpha").Args("render-graph", "quay.io/olmqe/nginxolm-operator-index:v1").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(string(output)).To(o.ContainSubstring("package \"nginx-operator\"")) o.Expect(string(output)).To(o.ContainSubstring("subgraph nginx-operator-alpha[\"alpha\"]")) exutil.By("step: opm alpha render-graph index-image with --minimum-edge") output, err = opmCLI.Run("alpha").Args("render-graph", "quay.io/olmqe/nginxolm-operator-index:v1", "--minimum-edge", "nginx-operator.v1.0.1").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(string(output)).To(o.ContainSubstring("package \"nginx-operator\"")) o.Expect(string(output)).To(o.ContainSubstring("nginx-operator.v1.0.1")) o.Expect(string(output)).NotTo(o.ContainSubstring("nginx-operator.v0.0.1")) exutil.By("step: create dir catalog") catsrcPath := filepath.Join("/tmp", "53917-catalog") defer os.RemoveAll(catsrcPath) errCreateDir := os.MkdirAll(catsrcPath, 0755) o.Expect(errCreateDir).NotTo(o.HaveOccurred()) exutil.By("step: opm alpha render-graph fbc-dir") output, err = opmCLI.Run("render").Args("quay.io/olmqe/nginxolm-operator-index:v1", "-o", "json").Output() o.Expect(err).NotTo(o.HaveOccurred()) indexFilePath := filepath.Join(catsrcPath, "index.json") if err = ioutil.WriteFile(indexFilePath, []byte(output), 0644); err != nil { e2e.Failf(fmt.Sprintf("Writefile %s Error: %v", indexFilePath, err)) } output, err = opmCLI.Run("alpha").Args("render-graph", catsrcPath).Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("package \"nginx-operator\"")) o.Expect(string(output)).To(o.ContainSubstring("subgraph nginx-operator-alpha[\"alpha\"]")) exutil.By("step: opm alpha render-graph sqlit-based catalog image") output, err = opmCLI.Run("alpha").Args("render-graph", "quay.io/olmqe/ditto-index:v1beta1").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(string(output)).To(o.ContainSubstring("subgraph \"ditto-operator\"")) o.Expect(string(output)).To(o.ContainSubstring("subgraph ditto-operator-alpha[\"alpha\"]")) o.Expect(string(output)).To(o.ContainSubstring("ditto-operator.v0.2.0")) }) // author: [email protected] g.It("ConnectedOnly-Author:scolange-VMonly-Medium-25934-Reference non-latest versions of bundles by image digests", func() { containerCLI := container.NewPodmanCLI() containerTool := "podman" opmBaseDir := exutil.FixturePath("testdata", "opm") TmpDataPath := filepath.Join(opmBaseDir, "tmp") err := os.MkdirAll(TmpDataPath, 0755) o.Expect(err).NotTo(o.HaveOccurred()) bundleImageTag1 := "quay.io/olmqe/etcd-bundle:0.9.0" bundleImageTag2 := "quay.io/olmqe/etcd-bundle:0.9.0-25934" defer DeleteDir(TmpDataPath, "fixture-testdata") defer containerCLI.RemoveImage(bundleImageTag2) defer containerCLI.RemoveImage(bundleImageTag1) defer exec.Command("kill", "-9", "$(lsof -t -i:25934)").Output() if output, err := containerCLI.Run("pull").Args(bundleImageTag1).Output(); err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } if output, err := containerCLI.Run("tag").Args(bundleImageTag1, bundleImageTag2).Output(); err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } if output, err := containerCLI.Run("push").Args(bundleImageTag2).Output(); err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } exutil.By("step: build bundle.db") dbFilePath := TmpDataPath + "bundles.db" if output, err := opmCLI.Run("registry").Args("add", "-b", bundleImageTag2, "-d", dbFilePath, "-c", containerTool, "--mode", "semver").Output(); err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } exutil.By("step: Run the opm registry server binary to load manifest and serves a grpc API to query it.") e2e.Logf("step: Run the registry-server ") cmd := exec.Command("opm", "registry", "serve", "-d", dbFilePath, "-p", "25934") e2e.Logf("cmd %v:", cmd) cmd.Dir = TmpDataPath err = cmd.Start() e2e.Logf("cmd %v raise error: %v", cmd, err) o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("step: check api.Registry/ListPackages") err = wait.PollUntilContextTimeout(context.TODO(), 20*time.Second, 240*time.Second, false, func(ctx context.Context) (bool, error) { outputCurl, err := exec.Command("grpcurl", "-plaintext", "localhost:25934", "api.Registry/ListPackages").Output() o.Expect(err).NotTo(o.HaveOccurred()) if strings.Contains(string(outputCurl), "etcd") { return true, nil } return false, nil }) exutil.AssertWaitPollNoErr(err, fmt.Sprintf("grpcurl %s not listet package", dbFilePath)) e2e.Logf("step: check api.Registry/GetBundleForChannel") outputCurl, err := exec.Command("grpcurl", "-plaintext", "localhost:25934", "api.Registry/ListBundles").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(string(outputCurl)).To(o.ContainSubstring("bundlePath")) cmd.Process.Kill() exutil.By("step: SUCCESS 25934") }) // author: [email protected] g.It("ConnectedOnly-Author:scolange-VMonly-Medium-47222-can't remove package from index: database is locked", func() { podmanCLI := container.NewPodmanCLI() baseDir := exutil.FixturePath("testdata", "olm") TestDataPath := filepath.Join(baseDir, "temp") indexTmpPath := filepath.Join(TestDataPath, getRandomString()) defer DeleteDir(TestDataPath, indexTmpPath) err := os.MkdirAll(indexTmpPath, 0755) o.Expect(err).NotTo(o.HaveOccurred()) indexImage := "registry.redhat.io/redhat/certified-operator-index:v4.7" exutil.By("remove package from index") dockerconfigjsonpath := filepath.Join(indexTmpPath, ".dockerconfigjson") defer exec.Command("rm", "-f", dockerconfigjsonpath).Output() _, err = oc.AsAdmin().Run("extract").Args("secret/pull-secret", "-n", "openshift-config", "--confirm", "--to="+indexTmpPath).Output() o.Expect(err).NotTo(o.HaveOccurred()) opmCLI.SetAuthFile(dockerconfigjsonpath) defer podmanCLI.RemoveImage(indexImage) output, err := opmCLI.Run("index").Args("rm", "--generate", "--binary-image", "registry.redhat.io/openshift4/ose-operator-registry:v4.7", "--from-index", indexImage, "--operators", "cert-manager-operator", "--pull-tool=podman").Output() e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("test case 47222 SUCCESS") }) // author: [email protected] g.It("ConnectedOnly-Author:jitli-Medium-60573-opm exclude bundles with olm.deprecated property when rendering", func() { exutil.By("opm render the sqlite index image message") msg, err := opmCLI.Run("render").Args("quay.io/olmqe/catalogtest-index:v4.12depre", "-oyaml").Output() o.Expect(err).NotTo(o.HaveOccurred()) if strings.Contains(msg, "olm.deprecated") { e2e.Failf("opm render the sqlite index image message, doesn't show the bundle with olm.dreprecated label") } exutil.By("opm render the fbc index image message") msg, err = opmCLI.Run("render").Args("quay.io/olmqe/test-index:mix", "-oyaml").Output() o.Expect(err).NotTo(o.HaveOccurred()) if strings.Contains(msg, "olm.deprecated") { e2e.Logf("opm render the fbc index image message, still show the bundle with olm.dreprecated label") } else { e2e.Failf("opm render the fbc index image message, should show the bundle with olm.dreprecated label") } }) // author: [email protected] g.It("Author:jitli-ConnectedOnly-Medium-73218-opm alpha render-graph indicate deprecated graph content", func() { if os.Getenv("HTTP_PROXY") != "" || os.Getenv("http_proxy") != "" { g.Skip("HTTP_PROXY is not empty - skipping test ...") } exutil.By("step: opm alpha render-graph index-image with deprecated label") output, err := opmCLI.Run("alpha").Args("render-graph", "quay.io/olmqe/olmtest-operator-index:nginxolm73218").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(string(output)).To(o.ContainSubstring("classDef deprecated fill:#E8960F")) o.Expect(string(output)).To(o.ContainSubstring("nginx73218-candidate-v1.0-nginx73218.v1.0.1[\"nginx73218.v1.0.1\"]:::deprecated")) o.Expect(string(output)).To(o.ContainSubstring("nginx73218-candidate-v1.0-nginx73218.v1.0.1[\"nginx73218.v1.0.1\"]-- skip --> nginx73218-candidate-v1.0-nginx73218.v1.0.3[\"nginx73218.v1.0.3\"]")) }) // author: [email protected] g.It("Author:jitli-VMonly-ConnectedOnly-High-75148-opm generate binary-less dockerfiles", func() { tmpBasePath := "/tmp/ocp-75148-" + getRandomString() tmpPath := filepath.Join(tmpBasePath, "catalog") dockerFile := filepath.Join(tmpBasePath, "catalog.Dockerfile") err := os.MkdirAll(tmpPath, 0o755) o.Expect(err).NotTo(o.HaveOccurred()) defer os.RemoveAll(tmpBasePath) opmCLI.ExecCommandPath = tmpBasePath exutil.By("Check flag --binary-image has been deprecated") output, err := opmCLI.Run("generate").Args("dockerfile", "--binary-image", "quay.io/operator-framework/opm:latest", "catalog").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("--binary-image has been deprecated, use --base-image instead")) err = os.Remove(dockerFile) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("Check parameter --base-image and --builder-image") _, err = opmCLI.Run("generate").Args("dockerfile", "catalog", "-i", "quay.io/openshifttest/opm:v1", "-b", "quay.io/openshifttest/opm:v2").Output() o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("Check the custom images in Dockerfile") waitErr := wait.PollUntilContextTimeout(context.TODO(), 2*time.Second, 6*time.Second, false, func(ctx context.Context) (bool, error) { if _, err := os.Stat(dockerFile); os.IsNotExist(err) { e2e.Logf("get catalog.Dockerfile Failed") return false, nil } return true, nil }) exutil.AssertWaitPollNoErr(waitErr, "get catalog.Dockerfile Failed") content, err := ioutil.ReadFile(dockerFile) o.Expect(err).NotTo(o.HaveOccurred()) if !strings.Contains(string(content), "FROM quay.io/openshifttest/opm:v2 as builder") || !strings.Contains(string(content), "FROM quay.io/openshifttest/opm:v1") { e2e.Failf("Fail to get the custom images in Dockerfile") } err = os.Remove(dockerFile) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("Create a binary-less dockerfile") _, err = opmCLI.Run("generate").Args("dockerfile", "catalog", "--base-image=scratch").Output() o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("Check the custom images in Dockerfile") waitErr = wait.PollUntilContextTimeout(context.TODO(), 2*time.Second, 6*time.Second, false, func(ctx context.Context) (bool, error) { if _, err := os.Stat(dockerFile); os.IsNotExist(err) { e2e.Logf("get catalog.Dockerfile Failed") return false, nil } return true, nil }) exutil.AssertWaitPollNoErr(waitErr, "get catalog.Dockerfile Failed") content, err = ioutil.ReadFile(dockerFile) o.Expect(err).NotTo(o.HaveOccurred()) if !strings.Contains(string(content), "OLMv0 CatalogSources that use binary-less images must set:") || !strings.Contains(string(content), "extractContent:") || !strings.Contains(string(content), "FROM scratch") { e2e.Failf("Fail to get the scratch in Dockerfile") } err = os.Remove(dockerFile) o.Expect(err).NotTo(o.HaveOccurred()) }) })
package opm
test case
openshift/openshift-tests-private
c8a0c4a1-a59c-47d5-ba38-45d539df8a86
Author:scolange-Medium-43769-Remove opm alpha add command
github.com/openshift/openshift-tests-private/test/extended/opm/opm.go
g.It("Author:scolange-Medium-43769-Remove opm alpha add command", func() { exutil.By("step: opm alpha --help") output1, err := opmCLI.Run("alpha").Args("--help").Output() e2e.Logf(output1) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output1).NotTo(o.ContainSubstring("add")) exutil.By("test case 43769 SUCCESS") })
test case
openshift/openshift-tests-private
574fbc58-4a69-4e14-88ca-9359f69b06bc
Author:kuiwang-Medium-43185-DC based opm subcommands out of alpha
github.com/openshift/openshift-tests-private/test/extended/opm/opm.go
g.It("Author:kuiwang-Medium-43185-DC based opm subcommands out of alpha", func() { exutil.By("check init, serve, render and validate under opm") output, err := opmCLI.Run("").Args("--help").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf(output) o.Expect(output).To(o.ContainSubstring("init ")) o.Expect(output).To(o.ContainSubstring("serve ")) o.Expect(output).To(o.ContainSubstring("render ")) o.Expect(output).To(o.ContainSubstring("validate ")) exutil.By("check init, serve, render and validate not under opm alpha") output, err = opmCLI.Run("alpha").Args("--help").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf(output) o.Expect(output).NotTo(o.ContainSubstring("init ")) o.Expect(output).NotTo(o.ContainSubstring("serve ")) o.Expect(output).NotTo(o.ContainSubstring("render ")) o.Expect(output).NotTo(o.ContainSubstring("validate ")) })
test case
openshift/openshift-tests-private
fad8c82a-1803-48f0-90b8-61a0e5fa350c
ConnectedOnly-Author:kuiwang-Medium-43171-opm render blob from bundle, db based index, dc based index, db file and directory
['"path/filepath"', 'db "github.com/openshift/openshift-tests-private/test/extended/util/db"']
github.com/openshift/openshift-tests-private/test/extended/opm/opm.go
g.It("ConnectedOnly-Author:kuiwang-Medium-43171-opm render blob from bundle, db based index, dc based index, db file and directory", func() { exutil.By("render db-based index image") output, err := opmCLI.Run("render").Args("quay.io/olmqe/olm-index:OLM-2199").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("\"name\": \"cockroachdb\"")) o.Expect(output).To(o.ContainSubstring("\"name\": \"cockroachdb.v5.0.3\"")) o.Expect(output).To(o.ContainSubstring("\"image\": \"quay.io/olmqe/cockroachdb-operator:5.0.3-2199\"")) o.Expect(output).To(o.ContainSubstring("quay.io/helmoperators/cockroachdb:v5.0.3")) o.Expect(output).To(o.ContainSubstring("\"name\": \"cockroachdb.v5.0.4\"")) o.Expect(output).To(o.ContainSubstring("\"replaces\": \"cockroachdb.v5.0.3\"")) o.Expect(output).To(o.ContainSubstring("quay.io/helmoperators/cockroachdb:v5.0.4")) o.Expect(output).To(o.ContainSubstring("\"name\": \"windup-operator.0.0.4\"")) o.Expect(output).To(o.ContainSubstring("quay.io/windupeng/windup-operator-native:0.0.4")) o.Expect(output).To(o.ContainSubstring("\"name\": \"windup-operator.0.0.5\"")) o.Expect(output).To(o.ContainSubstring("quay.io/windupeng/windup-operator-native:0.0.5")) exutil.By("render dc-based index image with one file") output, err = opmCLI.Run("render").Args("quay.io/olmqe/olm-index:OLM-2199-DC-example").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("\"name\": \"cockroachdb\"")) o.Expect(output).To(o.ContainSubstring("\"name\": \"cockroachdb.v5.0.3\"")) o.Expect(output).To(o.ContainSubstring("\"image\": \"quay.io/olmqe/cockroachdb-operator:5.0.3-2199\"")) o.Expect(output).To(o.ContainSubstring("quay.io/helmoperators/cockroachdb:v5.0.3")) o.Expect(output).To(o.ContainSubstring("\"name\": \"cockroachdb.v5.0.4\"")) o.Expect(output).To(o.ContainSubstring("\"replaces\": \"cockroachdb.v5.0.3\"")) o.Expect(output).To(o.ContainSubstring("quay.io/helmoperators/cockroachdb:v5.0.4")) o.Expect(output).To(o.ContainSubstring("\"name\": \"windup-operator.0.0.4\"")) o.Expect(output).To(o.ContainSubstring("quay.io/windupeng/windup-operator-native:0.0.4")) o.Expect(output).To(o.ContainSubstring("\"name\": \"windup-operator.0.0.5\"")) o.Expect(output).To(o.ContainSubstring("quay.io/windupeng/windup-operator-native:0.0.5")) exutil.By("render dc-based index image with different files") output, err = opmCLI.Run("render").Args("quay.io/olmqe/olm-index:OLM-2199-DC-example-Df").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("\"name\": \"cockroachdb\"")) o.Expect(output).To(o.ContainSubstring("\"name\": \"cockroachdb.v5.0.3\"")) o.Expect(output).To(o.ContainSubstring("\"image\": \"quay.io/olmqe/cockroachdb-operator:5.0.3-2199\"")) o.Expect(output).To(o.ContainSubstring("quay.io/helmoperators/cockroachdb:v5.0.3")) o.Expect(output).To(o.ContainSubstring("\"name\": \"cockroachdb.v5.0.4\"")) o.Expect(output).To(o.ContainSubstring("\"replaces\": \"cockroachdb.v5.0.3\"")) o.Expect(output).To(o.ContainSubstring("quay.io/helmoperators/cockroachdb:v5.0.4")) o.Expect(output).To(o.ContainSubstring("\"name\": \"windup-operator.0.0.4\"")) o.Expect(output).To(o.ContainSubstring("quay.io/windupeng/windup-operator-native:0.0.4")) o.Expect(output).To(o.ContainSubstring("\"name\": \"windup-operator.0.0.5\"")) o.Expect(output).To(o.ContainSubstring("quay.io/windupeng/windup-operator-native:0.0.5")) exutil.By("render dc-based index image with different directory") output, err = opmCLI.Run("render").Args("quay.io/olmqe/olm-index:OLM-2199-DC-example-Dd").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("\"name\": \"cockroachdb\"")) o.Expect(output).To(o.ContainSubstring("\"name\": \"cockroachdb.v5.0.3\"")) o.Expect(output).To(o.ContainSubstring("\"image\": \"quay.io/olmqe/cockroachdb-operator:5.0.3-2199\"")) o.Expect(output).To(o.ContainSubstring("quay.io/helmoperators/cockroachdb:v5.0.3")) o.Expect(output).To(o.ContainSubstring("\"name\": \"cockroachdb.v5.0.4\"")) o.Expect(output).To(o.ContainSubstring("\"replaces\": \"cockroachdb.v5.0.3\"")) o.Expect(output).To(o.ContainSubstring("quay.io/helmoperators/cockroachdb:v5.0.4")) o.Expect(output).To(o.ContainSubstring("\"name\": \"windup-operator.0.0.4\"")) o.Expect(output).To(o.ContainSubstring("quay.io/windupeng/windup-operator-native:0.0.4")) o.Expect(output).To(o.ContainSubstring("\"name\": \"windup-operator.0.0.5\"")) o.Expect(output).To(o.ContainSubstring("quay.io/windupeng/windup-operator-native:0.0.5")) exutil.By("render bundle image") output, err = opmCLI.Run("render").Args("quay.io/olmqe/cockroachdb-operator:5.0.4-2199", "quay.io/olmqe/cockroachdb-operator:5.0.3-2199").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).NotTo(o.ContainSubstring("\"name\": \"cockroachdb\"")) o.Expect(output).To(o.ContainSubstring("\"name\": \"cockroachdb.v5.0.4\"")) o.Expect(output).To(o.ContainSubstring("\"name\": \"cockroachdb.v5.0.3\"")) o.Expect(output).To(o.ContainSubstring("\"package\": \"cockroachdb\"")) o.Expect(output).To(o.ContainSubstring("quay.io/helmoperators/cockroachdb:v5.0.4")) o.Expect(output).To(o.ContainSubstring("quay.io/helmoperators/cockroachdb:v5.0.3")) o.Expect(output).To(o.ContainSubstring("\"group\": \"charts.operatorhub.io\"")) o.Expect(output).To(o.ContainSubstring("\"version\": \"5.0.4\"")) o.Expect(output).To(o.ContainSubstring("\"version\": \"5.0.3\"")) exutil.By("render directory") opmBaseDir := exutil.FixturePath("testdata", "opm") configDir := filepath.Join(opmBaseDir, "render", "configs") output, err = opmCLI.Run("render").Args(configDir).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("\"name\": \"cockroachdb\"")) o.Expect(output).To(o.ContainSubstring("\"name\": \"cockroachdb.v5.0.3\"")) o.Expect(output).To(o.ContainSubstring("\"image\": \"quay.io/olmqe/cockroachdb-operator:5.0.3-2199\"")) o.Expect(output).To(o.ContainSubstring("quay.io/helmoperators/cockroachdb:v5.0.3")) o.Expect(output).To(o.ContainSubstring("\"name\": \"cockroachdb.v5.0.4\"")) o.Expect(output).To(o.ContainSubstring("\"replaces\": \"cockroachdb.v5.0.3\"")) o.Expect(output).To(o.ContainSubstring("quay.io/helmoperators/cockroachdb:v5.0.4")) o.Expect(output).To(o.ContainSubstring("\"name\": \"windup-operator.0.0.4\"")) o.Expect(output).To(o.ContainSubstring("quay.io/windupeng/windup-operator-native:0.0.4")) o.Expect(output).To(o.ContainSubstring("\"name\": \"windup-operator.0.0.5\"")) o.Expect(output).To(o.ContainSubstring("quay.io/windupeng/windup-operator-native:0.0.5")) })
test case
openshift/openshift-tests-private
96b6020c-30c7-4dc3-a2c4-b50f06bc92e0
Author:kuiwang-Medium-43180-opm init dc configuration package
['"path/filepath"']
github.com/openshift/openshift-tests-private/test/extended/opm/opm.go
g.It("Author:kuiwang-Medium-43180-opm init dc configuration package", func() { exutil.By("init package") opmBaseDir := exutil.FixturePath("testdata", "opm") readme := filepath.Join(opmBaseDir, "render", "init", "readme.md") testpng := filepath.Join(opmBaseDir, "render", "init", "test.png") output, err := opmCLI.Run("init").Args("--default-channel=alpha", "-d", readme, "-i", testpng, "mta-operator").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf(output) o.Expect(output).To(o.ContainSubstring("\"schema\": \"olm.package\"")) o.Expect(output).To(o.ContainSubstring("\"name\": \"mta-operator\"")) o.Expect(output).To(o.ContainSubstring("\"defaultChannel\": \"alpha\"")) o.Expect(output).To(o.ContainSubstring("zcfHkVw9GfpbJmeev9F08WW8uDkaslwX6avlWGU6N")) o.Expect(output).To(o.ContainSubstring("\"description\": \"it is testing\"")) })
test case
openshift/openshift-tests-private
91ce17bf-9c8a-4c46-90ad-6510195b74f7
Author:kuiwang-Medium-43248-Support ignoring files when loading declarative configs
['"path"']
github.com/openshift/openshift-tests-private/test/extended/opm/opm.go
g.It("Author:kuiwang-Medium-43248-Support ignoring files when loading declarative configs", func() { opmBaseDir := exutil.FixturePath("testdata", "opm") correctIndex := path.Join(opmBaseDir, "render", "validate", "configs") wrongIndex := path.Join(opmBaseDir, "render", "validate", "configs-wrong") wrongIgnoreIndex := path.Join(opmBaseDir, "render", "validate", "configs-wrong-ignore") exutil.By("validate correct index") output, err := opmCLI.Run("validate").Args(correctIndex).Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf(output) exutil.By("validate wrong index") output, err = opmCLI.Run("validate").Args(wrongIndex).Output() o.Expect(err).To(o.HaveOccurred()) e2e.Logf(output) exutil.By("validate index with ignore wrong json") output, err = opmCLI.Run("validate").Args(wrongIgnoreIndex).Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf(output) })
test case
openshift/openshift-tests-private
87f88568-dbab-4e84-8442-34730f910be4
Author:jitli-Medium-43768-Improve formatting of opm alpha validate
['"path"']
github.com/openshift/openshift-tests-private/test/extended/opm/opm.go
g.It("Author:jitli-Medium-43768-Improve formatting of opm alpha validate", func() { opmBase := exutil.FixturePath("testdata", "opm") catalogdir := path.Join(opmBase, "render", "validate", "catalog") catalogerrdir := path.Join(opmBase, "render", "validate", "catalog-error") exutil.By("step: opm validate -h") output1, err := opmCLI.Run("validate").Args("--help").Output() e2e.Logf(output1) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output1).To(o.ContainSubstring("opm validate ")) exutil.By("opm validate catalog") output, err := opmCLI.Run("validate").Args(catalogdir).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.BeEmpty()) exutil.By("opm validate catalog-error") output, err = opmCLI.Run("validate").Args(catalogerrdir).Output() o.Expect(err).To(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("invalid package \\\"operator-1\\\"")) o.Expect(output).To(o.ContainSubstring("invalid channel \\\"alpha\\\"")) o.Expect(output).To(o.ContainSubstring("invalid bundle \\\"operator-1.v0.3.0\\\"")) e2e.Logf(output) })
test case
openshift/openshift-tests-private
8852c718-9ffa-434f-8dce-8337899feee9
Author:xzha-Medium-45401-opm validate should detect cycles in channels
['"path"', '"strings"']
github.com/openshift/openshift-tests-private/test/extended/opm/opm.go
g.It("Author:xzha-Medium-45401-opm validate should detect cycles in channels", func() { opmBase := exutil.FixturePath("testdata", "opm") catalogerrdir := path.Join(opmBase, "render", "validate", "catalog-error", "operator-1") exutil.By("opm validate catalog-error/operator-1") output, err := opmCLI.Run("validate").Args(catalogerrdir).Output() if err != nil { e2e.Logf(output) } o.Expect(err).To(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("invalid channel \\\"45401-1\\\"")) o.Expect(output).To(o.ContainSubstring("invalid channel \\\"45401-2\\\"")) o.Expect(output).To(o.ContainSubstring("invalid channel \\\"45401-3\\\"")) channelInfoList := strings.Split(output, "invalid channel") for _, channelInfo := range channelInfoList { if strings.Contains(channelInfo, "45401-1") { o.Expect(channelInfo).To(o.ContainSubstring("detected cycle in replaces chain of upgrade graph")) } if strings.Contains(channelInfo, "45401-2") { o.Expect(output).To(o.ContainSubstring("multiple channel heads found in graph")) } if strings.Contains(channelInfo, "45401-3") { o.Expect(output).To(o.ContainSubstring("no channel head found in graph")) } } exutil.By("45401 SUCCESS") })
test case
openshift/openshift-tests-private
d46d0b87-93b5-48f8-89c5-13d3fc40b97f
ConnectedOnly-Author:xzha-Medium-45402-opm render should automatically pulling in the image(s) used in the deployments
['"strings"']
github.com/openshift/openshift-tests-private/test/extended/opm/opm.go
g.It("ConnectedOnly-Author:xzha-Medium-45402-opm render should automatically pulling in the image(s) used in the deployments", func() { exutil.By("render bundle image") output, err := opmCLI.Run("render").Args("quay.io/olmqe/mta-operator:v0.0.4-45402", "quay.io/olmqe/eclipse-che:7.32.2-45402", "-oyaml").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("---")) bundleConfigBlobs := strings.Split(output, "---") for _, bundleConfigBlob := range bundleConfigBlobs { if strings.Contains(bundleConfigBlob, "packageName: mta-operator") { exutil.By("check putput of render bundle image which has no relatedimages defined in csv") o.Expect(bundleConfigBlob).To(o.ContainSubstring("relatedImages")) relatedImages := strings.Split(bundleConfigBlob, "relatedImages")[1] o.Expect(relatedImages).To(o.ContainSubstring("quay.io/olmqe/mta-operator:v0.0.4-45402")) o.Expect(relatedImages).To(o.ContainSubstring("quay.io/windupeng/windup-operator-native:0.0.4")) continue } if strings.Contains(bundleConfigBlob, "packageName: eclipse-che") { exutil.By("check putput of render bundle image which has relatedimages defined in csv") o.Expect(bundleConfigBlob).To(o.ContainSubstring("relatedImages")) relatedImages := strings.Split(bundleConfigBlob, "relatedImages")[1] o.Expect(relatedImages).To(o.ContainSubstring("index.docker.io/codercom/code-server")) o.Expect(relatedImages).To(o.ContainSubstring("quay.io/olmqe/eclipse-che:7.32.2-45402")) } } })
test case
openshift/openshift-tests-private
95db181e-02e8-4593-8867-e51f708a0cef
ConnectedOnly-Author:xzha-Medium-48438-opm render should support olm.constraint which is defined in dependencies
['"strings"']
github.com/openshift/openshift-tests-private/test/extended/opm/opm.go
g.It("ConnectedOnly-Author:xzha-Medium-48438-opm render should support olm.constraint which is defined in dependencies", func() { exutil.By("render bundle image") output, err := opmCLI.Run("render").Args("quay.io/olmqe/etcd-bundle:v0.9.2-48438", "-oyaml").Output() o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("check output of render bundle image contain olm.constraint which is defined in dependencies.yaml") if !strings.Contains(output, "olm.constraint") { e2e.Failf("output doesn't contain olm.constraint") } //exutil.By("check output of render bundle image contain olm.csv.metadata") //if !strings.Contains(output, "olm.csv.metadata") { // e2e.Failf("output doesn't contain olm.csv.metadata") //} })
test case
openshift/openshift-tests-private
b4238dbf-347f-40f0-979c-d2ef96e179c9
ConnectedOnly-VMonly-Author:xzha-High-30189-OPM can pull and unpack bundle images in a container
['"os/exec"', 'container "github.com/openshift/openshift-tests-private/test/extended/util/container"']
github.com/openshift/openshift-tests-private/test/extended/opm/opm.go
g.It("ConnectedOnly-VMonly-Author:xzha-High-30189-OPM can pull and unpack bundle images in a container", func() { imageTag := "quay.io/openshift/origin-operator-registry" containerCLI := container.NewPodmanCLI() containerName := "test-30189-" + getRandomString() e2e.Logf("create container with image %s", imageTag) id, err := containerCLI.ContainerCreate(imageTag, containerName, "/bin/sh", true) defer func() { e2e.Logf("stop container %s", id) containerCLI.ContainerStop(id) e2e.Logf("remove container %s", id) err := containerCLI.ContainerRemove(id) if err != nil { e2e.Failf("Defer: fail to remove container %s", id) } }() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("container id is %s", id) e2e.Logf("start container %s", id) err = containerCLI.ContainerStart(id) o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("start container %s successful", id) e2e.Logf("get grpcurl") _, err = containerCLI.Exec(id, []string{"wget", "https://github.com/fullstorydev/grpcurl/releases/download/v1.6.0/grpcurl_1.6.0_linux_x86_64.tar.gz"}) o.Expect(err).NotTo(o.HaveOccurred()) _, err = containerCLI.Exec(id, []string{"tar", "xzf", "grpcurl_1.6.0_linux_x86_64.tar.gz"}) o.Expect(err).NotTo(o.HaveOccurred()) _, err = containerCLI.Exec(id, []string{"chmod", "a+rx", "grpcurl"}) o.Expect(err).NotTo(o.HaveOccurred()) opmPath, err := exec.LookPath("opm") o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(opmPath).NotTo(o.BeEmpty()) err = containerCLI.CopyFile(id, opmPath, "/tmp/opm") o.Expect(err).NotTo(o.HaveOccurred()) commandStr := []string{"/tmp/opm", "version"} e2e.Logf("run command %s", commandStr) output, err := containerCLI.Exec(id, commandStr) o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("opm version is: %s", output) commandStr = []string{"/tmp/opm", "index", "add", "--bundles", "quay.io/olmqe/ditto-operator:0.1.0", "--from-index", "quay.io/olmqe/etcd-index:30189", "--generate"} e2e.Logf("run command %s", commandStr) output, err = containerCLI.Exec(id, commandStr) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("Pulling previous image")) o.Expect(output).To(o.ContainSubstring("writing dockerfile: index.Dockerfile")) commandStr = []string{"ls"} e2e.Logf("run command %s", commandStr) output, err = containerCLI.Exec(id, commandStr) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("database")) o.Expect(output).To(o.ContainSubstring("index.Dockerfile")) commandStr = []string{"/tmp/opm", "index", "export", "-i", "quay.io/olmqe/etcd-index:0.9.0-30189", "-f", "tmp", "-o", "etcd"} e2e.Logf("run command %s", commandStr) output, err = containerCLI.Exec(id, commandStr) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("Pulling previous image")) o.Expect(output).To(o.ContainSubstring("Preparing to pull bundles map")) commandStr = []string{"mv", "tmp/etcd", "."} e2e.Logf("run command %s", commandStr) _, err = containerCLI.Exec(id, commandStr) o.Expect(err).NotTo(o.HaveOccurred()) commandStr = []string{"ls", "-R", "etcd"} e2e.Logf("run command %s", commandStr) output, err = containerCLI.Exec(id, commandStr) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("etcdoperator.v0.9.0.clusterserviceversion.yaml")) commandStr = []string{"mkdir", "test"} e2e.Logf("run command %s", commandStr) _, err = containerCLI.Exec(id, commandStr) o.Expect(err).NotTo(o.HaveOccurred()) commandStr = []string{"/tmp/opm", "alpha", "bundle", "generate", "--directory", "etcd", "--package", "test-operator", "--channels", "stable,beta", "-u", "test"} e2e.Logf("run command %s", commandStr) output, err = containerCLI.Exec(id, commandStr) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("Writing bundle.Dockerfile")) commandStr = []string{"ls", "-R", "test"} e2e.Logf("run command %s", commandStr) output, err = containerCLI.Exec(id, commandStr) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("annotations.yaml")) o.Expect(output).To(o.ContainSubstring("etcdoperator.v0.9.0.clusterserviceversion.yaml")) commandStr = []string{"initializer", "-m", "test"} e2e.Logf("run command %s", commandStr) output, err = containerCLI.Exec(id, commandStr) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("loading Packages and Entries")) commandStr = []string{"/tmp/opm", "registry", "serve", "-p", "50050"} e2e.Logf("run command %s", commandStr) _, err = containerCLI.ExecBackgroud(id, commandStr) o.Expect(err).NotTo(o.HaveOccurred()) commandGRP := "podman exec " + id + " ./grpcurl -plaintext localhost:50050 api.Registry/ListBundles | jq '{csvName}'" outputGRP, err := exec.Command("bash", "-c", commandGRP).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(outputGRP).NotTo(o.ContainSubstring("etcdoperator.v0.9.2")) o.Expect(outputGRP).To(o.ContainSubstring("etcdoperator.v0.9.0")) commandStr = []string{"/tmp/opm", "registry", "add", "-b", "quay.io/olmqe/etcd-bundle:0.9.2"} e2e.Logf("run command %s", commandStr) output, err = containerCLI.Exec(id, commandStr) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("adding to the registry")) commandStr = []string{"/tmp/opm", "registry", "serve", "-p", "50051"} e2e.Logf("run command %s", commandStr) _, err = containerCLI.ExecBackgroud(id, commandStr) o.Expect(err).NotTo(o.HaveOccurred()) commandGRP = "podman exec " + id + " ./grpcurl -plaintext localhost:50051 api.Registry/ListBundles | jq '{csvName}'" outputGRP, err = exec.Command("bash", "-c", commandGRP).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(outputGRP).To(o.ContainSubstring("etcdoperator.v0.9.2")) o.Expect(outputGRP).To(o.ContainSubstring("etcdoperator.v0.9.0")) commandStr = []string{"/tmp/opm", "registry", "rm", "-o", "etcd"} e2e.Logf("run command %s", commandStr) output, err = containerCLI.Exec(id, commandStr) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("removing from the registry")) commandStr = []string{"/tmp/opm", "registry", "serve", "-p", "50052"} e2e.Logf("run command %s", commandStr) _, err = containerCLI.ExecBackgroud(id, commandStr) o.Expect(err).NotTo(o.HaveOccurred()) commandGRP = "podman exec " + id + " ./grpcurl -plaintext localhost:50052 api.Registry/ListBundles | jq '{csvName}'" outputGRP, err = exec.Command("bash", "-c", commandGRP).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(outputGRP).NotTo(o.ContainSubstring("etcd")) e2e.Logf("OCP 30189 SUCCESS") })
test case
openshift/openshift-tests-private
c9eb2ce1-06cd-4c67-9208-b05a8d11039b
ConnectedOnly-VMonly-Author:xzha-Medium-47335-opm should validate the constraint type for bundle
['"os"', '"path/filepath"']
github.com/openshift/openshift-tests-private/test/extended/opm/opm.go
g.It("ConnectedOnly-VMonly-Author:xzha-Medium-47335-opm should validate the constraint type for bundle", func() { opmBaseDir := exutil.FixturePath("testdata", "opm") tmpPath := filepath.Join(opmBaseDir, "temp"+getRandomString()) defer DeleteDir(tmpPath, "fixture-testdata") exutil.By("step: mkdir with mode 0755") err := os.MkdirAll(tmpPath, 0755) o.Expect(err).NotTo(o.HaveOccurred()) opmCLI.ExecCommandPath = tmpPath exutil.By("opm validate quay.io/olmqe/etcd-bundle:v0.9.2-47335-1") output, err := opmCLI.Run("alpha").Args("bundle", "validate", "-t", "quay.io/olmqe/etcd-bundle:v0.9.2-47335-1", "-b", "podman").Output() if err != nil { e2e.Logf(output) } o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("opm validate quay.io/olmqe/etcd-bundle:v0.9.2-47335-2") output, err = opmCLI.Run("alpha").Args("bundle", "validate", "-t", "quay.io/olmqe/etcd-bundle:v0.9.2-47335-2", "-b", "podman").Output() o.Expect(err).To(o.HaveOccurred()) o.Expect(string(output)).To(o.ContainSubstring("Bundle validation errors: Invalid CEL expression: ERROR")) o.Expect(string(output)).To(o.ContainSubstring("Syntax error: missing")) exutil.By("opm validate quay.io/olmqe/etcd-bundle:v0.9.2-47335-3") output, err = opmCLI.Run("alpha").Args("bundle", "validate", "-t", "quay.io/olmqe/etcd-bundle:v0.9.2-47335-3", "-b", "podman").Output() o.Expect(err).To(o.HaveOccurred()) o.Expect(string(output)).To(o.ContainSubstring("Bundle validation errors: The CEL expression is missing")) exutil.By("opm validate quay.io/olmqe/etcd-bundle:v0.9.2-47335-4") output, err = opmCLI.Run("alpha").Args("bundle", "validate", "-t", "quay.io/olmqe/etcd-bundle:v0.9.2-47335-4", "-b", "podman").Output() if err != nil { e2e.Logf(output) } o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("opm validate quay.io/olmqe/etcd-bundle:v0.9.2-47335-5") output, err = opmCLI.Run("alpha").Args("bundle", "validate", "-t", "quay.io/olmqe/etcd-bundle:v0.9.2-47335-5", "-b", "podman").Output() o.Expect(err).To(o.HaveOccurred()) o.Expect(string(output)).To(o.ContainSubstring("Bundle validation errors: Invalid CEL expression: ERROR")) o.Expect(string(output)).To(o.ContainSubstring("undeclared reference to 'semver_compares'")) exutil.By("opm validate quay.io/olmqe/etcd-bundle:v0.9.2-47335-6") output, err = opmCLI.Run("alpha").Args("bundle", "validate", "-t", "quay.io/olmqe/etcd-bundle:v0.9.2-47335-6", "-b", "podman").Output() o.Expect(err).To(o.HaveOccurred()) o.Expect(string(output)).To(o.ContainSubstring("Bundle validation errors: Invalid CEL expression: cel expressions must have type Bool")) exutil.By("47335 SUCCESS") })
test case
openshift/openshift-tests-private
501897e3-1d57-4c88-be7f-3c5d0f6b2d89
ConnectedOnly-Author:xzha-Medium-70013-opm support deprecated channel
['"strings"']
github.com/openshift/openshift-tests-private/test/extended/opm/opm.go
g.It("ConnectedOnly-Author:xzha-Medium-70013-opm support deprecated channel", func() { opmBaseDir := exutil.FixturePath("testdata", "opm", "70013") opmCLI.ExecCommandPath = opmBaseDir exutil.By("opm validate catalog") output, err := opmCLI.Run("validate").Args("catalog-valid").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.BeEmpty()) exutil.By("opm validate catalog") output, err = opmCLI.Run("validate").Args("catalog-invalid").Output() o.Expect(err).To(o.HaveOccurred()) o.Expect(string(output)).To(o.ContainSubstring("message must be set")) exutil.By("opm render") output, err = opmCLI.Run("render").Args("quay.io/olmqe/olmtest-operator-index:nginx70050", "-o", "yaml").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(strings.Contains(string(output), "schema: olm.deprecations")).To(o.BeTrue()) exutil.By("70013 SUCCESS") })
test case
openshift/openshift-tests-private
13b65dcb-94d6-4e80-9737-0b0fa0768d40
Author:bandrade-Medium-34016-opm can prune operators from catalog
['"fmt"', '"path/filepath"', '"strings"', 'db "github.com/openshift/openshift-tests-private/test/extended/util/db"']
github.com/openshift/openshift-tests-private/test/extended/opm/opm.go
g.It("Author:bandrade-Medium-34016-opm can prune operators from catalog", func() { opmBaseDir := exutil.FixturePath("testdata", "opm") indexDB := filepath.Join(opmBaseDir, "index_34016.db") output, err := opmCLI.Run("registry").Args("prune", "-d", indexDB, "-p", "lib-bucket-provisioner").Output() o.Expect(err).NotTo(o.HaveOccurred()) if !strings.Contains(output, "deleting packages") || !strings.Contains(output, "pkg=planetscale") { e2e.Failf(fmt.Sprintf("Failed to obtain the removed packages from prune : %s", output)) } })
test case
openshift/openshift-tests-private
92aabee7-f2c8-44ef-b05c-f49209271729
ConnectedOnly-Author:bandrade-Medium-54168-opm support '--use-http' global flag
['"fmt"', '"os"', '"path/filepath"', '"strings"']
github.com/openshift/openshift-tests-private/test/extended/opm/opm.go
g.It("ConnectedOnly-Author:bandrade-Medium-54168-opm support '--use-http' global flag", func() { if os.Getenv("HTTP_PROXY") != "" || os.Getenv("http_proxy") != "" { g.Skip("HTTP_PROXY is not empty - skipping test ...") } opmBaseDir := exutil.FixturePath("testdata", "opm", "53869") opmCLI.ExecCommandPath = opmBaseDir defer DeleteDir(opmBaseDir, "fixture-testdata") exutil.By("1) checking alpha list") output, err := opmCLI.Run("alpha").Args("list", "bundles", "quay.io/openshifttest/nginxolm-operator-index:v1", "--use-http").Output() o.Expect(err).NotTo(o.HaveOccurred()) if !strings.Contains(output, "nginx-operator") { e2e.Failf(fmt.Sprintf("Failed to obtain the packages from alpha list : %s", output)) } exutil.By("2) checking render") output, err = opmCLI.Run("render").Args("quay.io/openshifttest/nginxolm-operator-index:v1", "--use-http").Output() o.Expect(err).NotTo(o.HaveOccurred()) if !strings.Contains(output, "nginx-operator") { e2e.Failf(fmt.Sprintf("Failed run render command : %s", output)) } exutil.By("3) checking index add") output, err = opmCLI.Run("index").Args("add", "-b", "quay.io/openshifttest/nginxolm-operator-bundle:v0.0.1", "-t", "quay.io/olmqe/nginxolm-operator-index:v54168", "--use-http", "--generate").Output() o.Expect(err).NotTo(o.HaveOccurred()) if !strings.Contains(output, "writing dockerfile") { e2e.Failf(fmt.Sprintf("Failed run render command : %s", output)) } exutil.By("4) checking render-veneer semver") output, err = opmCLI.Run("alpha").Args("render-template", "--use-http", "basic", filepath.Join(opmBaseDir, "catalog-basic-template.yaml"), "-o", "yaml").Output() o.Expect(err).NotTo(o.HaveOccurred()) if !strings.Contains(output, "nginx-operator") { e2e.Failf(fmt.Sprintf("Failed run render command : %s", output)) } exutil.By("5) checking render-graph") output, err = opmCLI.Run("alpha").Args("render-graph", "quay.io/openshifttest/nginxolm-operator-index:v1", "--use-http").Output() o.Expect(err).NotTo(o.HaveOccurred()) if !strings.Contains(output, "nginx-operator") { e2e.Failf(fmt.Sprintf("Failed run render-graph command : %s", output)) } })
test case
openshift/openshift-tests-private
e0ff1a3a-192f-4ed5-abed-b2083524c023
Author:bandrade-VMonly-Low-30318-Bundle build understands packages
['"path/filepath"', '"strings"']
github.com/openshift/openshift-tests-private/test/extended/opm/opm.go
g.It("Author:bandrade-VMonly-Low-30318-Bundle build understands packages", func() { opmBaseDir := exutil.FixturePath("testdata", "opm") testDataPath := filepath.Join(opmBaseDir, "learn_operator") opmCLI.ExecCommandPath = testDataPath defer DeleteDir(testDataPath, "fixture-testdata") exutil.By("step: opm alpha bundle generate") output, err := opmCLI.Run("alpha").Args("bundle", "generate", "-d", "package/0.0.1", "-p", "25955-operator", "-c", "alpha", "-e", "alpha").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf(output) if !strings.Contains(output, "Writing annotations.yaml") || !strings.Contains(output, "Writing bundle.Dockerfile") { e2e.Failf("Failed to execute opm alpha bundle generate : %s", output) } })
test case
openshift/openshift-tests-private
f3f42d15-45de-4e5f-af59-b3aab1c1fb2f
Author:jitli-ConnectedOnly-VMonly-Medium-43641-opm index add fails during image extraction
['"os"', '"os/exec"', '"path/filepath"', '"strings"']
github.com/openshift/openshift-tests-private/test/extended/opm/opm.go
g.It("Author:jitli-ConnectedOnly-VMonly-Medium-43641-opm index add fails during image extraction", func() { bundleImage := "quay.io/olmqe/etcd:0.9.4-43641" indexImage := "quay.io/olmqe/etcd-index:v1-4.8" opmBaseDir := exutil.FixturePath("testdata", "opm") TestDataPath := filepath.Join(opmBaseDir, "temp") opmCLI.ExecCommandPath = TestDataPath defer DeleteDir(TestDataPath, "fixture-testdata") err := os.Mkdir(TestDataPath, 0755) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("step: checking user account is no-root") user, err := exec.Command("bash", "-c", "whoami").Output() e2e.Logf("User:%s", user) o.Expect(err).NotTo(o.HaveOccurred()) if strings.Compare(string(user), "root") == -1 { exutil.By("step: opm index add") output1, err := opmCLI.Run("index").Args("add", "--generate", "--bundles", bundleImage, "--from-index", indexImage, "--overwrite-latest").Output() e2e.Logf(output1) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("test case 43641 SUCCESS") } else { e2e.Logf("User is %s. the case should login as no-root account", user) } })
test case
openshift/openshift-tests-private
999f9e5f-5bd4-4b67-bdfc-71ac840900e5
Author:xzha-ConnectedOnly-VMonly-Medium-25955-opm Ability to generate scaffolding for Operator Bundle
['"path/filepath"', '"strings"', 'container "github.com/openshift/openshift-tests-private/test/extended/util/container"']
github.com/openshift/openshift-tests-private/test/extended/opm/opm.go
g.It("Author:xzha-ConnectedOnly-VMonly-Medium-25955-opm Ability to generate scaffolding for Operator Bundle", func() { var podmanCLI = container.NewPodmanCLI() opmBaseDir := exutil.FixturePath("testdata", "opm") TestDataPath := filepath.Join(opmBaseDir, "learn_operator") opmCLI.ExecCommandPath = TestDataPath defer DeleteDir(TestDataPath, "fixture-testdata") imageTag := "quay.io/olmqe/25955-operator-" + getRandomString() + ":v0.0.1" exutil.By("step: opm alpha bundle generate") output, err := opmCLI.Run("alpha").Args("bundle", "generate", "-d", "package/0.0.1", "-p", "25955-operator", "-c", "alpha", "-e", "alpha").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf(output) if !strings.Contains(output, "Writing annotations.yaml") || !strings.Contains(output, "Writing bundle.Dockerfile") { e2e.Failf("Failed to execute opm alpha bundle generate : %s", output) } exutil.By("step: opm alpha bundle build") e2e.Logf("clean test data") DeleteDir(TestDataPath, "fixture-testdata") opmBaseDir = exutil.FixturePath("testdata", "opm") TestDataPath = filepath.Join(opmBaseDir, "learn_operator") opmCLI.ExecCommandPath = TestDataPath _, err = podmanCLI.RemoveImage(imageTag) o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("run opm alpha bundle build") defer podmanCLI.RemoveImage(imageTag) output, _ = opmCLI.Run("alpha").Args("bundle", "build", "-d", "package/0.0.1", "-b", "podman", "--tag", imageTag, "-p", "25955-operator", "-c", "alpha", "-e", "alpha", "--overwrite").Output() e2e.Logf(output) if !strings.Contains(output, "COMMIT "+imageTag) { e2e.Failf("Failed to execute opm alpha bundle build : %s", output) } e2e.Logf("step: check image %s exist", imageTag) existFlag, err := podmanCLI.CheckImageExist(imageTag) o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("check image exist is %v", existFlag) o.Expect(existFlag).To(o.BeTrue()) })
test case
openshift/openshift-tests-private
86e245c8-da7d-4b04-af5d-9e6488a1228f
Author:xzha-ConnectedOnly-VMonly-Medium-37294-OPM can strand packages with prune stranded
['"os"', '"path"', '"path/filepath"', '"strings"', 'container "github.com/openshift/openshift-tests-private/test/extended/util/container"', 'db "github.com/openshift/openshift-tests-private/test/extended/util/db"']
github.com/openshift/openshift-tests-private/test/extended/opm/opm.go
g.It("Author:xzha-ConnectedOnly-VMonly-Medium-37294-OPM can strand packages with prune stranded", func() { var sqlit = db.NewSqlit() quayCLI := container.NewQuayCLI() containerTool := "podman" containerCLI := container.NewPodmanCLI() opmBaseDir := exutil.FixturePath("testdata", "opm") TestDataPath := filepath.Join(opmBaseDir, "temp") opmCLI.ExecCommandPath = TestDataPath defer DeleteDir(TestDataPath, "fixture-testdata") indexImage := "quay.io/olmqe/etcd-index:test-37294" indexImageSemver := "quay.io/olmqe/etcd-index:test-37294-semver" exutil.By("step: check etcd-index:test-37294, operatorbundle has two records, channel_entry has one record") indexdbpath1 := filepath.Join(TestDataPath, getRandomString()) err := os.Mkdir(TestDataPath, 0755) o.Expect(err).NotTo(o.HaveOccurred()) err = os.Mkdir(indexdbpath1, 0755) o.Expect(err).NotTo(o.HaveOccurred()) _, err = oc.AsAdmin().WithoutNamespace().Run("image").Args("extract", indexImage, "--path", "/database/index.db:"+indexdbpath1).Output() e2e.Logf("get index.db SUCCESS, path is %s", path.Join(indexdbpath1, "index.db")) o.Expect(err).NotTo(o.HaveOccurred()) result, err := sqlit.DBMatch(path.Join(indexdbpath1, "index.db"), "operatorbundle", "name", []string{"etcdoperator.v0.9.0", "etcdoperator.v0.9.2"}) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(result).To(o.BeTrue()) result, err = sqlit.DBMatch(path.Join(indexdbpath1, "index.db"), "channel_entry", "operatorbundle_name", []string{"etcdoperator.v0.9.2"}) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(result).To(o.BeTrue()) exutil.By("step: prune-stranded this index image") indexImageTmp1 := indexImage + getRandomString() defer containerCLI.RemoveImage(indexImageTmp1) output, err := opmCLI.Run("index").Args("prune-stranded", "-f", indexImage, "--tag", indexImageTmp1, "-c", containerTool).Output() if err != nil { e2e.Logf(output) } o.Expect(err).NotTo(o.HaveOccurred()) output, err = containerCLI.Run("push").Args(indexImageTmp1).Output() if err != nil { e2e.Logf(output) } defer quayCLI.DeleteTag(strings.Replace(indexImageTmp1, "quay.io/", "", 1)) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("step: check index image operatorbundle has one record") indexdbpath2 := filepath.Join(TestDataPath, getRandomString()) err = os.Mkdir(indexdbpath2, 0755) o.Expect(err).NotTo(o.HaveOccurred()) _, err = oc.AsAdmin().WithoutNamespace().Run("image").Args("extract", indexImageTmp1, "--path", "/database/index.db:"+indexdbpath2).Output() e2e.Logf("get index.db SUCCESS, path is %s", path.Join(indexdbpath2, "index.db")) o.Expect(err).NotTo(o.HaveOccurred()) result, err = sqlit.DBMatch(path.Join(indexdbpath2, "index.db"), "operatorbundle", "name", []string{"etcdoperator.v0.9.2"}) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(result).To(o.BeTrue()) result, err = sqlit.DBMatch(path.Join(indexdbpath2, "index.db"), "channel_entry", "operatorbundle_name", []string{"etcdoperator.v0.9.2"}) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(result).To(o.BeTrue()) exutil.By("test 2") exutil.By("step: step: check etcd-index:test-37294-semver, operatorbundle has two records, channel_entry has two records") indexdbpath3 := filepath.Join(TestDataPath, getRandomString()) err = os.Mkdir(indexdbpath3, 0755) o.Expect(err).NotTo(o.HaveOccurred()) _, err = oc.AsAdmin().WithoutNamespace().Run("image").Args("extract", indexImageSemver, "--path", "/database/index.db:"+indexdbpath3).Output() e2e.Logf("get index.db SUCCESS, path is %s", path.Join(indexdbpath3, "index.db")) o.Expect(err).NotTo(o.HaveOccurred()) result, err = sqlit.DBMatch(path.Join(indexdbpath3, "index.db"), "operatorbundle", "name", []string{"etcdoperator.v0.9.0", "etcdoperator.v0.9.2"}) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(result).To(o.BeTrue()) result, err = sqlit.DBMatch(path.Join(indexdbpath3, "index.db"), "channel_entry", "operatorbundle_name", []string{"etcdoperator.v0.9.0", "etcdoperator.v0.9.2"}) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(result).To(o.BeTrue()) exutil.By("step: prune-stranded this index image") indexImageTmp2 := indexImage + getRandomString() defer containerCLI.RemoveImage(indexImageTmp2) output, err = opmCLI.Run("index").Args("prune-stranded", "-f", indexImageSemver, "--tag", indexImageTmp2, "-c", containerTool).Output() if err != nil { e2e.Logf(output) } o.Expect(err).NotTo(o.HaveOccurred()) output, err = containerCLI.Run("push").Args(indexImageTmp2).Output() if err != nil { e2e.Logf(output) } defer quayCLI.DeleteTag(strings.Replace(indexImageTmp2, "quay.io/", "", 1)) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("step: check index image has both v0.9.2 and v0.9.2") indexdbpath4 := filepath.Join(TestDataPath, getRandomString()) err = os.Mkdir(indexdbpath4, 0755) o.Expect(err).NotTo(o.HaveOccurred()) _, err = oc.AsAdmin().WithoutNamespace().Run("image").Args("extract", indexImageTmp2, "--path", "/database/index.db:"+indexdbpath4).Output() e2e.Logf("get index.db SUCCESS, path is %s", path.Join(indexdbpath4, "index.db")) o.Expect(err).NotTo(o.HaveOccurred()) result, err = sqlit.DBMatch(path.Join(indexdbpath4, "index.db"), "operatorbundle", "name", []string{"etcdoperator.v0.9.0", "etcdoperator.v0.9.2"}) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(result).To(o.BeTrue()) result, err = sqlit.DBMatch(path.Join(indexdbpath4, "index.db"), "channel_entry", "operatorbundle_name", []string{"etcdoperator.v0.9.0", "etcdoperator.v0.9.2"}) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(result).To(o.BeTrue()) e2e.Logf("step: check index image has both v0.9.2 and v0.9.2 SUCCESS") })
test case
openshift/openshift-tests-private
e110a89c-dd63-4c3c-bbca-d22b5acc9ac0
Author:kuiwang-ConnectedOnly-VMonly-Medium-40167-bundle image is missed in index db of index image
['"os"', '"path"', '"path/filepath"', '"strings"', 'container "github.com/openshift/openshift-tests-private/test/extended/util/container"', 'db "github.com/openshift/openshift-tests-private/test/extended/util/db"']
github.com/openshift/openshift-tests-private/test/extended/opm/opm.go
g.It("Author:kuiwang-ConnectedOnly-VMonly-Medium-40167-bundle image is missed in index db of index image", func() { node, errNode := oc.AsAdmin().WithoutNamespace().Run("get").Args("node", "-o=jsonpath={.items[0].metadata.name}").Output() o.Expect(errNode).NotTo(o.HaveOccurred()) errSet := exutil.SetNamespacePrivileged(oc, oc.Namespace()) o.Expect(errSet).NotTo(o.HaveOccurred()) efips, errFips := oc.AsAdmin().WithoutNamespace().Run("debug").Args("node/"+node, "--to-namespace="+oc.Namespace(), "--", "chroot", "/host", "fips-mode-setup", "--check").Output() if errFips != nil || strings.Contains(efips, "FIPS mode is enabled") { g.Skip("skip it without impacting function") } exutil.SkipBaselineCaps(oc, "None") exutil.SkipForSNOCluster(oc) platform := exutil.CheckPlatform(oc) proxy, errProxy := oc.AsAdmin().WithoutNamespace().Run("get").Args("proxy", "cluster", "-o=jsonpath={.status.httpProxy}{.status.httpsProxy}").Output() o.Expect(errProxy).NotTo(o.HaveOccurred()) if proxy != "" || strings.Contains(platform, "openstack") || strings.Contains(platform, "baremetal") || strings.Contains(platform, "vsphere") || strings.Contains(platform, "none") { g.Skip("it is not supported") } var ( opmBaseDir = exutil.FixturePath("testdata", "opm") TestDataPath = filepath.Join(opmBaseDir, "temp") opmCLI = NewOpmCLI() quayCLI = container.NewQuayCLI() sqlit = db.NewSqlit() containerTool = "podman" containerCLI = container.NewPodmanCLI() // it is shared image. could not need to remove it. indexImage = "quay.io/olmqe/cockroachdb-index:2.1.11-40167" // it is generated by case. need to remove it after case exist normally or abnormally customIndexImage = "quay.io/olmqe/cockroachdb-index:2.1.11-40167-custome-" + getRandomString() ) defer DeleteDir(TestDataPath, "fixture-testdata") defer containerCLI.RemoveImage(customIndexImage) defer quayCLI.DeleteTag(strings.Replace(customIndexImage, "quay.io/", "", 1)) err := os.Mkdir(TestDataPath, 0755) o.Expect(err).NotTo(o.HaveOccurred()) opmCLI.ExecCommandPath = TestDataPath exutil.By("prune redhat index image to get custom index image") if output, err := opmCLI.Run("index").Args("prune", "-f", indexImage, "-p", "cockroachdb", "-t", customIndexImage, "-c", containerTool).Output(); err != nil { e2e.Logf(output) if strings.Contains(output, "error unmounting container") { g.Skip("skip case because we can not prepare data") } o.Expect(err).NotTo(o.HaveOccurred()) } if output, err := containerCLI.Run("push").Args(customIndexImage).Output(); err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } exutil.By("extract db file") indexdbpath1 := filepath.Join(TestDataPath, getRandomString()) err = os.Mkdir(indexdbpath1, 0755) o.Expect(err).NotTo(o.HaveOccurred()) _, err = oc.AsAdmin().WithoutNamespace().Run("image").Args("extract", customIndexImage, "--path", "/database/index.db:"+indexdbpath1).Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("get index.db SUCCESS, path is %s", path.Join(indexdbpath1, "index.db")) exutil.By("check if the bunld image is in db index") rows, err := sqlit.QueryDB(path.Join(indexdbpath1, "index.db"), "select image from related_image where operatorbundle_name like 'cockroachdb%';") o.Expect(err).NotTo(o.HaveOccurred()) defer rows.Close() var imageList string var image string for rows.Next() { rows.Scan(&image) imageList = imageList + image } e2e.Logf("imageList is %v", imageList) o.Expect(imageList).To(o.ContainSubstring("cockroachdb-operator")) })
test case
openshift/openshift-tests-private
9454f122-5635-4004-90d4-9c54dede7608
Author:xzha-ConnectedOnly-VMonly-Medium-40530-The index image generated by opm index prune should not leave unrelated images
['"os"', '"os/exec"', '"path"', '"path/filepath"', '"strings"', 'container "github.com/openshift/openshift-tests-private/test/extended/util/container"', 'db "github.com/openshift/openshift-tests-private/test/extended/util/db"']
github.com/openshift/openshift-tests-private/test/extended/opm/opm.go
g.It("Author:xzha-ConnectedOnly-VMonly-Medium-40530-The index image generated by opm index prune should not leave unrelated images", func() { quayCLI := container.NewQuayCLI() var sqlit = db.NewSqlit() containerCLI := container.NewPodmanCLI() containerTool := "podman" opmBaseDir := exutil.FixturePath("testdata", "opm") TestDataPath := filepath.Join(opmBaseDir, "temp") opmCLI.ExecCommandPath = TestDataPath defer DeleteDir(TestDataPath, "fixture-testdata") indexImage := "quay.io/olmqe/redhat-operator-index:40530" defer containerCLI.RemoveImage(indexImage) exutil.By("step: check the index image has other bundles except cluster-logging") indexTmpPath1 := filepath.Join(TestDataPath, getRandomString()) err := os.MkdirAll(indexTmpPath1, 0755) o.Expect(err).NotTo(o.HaveOccurred()) _, err = oc.AsAdmin().WithoutNamespace().Run("image").Args("extract", indexImage, "--path", "/database/index.db:"+indexTmpPath1).Output() e2e.Logf("get index.db SUCCESS, path is %s", path.Join(indexTmpPath1, "index.db")) o.Expect(err).NotTo(o.HaveOccurred()) rows, err := sqlit.QueryDB(path.Join(indexTmpPath1, "index.db"), "select distinct(operatorbundle_name) from related_image where operatorbundle_name not in (select operatorbundle_name from channel_entry)") o.Expect(err).NotTo(o.HaveOccurred()) defer rows.Close() var OperatorBundles []string var name string for rows.Next() { rows.Scan(&name) OperatorBundles = append(OperatorBundles, name) } o.Expect(OperatorBundles).NotTo(o.BeEmpty()) exutil.By("step: Prune the index image to keep cluster-logging only") indexImage1 := indexImage + getRandomString() defer containerCLI.RemoveImage(indexImage1) output, err := opmCLI.Run("index").Args("prune", "-f", indexImage, "-p", "cluster-logging", "-t", indexImage1, "-c", containerTool).Output() if err != nil { e2e.Logf(output) } o.Expect(err).NotTo(o.HaveOccurred()) output, err = containerCLI.Run("push").Args(indexImage1).Output() if err != nil { e2e.Logf(output) } defer quayCLI.DeleteTag(strings.Replace(indexImage1, "quay.io/", "", 1)) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("step: check database, there is no related images") indexTmpPath2 := filepath.Join(TestDataPath, getRandomString()) err = os.MkdirAll(indexTmpPath2, 0755) o.Expect(err).NotTo(o.HaveOccurred()) _, err = oc.AsAdmin().WithoutNamespace().Run("image").Args("extract", indexImage1, "--path", "/database/index.db:"+indexTmpPath2).Output() e2e.Logf("get index.db SUCCESS, path is %s", path.Join(indexTmpPath2, "index.db")) o.Expect(err).NotTo(o.HaveOccurred()) rows2, err := sqlit.QueryDB(path.Join(indexTmpPath2, "index.db"), "select distinct(operatorbundle_name) from related_image where operatorbundle_name not in (select operatorbundle_name from channel_entry)") o.Expect(err).NotTo(o.HaveOccurred()) OperatorBundles = nil defer rows2.Close() for rows2.Next() { rows2.Scan(&name) OperatorBundles = append(OperatorBundles, name) } o.Expect(OperatorBundles).To(o.BeEmpty()) exutil.By("step: check the image mirroring mapping") manifestsPath := filepath.Join(TestDataPath, getRandomString()) output, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("catalog", "mirror", indexImage1, "localhost:5000", "--manifests-only", "--to-manifests="+manifestsPath).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("/database/index.db")) result, err := exec.Command("bash", "-c", "cat "+manifestsPath+"/mapping.txt").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(result).NotTo(o.BeEmpty()) result, _ = exec.Command("bash", "-c", "cat "+manifestsPath+"/mapping.txt|grep -v ose-cluster-logging|grep -v ose-logging|grep -v redhat-operator-index:40530").Output() o.Expect(result).To(o.BeEmpty()) exutil.By("step: 40530 SUCCESS") })
test case
openshift/openshift-tests-private
164e9345-964c-4add-8efe-5af649565bbb
Author:bandrade-ConnectedOnly-VMonly-Medium-34049-opm can prune operators from index
['"fmt"', '"os"', '"path"', '"path/filepath"', '"strings"', 'container "github.com/openshift/openshift-tests-private/test/extended/util/container"', 'db "github.com/openshift/openshift-tests-private/test/extended/util/db"']
github.com/openshift/openshift-tests-private/test/extended/opm/opm.go
g.It("Author:bandrade-ConnectedOnly-VMonly-Medium-34049-opm can prune operators from index", func() { var sqlit = db.NewSqlit() quayCLI := container.NewQuayCLI() podmanCLI := container.NewPodmanCLI() opmBaseDir := exutil.FixturePath("testdata", "opm") TestDataPath := filepath.Join(opmBaseDir, "temp") indexTmpPath := filepath.Join(TestDataPath, getRandomString()) defer DeleteDir(TestDataPath, indexTmpPath) err := os.MkdirAll(indexTmpPath, 0755) o.Expect(err).NotTo(o.HaveOccurred()) containerCLI := container.NewPodmanCLI() containerTool := "podman" sourceImageTag := "quay.io/olmqe/multi-index:2.0" imageTag := "quay.io/olmqe/multi-index:3.0." + getRandomString() defer podmanCLI.RemoveImage(imageTag) defer podmanCLI.RemoveImage(sourceImageTag) output, err := opmCLI.Run("index").Args("prune", "-f", sourceImageTag, "-p", "planetscale", "-t", imageTag, "-c", containerTool).Output() o.Expect(err).NotTo(o.HaveOccurred()) if !strings.Contains(output, "deleting packages") || !strings.Contains(output, "pkg=lib-bucket-provisioner") { e2e.Failf(fmt.Sprintf("Failed to obtain the removed packages from prune : %s", output)) } output, err = containerCLI.Run("push").Args(imageTag).Output() if err != nil { e2e.Logf(output) } defer quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1)) o.Expect(err).NotTo(o.HaveOccurred()) _, err = oc.AsAdmin().WithoutNamespace().Run("image").Args("extract", imageTag, "--path", "/database/index.db:"+indexTmpPath).Output() e2e.Logf("get index.db SUCCESS, path is %s", path.Join(indexTmpPath, "index.db")) o.Expect(err).NotTo(o.HaveOccurred()) result, err := sqlit.DBMatch(path.Join(indexTmpPath, "index.db"), "channel_entry", "operatorbundle_name", []string{"lib-bucket-provisioner.v1.0.0"}) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(result).To(o.BeFalse()) })
test case
openshift/openshift-tests-private
b6294548-88c4-4ea9-942b-da809336f25e
Author:xzha-ConnectedOnly-VMonly-Medium-26594-Related Images
['"os"', '"os/exec"', '"path/filepath"', '"strings"', '"time"', 'container "github.com/openshift/openshift-tests-private/test/extended/util/container"', 'db "github.com/openshift/openshift-tests-private/test/extended/util/db"']
github.com/openshift/openshift-tests-private/test/extended/opm/opm.go
g.It("Author:xzha-ConnectedOnly-VMonly-Medium-26594-Related Images", func() { var sqlit = db.NewSqlit() quayCLI := container.NewQuayCLI() containerCLI := container.NewPodmanCLI() containerTool := "podman" opmBaseDir := exutil.FixturePath("testdata", "opm") TestDataPath := filepath.Join(opmBaseDir, "eclipse-che") TmpDataPath := filepath.Join(opmBaseDir, "tmp") err := os.MkdirAll(TmpDataPath, 0755) o.Expect(err).NotTo(o.HaveOccurred()) bundleImageTag := "quay.io/olmqe/eclipse-che:7.32.2-" + getRandomString() defer exec.Command("kill", "-9", "$(lsof -t -i:26594)").Output() defer DeleteDir(TestDataPath, "fixture-testdata") defer containerCLI.RemoveImage(bundleImageTag) defer quayCLI.DeleteTag(strings.Replace(bundleImageTag, "quay.io/", "", 1)) exutil.By("step: build bundle image ") opmCLI.ExecCommandPath = TestDataPath output, err := opmCLI.Run("alpha").Args("bundle", "build", "-d", "7.32.2", "-b", containerTool, "-t", bundleImageTag, "-p", "eclipse-che", "-c", "alpha", "-e", "alpha", "--overwrite").Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("Writing annotations.yaml")) o.Expect(string(output)).To(o.ContainSubstring("Writing bundle.Dockerfile")) if output, err = containerCLI.Run("push").Args(bundleImageTag).Output(); err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } exutil.By("step: build bundle.db") dbFilePath := TmpDataPath + "bundles.db" if output, err := opmCLI.Run("registry").Args("add", "-b", bundleImageTag, "-d", dbFilePath, "-c", containerTool, "--mode", "semver").Output(); err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } exutil.By("step: Check if the related images stores in this database") image := "quay.io/che-incubator/configbump@sha256:175ff2ba1bd74429de192c0a9facf39da5699c6da9f151bd461b3dc8624dd532" result, err := sqlit.DBMatch(dbFilePath, "package", "name", []string{"eclipse-che"}) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(result).To(o.BeTrue()) result, err = sqlit.DBHas(dbFilePath, "related_image", "image", []string{image}) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(result).To(o.BeTrue()) exutil.By("step: Run the opm registry server binary to load manifest and serves a grpc API to query it.") e2e.Logf("step: Run the registry-server ") cmd := exec.Command("opm", "registry", "serve", "-d", dbFilePath, "-t", filepath.Join(TmpDataPath, "26594.log"), "-p", "26594") cmd.Dir = TmpDataPath err = cmd.Start() o.Expect(err).NotTo(o.HaveOccurred()) time.Sleep(time.Second * 1) e2e.Logf("step: check api.Registry/ListPackages") outputCurl, err := exec.Command("grpcurl", "-plaintext", "localhost:26594", "api.Registry/ListPackages").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(string(outputCurl)).To(o.ContainSubstring("eclipse-che")) e2e.Logf("step: check api.Registry/GetBundleForChannel") outputCurl, err = exec.Command("grpcurl", "-plaintext", "-d", "{\"pkgName\":\"eclipse-che\",\"channelName\":\"alpha\"}", "localhost:26594", "api.Registry/GetBundleForChannel").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(string(outputCurl)).To(o.ContainSubstring(image)) cmd.Process.Kill() exutil.By("step: SUCCESS") })
test case
openshift/openshift-tests-private
757f2f4e-8bce-430a-90b9-7c6ac92e16a9
Author:xzha-ConnectedOnly-Medium-43409-opm can list catalog contents
['"os"', '"path"', '"path/filepath"', 'db "github.com/openshift/openshift-tests-private/test/extended/util/db"']
github.com/openshift/openshift-tests-private/test/extended/opm/opm.go
g.It("Author:xzha-ConnectedOnly-Medium-43409-opm can list catalog contents", func() { dbimagetag := "quay.io/olmqe/community-operator-index:v4.8" dcimagetag := "quay.io/olmqe/community-operator-index:v4.8-dc" exutil.By("1, testing with index.db image ") exutil.By("1.1 list packages") output, err := opmCLI.Run("alpha").Args("list", "packages", dbimagetag).Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("3scale-community-operator")) o.Expect(string(output)).To(o.ContainSubstring("3scale API Management")) o.Expect(string(output)).To(o.ContainSubstring("threescale-2.10")) exutil.By("1.2 list channels") output, err = opmCLI.Run("alpha").Args("list", "channels", dbimagetag).Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("3scale-community-operator")) o.Expect(string(output)).To(o.ContainSubstring("threescale-2.10")) o.Expect(string(output)).To(o.ContainSubstring("3scale-community-operator.v0.7.0")) exutil.By("1.3 list channels in a package") output, err = opmCLI.Run("alpha").Args("list", "channels", dbimagetag, "3scale-community-operator").Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("threescale-2.10")) o.Expect(string(output)).To(o.ContainSubstring("threescale-2.9")) exutil.By("1.4 list bundles") output, err = opmCLI.Run("alpha").Args("list", "bundles", dbimagetag).Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("3scale-community-operator.v0.6.0")) o.Expect(string(output)).To(o.ContainSubstring("3scale-community-operator.v0.7.0")) exutil.By("1.5 list bundles in a package") output, err = opmCLI.Run("alpha").Args("list", "bundles", dbimagetag, "wso2am-operator").Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("wso2am-operator.v1.0.0")) o.Expect(string(output)).To(o.ContainSubstring("wso2am-operator.v1.0.1")) o.Expect(string(output)).To(o.ContainSubstring("wso2am-operator.v1.1.0")) exutil.By("2, testing with dc format index image") exutil.By("2.1 list packages") output, err = opmCLI.Run("alpha").Args("list", "packages", dcimagetag).Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("3scale-community-operator")) o.Expect(string(output)).To(o.ContainSubstring("3scale API Management")) o.Expect(string(output)).To(o.ContainSubstring("threescale-2.10")) exutil.By("2.2 list channels") output, err = opmCLI.Run("alpha").Args("list", "channels", dcimagetag).Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("3scale-community-operator")) o.Expect(string(output)).To(o.ContainSubstring("threescale-2.10")) o.Expect(string(output)).To(o.ContainSubstring("3scale-community-operator.v0.7.0")) exutil.By("2.3 list channels in a package") output, err = opmCLI.Run("alpha").Args("list", "channels", dcimagetag, "3scale-community-operator").Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("threescale-2.10")) o.Expect(string(output)).To(o.ContainSubstring("threescale-2.9")) exutil.By("2.4 list bundles") output, err = opmCLI.Run("alpha").Args("list", "bundles", dcimagetag).Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("3scale-community-operator.v0.6.0")) o.Expect(string(output)).To(o.ContainSubstring("3scale-community-operator.v0.7.0")) exutil.By("2.5 list bundles in a package") output, err = opmCLI.Run("alpha").Args("list", "bundles", dcimagetag, "wso2am-operator").Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("wso2am-operator.v1.0.0")) o.Expect(string(output)).To(o.ContainSubstring("wso2am-operator.v1.0.1")) o.Expect(string(output)).To(o.ContainSubstring("wso2am-operator.v1.1.0")) exutil.By("3, testing with index.db file") opmBaseDir := exutil.FixturePath("testdata", "opm") TmpDataPath := filepath.Join(opmBaseDir, "tmp") indexdbFilePath := filepath.Join(TmpDataPath, "index.db") err = os.MkdirAll(TmpDataPath, 0755) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("get index.db") _, err = oc.AsAdmin().WithoutNamespace().Run("image").Args("extract", dbimagetag, "--path", "/database/index.db:"+TmpDataPath).Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("get index.db SUCCESS, path is %s", indexdbFilePath) if _, err := os.Stat(indexdbFilePath); os.IsNotExist(err) { e2e.Logf("get index.db Failed") } exutil.By("3.1 list packages") output, err = opmCLI.Run("alpha").Args("list", "packages", indexdbFilePath).Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("3scale-community-operator")) o.Expect(string(output)).To(o.ContainSubstring("3scale API Management")) o.Expect(string(output)).To(o.ContainSubstring("threescale-2.10")) exutil.By("3.2 list channels") output, err = opmCLI.Run("alpha").Args("list", "channels", indexdbFilePath).Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("3scale-community-operator")) o.Expect(string(output)).To(o.ContainSubstring("threescale-2.10")) o.Expect(string(output)).To(o.ContainSubstring("3scale-community-operator.v0.7.0")) exutil.By("3.3 list channels in a package") output, err = opmCLI.Run("alpha").Args("list", "channels", indexdbFilePath, "3scale-community-operator").Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("threescale-2.10")) o.Expect(string(output)).To(o.ContainSubstring("threescale-2.9")) exutil.By("3.4 list bundles") output, err = opmCLI.Run("alpha").Args("list", "bundles", indexdbFilePath).Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("3scale-community-operator.v0.6.0")) o.Expect(string(output)).To(o.ContainSubstring("3scale-community-operator.v0.7.0")) exutil.By("3.5 list bundles in a package") output, err = opmCLI.Run("alpha").Args("list", "bundles", indexdbFilePath, "wso2am-operator").Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("wso2am-operator.v1.0.0")) o.Expect(string(output)).To(o.ContainSubstring("wso2am-operator.v1.0.1")) o.Expect(string(output)).To(o.ContainSubstring("wso2am-operator.v1.1.0")) exutil.By("step: SUCCESS") })
test case
openshift/openshift-tests-private
368e89bf-c49a-4c12-8da7-a14be4ce1740
Author:xzha-ConnectedOnly-VMonly-Medium-43147-opm support rebuild index if any bundles have been truncated
['"strings"', 'container "github.com/openshift/openshift-tests-private/test/extended/util/container"']
github.com/openshift/openshift-tests-private/test/extended/opm/opm.go
g.It("Author:xzha-ConnectedOnly-VMonly-Medium-43147-opm support rebuild index if any bundles have been truncated", func() { quayCLI := container.NewQuayCLI() containerCLI := container.NewPodmanCLI() containerTool := "podman" indexImage := "quay.io/olmqe/ditto-index:43147" indexImageDep := "quay.io/olmqe/ditto-index:43147-dep" + getRandomString() indexImageOW := "quay.io/olmqe/ditto-index:43147-ow" + getRandomString() defer containerCLI.RemoveImage(indexImage) defer containerCLI.RemoveImage(indexImageDep) defer containerCLI.RemoveImage(indexImageOW) defer quayCLI.DeleteTag(strings.Replace(indexImageDep, "quay.io/", "", 1)) exutil.By("step: run deprecatetruncate") output, err := opmCLI.Run("index").Args("deprecatetruncate", "-b", "quay.io/olmqe/ditto-operator:0.1.1", "-f", indexImage, "-t", indexImageDep, "-c", containerTool).Output() if err != nil { e2e.Logf(output) } o.Expect(err).NotTo(o.HaveOccurred()) output, err = containerCLI.Run("push").Args(indexImageDep).Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } exutil.By("check there is no channel alpha") output, err = opmCLI.Run("alpha").Args("list", "channels", indexImageDep).Output() if err != nil { e2e.Logf(output) } o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(string(output)).NotTo(o.ContainSubstring("alpha")) o.Expect(string(output)).To(o.ContainSubstring("beta")) o.Expect(string(output)).NotTo(o.ContainSubstring("ditto-operator.v0.1.0")) exutil.By("re-adding the bundle") output, err = opmCLI.Run("index").Args("add", "-b", "quay.io/olmqe/ditto-operator:0.2.0-43147", "-f", indexImageDep, "-t", indexImageOW, "--overwrite-latest", "-c", containerTool).Output() if err != nil { e2e.Logf(output) } o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(string(output)).NotTo(o.ContainSubstring("ERRO")) exutil.By("step: 43147 SUCCESS") })
test case
openshift/openshift-tests-private
9c735d15-15d7-4a6a-9164-a292c407a3d3
Author:xzha-ConnectedOnly-VMonly-Medium-43562-opm should raise error when adding an bundle whose version is higher than the bundle being added
['container "github.com/openshift/openshift-tests-private/test/extended/util/container"']
github.com/openshift/openshift-tests-private/test/extended/opm/opm.go
g.It("Author:xzha-ConnectedOnly-VMonly-Medium-43562-opm should raise error when adding an bundle whose version is higher than the bundle being added", func() { containerCLI := container.NewPodmanCLI() containerTool := "podman" indexImage := "quay.io/olmqe/ditto-index:43562" indexImage1 := "quay.io/olmqe/ditto-index:43562-1" + getRandomString() indexImage2 := "quay.io/olmqe/ditto-index:43562-2" + getRandomString() defer containerCLI.RemoveImage(indexImage) defer containerCLI.RemoveImage(indexImage1) defer containerCLI.RemoveImage(indexImage2) exutil.By("step: run add ditto-operator.v0.1.0 replace ditto-operator.v0.1.1") output1, err := opmCLI.Run("index").Args("add", "-b", "quay.io/olmqe/ditto-operator:43562-0.1.0", "-f", indexImage, "-t", indexImage1, "-c", containerTool).Output() o.Expect(err).To(o.HaveOccurred()) o.Expect(string(output1)).To(o.ContainSubstring("error")) o.Expect(string(output1)).To(o.ContainSubstring("permissive mode disabled")) o.Expect(string(output1)).To(o.ContainSubstring("this may be due to incorrect channel head")) output2, err := opmCLI.Run("index").Args("add", "-b", "quay.io/olmqe/ditto-operator:43562-0.1.2", "-f", indexImage, "-t", indexImage1, "-c", containerTool).Output() o.Expect(err).To(o.HaveOccurred()) o.Expect(string(output2)).To(o.ContainSubstring("error")) o.Expect(string(output2)).To(o.ContainSubstring("permissive mode disabled")) o.Expect(string(output2)).To(o.ContainSubstring("this may be due to incorrect channel head")) exutil.By("test case 43562 SUCCESS") })
test case
openshift/openshift-tests-private
81ed8938-8c1b-44ef-ab19-259e18047df2
ConnectedOnly-Author:xzha-VMonly-High-30786-Bundle addition commutativity
['"fmt"', '"os"', '"path"', '"path/filepath"', '"regexp"', 'container "github.com/openshift/openshift-tests-private/test/extended/util/container"', 'db "github.com/openshift/openshift-tests-private/test/extended/util/db"']
github.com/openshift/openshift-tests-private/test/extended/opm/opm.go
g.It("ConnectedOnly-Author:xzha-VMonly-High-30786-Bundle addition commutativity", func() { var sqlit = db.NewSqlit() opmBaseDir := exutil.FixturePath("testdata", "opm") defer DeleteDir(opmBaseDir, "fixture-testdata") TestDataPath := filepath.Join(opmBaseDir, "temp") opmCLI.ExecCommandPath = TestDataPath var ( bundles [3]string bundleName [3]string indexName = "index30786" matched bool sqlResults []db.Channel ) exutil.By("Setup environment") // see OCP-30786 for creation of these images bundles[0] = "quay.io/olmqe/etcd-bundle:0.9.0-39795" bundles[1] = "quay.io/olmqe/etcd-bundle:0.9.2-39795" bundles[2] = "quay.io/olmqe/etcd-bundle:0.9.4-39795" bundleName[0] = "etcdoperator.v0.9.0" bundleName[1] = "etcdoperator.v0.9.2" bundleName[2] = "etcdoperator.v0.9.4" podmanCLI := container.NewPodmanCLI() containerCLI := podmanCLI indexTmpPath1 := filepath.Join(TestDataPath, "database") err := os.MkdirAll(indexTmpPath1, 0755) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("Create index image with a,b") index := 1 a := 0 b := 1 order := "a,b" s := fmt.Sprintf("%v,%v", bundles[a], bundles[b]) t1 := fmt.Sprintf("%v:%v", indexName, index) defer podmanCLI.RemoveImage(t1) msg, err := opmCLI.Run("index").Args("add", "-b", s, "-t", t1).Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf(msg) matched, _ = regexp.MatchString(fmt.Sprintf("bundles=.*%v %v", bundles[a], bundles[b]), msg) o.Expect(matched).To(o.BeTrue()) msg, err = containerCLI.Run("images").Args("-n", t1).Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("IMAGES in %v: %v", order, msg) o.Expect(msg).NotTo(o.BeEmpty()) podmanCLI.RemoveImage(t1) exutil.By("Generate db with a,b & check with sqlite") msg, err = opmCLI.Run("index").Args("add", "-b", s, "--generate").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf(msg) matched, _ = regexp.MatchString(fmt.Sprintf("bundles=.*%v %v", bundles[a], bundles[b]), msg) o.Expect(matched).To(o.BeTrue()) sqlResults, err = sqlit.QueryOperatorChannel(path.Join(indexTmpPath1, "index.db")) // force string compare o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("sqlite contents %v: %v", order, sqlResults) o.Expect(fmt.Sprintf("%v", sqlResults[0])).To(o.ContainSubstring(bundleName[1])) o.Expect(fmt.Sprintf("%v", sqlResults[1])).To(o.ContainSubstring(bundleName[0])) os.Remove(path.Join(indexTmpPath1, "index.db")) exutil.By("Create index image with b,a") index++ a = 1 b = 0 order = "b,a" s = fmt.Sprintf("%v,%v", bundles[a], bundles[b]) t2 := fmt.Sprintf("%v:%v", indexName, index) defer podmanCLI.RemoveImage(t2) msg, err = opmCLI.Run("index").Args("add", "-b", s, "-t", t2).Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf(msg) matched, _ = regexp.MatchString(fmt.Sprintf("bundles=.*%v %v", bundles[a], bundles[b]), msg) o.Expect(matched).To(o.BeTrue()) msg, err = containerCLI.Run("images").Args("-n", t2).Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("IMAGES in %v: %v", order, msg) o.Expect(msg).NotTo(o.BeEmpty()) podmanCLI.RemoveImage(t2) exutil.By("Generate db with b,a & check with sqlite") msg, err = opmCLI.Run("index").Args("add", "-b", s, "--generate").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf(msg) matched, _ = regexp.MatchString(fmt.Sprintf("bundles=.*%v %v", bundles[a], bundles[b]), msg) o.Expect(matched).To(o.BeTrue()) sqlResults, err = sqlit.QueryOperatorChannel(path.Join(indexTmpPath1, "index.db")) // force string compare o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("sqlite contents %v: %v", order, sqlResults) o.Expect(fmt.Sprintf("%v", sqlResults[0])).To(o.ContainSubstring(bundleName[1])) o.Expect(fmt.Sprintf("%v", sqlResults[1])).To(o.ContainSubstring(bundleName[0])) os.Remove(path.Join(indexTmpPath1, "index.db")) exutil.By("Create index image with a,b,c") index++ a = 0 b = 1 c := 2 order = "a,b,c" s = fmt.Sprintf("%v,%v,%v", bundles[a], bundles[b], bundles[c]) t3 := fmt.Sprintf("%v:%v", indexName, index) defer podmanCLI.RemoveImage(t3) msg, err = opmCLI.Run("index").Args("add", "-b", s, "-t", t3).Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf(msg) matched, _ = regexp.MatchString(fmt.Sprintf("bundles=.*%v %v %v", bundles[a], bundles[b], bundles[c]), msg) o.Expect(matched).To(o.BeTrue()) msg, err = containerCLI.Run("images").Args("-n", t3).Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("IMAGES in %v: %v", order, msg) o.Expect(msg).NotTo(o.BeEmpty()) podmanCLI.RemoveImage(t3) exutil.By("Generate db with a,b,c & check with sqlite") msg, err = opmCLI.Run("index").Args("add", "-b", s, "--generate").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf(msg) matched, _ = regexp.MatchString(fmt.Sprintf("bundles=.*%v %v %v", bundles[a], bundles[b], bundles[c]), msg) o.Expect(matched).To(o.BeTrue()) sqlResults, err = sqlit.QueryOperatorChannel(path.Join(indexTmpPath1, "index.db")) // force string compare o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("sqlite contents %v: %v", order, sqlResults) o.Expect(fmt.Sprintf("%v", sqlResults[0])).To(o.ContainSubstring(bundleName[2])) o.Expect(fmt.Sprintf("%v", sqlResults[1])).To(o.ContainSubstring(bundleName[1])) o.Expect(fmt.Sprintf("%v", sqlResults[2])).To(o.ContainSubstring(bundleName[0])) os.Remove(path.Join(indexTmpPath1, "index.db")) exutil.By("Create index image with b,c,a") index++ a = 1 b = 2 c = 0 order = "b,c,a" s = fmt.Sprintf("%v,%v,%v", bundles[a], bundles[b], bundles[c]) t4 := fmt.Sprintf("%v:%v", indexName, index) defer podmanCLI.RemoveImage(t4) msg, err = opmCLI.Run("index").Args("add", "-b", s, "-t", t4).Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf(msg) matched, _ = regexp.MatchString(fmt.Sprintf("bundles=.*%v %v %v", bundles[a], bundles[b], bundles[c]), msg) o.Expect(matched).To(o.BeTrue()) msg, err = containerCLI.Run("images").Args("-n", t4).Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("IMAGES in %v: %v", order, msg) o.Expect(msg).NotTo(o.BeEmpty()) podmanCLI.RemoveImage(t4) // no db check exutil.By("Create index image with c,a,b") index++ a = 2 b = 0 c = 1 order = "c,a,b" s = fmt.Sprintf("%v,%v,%v", bundles[a], bundles[b], bundles[c]) t5 := fmt.Sprintf("%v:%v", indexName, index) defer podmanCLI.RemoveImage(t5) msg, err = opmCLI.Run("index").Args("add", "-b", s, "-t", t5).Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf(msg) matched, _ = regexp.MatchString(fmt.Sprintf("bundles=.*%v %v %v", bundles[a], bundles[b], bundles[c]), msg) o.Expect(matched).To(o.BeTrue()) msg, err = containerCLI.Run("images").Args("-n", t5).Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("IMAGES in %v: %v", order, msg) o.Expect(msg).NotTo(o.BeEmpty()) podmanCLI.RemoveImage(t5) // no db check exutil.By("Generate db with b,a,c & check with sqlite") a = 1 b = 0 c = 2 order = "b,a,c" s = fmt.Sprintf("%v,%v,%v", bundles[a], bundles[b], bundles[c]) // no image check, just db msg, err = opmCLI.Run("index").Args("add", "-b", s, "--generate").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf(msg) matched, _ = regexp.MatchString(fmt.Sprintf("bundles=.*%v %v %v", bundles[a], bundles[b], bundles[c]), msg) o.Expect(matched).To(o.BeTrue()) sqlResults, err = sqlit.QueryOperatorChannel(path.Join(indexTmpPath1, "index.db")) // force string compare o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("sqlite contents %v: %v", order, sqlResults) o.Expect(fmt.Sprintf("%v", sqlResults[0])).To(o.ContainSubstring(bundleName[2])) o.Expect(fmt.Sprintf("%v", sqlResults[1])).To(o.ContainSubstring(bundleName[1])) o.Expect(fmt.Sprintf("%v", sqlResults[2])).To(o.ContainSubstring(bundleName[0])) os.Remove(path.Join(indexTmpPath1, "index.db")) exutil.By("Finished") })
test case
openshift/openshift-tests-private
2cb69c4d-5693-44a4-9e16-92e6ee2b1261
ConnectedOnly-Author:scolange-VMonly-Medium-25935-Ability to modify the contents of an existing registry database
['"path/filepath"', 'container "github.com/openshift/openshift-tests-private/test/extended/util/container"', 'db "github.com/openshift/openshift-tests-private/test/extended/util/db"', 'e2e "k8s.io/kubernetes/test/e2e/framework"']
github.com/openshift/openshift-tests-private/test/extended/opm/opm.go
g.It("ConnectedOnly-Author:scolange-VMonly-Medium-25935-Ability to modify the contents of an existing registry database", func() { containerCLI := container.NewPodmanCLI() containerTool := "podman" opmBaseDir := exutil.FixturePath("testdata", "opm") TmpDataPath := filepath.Join(opmBaseDir, "tmp") defer DeleteDir(TmpDataPath, "fixture-testdata") bundleImageTag1 := "quay.io/operator-framework/operator-bundle-prometheus:0.14.0" bundleImageTag2 := "quay.io/operator-framework/operator-bundle-prometheus:0.15.0" bundleImageTag3 := "quay.io/operator-framework/operator-bundle-prometheus:0.22.2" defer containerCLI.RemoveImage(bundleImageTag1) defer containerCLI.RemoveImage(bundleImageTag2) defer containerCLI.RemoveImage(bundleImageTag3) exutil.By("step: build bundle.db") dbFilePath := TmpDataPath + "bundles.db" if output, err := opmCLI.Run("registry").Args("add", "-b", bundleImageTag1, "-d", dbFilePath, "-c", containerTool, "--mode", "semver").Output(); err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } exutil.By("step1: modified the bundle.db already created") if output, err := opmCLI.Run("registry").Args("add", "-b", bundleImageTag2, "-d", dbFilePath, "-c", containerTool, "--mode", "semver").Output(); err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } exutil.By("step2: modified the bundle.db already created") if output, err := opmCLI.Run("registry").Args("add", "-b", bundleImageTag3, "-d", dbFilePath, "-c", containerTool, "--mode", "semver").Output(); err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } exutil.By("step: SUCCESS 25935") })
test case
openshift/openshift-tests-private
c36ec826-e510-4ebb-8d45-3d5eff759625
Author:xzha-Medium-45407-opm and oc should print sqlite deprecation warnings
github.com/openshift/openshift-tests-private/test/extended/opm/opm.go
g.It("Author:xzha-Medium-45407-opm and oc should print sqlite deprecation warnings", func() { exutil.By("opm render --help") output, err := opmCLI.Run("render").Args("--help").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("DEPRECATION NOTICE:")) exutil.By("opm index --help") output, err = opmCLI.Run("index").Args("--help").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("DEPRECATION NOTICE:")) exutil.By("opm registry --help") output, err = opmCLI.Run("registry").Args("--help").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("DEPRECATION NOTICE:")) exutil.By("oc adm catalog mirror --help") output, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("catalog", "mirror", "--help").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("DEPRECATION NOTICE:")) exutil.By("45407 SUCCESS") })
test case
openshift/openshift-tests-private
8d43e78c-278e-4ba7-a1be-2de2e3721731
Author:xzha-ConnectedOnly-VMonly-Medium-45403-opm index prune should report error if the working directory does not have write permissions
['"os"', '"path/filepath"', 'container "github.com/openshift/openshift-tests-private/test/extended/util/container"']
github.com/openshift/openshift-tests-private/test/extended/opm/opm.go
g.It("Author:xzha-ConnectedOnly-VMonly-Medium-45403-opm index prune should report error if the working directory does not have write permissions", func() { podmanCLI := container.NewPodmanCLI() opmBaseDir := exutil.FixturePath("testdata", "opm") tmpPath := filepath.Join(opmBaseDir, "temp"+getRandomString()) defer DeleteDir(tmpPath, "fixture-testdata") exutil.By("step: mkdir with mode 0555") err := os.MkdirAll(tmpPath, 0555) o.Expect(err).NotTo(o.HaveOccurred()) opmCLI.ExecCommandPath = tmpPath exutil.By("step: opm index prune") containerTool := "podman" sourceImageTag := "quay.io/olmqe/multi-index:2.0" imageTag := "quay.io/olmqe/multi-index:45403-" + getRandomString() defer podmanCLI.RemoveImage(imageTag) output, err := opmCLI.Run("index").Args("prune", "-f", sourceImageTag, "-p", "planetscale", "-t", imageTag, "-c", containerTool).Output() o.Expect(err).To(o.HaveOccurred()) o.Expect(output).To(o.MatchRegexp("(?i)mkdir .* permission denied(?i)")) exutil.By("45403 SUCCESS") })
test case
openshift/openshift-tests-private
53f05036-6248-4022-819e-bc5d7e769cd6
Author:xzha-ConnectedOnly-Medium-53869-opm supports creating a catalog using basic veneer
['"fmt"', '"io/ioutil"', '"os"', '"path/filepath"']
github.com/openshift/openshift-tests-private/test/extended/opm/opm.go
g.It("Author:xzha-ConnectedOnly-Medium-53869-opm supports creating a catalog using basic veneer", func() { if os.Getenv("HTTP_PROXY") != "" || os.Getenv("http_proxy") != "" { g.Skip("HTTP_PROXY is not empty - skipping test ...") } opmBaseDir := exutil.FixturePath("testdata", "opm", "53869") opmCLI.ExecCommandPath = opmBaseDir defer DeleteDir(opmBaseDir, "fixture-testdata") exutil.By("step: create dir catalog") catsrcPathYaml := filepath.Join(opmBaseDir, "catalog-yaml") err := os.MkdirAll(catsrcPathYaml, 0755) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("step: create a catalog using basic veneer with yaml format") output, err := opmCLI.Run("alpha").Args("render-template", "basic", filepath.Join(opmBaseDir, "catalog-basic-template.yaml"), "-o", "yaml").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(string(output)).To(o.ContainSubstring("nginx-operator")) indexFilePath := filepath.Join(catsrcPathYaml, "index.yaml") if err = ioutil.WriteFile(indexFilePath, []byte(output), 0644); err != nil { e2e.Failf(fmt.Sprintf("Writefile %s Error: %v", indexFilePath, err)) } output, err = opmCLI.Run("validate").Args(catsrcPathYaml).Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } output, err = opmCLI.Run("alpha").Args("list", "bundles", catsrcPathYaml).Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("quay.io/olmqe/nginxolm-operator-bundle:v0.0.1")) o.Expect(string(output)).To(o.ContainSubstring("quay.io/olmqe/nginxolm-operator-bundle:v1.0.1")) exutil.By("step: create dir catalog") catsrcPathJSON := filepath.Join(opmBaseDir, "catalog-json") err = os.MkdirAll(catsrcPathJSON, 0755) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("step: create a catalog using basic veneer with json format") output, err = opmCLI.Run("alpha").Args("render-template", "basic", filepath.Join(opmBaseDir, "catalog-basic-template.yaml"), "-o", "json").Output() o.Expect(err).NotTo(o.HaveOccurred()) indexFilePath = filepath.Join(catsrcPathJSON, "index.json") if err = ioutil.WriteFile(indexFilePath, []byte(output), 0644); err != nil { e2e.Failf(fmt.Sprintf("Writefile %s Error: %v", indexFilePath, err)) } output, err = opmCLI.Run("validate").Args(catsrcPathJSON).Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } output, err = opmCLI.Run("alpha").Args("list", "bundles", catsrcPathJSON, "nginx-operator").Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("quay.io/olmqe/nginxolm-operator-bundle:v0.0.1")) o.Expect(string(output)).To(o.ContainSubstring("quay.io/olmqe/nginxolm-operator-bundle:v1.0.1")) })
test case
openshift/openshift-tests-private
63414352-149f-420e-8be6-e382c8f3cc81
Author:xzha-ConnectedOnly-Medium-53871-Medium-53915-Medium-53996-opm supports creating a catalog using semver veneer
['"fmt"', '"io/ioutil"', '"os"', '"os/exec"', '"path/filepath"', 'g "github.com/onsi/ginkgo/v2"']
github.com/openshift/openshift-tests-private/test/extended/opm/opm.go
g.It("Author:xzha-ConnectedOnly-Medium-53871-Medium-53915-Medium-53996-opm supports creating a catalog using semver veneer", func() { if os.Getenv("HTTP_PROXY") != "" || os.Getenv("http_proxy") != "" { g.Skip("HTTP_PROXY is not empty - skipping test ...") } opmBaseDir := exutil.FixturePath("testdata", "opm", "53871") opmCLI.ExecCommandPath = opmBaseDir defer DeleteDir(opmBaseDir, "fixture-testdata") exutil.By("step: create dir catalog-1") catsrcPath1 := filepath.Join(opmBaseDir, "catalog-1") err := os.MkdirAll(catsrcPath1, 0755) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("step: GenerateMajorChannels: true GenerateMinorChannels: false") output, err := opmCLI.Run("alpha").Args("render-template", "semver", filepath.Join(opmBaseDir, "catalog-semver-veneer-1.yaml"), "-o", "yaml").Output() o.Expect(err).NotTo(o.HaveOccurred()) indexFilePath := filepath.Join(catsrcPath1, "index.yaml") if err = ioutil.WriteFile(indexFilePath, []byte(output), 0644); err != nil { e2e.Failf(fmt.Sprintf("Writefile %s Error: %v", indexFilePath, err)) } output, err = opmCLI.Run("validate").Args(catsrcPath1).Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } output, err = opmCLI.Run("alpha").Args("list", "channels", catsrcPath1, "nginx-operator").Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("candidate-v0 nginx-operator.v0.0.1")) o.Expect(string(output)).To(o.ContainSubstring("candidate-v1 nginx-operator.v1.0.2")) o.Expect(string(output)).To(o.ContainSubstring("candidate-v2 nginx-operator.v2.1.0")) o.Expect(string(output)).To(o.ContainSubstring("fast-v0 nginx-operator.v0.0.1")) o.Expect(string(output)).To(o.ContainSubstring("fast-v2 nginx-operator.v2.1.0")) o.Expect(string(output)).To(o.ContainSubstring("stable-v1 nginx-operator.v1.0.2")) o.Expect(string(output)).To(o.ContainSubstring("stable-v2 nginx-operator.v2.1.0")) exutil.By("step: create dir catalog-2") catsrcPath2 := filepath.Join(opmBaseDir, "catalog-2") err = os.MkdirAll(catsrcPath2, 0755) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("step: GenerateMajorChannels: true GenerateMinorChannels: true") output, err = opmCLI.Run("alpha").Args("render-template", "semver", filepath.Join(opmBaseDir, "catalog-semver-veneer-2.yaml"), "-o", "yaml").Output() o.Expect(err).NotTo(o.HaveOccurred()) indexFilePath = filepath.Join(catsrcPath2, "index.yaml") if err = ioutil.WriteFile(indexFilePath, []byte(output), 0644); err != nil { e2e.Failf(fmt.Sprintf("Writefile %s Error: %v", indexFilePath, err)) } output, err = opmCLI.Run("validate").Args(catsrcPath2).Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } output, err = opmCLI.Run("alpha").Args("list", "channels", catsrcPath2, "nginx-operator").Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("candidate-v0 nginx-operator.v0.0.1")) o.Expect(string(output)).To(o.ContainSubstring("candidate-v0.0 nginx-operator.v0.0.1")) o.Expect(string(output)).To(o.ContainSubstring("candidate-v1 nginx-operator.v1.0.1")) o.Expect(string(output)).To(o.ContainSubstring("candidate-v1.0 nginx-operator.v1.0.1")) o.Expect(string(output)).To(o.ContainSubstring("fast-v1 nginx-operator.v1.0.1-beta")) o.Expect(string(output)).To(o.ContainSubstring("fast-v1.0 nginx-operator.v1.0.1-beta")) o.Expect(string(output)).To(o.ContainSubstring("stable-v1 nginx-operator.v1.0.1")) o.Expect(string(output)).To(o.ContainSubstring("stable-v1.0 nginx-operator.v1.0.1")) exutil.By("step: create dir catalog-3") catsrcPath3 := filepath.Join(opmBaseDir, "catalog-3") err = os.MkdirAll(catsrcPath3, 0755) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("step: not set GenerateMajorChannels and GenerateMinorChannels") output, err = opmCLI.Run("alpha").Args("render-template", "semver", filepath.Join(opmBaseDir, "catalog-semver-veneer-3.yaml")).Output() o.Expect(err).NotTo(o.HaveOccurred()) indexFilePath = filepath.Join(catsrcPath3, "index.json") if err = ioutil.WriteFile(indexFilePath, []byte(output), 0644); err != nil { e2e.Failf(fmt.Sprintf("Writefile %s Error: %v", indexFilePath, err)) } output, err = opmCLI.Run("validate").Args(catsrcPath3).Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } output, err = opmCLI.Run("alpha").Args("list", "channels", catsrcPath3, "nginx-operator").Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).NotTo(o.ContainSubstring("candidate-v0 ")) o.Expect(string(output)).To(o.ContainSubstring("candidate-v0.0 nginx-operator.v0.0.1")) o.Expect(string(output)).NotTo(o.ContainSubstring("candidate-v1 ")) o.Expect(string(output)).To(o.ContainSubstring("candidate-v1.0 nginx-operator.v1.0.2")) o.Expect(string(output)).NotTo(o.ContainSubstring("fast-v0 ")) o.Expect(string(output)).To(o.ContainSubstring("fast-v0.0 nginx-operator.v0.0.1")) o.Expect(string(output)).NotTo(o.ContainSubstring("fast-v2 ")) o.Expect(string(output)).To(o.ContainSubstring("fast-v2.0 nginx-operator.v2.0.1")) o.Expect(string(output)).To(o.ContainSubstring("fast-v2.1 nginx-operator.v2.1.0")) o.Expect(string(output)).NotTo(o.ContainSubstring("stable-v2 ")) o.Expect(string(output)).To(o.ContainSubstring("stable-v2.1 nginx-operator.v2.1.0")) exutil.By("step: generate mermaid graph data for generated-channels") output, err = opmCLI.Run("alpha").Args("render-template", "semver", filepath.Join(opmBaseDir, "catalog-semver-veneer-4.yaml"), "-o", "mermaid").Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("channel \"fast-v2.0\"")) o.Expect(string(output)).To(o.ContainSubstring("subgraph nginx-operator-fast-v2.0[\"fast-v2.0\"]")) o.Expect(string(output)).To(o.ContainSubstring("nginx-operator-fast-v2.0-nginx-operator.v2.0.1[\"nginx-operator.v2.0.1\"]")) exutil.By("step: semver veneer should validate bundle versions") output, err = opmCLI.Run("alpha").Args("render-template", "semver", filepath.Join(opmBaseDir, "catalog-semver-veneer-5.yaml")).Output() o.Expect(err).To(o.HaveOccurred()) o.Expect(string(output)).To(o.ContainSubstring("encountered bundle versions which differ only by build metadata, which cannot be ordered")) o.Expect(string(output)).To(o.ContainSubstring("cannot be compared to \"1.0.1-alpha\"")) exutil.By("OCP-53996") filePath := filepath.Join(opmBaseDir, "catalog-semver-veneer-1.yaml") exutil.By("step: create dir catalog") catsrcPath53996 := filepath.Join(opmBaseDir, "catalog-53996") err = os.MkdirAll(catsrcPath53996, 0755) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("step: generate index.yaml with yaml format") command := "cat " + filePath + "| opm alpha render-template semver -o yaml - " contentByte, err := exec.Command("bash", "-c", command).Output() o.Expect(err).NotTo(o.HaveOccurred()) indexFilePath = filepath.Join(catsrcPath53996, "index.yaml") if err = ioutil.WriteFile(indexFilePath, contentByte, 0644); err != nil { e2e.Failf(fmt.Sprintf("Writefile %s Error: %v", indexFilePath, err)) } output, err = opmCLI.Run("validate").Args(catsrcPath53996).Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } output, err = opmCLI.Run("alpha").Args("list", "channels", catsrcPath53996, "nginx-operator").Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("candidate-v0 nginx-operator.v0.0.1")) o.Expect(string(output)).To(o.ContainSubstring("candidate-v1 nginx-operator.v1.0.2")) o.Expect(string(output)).To(o.ContainSubstring("candidate-v2 nginx-operator.v2.1.0")) o.Expect(string(output)).To(o.ContainSubstring("fast-v0 nginx-operator.v0.0.1")) o.Expect(string(output)).To(o.ContainSubstring("fast-v2 nginx-operator.v2.1.0")) o.Expect(string(output)).To(o.ContainSubstring("stable-v1 nginx-operator.v1.0.2")) o.Expect(string(output)).To(o.ContainSubstring("stable-v2 nginx-operator.v2.1.0")) exutil.By("step: generate json format file") command = "cat " + filePath + `| opm alpha render-template semver - | jq 'select(.schema=="olm.channel")'| jq '{name,entries}'` contentByte, err = exec.Command("bash", "-c", command).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(string(contentByte)).To(o.ContainSubstring("nginx-operator.v1.0.2")) o.Expect(string(contentByte)).To(o.ContainSubstring("candidate-v1")) exutil.By("step: generate mermaid graph data for generated-channels") command = "cat " + filePath + "| opm alpha render-template semver -o mermaid -" contentByte, err = exec.Command("bash", "-c", command).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(string(contentByte)).To(o.ContainSubstring("package \"nginx-operator\"")) o.Expect(string(contentByte)).To(o.ContainSubstring("nginx-operator-candidate-v1-nginx-operator.v1.0.1")) })
test case
openshift/openshift-tests-private
ca500bd5-b786-4977-9d11-68ba80eac901
Author:xzha-ConnectedOnly-Medium-53917-opm can visualize the update graph for a given Operator from an arbitrary version
['"fmt"', '"io/ioutil"', '"os"', '"path/filepath"']
github.com/openshift/openshift-tests-private/test/extended/opm/opm.go
g.It("Author:xzha-ConnectedOnly-Medium-53917-opm can visualize the update graph for a given Operator from an arbitrary version", func() { if os.Getenv("HTTP_PROXY") != "" || os.Getenv("http_proxy") != "" { g.Skip("HTTP_PROXY is not empty - skipping test ...") } exutil.By("step: check help message") output, err := opmCLI.Run("alpha").Args("render-graph", "-h").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(string(output)).To(o.ContainSubstring("--minimum-edge")) o.Expect(string(output)).To(o.ContainSubstring("--use-http")) exutil.By("step: opm alpha render-graph index-image") output, err = opmCLI.Run("alpha").Args("render-graph", "quay.io/olmqe/nginxolm-operator-index:v1").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(string(output)).To(o.ContainSubstring("package \"nginx-operator\"")) o.Expect(string(output)).To(o.ContainSubstring("subgraph nginx-operator-alpha[\"alpha\"]")) exutil.By("step: opm alpha render-graph index-image with --minimum-edge") output, err = opmCLI.Run("alpha").Args("render-graph", "quay.io/olmqe/nginxolm-operator-index:v1", "--minimum-edge", "nginx-operator.v1.0.1").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(string(output)).To(o.ContainSubstring("package \"nginx-operator\"")) o.Expect(string(output)).To(o.ContainSubstring("nginx-operator.v1.0.1")) o.Expect(string(output)).NotTo(o.ContainSubstring("nginx-operator.v0.0.1")) exutil.By("step: create dir catalog") catsrcPath := filepath.Join("/tmp", "53917-catalog") defer os.RemoveAll(catsrcPath) errCreateDir := os.MkdirAll(catsrcPath, 0755) o.Expect(errCreateDir).NotTo(o.HaveOccurred()) exutil.By("step: opm alpha render-graph fbc-dir") output, err = opmCLI.Run("render").Args("quay.io/olmqe/nginxolm-operator-index:v1", "-o", "json").Output() o.Expect(err).NotTo(o.HaveOccurred()) indexFilePath := filepath.Join(catsrcPath, "index.json") if err = ioutil.WriteFile(indexFilePath, []byte(output), 0644); err != nil { e2e.Failf(fmt.Sprintf("Writefile %s Error: %v", indexFilePath, err)) } output, err = opmCLI.Run("alpha").Args("render-graph", catsrcPath).Output() if err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } o.Expect(string(output)).To(o.ContainSubstring("package \"nginx-operator\"")) o.Expect(string(output)).To(o.ContainSubstring("subgraph nginx-operator-alpha[\"alpha\"]")) exutil.By("step: opm alpha render-graph sqlit-based catalog image") output, err = opmCLI.Run("alpha").Args("render-graph", "quay.io/olmqe/ditto-index:v1beta1").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(string(output)).To(o.ContainSubstring("subgraph \"ditto-operator\"")) o.Expect(string(output)).To(o.ContainSubstring("subgraph ditto-operator-alpha[\"alpha\"]")) o.Expect(string(output)).To(o.ContainSubstring("ditto-operator.v0.2.0")) })
test case
openshift/openshift-tests-private
219562c1-f510-49a0-aad4-c330dfd8f7b1
ConnectedOnly-Author:scolange-VMonly-Medium-25934-Reference non-latest versions of bundles by image digests
['"context"', '"fmt"', '"os"', '"os/exec"', '"path/filepath"', '"strings"', '"time"', 'container "github.com/openshift/openshift-tests-private/test/extended/util/container"', 'db "github.com/openshift/openshift-tests-private/test/extended/util/db"', '"k8s.io/apimachinery/pkg/util/wait"']
github.com/openshift/openshift-tests-private/test/extended/opm/opm.go
g.It("ConnectedOnly-Author:scolange-VMonly-Medium-25934-Reference non-latest versions of bundles by image digests", func() { containerCLI := container.NewPodmanCLI() containerTool := "podman" opmBaseDir := exutil.FixturePath("testdata", "opm") TmpDataPath := filepath.Join(opmBaseDir, "tmp") err := os.MkdirAll(TmpDataPath, 0755) o.Expect(err).NotTo(o.HaveOccurred()) bundleImageTag1 := "quay.io/olmqe/etcd-bundle:0.9.0" bundleImageTag2 := "quay.io/olmqe/etcd-bundle:0.9.0-25934" defer DeleteDir(TmpDataPath, "fixture-testdata") defer containerCLI.RemoveImage(bundleImageTag2) defer containerCLI.RemoveImage(bundleImageTag1) defer exec.Command("kill", "-9", "$(lsof -t -i:25934)").Output() if output, err := containerCLI.Run("pull").Args(bundleImageTag1).Output(); err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } if output, err := containerCLI.Run("tag").Args(bundleImageTag1, bundleImageTag2).Output(); err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } if output, err := containerCLI.Run("push").Args(bundleImageTag2).Output(); err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } exutil.By("step: build bundle.db") dbFilePath := TmpDataPath + "bundles.db" if output, err := opmCLI.Run("registry").Args("add", "-b", bundleImageTag2, "-d", dbFilePath, "-c", containerTool, "--mode", "semver").Output(); err != nil { e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) } exutil.By("step: Run the opm registry server binary to load manifest and serves a grpc API to query it.") e2e.Logf("step: Run the registry-server ") cmd := exec.Command("opm", "registry", "serve", "-d", dbFilePath, "-p", "25934") e2e.Logf("cmd %v:", cmd) cmd.Dir = TmpDataPath err = cmd.Start() e2e.Logf("cmd %v raise error: %v", cmd, err) o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("step: check api.Registry/ListPackages") err = wait.PollUntilContextTimeout(context.TODO(), 20*time.Second, 240*time.Second, false, func(ctx context.Context) (bool, error) { outputCurl, err := exec.Command("grpcurl", "-plaintext", "localhost:25934", "api.Registry/ListPackages").Output() o.Expect(err).NotTo(o.HaveOccurred()) if strings.Contains(string(outputCurl), "etcd") { return true, nil } return false, nil }) exutil.AssertWaitPollNoErr(err, fmt.Sprintf("grpcurl %s not listet package", dbFilePath)) e2e.Logf("step: check api.Registry/GetBundleForChannel") outputCurl, err := exec.Command("grpcurl", "-plaintext", "localhost:25934", "api.Registry/ListBundles").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(string(outputCurl)).To(o.ContainSubstring("bundlePath")) cmd.Process.Kill() exutil.By("step: SUCCESS 25934") })
test case
openshift/openshift-tests-private
81f1a392-acc6-4660-baa1-5fc8776577dc
ConnectedOnly-Author:scolange-VMonly-Medium-47222-can't remove package from index: database is locked
['"os"', '"os/exec"', '"path/filepath"', 'container "github.com/openshift/openshift-tests-private/test/extended/util/container"']
github.com/openshift/openshift-tests-private/test/extended/opm/opm.go
g.It("ConnectedOnly-Author:scolange-VMonly-Medium-47222-can't remove package from index: database is locked", func() { podmanCLI := container.NewPodmanCLI() baseDir := exutil.FixturePath("testdata", "olm") TestDataPath := filepath.Join(baseDir, "temp") indexTmpPath := filepath.Join(TestDataPath, getRandomString()) defer DeleteDir(TestDataPath, indexTmpPath) err := os.MkdirAll(indexTmpPath, 0755) o.Expect(err).NotTo(o.HaveOccurred()) indexImage := "registry.redhat.io/redhat/certified-operator-index:v4.7" exutil.By("remove package from index") dockerconfigjsonpath := filepath.Join(indexTmpPath, ".dockerconfigjson") defer exec.Command("rm", "-f", dockerconfigjsonpath).Output() _, err = oc.AsAdmin().Run("extract").Args("secret/pull-secret", "-n", "openshift-config", "--confirm", "--to="+indexTmpPath).Output() o.Expect(err).NotTo(o.HaveOccurred()) opmCLI.SetAuthFile(dockerconfigjsonpath) defer podmanCLI.RemoveImage(indexImage) output, err := opmCLI.Run("index").Args("rm", "--generate", "--binary-image", "registry.redhat.io/openshift4/ose-operator-registry:v4.7", "--from-index", indexImage, "--operators", "cert-manager-operator", "--pull-tool=podman").Output() e2e.Logf(output) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("test case 47222 SUCCESS") })
test case
openshift/openshift-tests-private
b823bb92-6256-4c9c-b74b-8318c2aed916
ConnectedOnly-Author:jitli-Medium-60573-opm exclude bundles with olm.deprecated property when rendering
['"strings"']
github.com/openshift/openshift-tests-private/test/extended/opm/opm.go
g.It("ConnectedOnly-Author:jitli-Medium-60573-opm exclude bundles with olm.deprecated property when rendering", func() { exutil.By("opm render the sqlite index image message") msg, err := opmCLI.Run("render").Args("quay.io/olmqe/catalogtest-index:v4.12depre", "-oyaml").Output() o.Expect(err).NotTo(o.HaveOccurred()) if strings.Contains(msg, "olm.deprecated") { e2e.Failf("opm render the sqlite index image message, doesn't show the bundle with olm.dreprecated label") } exutil.By("opm render the fbc index image message") msg, err = opmCLI.Run("render").Args("quay.io/olmqe/test-index:mix", "-oyaml").Output() o.Expect(err).NotTo(o.HaveOccurred()) if strings.Contains(msg, "olm.deprecated") { e2e.Logf("opm render the fbc index image message, still show the bundle with olm.dreprecated label") } else { e2e.Failf("opm render the fbc index image message, should show the bundle with olm.dreprecated label") } })
test case
openshift/openshift-tests-private
0b6d48e6-ce24-4392-8e0d-190a05b18ca4
Author:jitli-ConnectedOnly-Medium-73218-opm alpha render-graph indicate deprecated graph content
['"os"']
github.com/openshift/openshift-tests-private/test/extended/opm/opm.go
g.It("Author:jitli-ConnectedOnly-Medium-73218-opm alpha render-graph indicate deprecated graph content", func() { if os.Getenv("HTTP_PROXY") != "" || os.Getenv("http_proxy") != "" { g.Skip("HTTP_PROXY is not empty - skipping test ...") } exutil.By("step: opm alpha render-graph index-image with deprecated label") output, err := opmCLI.Run("alpha").Args("render-graph", "quay.io/olmqe/olmtest-operator-index:nginxolm73218").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(string(output)).To(o.ContainSubstring("classDef deprecated fill:#E8960F")) o.Expect(string(output)).To(o.ContainSubstring("nginx73218-candidate-v1.0-nginx73218.v1.0.1[\"nginx73218.v1.0.1\"]:::deprecated")) o.Expect(string(output)).To(o.ContainSubstring("nginx73218-candidate-v1.0-nginx73218.v1.0.1[\"nginx73218.v1.0.1\"]-- skip --> nginx73218-candidate-v1.0-nginx73218.v1.0.3[\"nginx73218.v1.0.3\"]")) })
test case
openshift/openshift-tests-private
c6318f47-2e83-4fb5-ad9b-b3a7dc2806a8
Author:jitli-VMonly-ConnectedOnly-High-75148-opm generate binary-less dockerfiles
['"context"', '"io/ioutil"', '"os"', '"path/filepath"', '"strings"', '"time"', 'g "github.com/onsi/ginkgo/v2"', '"k8s.io/apimachinery/pkg/util/wait"', 'e2e "k8s.io/kubernetes/test/e2e/framework"']
github.com/openshift/openshift-tests-private/test/extended/opm/opm.go
g.It("Author:jitli-VMonly-ConnectedOnly-High-75148-opm generate binary-less dockerfiles", func() { tmpBasePath := "/tmp/ocp-75148-" + getRandomString() tmpPath := filepath.Join(tmpBasePath, "catalog") dockerFile := filepath.Join(tmpBasePath, "catalog.Dockerfile") err := os.MkdirAll(tmpPath, 0o755) o.Expect(err).NotTo(o.HaveOccurred()) defer os.RemoveAll(tmpBasePath) opmCLI.ExecCommandPath = tmpBasePath exutil.By("Check flag --binary-image has been deprecated") output, err := opmCLI.Run("generate").Args("dockerfile", "--binary-image", "quay.io/operator-framework/opm:latest", "catalog").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("--binary-image has been deprecated, use --base-image instead")) err = os.Remove(dockerFile) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("Check parameter --base-image and --builder-image") _, err = opmCLI.Run("generate").Args("dockerfile", "catalog", "-i", "quay.io/openshifttest/opm:v1", "-b", "quay.io/openshifttest/opm:v2").Output() o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("Check the custom images in Dockerfile") waitErr := wait.PollUntilContextTimeout(context.TODO(), 2*time.Second, 6*time.Second, false, func(ctx context.Context) (bool, error) { if _, err := os.Stat(dockerFile); os.IsNotExist(err) { e2e.Logf("get catalog.Dockerfile Failed") return false, nil } return true, nil }) exutil.AssertWaitPollNoErr(waitErr, "get catalog.Dockerfile Failed") content, err := ioutil.ReadFile(dockerFile) o.Expect(err).NotTo(o.HaveOccurred()) if !strings.Contains(string(content), "FROM quay.io/openshifttest/opm:v2 as builder") || !strings.Contains(string(content), "FROM quay.io/openshifttest/opm:v1") { e2e.Failf("Fail to get the custom images in Dockerfile") } err = os.Remove(dockerFile) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("Create a binary-less dockerfile") _, err = opmCLI.Run("generate").Args("dockerfile", "catalog", "--base-image=scratch").Output() o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("Check the custom images in Dockerfile") waitErr = wait.PollUntilContextTimeout(context.TODO(), 2*time.Second, 6*time.Second, false, func(ctx context.Context) (bool, error) { if _, err := os.Stat(dockerFile); os.IsNotExist(err) { e2e.Logf("get catalog.Dockerfile Failed") return false, nil } return true, nil }) exutil.AssertWaitPollNoErr(waitErr, "get catalog.Dockerfile Failed") content, err = ioutil.ReadFile(dockerFile) o.Expect(err).NotTo(o.HaveOccurred()) if !strings.Contains(string(content), "OLMv0 CatalogSources that use binary-less images must set:") || !strings.Contains(string(content), "extractContent:") || !strings.Contains(string(content), "FROM scratch") { e2e.Failf("Fail to get the scratch in Dockerfile") } err = os.Remove(dockerFile) o.Expect(err).NotTo(o.HaveOccurred()) })
test
openshift/openshift-tests-private
08bea427-253f-4d64-bddc-79c0aad18a55
cli
import ( "fmt" "io/ioutil" "os" "os/exec" "path/filepath" "strconv" "strings" g "github.com/onsi/ginkgo/v2" o "github.com/onsi/gomega" exutil "github.com/openshift/openshift-tests-private/test/extended/util" e2e "k8s.io/kubernetes/test/e2e/framework" )
github.com/openshift/openshift-tests-private/test/extended/ota/cvo/cli.go
package cvo import ( "fmt" "io/ioutil" "os" "os/exec" "path/filepath" "strconv" "strings" g "github.com/onsi/ginkgo/v2" o "github.com/onsi/gomega" exutil "github.com/openshift/openshift-tests-private/test/extended/util" e2e "k8s.io/kubernetes/test/e2e/framework" ) var _ = g.Describe("[sig-updates] OTA oc should", func() { defer g.GinkgoRecover() oc := exutil.NewCLIWithoutNamespace("ota-oc") //author: [email protected] //this test does not reply on a live cluster, so connectedonly is for access to quay.io g.It("ConnectedOnly-Author:jiajliu-High-66746-Extract CredentialsRequest from a single-arch release image with --included --install-config", func() { testDataDir := exutil.FixturePath("testdata", "ota/cvo/cfg-ocp-66746") exutil.By("Get expected release image for the test") clusterVersion, _, err := exutil.GetClusterVersion(oc) o.Expect(err).NotTo(o.HaveOccurred()) latest4StableImage, err := exutil.GetLatest4StableImage() o.Expect(latest4StableImage).NotTo(o.BeEmpty()) o.Expect(err).NotTo(o.HaveOccurred()) if !strings.Contains(latest4StableImage, clusterVersion) { g.Skip("There is not expected release image for the test") } exutil.By("Check the help info on the two vars --included and --install-config") out, err := oc.AsAdmin().WithoutNamespace().Run("adm").Args("release", "extract", "--help").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(strings.Contains(out, `--included=false: Exclude manifests that are not expected to be included in the cluster.`)) o.Expect(strings.Contains(out, `--install-config='': Path to an install-config file, as consumed by the openshift-install command. Works only in combination with --included.`)) exutil.By("Extract all CR manifests from the specified release payload and check correct caps and featureset credential request extracted") files, err := ioutil.ReadDir(testDataDir) o.Expect(err).NotTo(o.HaveOccurred()) caps := getDefaultCapsInCR(clusterVersion) o.Expect(caps).NotTo(o.BeNil()) for _, file := range files { filepath := filepath.Join(testDataDir, file.Name()) if strings.Contains(file.Name(), "4.x") { cmd := fmt.Sprintf("sed -i 's/4.x/%s/g' %s", clusterVersion, filepath) out, err := exec.Command("bash", "-c", cmd).CombinedOutput() o.Expect(err).NotTo(o.HaveOccurred(), "Command: \"%s\" returned error: %s", cmd, string(out)) defer func() { cmd := fmt.Sprintf("sed -i 's/%s/4.x/g' %s", clusterVersion, filepath) out, err := exec.Command("bash", "-c", cmd).CombinedOutput() o.Expect(err).NotTo(o.HaveOccurred(), "Command: \"%s\" returned error: %s", cmd, string(out)) }() } extractedCR, err := extractIncludedManifestWithInstallcfg(oc, true, filepath, latest4StableImage, "") defer func() { o.Expect(os.RemoveAll(extractedCR)).NotTo(o.HaveOccurred()) }() o.Expect(err).NotTo(o.HaveOccurred()) cmd := fmt.Sprintf("grep -r 'release.openshift.io/feature-set\\|capability.openshift.io/name' %s|awk -F\":\" '{print $NF}'|sort -u", extractedCR) out, _ := exec.Command("bash", "-c", cmd).CombinedOutput() extractedCAP := strings.Fields(string(out)) switch { case strings.Contains(file.Name(), "featureset"): o.Expect(len(extractedCAP)).To(o.Equal(len(caps) + 1)) o.Expect(string(out)).To(o.ContainSubstring("TechPreviewNoUpgrade")) for _, cap := range caps { o.Expect(string(out)).To(o.ContainSubstring(cap)) } case strings.Contains(file.Name(), "none"): o.Expect(string(out)).To(o.BeEmpty()) case strings.Contains(file.Name(), "4.x"), strings.Contains(file.Name(), "vcurrent"): o.Expect(len(extractedCAP)).To(o.Equal(len(caps))) o.Expect(string(out)).NotTo(o.ContainSubstring("TechPreviewNoUpgrade")) for _, cap := range caps { o.Expect(string(out)).To(o.ContainSubstring(cap)) } default: e2e.Failf("No expected test file found!") } } }) //author: [email protected] //this is an oc test which does not need a live cluster, so connectedonly is for access to quay.io, and getRandomPlatform is to limit test frequency g.It("ConnectedOnly-Author:jiajliu-Medium-66751-Extract CredentialsRequest from a multi-arch release image with --included --install-config", func() { platform := getRandomPlatform() exutil.SkipIfPlatformTypeNot(oc, platform) testDataDir := exutil.FixturePath("testdata", "ota/cvo") cfgFile := filepath.Join(testDataDir, "ocp-66751.yaml") exutil.By("Get expected release image for the test") clusterVersion, _, err := exutil.GetClusterVersion(oc) o.Expect(err).NotTo(o.HaveOccurred()) minorVer, err := strconv.Atoi(strings.Split(clusterVersion, ".")[1]) o.Expect(err).NotTo(o.HaveOccurred()) stream := fmt.Sprintf("4-stable-multi/latest?in=>4.%s.0-0+<4.%s.0-0", minorVer, minorVer+1) latest4StableMultiImage, err := exutil.GetLatest4StableImageByStream("multi", stream) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(latest4StableMultiImage).NotTo(o.BeEmpty()) exutil.By("Extract all manifests from the specified release payload") extractedManifest, err := extractIncludedManifestWithInstallcfg(oc, false, cfgFile, latest4StableMultiImage, "") defer func() { o.Expect(os.RemoveAll(extractedManifest)).NotTo(o.HaveOccurred()) }() o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("Check correct caps and featureset manifests extracted") caps := []string{"Console", "MachineAPI"} cmd := fmt.Sprintf("grep -rh 'release.openshift.io/feature-set\\|capability.openshift.io/name' %s|awk -F\":\" '{print $NF}'|sort -u", extractedManifest) out, _ := exec.Command("bash", "-c", cmd).CombinedOutput() extractedCAP := strings.Fields(string(out)) o.Expect(len(extractedCAP)).To(o.Equal(4), "unexpected extracted cap lengh in: %v", extractedCAP) // in 4.16 we also have "CustomNoUpgrade,TechPreviewNoUpgrade" o.Expect(string(out)).To(o.ContainSubstring("TechPreviewNoUpgrade")) for _, cap := range caps { o.Expect(string(out)).To(o.ContainSubstring(cap)) } }) //author: [email protected] //this is an oc test which does not need a live cluster, so connectedonly is for access to quay.io, and getRandomPlatform is to limit test frequency g.It("ConnectedOnly-Author:jiajliu-Low-66747-Run extract --included --install-config against bad config files or unavailable release payload", func() { platform := getRandomPlatform() exutil.SkipIfPlatformTypeNot(oc, platform) testDataDir := exutil.FixturePath("testdata", "ota/cvo/cfg-ocp-66747") cfgFile := filepath.Join(testDataDir, "gcp.yaml") badFile := filepath.Join(testDataDir, "bad.yaml") fakeReleasePayload := "quay.io/openshift-release-dev/ocp-release@sha256:fd96300600f9585e5847f5855ca14e2b3cafbce12aefe3b3f52c5da10c466666" exutil.By("Get expected release image for the test") latest4StableImage, err := exutil.GetLatest4StableImage() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(latest4StableImage).NotTo(o.BeEmpty()) exutil.By("Check the error msg is about the wrong cloud type") _, err = extractIncludedManifestWithInstallcfg(oc, true, cfgFile, latest4StableImage, "aws") o.Expect(err).To(o.HaveOccurred()) o.Expect(err.Error()).To(o.ContainSubstring("error: --cloud \"aws\" set")) o.Expect(err.Error()).To(o.ContainSubstring("has \"gcp\"")) exutil.By("Check the error msg is about wrong format of baselineCapabilitySet") _, err = extractIncludedManifestWithInstallcfg(oc, true, badFile, latest4StableImage, "") o.Expect(err).To(o.HaveOccurred()) o.Expect(err.Error()).To(o.ContainSubstring("error: unrecognized baselineCapabilitySet \"none\"")) exutil.By("Check the error msg is about image not found") _, err = extractIncludedManifestWithInstallcfg(oc, true, cfgFile, fakeReleasePayload, "") o.Expect(err).To(o.HaveOccurred()) o.Expect(err.Error()).To(o.ContainSubstring("not found: manifest unknown: manifest unknown")) }) })
package cvo
test case
openshift/openshift-tests-private
efd984bd-200f-49fc-869f-dbf0932cc37f
ConnectedOnly-Author:jiajliu-High-66746-Extract CredentialsRequest from a single-arch release image with --included --install-config
['"fmt"', '"io/ioutil"', '"os"', '"os/exec"', '"path/filepath"', '"strings"']
github.com/openshift/openshift-tests-private/test/extended/ota/cvo/cli.go
g.It("ConnectedOnly-Author:jiajliu-High-66746-Extract CredentialsRequest from a single-arch release image with --included --install-config", func() { testDataDir := exutil.FixturePath("testdata", "ota/cvo/cfg-ocp-66746") exutil.By("Get expected release image for the test") clusterVersion, _, err := exutil.GetClusterVersion(oc) o.Expect(err).NotTo(o.HaveOccurred()) latest4StableImage, err := exutil.GetLatest4StableImage() o.Expect(latest4StableImage).NotTo(o.BeEmpty()) o.Expect(err).NotTo(o.HaveOccurred()) if !strings.Contains(latest4StableImage, clusterVersion) { g.Skip("There is not expected release image for the test") } exutil.By("Check the help info on the two vars --included and --install-config") out, err := oc.AsAdmin().WithoutNamespace().Run("adm").Args("release", "extract", "--help").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(strings.Contains(out, `--included=false: Exclude manifests that are not expected to be included in the cluster.`)) o.Expect(strings.Contains(out, `--install-config='': Path to an install-config file, as consumed by the openshift-install command. Works only in combination with --included.`)) exutil.By("Extract all CR manifests from the specified release payload and check correct caps and featureset credential request extracted") files, err := ioutil.ReadDir(testDataDir) o.Expect(err).NotTo(o.HaveOccurred()) caps := getDefaultCapsInCR(clusterVersion) o.Expect(caps).NotTo(o.BeNil()) for _, file := range files { filepath := filepath.Join(testDataDir, file.Name()) if strings.Contains(file.Name(), "4.x") { cmd := fmt.Sprintf("sed -i 's/4.x/%s/g' %s", clusterVersion, filepath) out, err := exec.Command("bash", "-c", cmd).CombinedOutput() o.Expect(err).NotTo(o.HaveOccurred(), "Command: \"%s\" returned error: %s", cmd, string(out)) defer func() { cmd := fmt.Sprintf("sed -i 's/%s/4.x/g' %s", clusterVersion, filepath) out, err := exec.Command("bash", "-c", cmd).CombinedOutput() o.Expect(err).NotTo(o.HaveOccurred(), "Command: \"%s\" returned error: %s", cmd, string(out)) }() } extractedCR, err := extractIncludedManifestWithInstallcfg(oc, true, filepath, latest4StableImage, "") defer func() { o.Expect(os.RemoveAll(extractedCR)).NotTo(o.HaveOccurred()) }() o.Expect(err).NotTo(o.HaveOccurred()) cmd := fmt.Sprintf("grep -r 'release.openshift.io/feature-set\\|capability.openshift.io/name' %s|awk -F\":\" '{print $NF}'|sort -u", extractedCR) out, _ := exec.Command("bash", "-c", cmd).CombinedOutput() extractedCAP := strings.Fields(string(out)) switch { case strings.Contains(file.Name(), "featureset"): o.Expect(len(extractedCAP)).To(o.Equal(len(caps) + 1)) o.Expect(string(out)).To(o.ContainSubstring("TechPreviewNoUpgrade")) for _, cap := range caps { o.Expect(string(out)).To(o.ContainSubstring(cap)) } case strings.Contains(file.Name(), "none"): o.Expect(string(out)).To(o.BeEmpty()) case strings.Contains(file.Name(), "4.x"), strings.Contains(file.Name(), "vcurrent"): o.Expect(len(extractedCAP)).To(o.Equal(len(caps))) o.Expect(string(out)).NotTo(o.ContainSubstring("TechPreviewNoUpgrade")) for _, cap := range caps { o.Expect(string(out)).To(o.ContainSubstring(cap)) } default: e2e.Failf("No expected test file found!") } } })
test case
openshift/openshift-tests-private
f253a295-ee7d-47d5-bf83-f534f3e99306
ConnectedOnly-Author:jiajliu-Medium-66751-Extract CredentialsRequest from a multi-arch release image with --included --install-config
['"fmt"', '"os"', '"os/exec"', '"path/filepath"', '"strconv"', '"strings"']
github.com/openshift/openshift-tests-private/test/extended/ota/cvo/cli.go
g.It("ConnectedOnly-Author:jiajliu-Medium-66751-Extract CredentialsRequest from a multi-arch release image with --included --install-config", func() { platform := getRandomPlatform() exutil.SkipIfPlatformTypeNot(oc, platform) testDataDir := exutil.FixturePath("testdata", "ota/cvo") cfgFile := filepath.Join(testDataDir, "ocp-66751.yaml") exutil.By("Get expected release image for the test") clusterVersion, _, err := exutil.GetClusterVersion(oc) o.Expect(err).NotTo(o.HaveOccurred()) minorVer, err := strconv.Atoi(strings.Split(clusterVersion, ".")[1]) o.Expect(err).NotTo(o.HaveOccurred()) stream := fmt.Sprintf("4-stable-multi/latest?in=>4.%s.0-0+<4.%s.0-0", minorVer, minorVer+1) latest4StableMultiImage, err := exutil.GetLatest4StableImageByStream("multi", stream) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(latest4StableMultiImage).NotTo(o.BeEmpty()) exutil.By("Extract all manifests from the specified release payload") extractedManifest, err := extractIncludedManifestWithInstallcfg(oc, false, cfgFile, latest4StableMultiImage, "") defer func() { o.Expect(os.RemoveAll(extractedManifest)).NotTo(o.HaveOccurred()) }() o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("Check correct caps and featureset manifests extracted") caps := []string{"Console", "MachineAPI"} cmd := fmt.Sprintf("grep -rh 'release.openshift.io/feature-set\\|capability.openshift.io/name' %s|awk -F\":\" '{print $NF}'|sort -u", extractedManifest) out, _ := exec.Command("bash", "-c", cmd).CombinedOutput() extractedCAP := strings.Fields(string(out)) o.Expect(len(extractedCAP)).To(o.Equal(4), "unexpected extracted cap lengh in: %v", extractedCAP) // in 4.16 we also have "CustomNoUpgrade,TechPreviewNoUpgrade" o.Expect(string(out)).To(o.ContainSubstring("TechPreviewNoUpgrade")) for _, cap := range caps { o.Expect(string(out)).To(o.ContainSubstring(cap)) } })
test case
openshift/openshift-tests-private
3013c550-0888-4d96-b511-8c0aa373315d
ConnectedOnly-Author:jiajliu-Low-66747-Run extract --included --install-config against bad config files or unavailable release payload
['"path/filepath"']
github.com/openshift/openshift-tests-private/test/extended/ota/cvo/cli.go
g.It("ConnectedOnly-Author:jiajliu-Low-66747-Run extract --included --install-config against bad config files or unavailable release payload", func() { platform := getRandomPlatform() exutil.SkipIfPlatformTypeNot(oc, platform) testDataDir := exutil.FixturePath("testdata", "ota/cvo/cfg-ocp-66747") cfgFile := filepath.Join(testDataDir, "gcp.yaml") badFile := filepath.Join(testDataDir, "bad.yaml") fakeReleasePayload := "quay.io/openshift-release-dev/ocp-release@sha256:fd96300600f9585e5847f5855ca14e2b3cafbce12aefe3b3f52c5da10c466666" exutil.By("Get expected release image for the test") latest4StableImage, err := exutil.GetLatest4StableImage() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(latest4StableImage).NotTo(o.BeEmpty()) exutil.By("Check the error msg is about the wrong cloud type") _, err = extractIncludedManifestWithInstallcfg(oc, true, cfgFile, latest4StableImage, "aws") o.Expect(err).To(o.HaveOccurred()) o.Expect(err.Error()).To(o.ContainSubstring("error: --cloud \"aws\" set")) o.Expect(err.Error()).To(o.ContainSubstring("has \"gcp\"")) exutil.By("Check the error msg is about wrong format of baselineCapabilitySet") _, err = extractIncludedManifestWithInstallcfg(oc, true, badFile, latest4StableImage, "") o.Expect(err).To(o.HaveOccurred()) o.Expect(err.Error()).To(o.ContainSubstring("error: unrecognized baselineCapabilitySet \"none\"")) exutil.By("Check the error msg is about image not found") _, err = extractIncludedManifestWithInstallcfg(oc, true, cfgFile, fakeReleasePayload, "") o.Expect(err).To(o.HaveOccurred()) o.Expect(err.Error()).To(o.ContainSubstring("not found: manifest unknown: manifest unknown")) })
test
openshift/openshift-tests-private
29fd94e3-6bd5-4539-acf1-56d1e57772ed
cvo
import ( "context" "encoding/json" "fmt" "os" "os/exec" "path/filepath" "reflect" "regexp" "strconv" "strings" "time" "cloud.google.com/go/storage" g "github.com/onsi/ginkgo/v2" o "github.com/onsi/gomega" configv1 "github.com/openshift/api/config/v1" exutil "github.com/openshift/openshift-tests-private/test/extended/util" "github.com/tidwall/gjson" "k8s.io/apimachinery/pkg/util/wait" e2e "k8s.io/kubernetes/test/e2e/framework" "sigs.k8s.io/yaml" )
github.com/openshift/openshift-tests-private/test/extended/ota/cvo/cvo.go
package cvo import ( "context" "encoding/json" "fmt" "os" "os/exec" "path/filepath" "reflect" "regexp" "strconv" "strings" "time" "cloud.google.com/go/storage" g "github.com/onsi/ginkgo/v2" o "github.com/onsi/gomega" configv1 "github.com/openshift/api/config/v1" exutil "github.com/openshift/openshift-tests-private/test/extended/util" "github.com/tidwall/gjson" "k8s.io/apimachinery/pkg/util/wait" e2e "k8s.io/kubernetes/test/e2e/framework" "sigs.k8s.io/yaml" ) var _ = g.Describe("[sig-updates] OTA cvo should", func() { defer g.GinkgoRecover() projectName := "openshift-cluster-version" oc := exutil.NewCLIWithoutNamespace(projectName) //author: [email protected] g.It("NonHyperShiftHOST-Author:dis-High-56072-CVO pod should not crash", func() { exutil.By("Get CVO container status") CVOStatus, err := getCVOPod(oc, ".status.containerStatuses[]") o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(CVOStatus).NotTo(o.BeNil()) exutil.By("Check ready is true") o.Expect(CVOStatus["ready"]).To(o.BeTrue(), "CVO is not ready: %v", CVOStatus) exutil.By("Check started is true") o.Expect(CVOStatus["started"]).To(o.BeTrue(), "CVO is not started: %v", CVOStatus) exutil.By("Check state is running") o.Expect(CVOStatus["state"]).NotTo(o.BeNil(), "CVO have no state: %v", CVOStatus) o.Expect(CVOStatus["state"].(map[string]interface{})["running"]).NotTo(o.BeNil(), "CVO state have no running: %v", CVOStatus) exutil.By("Check exitCode of lastState is 0 if lastState is not empty") lastState := CVOStatus["lastState"] o.Expect(lastState).NotTo(o.BeNil(), "CVO have no lastState: %v", CVOStatus) if reflect.ValueOf(lastState).Len() == 0 { e2e.Logf("lastState is empty which is expected") } else { o.Expect(lastState.(map[string]interface{})["terminated"]).NotTo(o.BeNil(), "no terminated for non-empty CVO lastState: %v", CVOStatus) exitCode := lastState.(map[string]interface{})["terminated"].(map[string]interface{})["exitCode"].(float64) if exitCode == 255 && strings.Contains( lastState.(map[string]interface{})["terminated"].(map[string]interface{})["message"].(string), "Failed to get FeatureGate from cluster") { e2e.Logf("detected a known issue OCPBUGS-13873, skipping lastState check") } else { o.Expect(exitCode).To(o.BeZero(), "CVO terminated with non-zero code: %v", CVOStatus) reason := lastState.(map[string]interface{})["terminated"].(map[string]interface{})["reason"] o.Expect(reason.(string)).To(o.Equal("Completed"), "CVO terminated with unexpected reason: %v", CVOStatus) } } }) //author: [email protected] g.It("NonHyperShiftHOST-Author:dis-Medium-49508-disable capabilities by modifying the cv.spec.capabilities.baselineCapabilitySet [Serial]", func() { orgBaseCap, err := getCVObyJP(oc, ".spec.capabilities.baselineCapabilitySet") o.Expect(err).NotTo(o.HaveOccurred()) if orgBaseCap == "None" { g.Skip("The test cannot run on baselineCapabilitySet None") } defer func() { if newBaseCap, _ := getCVObyJP(oc, ".spec.capabilities.baselineCapabilitySet"); orgBaseCap != newBaseCap { var out string var err error e2e.Logf("restoring original base caps to '%s'", orgBaseCap) if orgBaseCap == "" { out, err = changeCap(oc, true, nil) } else { out, err = changeCap(oc, true, orgBaseCap) } o.Expect(err).NotTo(o.HaveOccurred(), out) } else { e2e.Logf("defer baselineCapabilitySet skipped for original value already matching '%v'", newBaseCap) } }() exutil.By("Check cap status and condition prior to change") enabledCap, err := getCVObyJP(oc, ".status.capabilities.enabledCapabilities[*]") o.Expect(err).NotTo(o.HaveOccurred()) capSet := strings.Split(enabledCap, " ") o.Expect(verifyCaps(oc, capSet)).NotTo(o.HaveOccurred()) out, err := getCVObyJP(oc, ".status.conditions[?(.type=='ImplicitlyEnabledCapabilities')]") o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(gjson.Get(out, "status").Bool()).To(o.Equal(false), "unexpected status dumping implicit %s", out) o.Expect(gjson.Get(out, "reason").String()).To(o.Equal("AsExpected"), "unexpected reason dumping implicit %s", out) o.Expect(gjson.Get(out, "message").String()).To(o.ContainSubstring("Capabilities match configured spec"), "unexpected message dumping implicit %s", out) exutil.By("Disable capabilities by modifying the baselineCapabilitySet") _, err = changeCap(oc, true, "None") o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("Check cap status and condition after change") enabledCapPost, err := getCVObyJP(oc, ".status.capabilities.enabledCapabilities[*]") o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(enabledCapPost).To(o.Equal(enabledCap)) o.Expect(verifyCaps(oc, capSet)).NotTo(o.HaveOccurred(), "verifyCaps for enabled %v failed", capSet) exutil.By("Check implicitly enabled caps are correct") out, err = getCVObyJP(oc, ".status.conditions[?(.type=='ImplicitlyEnabledCapabilities')]") o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(gjson.Get(out, "status").Bool()).To(o.Equal(true), "unexpected status dumping implicit %s", out) o.Expect(gjson.Get(out, "reason").String()).To(o.Equal("CapabilitiesImplicitlyEnabled"), "unexpected reason dumping implicit %s", out) o.Expect(gjson.Get(out, "message").String()).To(o.ContainSubstring("The following capabilities could not be disabled"), "unexpected message dumping implicit %s", out) o.Expect(gjson.Get(out, "message").String()).To(o.ContainSubstring(strings.Join(capSet, ", ")), "unexpected message dumping implicit %s", out) }) //author: [email protected] g.It("NonHyperShiftHOST-Author:dis-Low-49670-change spec.capabilities to invalid value", func() { orgCap, err := getCVObyJP(oc, ".spec.capabilities") o.Expect(err).NotTo(o.HaveOccurred()) if orgCap == "" { defer func() { out, err := ocJSONPatch(oc, "", "clusterversion/version", []JSONp{{"remove", "/spec/capabilities", nil}}) o.Expect(err).NotTo(o.HaveOccurred(), out) }() } else { orgBaseCap, err := getCVObyJP(oc, ".spec.capabilities.baselineCapabilitySet") o.Expect(err).NotTo(o.HaveOccurred()) orgAddCapstr, err := getCVObyJP(oc, ".spec.capabilities.additionalEnabledCapabilities[*]") o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("original baseline: '%s', original additional: '%s'", orgBaseCap, orgAddCapstr) orgAddCap := strings.Split(orgAddCapstr, " ") defer func() { if newBaseCap, _ := getCVObyJP(oc, ".spec.capabilities.baselineCapabilitySet"); orgBaseCap != newBaseCap { var out string var err error if orgBaseCap == "" { out, err = changeCap(oc, true, nil) } else { out, err = changeCap(oc, true, orgBaseCap) } o.Expect(err).NotTo(o.HaveOccurred(), out) } else { e2e.Logf("defer baselineCapabilitySet skipped for original value already matching '%v'", newBaseCap) } }() defer func() { if newAddCap, _ := getCVObyJP(oc, ".spec.capabilities.additionalEnabledCapabilities[*]"); !reflect.DeepEqual(orgAddCap, strings.Split(newAddCap, " ")) { var out string var err error if reflect.DeepEqual(orgAddCap, make([]string, 1)) { // need this cause strings.Split of an empty string creates len(1) slice which isn't nil out, err = changeCap(oc, false, nil) } else { out, err = changeCap(oc, false, orgAddCap) } o.Expect(err).NotTo(o.HaveOccurred(), out) } else { e2e.Logf("defer additionalEnabledCapabilities skipped for original value already matching '%v'", strings.Split(newAddCap, " ")) } }() } exutil.By("Set invalid baselineCapabilitySet") cmdOut, err := changeCap(oc, true, "Invalid") o.Expect(err).To(o.HaveOccurred()) clusterVersion, _, err := exutil.GetClusterVersion(oc) o.Expect(err).NotTo(o.HaveOccurred()) version := strings.Split(clusterVersion, ".") minor_version := version[1] latest_version, err := strconv.Atoi(minor_version) o.Expect(err).NotTo(o.HaveOccurred()) var versions []string for i := 11; i <= latest_version; i++ { versions = append(versions, "\"v4."+strconv.Itoa(i)+"\"") } versions = append(versions, "\"vCurrent\"") result := "Unsupported value: \"Invalid\": supported values: \"None\", " + strings.Join(versions, ", ") o.Expect(cmdOut).To(o.ContainSubstring(result)) // Important! this one should be updated each version with new capabilities, as they added to openshift. exutil.By("Set invalid additionalEnabledCapabilities") cmdOut, err = changeCap(oc, false, []string{"Invalid"}) o.Expect(err).To(o.HaveOccurred()) o.Expect(cmdOut).To(o.ContainSubstring("Unsupported value: \"Invalid\": supported values: \"openshift-samples\", \"baremetal\", \"marketplace\", \"Console\", \"Insights\", \"Storage\", \"CSISnapshot\", \"NodeTuning\", \"MachineAPI\", \"Build\", \"DeploymentConfig\", \"ImageRegistry\", \"OperatorLifecycleManager\", \"CloudCredential\", \"Ingress\", \"CloudControllerManager\", \"OperatorLifecycleManagerV1\"")) }) //author: [email protected] g.It("Longduration-NonPreRelease-ConnectedOnly-Author:jianl-Medium-45879-check update info with oc adm upgrade --include-not-recommended [Serial][Slow]", func() { exutil.By("Check if it's a GCP cluster") exutil.SkipIfPlatformTypeNot(oc, "gcp") orgUpstream, err := getCVObyJP(oc, ".spec.upstream") o.Expect(err).NotTo(o.HaveOccurred()) orgChannel, err := getCVObyJP(oc, ".spec.channel") o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("Original upstream: %s, original channel: %s", orgUpstream, orgChannel) exutil.By("Patch upstream and channel") projectID := "openshift-qe" ctx := context.Background() client, err := storage.NewClient(ctx) o.Expect(err).NotTo(o.HaveOccurred()) defer func() { o.Expect(client.Close()).NotTo(o.HaveOccurred()) }() graphURL, bucket, object, _, _, err := buildGraph(client, oc, projectID, "cincy-conditional-edge.json") defer func() { o.Expect(DeleteBucket(client, bucket)).NotTo(o.HaveOccurred()) }() defer func() { o.Expect(DeleteObject(client, bucket, object)).NotTo(o.HaveOccurred()) }() o.Expect(err).NotTo(o.HaveOccurred()) _, err = ocJSONPatch(oc, "", "clusterversion/version", []JSONp{ {"add", "/spec/upstream", graphURL}, {"add", "/spec/channel", "stable-a"}, }) o.Expect(err).NotTo(o.HaveOccurred()) defer restoreCVSpec(orgUpstream, orgChannel, oc) exutil.By("Check recommended update and notes about additional updates present on the output of oc adm upgrade") o.Expect(checkUpdates(oc, false, 1, 10, "Additional updates which are not recommended", //"based on your cluster configuration are available", //"or where the recommended status is \"Unknown\"", "for your cluster configuration are available", "to view those re-run the command with --include-not-recommended", "Recommended updates:", "4.99.999999 registry.ci.openshift.org/ocp/release@sha256:"+ "9999999999999999999999999999999999999999999999999999999999999999", )).To(o.BeTrue(), "recommended update and notes about additional updates") exutil.By("Check risk type=Always updates and 2 risks update present") o.Expect(checkUpdates(oc, true, 1, 3, "Updates with known issues", "Version: 4.88.888888", "Image: registry.ci.openshift.org/ocp/release@sha256:"+ "8888888888888888888888888888888888888888888888888888888888888888", "Reason: ExposedToRisks", "Message: Too many CI failures on this release, so do not update to it", "Version: 4.77.777777", "Image: registry.ci.openshift.org/ocp/release@sha256:"+ "7777777777777777777777777777777777777777777777777777777777777777", "Reason: MultipleReasons", "Message: On clusters on default invoker user, this imaginary bug can happen. "+ "https://bug.example.com/a", )).To(o.BeTrue(), "risk type=Always updates and 2 risks update") exutil.By("Check The reason for the multiple risks is changed to SomeInvokerThing") o.Expect(checkUpdates(oc, true, 60, 6*60, "Updates with known issues", "Version: 4.77.777777", "Image: registry.ci.openshift.org/ocp/release@sha256:"+ "7777777777777777777777777777777777777777777777777777777777777777", "Reason: SomeInvokerThing", "Message: On clusters on default invoker user, this imaginary bug can happen. "+ "https://bug.example.com/a", )).To(o.BeTrue(), "reason for the multiple risks is changed to SomeInvokerThing") exutil.By("Check multiple reason conditional update present") _, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade", "channel", "buggy").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(checkUpdates(oc, true, 300, 75*60, "Version: 4.77.777777", "Image: registry.ci.openshift.org/ocp/release@sha256:"+ "7777777777777777777777777777777777777777777777777777777777777777", "Reason: MultipleReasons", "Message: On clusters on default invoker user, this imaginary bug can happen. "+ "https://bug.example.com/a", "On clusters with the channel set to 'buggy', this imaginary bug can happen. "+ "https://bug.example.com/b", )).To(o.BeTrue(), "multiple reason conditional update present") }) //author: [email protected] g.It("ConnectedOnly-Author:jianl-Low-46422-cvo drops invalid conditional edges [Serial]", func() { exutil.By("Check if it's a GCP cluster") exutil.SkipIfPlatformTypeNot(oc, "gcp") orgUpstream, err := getCVObyJP(oc, ".spec.upstream") o.Expect(err).NotTo(o.HaveOccurred()) orgChannel, err := getCVObyJP(oc, ".spec.channel") o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("Original upstream: %s, original channel: %s", orgUpstream, orgChannel) exutil.By("Patch upstream") projectID := "openshift-qe" ctx := context.Background() client, err := storage.NewClient(ctx) o.Expect(err).NotTo(o.HaveOccurred()) defer func() { o.Expect(client.Close()).NotTo(o.HaveOccurred()) }() graphURL, bucket1, object1, _, _, err := buildGraph(client, oc, projectID, "cincy-conditional-edge-invalid-null-node.json") defer func() { o.Expect(DeleteBucket(client, bucket1)).NotTo(o.HaveOccurred()) }() defer func() { o.Expect(DeleteObject(client, bucket1, object1)).NotTo(o.HaveOccurred()) }() o.Expect(err).NotTo(o.HaveOccurred()) _, err = ocJSONPatch(oc, "", "clusterversion/version", []JSONp{ {"add", "/spec/upstream", graphURL}, {"add", "/spec/channel", "stable-a"}, }) o.Expect(err).NotTo(o.HaveOccurred()) defer restoreCVSpec(orgUpstream, orgChannel, oc) exutil.By("Check CVO prompts correct reason and message") expString := "warning: Cannot display available updates:\n" + " Reason: ResponseInvalid\n" + " Message: Unable to retrieve available updates: no node for conditional update" exutil.AssertWaitPollNoErr(wait.Poll(5*time.Second, 15*time.Second, func() (bool, error) { cmdOut, err := oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade").Output() e2e.Logf("oc adm upgrade returned:\n%s", cmdOut) if err != nil { return false, fmt.Errorf("oc adm upgrade returned error: %v", err) } return strings.Contains(cmdOut, expString), nil }), "Test on empty target node failed") graphURL, bucket2, object2, _, _, err := buildGraph(client, oc, projectID, "cincy-conditional-edge-invalid-multi-risks.json") defer func() { o.Expect(DeleteBucket(client, bucket2)).NotTo(o.HaveOccurred()) }() defer func() { o.Expect(DeleteObject(client, bucket2, object2)).NotTo(o.HaveOccurred()) }() o.Expect(err).NotTo(o.HaveOccurred()) _, err = ocJSONPatch(oc, "", "clusterversion/version", []JSONp{{"add", "/spec/upstream", graphURL}}) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("Check no updates") exutil.AssertWaitPollNoErr(wait.Poll(5*time.Second, 15*time.Second, func() (bool, error) { cmdOut, err := oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade").Output() e2e.Logf("oc adm upgrade returned:\n%s", cmdOut) if err != nil { return false, fmt.Errorf("oc adm upgrade returned error: %v", err) } return strings.Contains(cmdOut, "No updates available"), nil }), "Test on multiple invalid risks failed") }) //author: [email protected] g.It("ConnectedOnly-Author:jianl-Low-47175-upgrade cluster when current version is in the upstream but there are not update paths [Serial]", func() { exutil.By("Check if it's a GCP cluster") exutil.SkipIfPlatformTypeNot(oc, "gcp") orgUpstream, err := getCVObyJP(oc, ".spec.upstream") o.Expect(err).NotTo(o.HaveOccurred()) orgChannel, err := getCVObyJP(oc, ".spec.channel") o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("Original upstream: %s, original channel: %s", orgUpstream, orgChannel) exutil.By("Patch upstream") projectID := "openshift-qe" ctx := context.Background() client, err := storage.NewClient(ctx) o.Expect(err).NotTo(o.HaveOccurred()) defer func() { o.Expect(client.Close()).NotTo(o.HaveOccurred()) }() graphURL, bucket, object, _, _, err := buildGraph(client, oc, projectID, "cincy-conditional-edge-invalid-multi-risks.json") defer func() { o.Expect(DeleteBucket(client, bucket)).NotTo(o.HaveOccurred()) }() defer func() { o.Expect(DeleteObject(client, bucket, object)).NotTo(o.HaveOccurred()) }() o.Expect(err).NotTo(o.HaveOccurred()) _, err = ocJSONPatch(oc, "", "clusterversion/version", []JSONp{ {"add", "/spec/upstream", graphURL}, {"add", "/spec/channel", "stable-a"}, }) o.Expect(err).NotTo(o.HaveOccurred()) defer restoreCVSpec(orgUpstream, orgChannel, oc) var cmdOut string exutil.By("Check no updates but RetrievedUpdates=True") exutil.AssertWaitPollNoErr(wait.Poll(5*time.Second, 15*time.Second, func() (bool, error) { cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade").Output() e2e.Logf("oc adm upgrade returned:\n%s", cmdOut) if err != nil { return false, fmt.Errorf("oc adm upgrade returned error: %v", err) } return strings.Contains(cmdOut, "No updates available"), nil }), "failure: missing expected 'No updates available'") status, err := getCVObyJP(oc, ".status.conditions[?(.type=='RetrievedUpdates')].status") o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(status).To(o.Equal("True")) target := GenerateReleaseVersion(oc) o.Expect(target).NotTo(o.BeEmpty()) exutil.By("Upgrade with oc adm upgrade --to") cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade", "--to", target).Output() o.Expect(cmdOut).To(o.ContainSubstring( "no recommended updates, specify --to-image to conti" + "nue with the update or wait for new updates to be available")) o.Expect(err).To(o.HaveOccurred()) exutil.By("Upgrade with oc adm upgrade --to --allow-not-recommended") cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm"). Args("upgrade", "--allow-not-recommended", "--to", target).Output() o.Expect(cmdOut).To(o.ContainSubstring( "no recommended or conditional updates, specify --to-image to conti" + "nue with the update or wait for new updates to be available")) o.Expect(err).To(o.HaveOccurred()) targetPullspec := GenerateReleasePayload(oc) o.Expect(targetPullspec).NotTo(o.BeEmpty()) exutil.By("Upgrade with oc adm upgrade --to-image") cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm"). Args("upgrade", "--to-image", targetPullspec).Output() o.Expect(cmdOut).To(o.ContainSubstring( "no recommended updates, specify --allow-explicit-upgrade to conti" + "nue with the update or wait for new updates to be available")) o.Expect(err).To(o.HaveOccurred()) exutil.By("Upgrade with oc adm upgrade --to-image --allow-not-recommended") cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm"). Args("upgrade", "--allow-not-recommended", "--to-image", targetPullspec).Output() o.Expect(cmdOut).To(o.ContainSubstring( "no recommended or conditional updates, specify --allow-explicit-upgrade to conti" + "nue with the update or wait for new updates to be available")) o.Expect(err).To(o.HaveOccurred()) }) //author: [email protected] g.It("NonHyperShiftHOST-Author:dis-Medium-41391-cvo serves metrics over only https not http", func() { exutil.By("Check cvo delopyment config file...") cvoDeploymentYaml, err := GetDeploymentsYaml(oc, "cluster-version-operator", projectName) o.Expect(err).NotTo(o.HaveOccurred()) var keywords = []string{"--listen=0.0.0.0:9099", "--serving-cert-file=/etc/tls/serving-cert/tls.crt", "--serving-key-file=/etc/tls/serving-cert/tls.key"} for _, v := range keywords { o.Expect(cvoDeploymentYaml).Should(o.ContainSubstring(v)) } exutil.By("Check cluster-version-operator binary help") cvoPodsList, err := exutil.WaitForPods( oc.AdminKubeClient().CoreV1().Pods(projectName), exutil.ParseLabelsOrDie("k8s-app=cluster-version-operator"), exutil.CheckPodIsReady, 1, 3*time.Minute) o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("Get cvo pods: %v", cvoPodsList) output, err := PodExec(oc, "/usr/bin/cluster-version-operator start --help", projectName, cvoPodsList[0]) exutil.AssertWaitPollNoErr(err, fmt.Sprintf( "/usr/bin/cluster-version-operator start --help executs error on %v", cvoPodsList[0])) e2e.Logf("CVO help returned: %s", output) keywords = []string{"You must set both --serving-cert-file and --serving-key-file unless you set --listen empty"} for _, v := range keywords { o.Expect(output).Should(o.ContainSubstring(v)) } exutil.By("Verify cvo metrics is only exported via https") output, err = oc.AsAdmin().WithoutNamespace().Run("get"). Args("servicemonitor", "cluster-version-operator", "-n", projectName, "-o=json").Output() o.Expect(err).NotTo(o.HaveOccurred()) var result map[string]interface{} err = json.Unmarshal([]byte(output), &result) o.Expect(err).NotTo(o.HaveOccurred()) endpoints := result["spec"].(map[string]interface{})["endpoints"] e2e.Logf("Get cvo's spec.endpoints: %v", endpoints) o.Expect(endpoints).Should(o.HaveLen(1)) output, err = oc.AsAdmin().WithoutNamespace().Run("get"). Args("servicemonitor", "cluster-version-operator", "-n", projectName, "-o=jsonpath={.spec.endpoints[].scheme}").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("Get cvo's spec.endpoints scheme: %v", output) o.Expect(output).Should(o.Equal("https")) exutil.By("Get cvo endpoint URI") //output, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("endpoints", "cluster-version-operator", "-n", projectName, "-o=jsonpath='{.subsets[0].addresses[0].ip}:{.subsets[0].ports[0].port}'").Output() output, err = oc.AsAdmin().WithoutNamespace().Run("get"). Args("endpoints", "cluster-version-operator", "-n", projectName, "--no-headers").Output() o.Expect(err).NotTo(o.HaveOccurred()) re := regexp.MustCompile(`cluster-version-operator\s+([^\s]*)`) matchedResult := re.FindStringSubmatch(output) e2e.Logf("Regex mached result: %v", matchedResult) o.Expect(matchedResult).Should(o.HaveLen(2)) endpointURI := matchedResult[1] e2e.Logf("Get cvo endpoint URI: %v", endpointURI) o.Expect(endpointURI).ShouldNot(o.BeEmpty()) exutil.By("Check metric server is providing service https, but not http") cmd := fmt.Sprintf("curl http://%s/metrics", endpointURI) output, err = PodExec(oc, cmd, projectName, cvoPodsList[0]) exutil.AssertWaitPollNoErr(err, fmt.Sprintf("cmd %s executs error on %v", cmd, cvoPodsList[0])) keywords = []string{"Client sent an HTTP request to an HTTPS server"} for _, v := range keywords { o.Expect(output).Should(o.ContainSubstring(v)) } exutil.By("Check metric server is providing service via https correctly.") cmd = fmt.Sprintf("curl -k -I https://%s/metrics", endpointURI) output, err = PodExec(oc, cmd, projectName, cvoPodsList[0]) exutil.AssertWaitPollNoErr(err, fmt.Sprintf("cmd %s executs error on %v", cmd, cvoPodsList[0])) keywords = []string{"HTTP/1.1 200 OK"} for _, v := range keywords { o.Expect(output).Should(o.ContainSubstring(v)) } }) //author: [email protected] g.It("Longduration-NonPreRelease-Author:dis-Medium-32138-cvo alert should not be fired when RetrievedUpdates failed due to nochannel [Serial][Slow]", func() { orgChannel, err := getCVObyJP(oc, ".spec.channel") o.Expect(err).NotTo(o.HaveOccurred()) defer func() { o.Expect(oc.AsAdmin().WithoutNamespace().Run("adm"). Args("upgrade", "channel", orgChannel).Execute()).NotTo(o.HaveOccurred()) }() exutil.By("Enable alert by clearing channel") err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade", "channel").Execute() o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("Check RetrievedUpdates condition") reason, err := getCVObyJP(oc, ".status.conditions[?(.type=='RetrievedUpdates')].reason") o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(reason).To(o.Equal("NoChannel")) exutil.By("Alert CannotRetrieveUpdates does not appear within 60m") appeared, _, err := waitForAlert(oc, "CannotRetrieveUpdates", 600, 3600, "") o.Expect(appeared).NotTo(o.BeTrue(), "no CannotRetrieveUpdates within 60m") o.Expect(err.Error()).To(o.ContainSubstring("timed out waiting for the condition")) exutil.By("Alert CannotRetrieveUpdates does not appear after 60m") appeared, _, err = waitForAlert(oc, "CannotRetrieveUpdates", 300, 600, "") o.Expect(appeared).NotTo(o.BeTrue(), "no CannotRetrieveUpdates after 60m") o.Expect(err.Error()).To(o.ContainSubstring("timed out waiting for the condition")) }) //author: [email protected] g.It("ConnectedOnly-Author:jianl-Medium-43178-manage channel by using oc adm upgrade channel [Serial]", func() { exutil.By("Check if it's a GCP cluster") exutil.SkipIfPlatformTypeNot(oc, "gcp") orgUpstream, err := getCVObyJP(oc, ".spec.upstream") o.Expect(err).NotTo(o.HaveOccurred()) orgChannel, err := getCVObyJP(oc, ".spec.channel") o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("Original upstream: %s, original channel: %s", orgUpstream, orgChannel) projectID := "openshift-qe" ctx := context.Background() client, err := storage.NewClient(ctx) o.Expect(err).NotTo(o.HaveOccurred()) defer func() { o.Expect(client.Close()).NotTo(o.HaveOccurred()) }() graphURL, bucket, object, _, _, err := buildGraph(client, oc, projectID, "cincy.json") defer func() { o.Expect(DeleteBucket(client, bucket)).NotTo(o.HaveOccurred()) }() defer func() { o.Expect(DeleteObject(client, bucket, object)).NotTo(o.HaveOccurred()) }() o.Expect(err).NotTo(o.HaveOccurred()) defer restoreCVSpec(orgUpstream, orgChannel, oc) // Prerequisite: the available channels are not present exutil.By("The test requires the available channels are not present as a prerequisite") cmdOut, err := oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(cmdOut).NotTo(o.ContainSubstring("available channels:")) version, err := getCVObyJP(oc, ".status.desired.version") o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("Set to an unknown channel when available channels are not present") cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade", "channel", "unknown-channel").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(cmdOut).To(o.ContainSubstring( fmt.Sprintf("warning: No channels known to be compatible with the current version \"%s\"; unable to vali"+ "date \"unknown-channel\". Setting the update channel to \"unknown-channel\" anyway.", version))) cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(cmdOut).To(o.ContainSubstring("Channel: unknown-channel")) exutil.By("Clear an unknown channel when available channels are not present") cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade", "channel").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(cmdOut).To(o.ContainSubstring( "warning: Clearing channel \"unknown-channel\"; cluster will no longer request available update recommendations.")) cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(cmdOut).To(o.ContainSubstring("NoChannel")) // Prerequisite: a dummy update server is ready and the available channels is present exutil.By("Change to a dummy update server") _, err = ocJSONPatch(oc, "", "clusterversion/version", []JSONp{ {"add", "/spec/upstream", graphURL}, {"add", "/spec/channel", "channel-a"}, }) o.Expect(err).NotTo(o.HaveOccurred()) time.Sleep(5 * time.Second) cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(cmdOut).To(o.ContainSubstring("Channel: channel-a (available channels: channel-a, channel-b)")) exutil.By("Specify multiple channels") cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade", "channel", "channel-a", "channel-b").Output() o.Expect(err).To(o.HaveOccurred()) o.Expect(cmdOut).To(o.ContainSubstring( "error: multiple positional arguments given\nSee 'oc adm upgrade channel -h' for help and examples")) exutil.By("Set a channel which is same as the current channel") cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade", "channel", "channel-a").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(cmdOut).To(o.ContainSubstring("info: Cluster is already in channel-a (no change)")) exutil.By("Clear a known channel which is in the available channels without --allow-explicit-channel") cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade", "channel").Output() o.Expect(err).To(o.HaveOccurred()) o.Expect(cmdOut).To(o.ContainSubstring( "error: You are requesting to clear the update channel. The current channel \"channel-a\" is " + "one of the available channels, you must pass --allow-explicit-channel to continue")) exutil.By("Clear a known channel which is in the available channels with --allow-explicit-channel") cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade", "channel", "--allow-explicit-channel").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(cmdOut).To(o.ContainSubstring( "warning: Clearing channel \"channel-a\"; cluster will no longer request available update recommendations.")) cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(cmdOut).To(o.ContainSubstring("NoChannel")) exutil.By("Re-clear the channel") cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade", "channel").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(cmdOut).To(o.ContainSubstring("info: Cluster channel is already clear (no change)")) exutil.By("Set to an unknown channel when the available channels are not present without --allow-explicit-channel") cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade", "channel", "channel-d").Output() o.Expect(err).NotTo(o.HaveOccurred()) time.Sleep(5 * time.Second) o.Expect(cmdOut).To(o.ContainSubstring( fmt.Sprintf("warning: No channels known to be compatible with the current version \"%s\"; unable to vali"+ "date \"channel-d\". Setting the update channel to \"channel-d\" anyway.", version))) cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(cmdOut).To(o.ContainSubstring("Channel: channel-d (available channels: channel-a, channel-b)")) exutil.By("Set to an unknown channel which is not in the available channels without --allow-explicit-channel") cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade", "channel", "channel-f").Output() o.Expect(err).To(o.HaveOccurred()) time.Sleep(5 * time.Second) o.Expect(cmdOut).To(o.ContainSubstring( "error: the requested channel \"channel-f\" is not one of the avail" + "able channels (channel-a, channel-b), you must pass --allow-explicit-channel to continue")) exutil.By("Set to an unknown channel which is not in the available channels with --allow-explicit-channel") cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm"). Args("upgrade", "channel", "channel-f", "--allow-explicit-channel").Output() o.Expect(err).NotTo(o.HaveOccurred()) time.Sleep(5 * time.Second) o.Expect(cmdOut).To(o.ContainSubstring( "warning: The requested channel \"channel-f\" is not one of the avail" + "able channels (channel-a, channel-b). You have used --allow-explicit-cha" + "nnel to proceed anyway. Setting the update channel to \"channel-f\".")) cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(cmdOut).To(o.ContainSubstring("Channel: channel-f (available channels: channel-a, channel-b)")) exutil.By("Clear an unknown channel which is not in the available channels without --allow-explicit-channel") cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade", "channel").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(cmdOut).To(o.ContainSubstring( "warning: Clearing channel \"channel-f\"; cluster will no longer request available update recommendations.")) cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(cmdOut).To(o.ContainSubstring("NoChannel")) exutil.By("Set to a known channel when the available channels are not present") cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade", "channel", "channel-a").Output() o.Expect(err).NotTo(o.HaveOccurred()) time.Sleep(5 * time.Second) o.Expect(cmdOut).To(o.ContainSubstring( fmt.Sprintf("warning: No channels known to be compatible with the current version \"%s\"; un"+ "able to validate \"channel-a\". Setting the update channel to \"channel-a\" anyway.", version))) cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(cmdOut).To(o.ContainSubstring("Channel: channel-a (available channels: channel-a, channel-b)")) exutil.By("Set to a known channel without --allow-explicit-channel") _, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade", "channel", "channel-b").Output() o.Expect(err).NotTo(o.HaveOccurred()) time.Sleep(5 * time.Second) cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(cmdOut).To(o.ContainSubstring("Channel: channel-b (available channels: channel-a, channel-b)")) }) //author: [email protected] g.It("Author:jianl-High-42543-the removed resources are not created in a fresh installed cluster", func() { exutil.By("Check the annotation delete:true for imagestream/hello-openshift is set in manifest") tempDataDir, err := extractManifest(oc) defer func() { o.Expect(os.RemoveAll(tempDataDir)).NotTo(o.HaveOccurred()) }() o.Expect(err).NotTo(o.HaveOccurred()) manifestDir := filepath.Join(tempDataDir, "manifest") cmd := fmt.Sprintf("grep -rl \"name: hello-openshift\" %s", manifestDir) out, err := exec.Command("bash", "-c", cmd).CombinedOutput() o.Expect(err).NotTo(o.HaveOccurred(), "Command: \"%s\" returned error: %s", cmd, string(out)) o.Expect(string(out)).NotTo(o.BeEmpty()) file := strings.TrimSpace(string(out)) cmd = fmt.Sprintf("grep -C5 'name: hello-openshift' %s | grep 'release.openshift.io/delete: \"true\"'", file) out, err = exec.Command("bash", "-c", cmd).CombinedOutput() o.Expect(err).NotTo(o.HaveOccurred(), "Command: \"%s\" returned error: %s", cmd, string(out)) o.Expect(string(out)).NotTo(o.BeEmpty()) exutil.By("Check imagestream hello-openshift not present in a fresh installed cluster") cmdOut, err := oc.AsAdmin().WithoutNamespace().Run("get"). Args("imagestream", "hello-openshift", "-n", "openshift").Output() o.Expect(err).To(o.HaveOccurred()) o.Expect(cmdOut).To(o.ContainSubstring( "Error from server (NotFound): imagestreams.image.openshift.io \"hello-openshift\" not found")) }) //author: [email protected] g.It("ConnectedOnly-Author:jianl-Medium-43172-get the upstream and channel info by using oc adm upgrade [Serial]", func() { exutil.By("Check if it's a GCP cluster") exutil.SkipIfPlatformTypeNot(oc, "gcp") orgUpstream, err := getCVObyJP(oc, ".spec.upstream") o.Expect(err).NotTo(o.HaveOccurred()) orgChannel, err := getCVObyJP(oc, ".spec.channel") o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("Original upstream: %s, original channel: %s", orgUpstream, orgChannel) defer restoreCVSpec(orgUpstream, orgChannel, oc) exutil.By("Check when upstream is unset") if orgUpstream != "" { _, err := ocJSONPatch(oc, "", "clusterversion/version", []JSONp{{"remove", "/spec/upstream", nil}}) o.Expect(err).NotTo(o.HaveOccurred()) } _, err = ocJSONPatch(oc, "", "clusterversion/version", []JSONp{{"add", "/spec/channel", "stable-a"}}) o.Expect(err).NotTo(o.HaveOccurred()) cmdOut, err := oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(cmdOut).To(o.ContainSubstring("Upstream is unset, so the cluster will use an appropriate default.")) o.Expect(cmdOut).To(o.ContainSubstring("Channel: stable-a")) desiredChannel, err := getCVObyJP(oc, ".status.desired.channels") o.Expect(err).NotTo(o.HaveOccurred()) if desiredChannel == "" { o.Expect(cmdOut).NotTo(o.ContainSubstring("available channels:")) } else { msg := "available channels: " desiredChannel = desiredChannel[1 : len(desiredChannel)-1] splits := strings.Split(desiredChannel, ",") for _, split := range splits { split = strings.Trim(split, "\"") msg = msg + split + ", " } msg = msg[:len(msg)-2] o.Expect(cmdOut).To(o.ContainSubstring(msg)) } exutil.By("Check when upstream is set") projectID := "openshift-qe" ctx := context.Background() client, err := storage.NewClient(ctx) o.Expect(err).NotTo(o.HaveOccurred()) defer func() { o.Expect(client.Close()).NotTo(o.HaveOccurred()) }() graphURL, bucket, object, targetVersion, targetPayload, err := buildGraph(client, oc, projectID, "cincy.json") defer func() { o.Expect(DeleteBucket(client, bucket)).NotTo(o.HaveOccurred()) }() defer func() { o.Expect(DeleteObject(client, bucket, object)).NotTo(o.HaveOccurred()) }() o.Expect(err).NotTo(o.HaveOccurred()) _, err = ocJSONPatch(oc, "", "clusterversion/version", []JSONp{ {"add", "/spec/upstream", graphURL}, {"add", "/spec/channel", "channel-a"}, }) o.Expect(err).NotTo(o.HaveOccurred()) time.Sleep(5 * time.Second) cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade").Output() o.Expect(err).NotTo(o.HaveOccurred()) expStr := []string{ fmt.Sprintf("Upstream: %s", graphURL), "Channel: channel-a (available channels: channel-a, channel-b)", "Recommended updates:", targetVersion, targetPayload} for _, v := range expStr { o.Expect(cmdOut).To(o.ContainSubstring(v)) } cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm"). Args("upgrade", "--include-not-recommended").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(cmdOut).To(o.ContainSubstring( "No updates which are not recommended based on your cluster configuration are available")) exutil.By("Check when channel is unset") _, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade", "channel", "--allow-explicit-channel").Output() o.Expect(err).NotTo(o.HaveOccurred()) cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade").Output() o.Expect(err).NotTo(o.HaveOccurred()) expStr = []string{ "Upstream:", "Channel:", "Reason: NoChannel", "Message: The update channel has not been configured"} for _, v := range expStr[:2] { o.Expect(cmdOut).NotTo(o.ContainSubstring(v)) } for _, v := range expStr[2:] { o.Expect(cmdOut).To(o.ContainSubstring(v)) } }) //author: [email protected] g.It("Longduration-NonPreRelease-Author:jiajliu-Medium-41728-cvo alert ClusterOperatorDegraded on degraded operators [Disruptive][Slow]", func() { testDataDir := exutil.FixturePath("testdata", "ota/cvo") badOauthFile := filepath.Join(testDataDir, "bad-oauth.yaml") exutil.By("Get goodOauthFile from the initial oauth yaml file to oauth-41728.yaml") goodOauthFile, err := oc.AsAdmin().WithoutNamespace().Run("get"). Args("oauth", "cluster", "-o", "yaml").OutputToFile("oauth-41728.yaml") defer func() { o.Expect(os.RemoveAll(goodOauthFile)).NotTo(o.HaveOccurred()) }() o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("Prune goodOauthFile") cmd := fmt.Sprintf("sed -i \"/resourceVersion/d\" %s && cat %s", goodOauthFile, goodOauthFile) oauthfile, err := exec.Command("bash", "-c", cmd).CombinedOutput() o.Expect(err).NotTo(o.HaveOccurred(), "Command: \"%s\" returned error: %s", cmd, string(oauthfile)) o.Expect(string(oauthfile)).NotTo(o.ContainSubstring("resourceVersion")) exutil.By("Enable ClusterOperatorDegraded alert") err = oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", badOauthFile).Execute() defer func() { // after applying good auth, co is back to normal, while cvo condition failing is still present for up to ~2-4 minutes o.Expect(waitForCVOStatus(oc, 30, 4*60, "ClusterOperatorDegraded", ".status.conditions[?(.type=='Failing')].reason", false)).NotTo(o.HaveOccurred()) }() defer func() { o.Expect(oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", goodOauthFile).Execute()).NotTo(o.HaveOccurred()) }() o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("Check ClusterOperatorDegraded condition...") if err = waitForCondition(oc, 60, 480, "True", "get", "co", "authentication", "-o", "jsonpath={.status.conditions[?(@.type=='Degraded')].status}"); err != nil { //dump contents to log _ = oc.AsAdmin().WithoutNamespace().Run("get").Args("co", "authentication", "-o", "yaml").Execute() _ = oc.AsAdmin().WithoutNamespace().Run("get").Args("oauth", "cluster", "-o", "yaml").Execute() exutil.AssertWaitPollNoErr(err, "authentication operator is not degraded in 8m") } exutil.By("Check ClusterOperatorDown alert is not firing and ClusterOperatorDegraded alert is fired correctly.") var alertDown, alertDegraded map[string]interface{} err = wait.Poll(5*time.Minute, 35*time.Minute, func() (bool, error) { alertDown = getAlertByName(oc, "ClusterOperatorDown", "authentication") alertDegraded = getAlertByName(oc, "ClusterOperatorDegraded", "authentication") if alertDown != nil { return false, fmt.Errorf("alert ClusterOperatorDown is not nil: %v", alertDown) } if alertDegraded == nil || alertDegraded["state"] != "firing" { e2e.Logf("Waiting for alert ClusterOperatorDegraded to be triggered and fired...") return false, nil } o.Expect(alertDegraded["labels"].(map[string]interface{})["severity"].(string)).To(o.Equal("warning")) o.Expect(alertDegraded["labels"].(map[string]interface{})["namespace"].(string)).To(o.Equal("openshift-cluster-version")) o.Expect(alertDegraded["annotations"].(map[string]interface{})["summary"].(string)). To(o.ContainSubstring("Cluster operator has been degraded for 30 minutes.")) o.Expect(alertDegraded["annotations"].(map[string]interface{})["description"].(string)). To(o.ContainSubstring("The authentication operator is degraded")) return true, nil }) exutil.AssertWaitPollNoErr(err, fmt.Sprintf("ClusterOperatorDegraded alert is not fired in 30m: %v", alertDegraded)) exutil.By("Disable ClusterOperatorDegraded alert") err = oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", goodOauthFile).Execute() o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("Check alert is disabled") exutil.AssertWaitPollNoErr(wait.Poll(10*time.Second, 60*time.Second, func() (bool, error) { alertDegraded = getAlertByName(oc, "ClusterOperatorDegraded", "authentication") e2e.Logf("Waiting for alert being disabled...") return alertDegraded == nil, nil }), fmt.Sprintf("alert is not disabled: %v", alertDegraded)) }) //author: [email protected] g.It("Longduration-NonPreRelease-Author:jiajliu-Medium-41778-ClusterOperatorDown and ClusterOperatorDegradedon alerts when unset conditions [Slow]", func() { testDataDir := exutil.FixturePath("testdata", "ota/cvo") badOauthFile := filepath.Join(testDataDir, "co-test.yaml") exutil.By("Enable alerts") err := oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", badOauthFile).Execute() // if normal already deleted before. discarding error. defer func() { _ = oc.AsAdmin().WithoutNamespace().Run("delete").Args("co", "test").Execute() }() o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("Check operator's condition...") output, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("co", "test", "-o=jsonpath={.status}").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.Equal("")) exutil.By("Waiting for alerts triggered...") var alertDown, alertDegraded map[string]interface{} exutil.AssertWaitPollNoErr(wait.Poll(30*time.Second, 180*time.Second, func() (bool, error) { alertDown = getAlertByName(oc, "ClusterOperatorDown", "test") alertDegraded = getAlertByName(oc, "ClusterOperatorDegraded", "test") e2e.Logf("Waiting for alerts to be triggered...") return alertDown != nil && alertDegraded != nil, nil }), fmt.Sprintf("failed expecting both alerts triggered: Down=%v Degraded=%v", alertDown, alertDegraded)) exutil.By("Check alert ClusterOperatorDown fired.") exutil.AssertWaitPollNoErr(wait.Poll(5*time.Minute, 10*time.Minute, func() (bool, error) { alertDown = getAlertByName(oc, "ClusterOperatorDown", "test") e2e.Logf("Waiting for alert ClusterOperatorDown to be triggered and fired...") return alertDown["state"] == "firing", nil }), fmt.Sprintf("ClusterOperatorDown alert is not fired in 10m: %v", alertDown)) exutil.By("Check alert ClusterOperatorDegraded fired.") exutil.AssertWaitPollNoErr(wait.Poll(5*time.Minute, 20*time.Minute, func() (bool, error) { alertDegraded = getAlertByName(oc, "ClusterOperatorDegraded", "test") e2e.Logf("Waiting for alert ClusterOperatorDegraded to be triggered and fired...") return alertDegraded["state"] == "firing", nil }), fmt.Sprintf("ClusterOperatorDegraded alert is not fired in 30m: %v", alertDegraded)) exutil.By("Disable alerts") err = oc.AsAdmin().WithoutNamespace().Run("delete").Args("co", "test").Execute() o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("Check alerts are disabled...") exutil.AssertWaitPollNoErr(wait.Poll(10*time.Second, 60*time.Second, func() (bool, error) { alertDown := getAlertByName(oc, "ClusterOperatorDown", "test") alertDegraded := getAlertByName(oc, "ClusterOperatorDegraded", "test") e2e.Logf("Waiting for alerts being disabled...") return alertDown == nil && alertDegraded == nil, nil }), fmt.Sprintf("alerts are not disabled: Down=%v Degraded=%v", alertDown, alertDegraded)) }) //author: [email protected] g.It("Longduration-NonPreRelease-Author:jiajliu-Medium-41736-cvo alert ClusterOperatorDown on unavailable operators [Disruptive][Slow]", func() { operator := "image-registry" nodeLabel := "node-role.kubernetes.io/worker=" exutil.By("Cordon worker nodes") workerNodes, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("nodes", "--selector", nodeLabel, "-o=jsonpath={.items[*].metadata.name}").Output() o.Expect(err).NotTo(o.HaveOccurred(), "fail to get node list: %v", err) nodeList := strings.Fields(workerNodes) defer func() { e2e.Logf("Restore worker node in defer") oc.AsAdmin().WithoutNamespace().Run("adm").Args("uncordon", "-l", nodeLabel).Execute() for _, node := range nodeList { err = wait.PollUntilContextTimeout(context.Background(), 1*time.Minute, 5*time.Minute, true, func(context.Context) (bool, error) { nodeReady, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("node", node, "-o=jsonpath={.status.conditions[?(@.type==\"Ready\")].status}").Output() if err != nil || nodeReady != "True" { e2e.Logf("error: %v; node %s status: %s", err, node, nodeReady) return false, nil } return true, nil }) exutil.AssertWaitPollNoErr(err, "timeout to restore node!") } e2e.Logf("Ensure operator back to good status after uncordon") err = wait.PollUntilContextTimeout(context.Background(), 1*time.Minute, 5*time.Minute, true, func(context.Context) (bool, error) { output, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("co", operator).Output() matched, _ := regexp.MatchString("True.*False.*False", output) if err != nil || !matched { e2e.Logf("error:%; operator status: %s", err, output) return false, nil } return true, nil }) exutil.AssertWaitPollNoErr(err, "timeout to restore operator!") }() err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("cordon", "-l", nodeLabel).Execute() o.Expect(err).NotTo(o.HaveOccurred(), "fail to cordon worker node: %v", err) exutil.By("Delete namespace openshift-image-registry") err = oc.AsAdmin().WithoutNamespace().Run("delete").Args("namespace", "openshift-image-registry").Execute() o.Expect(err).NotTo(o.HaveOccurred(), "fail to delete namespace: %v", err) exutil.By("Check ClusterOperatorDown condition...") if err = waitForCondition(oc, 60, 900, "False", "get", "co", operator, "-o", "jsonpath={.status.conditions[?(@.type=='Available')].status}"); err != nil { //dump contents to log _ = oc.AsAdmin().WithoutNamespace().Run("get").Args("co", operator, "-o", "yaml").Execute() exutil.AssertWaitPollNoErr(err, fmt.Sprintf("%s operator is not down in 15m", operator)) } exutil.By("Check ClusterOperatorDown alert is fired correctly") var alertDown map[string]interface{} err = wait.Poll(2*time.Minute, 10*time.Minute, func() (bool, error) { alertDown = getAlertByName(oc, "ClusterOperatorDown", operator) if alertDown == nil || alertDown["state"] != "firing" { e2e.Logf("Waiting for alert ClusterOperatorDown to be triggered and fired...") return false, nil } o.Expect(alertDown["labels"].(map[string]interface{})["severity"].(string)).To(o.Equal("critical")) o.Expect(alertDown["labels"].(map[string]interface{})["namespace"].(string)).To(o.Equal("openshift-cluster-version")) o.Expect(alertDown["annotations"].(map[string]interface{})["summary"].(string)). To(o.ContainSubstring("Cluster operator has not been available for 10 minutes.")) o.Expect(alertDown["annotations"].(map[string]interface{})["description"].(string)). To(o.ContainSubstring(fmt.Sprintf("The %s operator may be down or disabled", operator))) return true, nil }) exutil.AssertWaitPollNoErr(err, fmt.Sprintf("ClusterOperatorDown alert is not fired in 10m: %v", alertDown)) exutil.By("Disable ClusterOperatorDown alert") e2e.Logf("Uncordon worker node") err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("uncordon", "-l", nodeLabel).Execute() o.Expect(err).NotTo(o.HaveOccurred(), "fail to uncordon worker node: %v", err) exutil.By("Check alert is disabled") exutil.AssertWaitPollNoErr(wait.Poll(1*time.Minute, 5*time.Minute, func() (bool, error) { alertDown = getAlertByName(oc, "ClusterOperatorDown", operator) e2e.Logf("Waiting for alert being disabled...") return alertDown == nil, nil }), fmt.Sprintf("alert is not disabled: %v", alertDown)) }) //author: [email protected] g.It("NonHyperShiftHOST-Author:jiajliu-Low-46922-check runlevel in cvo ns", func() { exutil.By("Check runlevel in cvo namespace.") runLevel, err := oc.AsAdmin().WithoutNamespace().Run("get"). Args("ns", "openshift-cluster-version", "-o=jsonpath={.metadata.labels.openshift\\.io/run-level}").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(runLevel).To(o.Equal("")) exutil.By("Check scc of cvo pod.") runningPodName, err := oc.AsAdmin().WithoutNamespace().Run("get"). Args("pod", "-n", "openshift-cluster-version", "-o=jsonpath='{.items[?(@.status.phase == \"Running\")].metadata.name}'").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(runningPodName).NotTo(o.Equal("''")) runningPodList := strings.Fields(runningPodName) if len(runningPodList) != 1 { e2e.Failf("Unexpected running cvo pods detected:" + runningPodName) } scc, err := oc.AsAdmin().WithoutNamespace().Run("get"). Args("pod", "-n", "openshift-cluster-version", strings.Trim(runningPodList[0], "'"), "-o=jsonpath={.metadata.annotations.openshift\\.io/scc}").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(scc).To(o.Equal("hostaccess")) }) //author: [email protected] g.It("Author:dis-Medium-46724-cvo defaults deployment replicas to one if it's unset in manifest [Flaky]", func() { exutil.SkipBaselineCaps(oc, "None, v4.11") exutil.By("Check the replicas for openshift-insights/insights-operator is unset in manifest") tempDataDir, err := extractManifest(oc) defer func() { o.Expect(os.RemoveAll(tempDataDir)).NotTo(o.HaveOccurred()) }() o.Expect(err).NotTo(o.HaveOccurred()) manifestDir := filepath.Join(tempDataDir, "manifest") namespace, name := "openshift-insights", "insights-operator" cmd := fmt.Sprintf( "grep -rlZ 'kind: Deployment' %s | xargs -0 grep -l 'name: %s\\|namespace: %s' | xargs grep replicas", manifestDir, name, namespace) e2e.Logf("executing: bash -c %s", cmd) out, err := exec.Command("bash", "-c", cmd).CombinedOutput() // We expect no replicas could be found, so the cmd should return with non-zero o.Expect(err).To(o.HaveOccurred(), "Command: \"%s\" returned success instead of error: %s", cmd, string(out)) o.Expect(string(out)).To(o.BeEmpty()) exutil.By("Check only one insights-operator pod in a fresh installed cluster") num, err := oc.AsAdmin().WithoutNamespace().Run("get"). Args("deployment", name, "-o=jsonpath={.spec.replicas}", "-n", namespace).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(num).To(o.Equal("1")) defer func() { out, err := oc.AsAdmin().WithoutNamespace().Run("scale"). Args("--replicas", "1", fmt.Sprintf("deployment/%s", name), "-n", namespace).Output() o.Expect(err).NotTo(o.HaveOccurred(), out) }() exutil.By("Scale down insights-operator replica to 0") _, err = oc.AsAdmin().WithoutNamespace().Run("scale"). Args("--replicas", "0", fmt.Sprintf("deployment/%s", name), "-n", namespace).Output() o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("Check the insights-operator replica recovers to one") exutil.AssertWaitPollNoErr(wait.Poll(30*time.Second, 5*time.Minute, func() (bool, error) { num, err = oc.AsAdmin().WithoutNamespace().Run("get"). Args("deployment", name, "-o=jsonpath={.spec.replicas}", "-n", namespace).Output() return num == "1", err }), "insights-operator replicas is not 1") exutil.By("Scale up insights-operator replica to 2") _, err = oc.AsAdmin().WithoutNamespace().Run("scale"). Args("--replicas", "2", fmt.Sprintf("deployment/%s", name), "-n", namespace).Output() o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("Check the insights-operator replica recovers to one") exutil.AssertWaitPollNoErr(wait.Poll(30*time.Second, 5*time.Minute, func() (bool, error) { num, err = oc.AsAdmin().WithoutNamespace().Run("get"). Args("deployment", name, "-o=jsonpath={.spec.replicas}", "-n", namespace).Output() return num == "1", err }), "insights-operator replicas is not 1") }) //author: [email protected] g.It("Author:jiajliu-Medium-47198-Techpreview operator will not be installed on a fresh installed", func() { tpOperatorNames := []string{"cluster-api"} tpOperator := []map[string]string{ {"ns": "openshift-cluster-api", "co": tpOperatorNames[0]}} featuregate, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("featuregate", "cluster", "-o=jsonpath={.spec}").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("Featuregate: %s", featuregate) if featuregate != "{}" { if strings.Contains(featuregate, "TechPreviewNoUpgrade") { g.Skip("This case is only suitable for non-techpreview cluster!") } else if strings.Contains(featuregate, "CustomNoUpgrade") { e2e.Logf("Drop openshift-cluster-api ns due to CustomNoUpgrade fs enabled!") delete(tpOperator[0], "ns") } else { e2e.Failf("Neither TechPreviewNoUpgrade fs nor CustomNoUpgrade fs enabled, stop here to confirm expected behavior first!") } } exutil.By("Check annotation release.openshift.io/feature-set=TechPreviewNoUpgrade in manifests are correct.") tempDataDir, err := extractManifest(oc) defer func() { o.Expect(os.RemoveAll(tempDataDir)).NotTo(o.HaveOccurred()) }() o.Expect(err).NotTo(o.HaveOccurred()) manifestDir := filepath.Join(tempDataDir, "manifest") cmd := fmt.Sprintf("grep -rl 'release.openshift.io/feature-set: .*TechPreviewNoUpgrade.*' %s|grep 'cluster.*operator.yaml'", manifestDir) featuresetTechPreviewManifest, err := exec.Command("bash", "-c", cmd).CombinedOutput() o.Expect(err).NotTo(o.HaveOccurred(), "Command: \"%s\" returned error: %s", cmd, string(featuresetTechPreviewManifest)) tpOperatorFilePaths := strings.Split(strings.TrimSpace(string(featuresetTechPreviewManifest)), "\n") o.Expect(len(tpOperatorFilePaths)).To(o.Equal(len(tpOperator))) e2e.Logf("Expected number of cluster operator manifest files with correct annotation found!") for _, file := range tpOperatorFilePaths { data, err := os.ReadFile(file) o.Expect(err).NotTo(o.HaveOccurred()) var co configv1.ClusterOperator err = yaml.Unmarshal(data, &co) o.Expect(err).NotTo(o.HaveOccurred()) for i := 0; i < len(tpOperatorNames); i++ { if co.Name == tpOperatorNames[i] { e2e.Logf("Found %s in file %v!", tpOperatorNames[i], file) tpOperatorNames = append(tpOperatorNames[:i], tpOperatorNames[i+1:]...) break } } } o.Expect(len(tpOperatorNames)).To(o.Equal(0)) e2e.Logf("All expected tp operators found in manifests!") exutil.By("Check no TP operator installed by default.") for i := 0; i < len(tpOperator); i++ { for k, v := range tpOperator[i] { output, err := oc.AsAdmin().WithoutNamespace().Run("get").Args(k, v).Output() o.Expect(err).To(o.HaveOccurred(), "techpreview operator '%s %s' absence check failed: expecting an error, received: '%s'", k, v, output) o.Expect(output).To(o.ContainSubstring("NotFound")) e2e.Logf("Expected: Resource %s/%v not found!", k, v) } } }) //author: [email protected] g.It("Author:dis-Medium-47757-cvo respects the deployment strategy in manifests [Serial]", func() { exutil.SkipBaselineCaps(oc, "None, v4.11") exutil.By("Get the strategy for openshift-insights/insights-operator in manifest") tempDataDir, err := extractManifest(oc) defer func() { o.Expect(os.RemoveAll(tempDataDir)).NotTo(o.HaveOccurred()) }() o.Expect(err).NotTo(o.HaveOccurred()) manifestDir := filepath.Join(tempDataDir, "manifest") namespace, name := "openshift-insights", "insights-operator" cmd := fmt.Sprintf( "grep -rlZ 'kind: Deployment' %s | xargs -0 grep -l 'name: %s' | xargs grep strategy -A1 | sed -n 2p | cut -f2 -d ':'", manifestDir, name) e2e.Logf("executing: bash -c %s", cmd) out, err := exec.Command("bash", "-c", cmd).CombinedOutput() o.Expect(err).NotTo(o.HaveOccurred(), "Command: \"%s\" returned error: %s", cmd, string(out)) o.Expect(out).NotTo(o.BeEmpty()) expectStrategy := strings.TrimSpace(string(out)) e2e.Logf(expectStrategy) exutil.By("Check in-cluster insights-operator has the same strategy with manifest") existStrategy, err := oc.AsAdmin().WithoutNamespace().Run("get"). Args("deployment", name, "-o=jsonpath={.spec.strategy}", "-n", namespace).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(existStrategy).To(o.ContainSubstring(expectStrategy)) exutil.By("Change the strategy") var patch []JSONp if expectStrategy == "Recreate" { patch = []JSONp{{"replace", "/spec/strategy/type", "RollingUpdate"}} } else { patch = []JSONp{ {"remove", "/spec/strategy/rollingUpdate", nil}, {"replace", "/spec/strategy/type", "Recreate"}, } } _, err = ocJSONPatch(oc, namespace, fmt.Sprintf("deployment/%s", name), patch) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("Check the strategy reverted after 5 minutes") if pollErr := wait.Poll(30*time.Second, 5*time.Minute, func() (bool, error) { curStrategy, err := oc.AsAdmin().WithoutNamespace().Run("get"). Args("deployment", name, "-o=jsonpath={.spec.strategy}", "-n", namespace).Output() if err != nil { return false, fmt.Errorf("oc get deployment %s returned error: %v", name, err) } return strings.Contains(curStrategy, expectStrategy), nil }); pollErr != nil { //dump contents to log _ = oc.AsAdmin().WithoutNamespace().Run("get").Args("deployment", name, "-o", "yaml").Execute() //If the strategy is not reverted, manually change it back if expectStrategy == "Recreate" { patch = []JSONp{ {"remove", "/spec/strategy/rollingUpdate", nil}, {"replace", "/spec/strategy/type", "Recreate"}, } } else { patch = []JSONp{{"replace", "/spec/strategy/type", "RollingUpdate"}} } _, err = ocJSONPatch(oc, namespace, fmt.Sprintf("deployment/%s", name), patch) o.Expect(err).NotTo(o.HaveOccurred()) exutil.AssertWaitPollNoErr(pollErr, "Strategy is not reverted back after 5 minutes") } }) //author: [email protected] g.It("Longduration-NonPreRelease-Author:evakhoni-Medium-48247-Prometheus is able to scrape metrics from the CVO after rotation of the signer ca in openshift-service-ca [Disruptive]", func() { exutil.By("Check for alerts Before signer ca rotation.") alertCVODown := getAlert(oc, ".labels.alertname == \"ClusterVersionOperatorDown\"") alertTargetDown := getAlert(oc, ".labels.alertname == \"TargetDown\" and .labels.service == \"cluster-version-operator\"") o.Expect(alertCVODown).To(o.BeNil()) o.Expect(alertTargetDown).To(o.BeNil()) exutil.By("Force signer ca rotation by deleting signing-key.") result, err := oc.AsAdmin().WithoutNamespace().Run("delete"). Args("secret/signing-key", "-n", "openshift-service-ca").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("delete returned: %s", result) o.Expect(result).To(o.ContainSubstring("deleted")) exutil.By("Check new signing-key is recreated") exutil.AssertWaitPollNoErr(wait.Poll(3*time.Second, 30*time.Second, func() (bool, error) { // supposed to fail until available so polling and suppressing the error out, _ := exec.Command( "bash", "-c", "oc -n openshift-service-ca get secret/signing-key -o jsonpath='{.metadata.name}'").Output() e2e.Logf("signing-key name: %s", string(out)) return strings.Contains(string(out), "signing-key"), nil }), "signing-key not recreated within 30s") exutil.By("Wait for Prometheus route to be available") // firstly wait until route is unavailable err = wait.Poll(3*time.Second, 30*time.Second, func() (bool, error) { out, cmderr := exec.Command("bash", "-c", "oc get route prometheus-k8s -n openshift-monitoring").CombinedOutput() if cmderr != nil { // oc get route returns "exit status 1" once unavailable if !strings.Contains(cmderr.Error(), "exit status 1") { return false, fmt.Errorf("oc get route prometheus-k8s returned different unexpected error: %v\n%s", cmderr, string(out)) } return true, nil } return false, nil }) if err != nil { // sometimes route stays available, won't impact rest of the test o.Expect(err.Error()).To(o.ContainSubstring("timed out waiting for the condition")) } // wait until available again exutil.AssertWaitPollNoErr(wait.Poll(10*time.Second, 600*time.Second, func() (bool, error) { // supposed to fail until available so polling and suppressing the error out, _ := exec.Command( "bash", "-c", "oc get route prometheus-k8s -n openshift-monitoring -o jsonpath='{.status.ingress[].conditions[].status}'").Output() e2e.Logf("prometheus route status: '%s'", string(out)) return strings.Contains(string(out), "True"), nil }), "Prometheus route is unavailable for 10m") exutil.By("Check CVO accessible by Prometheus - After signer ca rotation.") seenAlertCVOd, seenAlertTD := false, false // alerts may appear within first 5 minutes, and fire after 10 more mins err = wait.Poll(1*time.Minute, 15*time.Minute, func() (bool, error) { alertCVODown = getAlert(oc, ".labels.alertname == \"ClusterVersionOperatorDown\"") alertTargetDown = getAlert(oc, ".labels.alertname == \"TargetDown\" and .labels.service == \"cluster-version-operator\"") if alertCVODown != nil { e2e.Logf("alert ClusterVersionOperatorDown found - checking state..") o.Expect(alertCVODown["state"]).NotTo(o.Equal("firing")) seenAlertCVOd = true } if alertTargetDown != nil { e2e.Logf("alert TargetDown for CVO found - checking state..") o.Expect(alertTargetDown["state"]).NotTo(o.Equal("firing")) seenAlertTD = true } if alertCVODown == nil && alertTargetDown == nil { if seenAlertCVOd && seenAlertTD { e2e.Logf("alerts pended and disappeared. success.") return true, nil } } return false, nil }) if err != nil { o.Expect(err.Error()).To(o.ContainSubstring("timed out waiting for the condition")) } }) //author: [email protected] g.It("ConnectedOnly-Author:jianl-Low-21771-Upgrade cluster when current version is not in the graph from upstream [Serial]", func() { var graphURL, bucket, object, targetVersion, targetPayload string origVersion, err := getCVObyJP(oc, ".status.desired.version") o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("Check if upstream patch required") jsonpath := ".status.conditions[?(.type=='RetrievedUpdates')].reason" reason, err := getCVObyJP(oc, jsonpath) o.Expect(err).NotTo(o.HaveOccurred()) if strings.Contains(reason, "VersionNotFound") { e2e.Logf("no patch required. skipping upstream creation") targetVersion = GenerateReleaseVersion(oc) targetPayload = GenerateReleasePayload(oc) } else { exutil.By("Check if it's a GCP cluster") exutil.SkipIfPlatformTypeNot(oc, "gcp") origUpstream, err := getCVObyJP(oc, ".spec.upstream") o.Expect(err).NotTo(o.HaveOccurred()) origChannel, err := getCVObyJP(oc, ".spec.channel") o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("Original upstream: %s, original channel: %s", origUpstream, origChannel) defer restoreCVSpec(origUpstream, origChannel, oc) exutil.By("Patch upstream") projectID := "openshift-qe" ctx := context.Background() client, err := storage.NewClient(ctx) o.Expect(err).NotTo(o.HaveOccurred()) defer func() { o.Expect(client.Close()).NotTo(o.HaveOccurred()) }() graphURL, bucket, object, targetVersion, targetPayload, err = buildGraph( client, oc, projectID, "cincy-source-not-in-graph.json") defer func() { o.Expect(DeleteBucket(client, bucket)).NotTo(o.HaveOccurred()) }() defer func() { o.Expect(DeleteObject(client, bucket, object)).NotTo(o.HaveOccurred()) }() o.Expect(err).NotTo(o.HaveOccurred()) _, err = ocJSONPatch(oc, "", "clusterversion/version", []JSONp{ {"add", "/spec/upstream", graphURL}, {"add", "/spec/channel", "channel-a"}, }) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("Check RetrievedUpdates reason VersionNotFound after patching upstream") jsonpath = ".status.conditions[?(.type=='RetrievedUpdates')].reason" exutil.AssertWaitPollNoErr(wait.Poll(5*time.Second, 15*time.Second, func() (bool, error) { reason, err := getCVObyJP(oc, jsonpath) if err != nil { return false, fmt.Errorf("get CVO RetrievedUpdates condition returned error: %v", err) } e2e.Logf("received reason: '%s'", reason) return strings.Contains(reason, "VersionNotFound"), nil }), "Failed to check RetrievedUpdates!=True") } exutil.By("Give appropriate error on oc adm upgrade --to") toOutput, err := oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade", "--to", targetVersion).Output() o.Expect(err).To(o.HaveOccurred()) o.Expect(toOutput).To(o.ContainSubstring("Unable to retrieve available updates")) o.Expect(toOutput).To(o.ContainSubstring("specify --to-image to continue with the update")) exutil.By("Give appropriate error on oc adm upgrade --to-image") toImageOutput, err := oc.AsAdmin().WithoutNamespace().Run("adm"). Args("upgrade", "--to-image", targetPayload).Output() o.Expect(err).To(o.HaveOccurred()) o.Expect(toImageOutput).To(o.ContainSubstring("Unable to retrieve available updates")) o.Expect(toImageOutput).To(o.ContainSubstring("specify --allow-explicit-upgrade to continue with the update")) defer func() { o.Expect(recoverReleaseAccepted(oc)).NotTo(o.HaveOccurred()) }() exutil.By("give appropriate error on CVO for upgrade to invalid payload ") invalidPayload := "quay.io/openshift-release-dev/ocp-release@sha256:0000000000000000000000000000000000000000000000000000000000000000" invalidPayloadOutput, err := oc.AsAdmin().WithoutNamespace().Run("adm"). Args("upgrade", "--allow-explicit-upgrade", "--force", "--to-image", invalidPayload).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(invalidPayloadOutput).To(o.ContainSubstring("Updating to release image")) // usually happens quicker, but 8 minutes is safe deadline if err = waitForCondition(oc, 30, 480, "False", "get", "clusterversion", "version", "-o", "jsonpath={.status.conditions[?(@.type=='ReleaseAccepted')].status}"); err != nil { //dump contents to log _ = oc.AsAdmin().WithoutNamespace().Run("get").Args("clusterversion", "version", "-o", "yaml").Execute() exutil.AssertWaitPollNoErr(err, "ReleaseAccepted condition is not false in 8m") } message, err := getCVObyJP(oc, ".status.conditions[?(.type=='ReleaseAccepted')].message") o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(message).To(o.ContainSubstring("Retrieving payload failed")) o.Expect(message).To(o.ContainSubstring("status initcontainer cleanup is waiting with reason \"ErrImagePull\"")) o.Expect(message).To(o.ContainSubstring(invalidPayload)) o.Expect(recoverReleaseAccepted(oc)).NotTo(o.HaveOccurred()) exutil.By("Find enable-auto-update index in deployment") origAutoState, autoUpdIndex, err := getCVOcontArg(oc, "enable-auto-update") defer func() { out, err := patchCVOcontArg(oc, autoUpdIndex, fmt.Sprintf("--enable-auto-update=%s", origAutoState)) o.Expect(err).NotTo(o.HaveOccurred(), out) }() o.Expect(err).NotTo(o.HaveOccurred()) _, err = patchCVOcontArg(oc, autoUpdIndex, "--enable-auto-update=true") o.Expect(err).NotTo(o.HaveOccurred()) // recovery: once enable-auto-update is reconciled (~30sec), deployment becomes unavailable for up to CVO minimum reconcile period (~2-4min) defer func() { if err = waitForCondition(oc, 30, 240, "True", "get", "-n", "openshift-cluster-version", "deployments/cluster-version-operator", "-o", "jsonpath={.status.conditions[?(.type=='Available')].status}"); err != nil { //dump contents to log _ = oc.AsAdmin().WithoutNamespace().Run("get").Args("-n", "openshift-cluster-version", "deployments/cluster-version-operator", "-o", "yaml").Execute() exutil.AssertWaitPollNoErr(err, "deployments/cluster-version-operator not available after 4m") } }() defer func() { exutil.AssertWaitPollNoErr(wait.PollImmediate(10*time.Second, 60*time.Second, func() (bool, error) { depArgs, _, err := getCVOcontArg(oc, "enable-auto-update") if err != nil { return false, fmt.Errorf("get CVO container args returned error: %v", err) } e2e.Logf("argument: %s", depArgs) return strings.Contains(depArgs, "false"), nil }), "Failed waiting for enable-auto-update=false") }() exutil.By("Wait for enable-auto-update") exutil.AssertWaitPollNoErr(wait.PollImmediate(2*time.Second, 10*time.Second, func() (bool, error) { depArgs, _, err := getCVOcontArg(oc, "enable-auto-update") if err != nil { return false, fmt.Errorf("get CVO container args returned error: %v", err) } e2e.Logf("argument: %s", depArgs) return strings.Contains(depArgs, "true"), nil }), "Failed waiting for enable-auto-update=true") exutil.By("Check cvo can not get available update after setting enable-auto-update") exutil.AssertWaitPollNoErr(wait.Poll(5*time.Second, 15*time.Second, func() (bool, error) { reason, err := getCVObyJP(oc, ".status.conditions[?(.type=='RetrievedUpdates')].reason") if err != nil { return false, fmt.Errorf("get CVO RetreivedUpdates condition returned error: %v", err) } e2e.Logf("reason: %s", reason) return strings.Contains(reason, "VersionNotFound"), nil }), "Failed to check cvo can not get available update") exutil.By("Check availableUpdates is null") o.Expect(getCVObyJP(oc, ".status.availableUpdates")).To(o.Equal("null"), "unexpected availableUpdates") // changed from <nil> to null in 4.16 exutil.By("Check desired version haven't changed") o.Expect(getCVObyJP(oc, ".status.desired.version")).To(o.Equal(origVersion), "unexpected desired version change") }) //author: [email protected] g.It("Longduration-NonPreRelease-Author:evakhoni-Medium-22641-Rollback against a dummy start update with oc adm upgrade clear [Serial]", func() { // preserve original message originalMessage, err := getCVObyJP(oc, ".status.conditions[?(.type=='ReleaseAccepted')].message") o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("request upgrade to fake payload") fakeReleasePayload := "registry.ci.openshift.org/ocp/release@sha256:5a561dc23a9d323c8bd7a8631bed078a9e5eec690ce073f78b645c83fb4cdf74" err = oc.AsAdmin().WithoutNamespace().Run("adm"). Args("upgrade", "--allow-explicit-upgrade", "--force", "--to-image", fakeReleasePayload).Execute() o.Expect(err).NotTo(o.HaveOccurred()) defer func() { o.Expect(recoverReleaseAccepted(oc)).NotTo(o.HaveOccurred()) }() exutil.By("check ReleaseAccepted=False") // usually happens quicker, but 8 minutes is safe deadline if err = waitForCondition(oc, 30, 480, "False", "get", "clusterversion", "version", "-o", "jsonpath={.status.conditions[?(@.type=='ReleaseAccepted')].status}"); err != nil { //dump contents to log _ = oc.AsAdmin().WithoutNamespace().Run("get").Args("clusterversion", "version", "-o", "yaml").Execute() exutil.AssertWaitPollNoErr(err, "ReleaseAccepted condition is not false in 8m") } exutil.By("check ReleaseAccepted False have correct message") message, err := getCVObyJP(oc, ".status.conditions[?(.type=='ReleaseAccepted')].message") o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(message).To(o.ContainSubstring("Unable to download and prepare the update: deadline exceeded")) o.Expect(message).To(o.ContainSubstring("Job was active longer than specified deadline")) o.Expect(message).To(o.ContainSubstring(fakeReleasePayload)) exutil.By("check version pod in ImagePullBackOff") // swinging betseen Init:0/4 Init:ErrImagePull and Init:ImagePullBackOff so need a few retries if err = waitForCondition(oc, 5, 30, "ImagePullBackOff", "get", "-n", "openshift-cluster-version", "pods", "-o", "jsonpath={.items[*].status.initContainerStatuses[0].state.waiting.reason}"); err != nil { //dump contents to log _ = oc.AsAdmin().WithoutNamespace().Run("get").Args("-n", "openshift-cluster-version", "pods", "-o", "yaml").Execute() exutil.AssertWaitPollNoErr(err, "ImagePullBackOff not detected in 30s") } exutil.By("Clear above unstarted upgrade") err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade", "--clear").Execute() o.Expect(err).NotTo(o.HaveOccurred()) if err = waitForCondition(oc, 30, 480, "True", "get", "clusterversion", "version", "-o", "jsonpath={.status.conditions[?(@.type=='ReleaseAccepted')].status}"); err != nil { //dump contents to log _ = oc.AsAdmin().WithoutNamespace().Run("get").Args("clusterversion", "version", "-o", "yaml").Execute() exutil.AssertWaitPollNoErr(err, "ReleaseAccepted condition is not false in 8m") } exutil.By("check ReleaseAccepted False have correct message") message, err = getCVObyJP(oc, ".status.conditions[?(.type=='ReleaseAccepted')].message") o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(message).To(o.ContainSubstring(regexp.MustCompile(` architecture=".*"`).ReplaceAllString(originalMessage, ""))) // until OCPBUGS-4032 is fixed exutil.By("no version pod in ImagePullBackOff") if err = waitForCondition(oc, 5, 30, "", "get", "-n", "openshift-cluster-version", "pods", "-o", "jsonpath={.items[*].status.initContainerStatuses[0].state.waiting.reason}"); err != nil { //dump contents to log _ = oc.AsAdmin().WithoutNamespace().Run("get").Args("-n", "openshift-cluster-version", "pods", "-o", "yaml").Execute() exutil.AssertWaitPollNoErr(err, "ImagePullBackOff not cleared in 30s") } }) //author: [email protected] g.It("Longduration-NonPreRelease-Author:jiajliu-High-46017-CVO should keep reconcile manifests when update failed on precondition check [Disruptive]", func() { exutil.SkipBaselineCaps(oc, "None") //Take openshift-marketplace/deployment as an example, it can be any resource which included in manifest files resourceKindName := "deployment/marketplace-operator" resourceNamespace := "openshift-marketplace" exutil.By("Check default rollingUpdate strategy in a fresh installed cluster.") defaultValueMaxUnavailable, err := oc.AsAdmin().WithoutNamespace().Run("get"). Args(resourceKindName, "-o=jsonpath={.spec.strategy.rollingUpdate.maxUnavailable}", "-n", resourceNamespace).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(defaultValueMaxUnavailable).To(o.Equal("25%")) exutil.By("Ensure upgradeable=false.") upgStatusOutput, err := oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade").Output() o.Expect(err).NotTo(o.HaveOccurred()) if !strings.Contains(upgStatusOutput, "Upgradeable=False") { e2e.Logf("Enable upgradeable=false explicitly...") //set overrides in cv to trigger upgradeable=false condition if it is not enabled by default err = setCVOverrides(oc, "deployment", "network-operator", "openshift-network-operator") defer unsetCVOverrides(oc) exutil.AssertWaitPollNoErr(err, "timeout to set overrides!") } exutil.By("Trigger update when upgradeable=false and precondition check fail.") //Choose a fixed old release payload to trigger a fake upgrade when upgradeable=false oldReleasePayload := "quay.io/openshift-release-dev/ocp-release@sha256:fd96300600f9585e5847f5855ca14e2b3cafbce12aefe3b3f52c5da10c4476eb" err = oc.AsAdmin().WithoutNamespace().Run("adm"). Args("upgrade", "--allow-explicit-upgrade", "--to-image", oldReleasePayload).Execute() o.Expect(err).NotTo(o.HaveOccurred()) defer func() { o.Expect(recoverReleaseAccepted(oc)).NotTo(o.HaveOccurred()) }() if err = waitForCondition(oc, 30, 480, "False", "get", "clusterversion", "version", "-o", "jsonpath={.status.conditions[?(@.type=='ReleaseAccepted')].status}"); err != nil { //dump contents to log _ = oc.AsAdmin().WithoutNamespace().Run("get").Args("clusterversion", "version", "-o", "yaml").Execute() exutil.AssertWaitPollNoErr(err, "ReleaseAccepted condition is not false in 8m") } exutil.By("Change strategy.rollingUpdate.maxUnavailable to be 50%.") _, err = ocJSONPatch(oc, resourceNamespace, resourceKindName, []JSONp{ {"replace", "/spec/strategy/rollingUpdate/maxUnavailable", "50%"}, }) o.Expect(err).NotTo(o.HaveOccurred()) defer func() { out, err := ocJSONPatch(oc, resourceNamespace, resourceKindName, []JSONp{ {"replace", "/spec/strategy/rollingUpdate/maxUnavailable", "25%"}, }) o.Expect(err).NotTo(o.HaveOccurred(), out) }() exutil.By("Check the deployment was reconciled back.") exutil.AssertWaitPollNoErr(wait.Poll(30*time.Second, 20*time.Minute, func() (bool, error) { valueMaxUnavailable, err := oc.AsAdmin().WithoutNamespace().Run("get"). Args(resourceKindName, "-o=jsonpath={.spec.strategy.rollingUpdate.maxUnavailable}", "-n", resourceNamespace).Output() if err != nil { return false, fmt.Errorf("oc get %s -n %s returned error: %v", resourceKindName, resourceNamespace, err) } if strings.Compare(valueMaxUnavailable, defaultValueMaxUnavailable) != 0 { e2e.Logf("valueMaxUnavailable is %v. Waiting for deployment being reconciled...", valueMaxUnavailable) return false, nil } return true, nil }), "the deployment was not reconciled back in 20min.") }) //author: [email protected] g.It("Longduration-NonPreRelease-Author:jiajliu-Medium-51973-setting cv.overrides should work while ReleaseAccepted=False [Disruptive]", func() { resourceKind := "deployment" resourceName := "network-operator" resourceNamespace := "openshift-network-operator" exutil.By("Trigger ReleaseAccepted=False condition.") fakeReleasePayload := "quay.io/openshift-release-dev-test/ocp-release@sha256:39efe13ef67cb4449f5e6cdd8a26c83c07c6a2ce5d235dfbc3ba58c64418fcf3" err := oc.AsAdmin().WithoutNamespace().Run("adm"). Args("upgrade", "--allow-explicit-upgrade", "--to-image", fakeReleasePayload).Execute() o.Expect(err).NotTo(o.HaveOccurred()) defer func() { o.Expect(recoverReleaseAccepted(oc)).NotTo(o.HaveOccurred()) }() if err = waitForCondition(oc, 30, 480, "False", "get", "clusterversion", "version", "-o", "jsonpath={.status.conditions[?(@.type=='ReleaseAccepted')].status}"); err != nil { //dump contents to log _ = oc.AsAdmin().WithoutNamespace().Run("get").Args("clusterversion", "version", "-o", "yaml").Execute() exutil.AssertWaitPollNoErr(err, "ReleaseAccepted condition is not false in 8m") } exutil.By("Disable deployment/network-operator's management through setting cv.overrides.") err = setCVOverrides(oc, resourceKind, resourceName, resourceNamespace) defer unsetCVOverrides(oc) exutil.AssertWaitPollNoErr(err, "timeout to set overrides!") exutil.By("Check default rollingUpdate strategy.") defaultValueMaxUnavailable, err := oc.AsAdmin().WithoutNamespace().Run("get"). Args(resourceKind, resourceName, "-o=jsonpath={.spec.strategy.rollingUpdate.maxUnavailable}", "-n", resourceNamespace).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(defaultValueMaxUnavailable).To(o.Equal("1")) exutil.By("Change strategy.rollingUpdate.maxUnavailable to be 50%.") _, err = ocJSONPatch(oc, resourceNamespace, fmt.Sprintf("%s/%s", resourceKind, resourceName), []JSONp{ {"replace", "/spec/strategy/rollingUpdate/maxUnavailable", "50%"}, }) o.Expect(err).NotTo(o.HaveOccurred()) defer func() { out, err := ocJSONPatch(oc, resourceNamespace, fmt.Sprintf("%s/%s", resourceKind, resourceName), []JSONp{ {"replace", "/spec/strategy/rollingUpdate/maxUnavailable", 1}, }) o.Expect(err).NotTo(o.HaveOccurred(), out) }() exutil.By("Check the deployment will not be reconciled back.") err = wait.Poll(30*time.Second, 8*time.Minute, func() (bool, error) { valueMaxUnavailable, err := oc.AsAdmin().WithoutNamespace().Run("get"). Args(resourceKind, resourceName, "-o=jsonpath={.spec.strategy.rollingUpdate.maxUnavailable}", "-n", resourceNamespace).Output() if err != nil { return false, fmt.Errorf("oc get %s %s -n %s returned error: %v", resourceKind, resourceName, resourceNamespace, err) } if strings.Compare(valueMaxUnavailable, defaultValueMaxUnavailable) == 0 { e2e.Logf("valueMaxUnavailable is %v. Waiting for deployment being reconciled...", valueMaxUnavailable) return false, nil } return true, nil }) if err != nil { o.Expect(err.Error()).To(o.ContainSubstring("timed out waiting for the condition")) } }) //author: [email protected] g.It("Author:jiajliu-Medium-53906-The architecture info in clusterversion’s status should be correct", func() { const heterogeneousArchKeyword = "multi" expectedArchMsg := "architecture=\"Multi\"" exutil.By("Get release info from current cluster") releaseInfo, err := getReleaseInfo(oc) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(releaseInfo).NotTo(o.BeEmpty()) exutil.By("Check the arch info cv.status is expected") cvArchInfo, err := getCVObyJP(oc, ".status.conditions[?(.type=='ReleaseAccepted')].message") o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("Release payload info in cv.status: %v", cvArchInfo) if releaseArch := gjson.Get(releaseInfo, `metadata.metadata.release\.openshift\.io/architecture`).String(); releaseArch != heterogeneousArchKeyword { e2e.Logf("This current release is a non-heterogeneous payload") //It's a non-heterogeneous payload, the architecture info in clusterversion’s status should be consistent with runtime.GOARCH. output, err := oc.AsAdmin().WithoutNamespace(). Run("get").Args("nodes", "-o", "jsonpath={.items[*].status.nodeInfo.architecture}").Output() o.Expect(err).NotTo(o.HaveOccurred()) nodesArchInfo := strings.Split(strings.TrimSpace(output), " ") e2e.Logf("Nodes arch list: %v", nodesArchInfo) for _, nArch := range nodesArchInfo { if nArch != nodesArchInfo[0] { e2e.Failf("unexpected node arch in non-hetero cluster: %s expecting: %s", nArch, nodesArchInfo[0]) } } e2e.Logf("Expected arch info: %v", nodesArchInfo[0]) o.Expect(cvArchInfo).To(o.ContainSubstring(nodesArchInfo[0])) } else { e2e.Logf("This current release is a heterogeneous payload") // It's a heterogeneous payload, the architecture info in clusterversion’s status should be multi. e2e.Logf("Expected arch info: %v", expectedArchMsg) o.Expect(cvArchInfo).To(o.ContainSubstring(expectedArchMsg)) } }) // author: [email protected] g.It("Longduration-NonPreRelease-Author:jianl-high-68398-CVO reconcile SCC resources which have release.openshift.io/create-only: true [Slow]", func() { exutil.By("Get default SCC spec") scc := "restricted" sccManifest := "0000_20_kube-apiserver-operator_00_scc-restricted.yaml" tempDataDir, err := extractManifest(oc) defer func() { o.Expect(os.RemoveAll(tempDataDir)).NotTo(o.HaveOccurred()) }() o.Expect(err).NotTo(o.HaveOccurred()) goodSCCFile, getSCCFileErr := oc.AsAdmin().WithoutNamespace(). Run("get").Args("scc", scc, "-ojson").OutputToFile("ocp-68398.json") o.Expect(getSCCFileErr).NotTo(o.HaveOccurred()) defer func() { o.Expect(oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", goodSCCFile, "--force").Execute()).NotTo(o.HaveOccurred()) o.Expect(os.RemoveAll(goodSCCFile)).NotTo(o.HaveOccurred()) }() originalOutputByte, readFileErr := os.ReadFile(goodSCCFile) o.Expect(readFileErr).NotTo(o.HaveOccurred()) originalOutput := string(originalOutputByte) o.Expect(originalOutput).Should(o.ContainSubstring("release.openshift.io/create-only")) createOnly := gjson.Get(originalOutput, "metadata.annotations.release?openshift?io/create-only").Bool() o.Expect(createOnly).Should(o.BeTrue()) // update allowHostIPC should not cause upgradeable=false and will not be reconsiled originalAllowHostIPC := gjson.Get(originalOutput, "allowHostIPC").Bool() ocJSONPatch(oc, "", fmt.Sprintf("scc/%s", scc), []JSONp{{"replace", "/allowHostIPC", !originalAllowHostIPC}}) o.Consistently(func() bool { hostIPC_output, _ := oc.AsAdmin().WithoutNamespace(). Run("get").Args("scc", scc, "-ojson").Output() boolValue := gjson.Get(hostIPC_output, "allowHostIPC").Bool() // boolValue == original_allowHostIPC means resource has been reconciled return boolValue }, 300*time.Second, 30*time.Second).ShouldNot(o.Equal(originalAllowHostIPC), "Error: allowHostIPC was reconciled back, check point: allowHostIPC") upgradeableOutput, _ := oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade").Output() o.Expect(string(upgradeableOutput)).ShouldNot(o.ContainSubstring("Detected modified SecurityContextConstraints"), "Error occured in oc adm upgrade") originalVolumes := gjson.Get(originalOutput, "volumes").Array() ocJSONPatch(oc, "", fmt.Sprintf("scc/%s", scc), []JSONp{ {"remove", "/volumes/0", nil}, {"add", "/volumes/0", "Test"}, }) o.Consistently(func() bool { volumesOutput, _ := oc.AsAdmin().WithoutNamespace(). Run("get").Args("scc", scc, "-ojson").Output() newVolumes := gjson.Get(volumesOutput, "volumes").Array() return newVolumes[0].String() == "Test" && newVolumes[5].String() != originalVolumes[4].String() }, 5*time.Minute, 30*time.Second).Should(o.BeTrue(), fmt.Sprintf("Error: %s was reconciled back, check point: volumes", scc)) upgradeableOutput, _ = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade").Output() o.Expect(string(upgradeableOutput)).ShouldNot(o.ContainSubstring("Detected modified SecurityContextConstraints"), "Error occured in oc adm upgrade") // allowPrivilegeEscalation should be set to true immediately after removing it pe_log, _ := ocJSONPatch(oc, "", fmt.Sprintf("scc/%s", scc), []JSONp{ {"remove", "/allowPrivilegeEscalation", nil}, }) e2e.Logf(string(pe_log)) o.Consistently(func() bool { pe_output, _ := oc.AsAdmin().WithoutNamespace(). Run("get").Args("scc", scc, "-ojson").Output() pe_value := gjson.Get(pe_output, "allowPrivilegeEscalation").Bool() return pe_value }, 30*time.Second, 10*time.Second).Should(o.BeTrue(), "Error: allowPrivilegeEscalation is not true") upgradeableOutput, _ = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade").Output() o.Expect(string(upgradeableOutput)).ShouldNot(o.ContainSubstring("Detected modified SecurityContextConstraints"), "Error occured in oc adm upgrade") // SCC should be recreated after deleting it outputBeforeDelete, _ := oc.AsAdmin().WithoutNamespace(). Run("get").Args("scc", scc, "-ojson").Output() resourceVersion := gjson.Get(outputBeforeDelete, "metadata.resourceVersion").String() deleteLog, deleteErr := oc.AsAdmin().WithoutNamespace().Run("delete").Args("scc", scc).Output() e2e.Logf("Delete scc %s: %s", scc, deleteLog) o.Expect(deleteErr).NotTo(o.HaveOccurred()) err = wait.PollUntilContextTimeout(context.Background(), 30*time.Second, 10*time.Minute, true, func(context.Context) (bool, error) { newOutput, newErr := oc.AsAdmin().WithoutNamespace(). Run("get").Args("scc", scc, "-ojson").Output() if newErr != nil { return false, nil } else { newResourceVersion := gjson.Get(newOutput, "metadata.resourceVersion").String() return resourceVersion != newResourceVersion, nil } }) exutil.AssertWaitPollNoErr(err, "Error: SCC have not recreated after 5 minutes") manifest := filepath.Join(tempDataDir, "manifest", sccManifest) manifestContent, _ := os.ReadFile(manifest) expectedValues, err := exutil.Yaml2Json(string(manifestContent)) o.Expect(err).NotTo(o.HaveOccurred()) finalOutput, _ := oc.AsAdmin().WithoutNamespace(). Run("get").Args("scc", scc, "-ojson").Output() o.Expect(finalOutput).Should(o.ContainSubstring("release.openshift.io/create-only")) createOnly = gjson.Get(finalOutput, "metadata.annotations.release?openshift?io/create-only").Bool() o.Expect(createOnly).Should(o.BeTrue()) final_allowHostIPC := gjson.Get(finalOutput, "allowHostIPC").Bool() o.Expect(final_allowHostIPC).Should(o.Equal(gjson.Get(expectedValues, "allowHostIPC").Bool()), "allowHostIPC is not correct") final_pe_value := gjson.Get(finalOutput, "allowPrivilegeEscalation").Bool() pe := gjson.Get(expectedValues, "allowPrivilegeEscalation").Bool() e2e.Logf("pe: %v", pe) o.Expect(final_pe_value).Should(o.Equal(pe), "allowPrivilegeEscalation is not correct") finalVolumes := gjson.Get(finalOutput, "volumes").Array() expectedVolumes := gjson.Get(expectedValues, "volumes").Array() o.Expect(len(finalVolumes)).Should(o.Equal(len(expectedVolumes)), "volumes have different number of expected values") var finalResult []string for _, v := range finalVolumes { finalResult = append(finalResult, v.Str) } var expectedResult []string for _, v := range expectedVolumes { expectedResult = append(expectedResult, v.Str) } e2e.Logf("Final volumes are: %v", finalResult) e2e.Logf("Expected volumes are: %v", expectedResult) o.Expect(finalResult).Should(o.ContainElements(expectedResult), "volumns are not exact equal to manifest") upgradeableOutput, _ = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade").Output() o.Expect(string(upgradeableOutput)).ShouldNot(o.ContainSubstring("Detected modified SecurityContextConstraints"), "Error occured in oc adm upgrade") }) // author: [email protected] g.It("Longduration-NonPreRelease-Author:jianl-high-68397-CVO reconciles SCC resources which do not have release.openshift.io/create-only: true [Disruptive]", func() { scc := "restricted-v2" exutil.By("Get default SCC spec") sccManifest := "0000_20_kube-apiserver-operator_00_scc-restricted-v2.yaml" tempDataDir, err := extractManifest(oc) defer func() { o.Expect(os.RemoveAll(tempDataDir)).NotTo(o.HaveOccurred()) }() o.Expect(err).NotTo(o.HaveOccurred()) goodSCCFile, getSCCFileErr := oc.AsAdmin().WithoutNamespace(). Run("get").Args("scc", scc, "-ojson").OutputToFile("ocp-68397-scc.json") o.Expect(getSCCFileErr).NotTo(o.HaveOccurred()) defer func() { o.Expect(oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", goodSCCFile, "--force").Execute()).NotTo(o.HaveOccurred()) o.Expect(os.RemoveAll(goodSCCFile)).NotTo(o.HaveOccurred()) output, _ := oc.AsAdmin().WithoutNamespace(). Run("get").Args("scc", scc, "-ojson").Output() e2e.Logf("New scc after runing apply command: \n %s", output) }() originalOutputByte, readFileErr := os.ReadFile(goodSCCFile) o.Expect(readFileErr).NotTo(o.HaveOccurred()) originalOutput := string(originalOutputByte) o.Expect(originalOutput).ShouldNot(o.ContainSubstring("release.openshift.io/create-only")) // update allowHostIPC should not cause upgradeable=false and will be reconciled originalAllowHostIPC := gjson.Get(originalOutput, "allowHostIPC").Bool() ocJSONPatch(oc, "", fmt.Sprintf("scc/%s", scc), []JSONp{{"replace", "/allowHostIPC", !originalAllowHostIPC}}) var observedAllowHostIPC bool var output string err = wait.Poll(30*time.Second, 5*time.Minute, func() (bool, error) { output, err = oc.AsAdmin().WithoutNamespace(). Run("get").Args("scc", scc, "-ojson").Output() if err != nil { return false, err } else { observedAllowHostIPC = gjson.Get(output, "allowHostIPC").Bool() // observedAllowHostIPC == original_allowHostIPC means resource has been reconciled return observedAllowHostIPC == originalAllowHostIPC, nil } }) exutil.AssertWaitPollNoErr(err, "AllowHostIPC is not reconciled") // there is no Upgradeable=False guard o.Expect(checkUpdates(oc, false, 10, 30, "Detected modified SecurityContextConstraints")).To(o.BeFalse(), "Error occured in oc adm upgrade after updating allowHostIPC") // SCC should be recreated after deleting it outputBeforeDelete, _ := oc.AsAdmin().WithoutNamespace(). Run("get").Args("scc", scc, "-ojson").Output() resourceVersion := gjson.Get(outputBeforeDelete, "metadata.resourceVersion").String() deleteLog, deleteErr := oc.AsAdmin().WithoutNamespace().Run("delete").Args("scc", scc).Output() e2e.Logf("Delete scc %s: %s", scc, deleteLog) o.Expect(deleteErr).NotTo(o.HaveOccurred()) // wait some minutes scc will regenerated var newErr error err = wait.Poll(30*time.Second, 5*time.Minute, func() (bool, error) { output, newErr = oc.AsAdmin().WithoutNamespace(). Run("get").Args("scc", scc, "-ojson").Output() if newErr != nil { return false, nil } else { newResourceVersion := gjson.Get(output, "metadata.resourceVersion").String() return resourceVersion != newResourceVersion, nil } }) exutil.AssertWaitPollNoErr(err, "Error: SCC have not recreated after 5 minutes") o.Expect(checkUpdates(oc, false, 30, 60*3, "Detected modified SecurityContextConstraints")).To(o.BeFalse(), "Error occured in oc adm upgrade after deleting scc") manifest := filepath.Join(tempDataDir, "manifest", sccManifest) manifestContent, _ := os.ReadFile(manifest) expectedValues, err := exutil.Yaml2Json(string(manifestContent)) o.Expect(err).NotTo(o.HaveOccurred()) observedAllowHostIPC = gjson.Get(output, "allowHostIPC").Bool() allowHostIPCManifest := gjson.Get(expectedValues, "allowHostIPC").Bool() o.Expect(allowHostIPCManifest).Should(o.Equal(observedAllowHostIPC), "Error: allowHostIPC is not same with its value in manifest") finalVolumes := gjson.Get(output, "volumes").Array() expectedVolumesManifest := gjson.Get(expectedValues, "volumes").Array() o.Expect(len(finalVolumes)).Should(o.Equal(len(expectedVolumesManifest)), "Error: volumes have different number of expected values") var finalResult []string for _, v := range finalVolumes { finalResult = append(finalResult, v.Str) } var expectedResult []string for _, v := range expectedVolumesManifest { expectedResult = append(expectedResult, v.Str) } e2e.Logf("Final volumes are: %v", finalResult) e2e.Logf("Expected volumes in menifest are: %v", expectedResult) o.Expect(finalResult).Should(o.ContainElements(expectedResult), "Error: volumns are not exactly equal to manifest") // allowPrivilegeEscalation should be set to true immediately after removing it allowPrivilegeEscalationManifest := gjson.Get(manifest, "allowPrivilegeEscalation").Bool() ocJSONPatch(oc, "", fmt.Sprintf("scc/%s", scc), []JSONp{ {"remove", "/allowPrivilegeEscalation", nil}, }) output, _ = oc.AsAdmin().WithoutNamespace(). Run("get").Args("scc", scc, "-ojson").Output() allowPrivilegeEscalation := gjson.Get(output, "allowPrivilegeEscalation").Bool() o.Expect(allowPrivilegeEscalation).Should(o.BeTrue(), "Error: allowPrivilegeEscalation is not be set to true immediately") err = wait.Poll(30*time.Second, 10*time.Minute, func() (bool, error) { output, _ = oc.AsAdmin().WithoutNamespace(). Run("get").Args("scc", scc, "-ojson").Output() allowPrivilegeEscalation = gjson.Get(output, "allowPrivilegeEscalation").Bool() return allowPrivilegeEscalation == allowPrivilegeEscalationManifest, nil }) exutil.AssertWaitPollNoErr(err, "Error: allowPrivilegeEscalation is not be set to manifest") o.Expect(checkUpdates(oc, false, 30, 60*3, "Detected modified SecurityContextConstraints")).To(o.BeFalse(), "Error: upgrade guard error occured for SecurityContextConstraints") ocJSONPatch(oc, "", fmt.Sprintf("scc/%s", scc), []JSONp{ {"remove", "/volumes/4", nil}, {"add", "/volumes/0", "Test"}, }) expectedResult = expectedResult[:0] for _, v := range expectedVolumesManifest { expectedResult = append(expectedResult, v.Str) } err = wait.Poll(30*time.Second, 5*time.Minute, func() (bool, error) { output, _ = oc.AsAdmin().WithoutNamespace(). Run("get").Args("scc", scc, "-ojson").Output() finalVolumes := gjson.Get(output, "volumes").Array() if len(finalVolumes) != len(expectedResult) { return false, nil } finalResult = finalResult[:0] for _, v := range finalVolumes { finalResult = append(finalResult, v.Str) } return reflect.DeepEqual(finalResult, expectedResult), nil }) exutil.AssertWaitPollNoErr(err, "volumns are not correct") o.Expect(checkUpdates(oc, false, 1, 10, "Detected modified SecurityContextConstraints")).To(o.BeFalse(), "Error: There should not be upgradeable=false gate for non-4.13 cluster") }) //author: [email protected] g.It("NonPreRelease-Author:jiajliu-Medium-70931-CVO reconcile metadata on ClusterOperators [Disruptive]", func() { var annotationCOs []annotationCO resourcePath := "/metadata/annotations" exutil.By("Remove metadata.annotation") operatorName, err := oc.AsAdmin().WithoutNamespace().Run("get"). Args("co", "-o=jsonpath={.items[*].metadata.name}").Output() o.Expect(err).NotTo(o.HaveOccurred()) operatorList := strings.Fields(operatorName) defer func() { for _, annotationCO := range annotationCOs { anno, _ := oc.AsAdmin().WithoutNamespace().Run("get"). Args("co", annotationCO.name, "-o=jsonpath={.metadata.annotations}").Output() if anno == "" { _, err = ocJSONPatch(oc, "", "clusteroperator/"+annotationCO.name, []JSONp{{"add", resourcePath, annotationCO.annotation}}) o.Expect(err).NotTo(o.HaveOccurred()) } } }() for _, op := range operatorList { var anno map[string]string annoOutput, err := oc.AsAdmin().WithoutNamespace().Run("get"). Args("co", op, "-o=jsonpath={.metadata.annotations}").Output() o.Expect(err).NotTo(o.HaveOccurred()) err = json.Unmarshal([]byte(annoOutput), &anno) o.Expect(err).NotTo(o.HaveOccurred()) annotationCOs = append(annotationCOs, annotationCO{op, anno}) _, err = ocJSONPatch(oc, "", "clusteroperator/"+op, []JSONp{{"remove", resourcePath, nil}}) o.Expect(err).NotTo(o.HaveOccurred()) } exutil.By("Check metadata.annotation is reconciled back") for _, op := range operatorList { o.Eventually(func() string { anno, _ := oc.AsAdmin().WithoutNamespace().Run("get"). Args("co", op, "-o=jsonpath={.metadata.annotations}").Output() return anno }, 5*time.Minute, 1*time.Minute).ShouldNot(o.BeEmpty(), fmt.Sprintf("Fail to reconcile metadata of %s", op)) } }) g.It("Author:jianl-ConnectedOnly-Medium-77520-oc adm upgrade recommend", func() { exutil.By("Check if it's a GCP cluster") exutil.SkipIfPlatformTypeNot(oc, "gcp") exutil.By("export OC_ENABLE_CMD_UPGRADE_RECOMMEND=true") os.Setenv("OC_ENABLE_CMD_UPGRADE_RECOMMEND", "true") defer func() { os.Setenv("OC_ENABLE_CMD_UPGRADE_RECOMMEND", "") }() exutil.By("oc adm upgrade recommend --help") help, err := oc.AsAdmin().WithoutNamespace().Run("adm"). Args("upgrade", "recommend", "--help").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(help).Should(o.ContainSubstring("This subcommand is read-only and does not affect the state of the cluster. To request an update, use the 'oc adm upgrade' subcommand.")) o.Expect(help).Should(o.ContainSubstring("--show-outdated-releases=false")) o.Expect(help).Should(o.ContainSubstring("--version=''")) exutil.By("Update graph data") testDataDir := exutil.FixturePath("testdata", "ota/cvo") graphFile := filepath.Join(testDataDir, "cincy-77520.json") e2e.Logf("Origin graph template file path: ", graphFile) dest := filepath.Join(testDataDir, "cincy-77520_bak.json") err = copy(graphFile, dest) o.Expect(err).NotTo(o.HaveOccurred()) defer func() { os.Remove(dest) }() version, err := getCVObyJP(oc, ".status.history[0].version") o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("Current OCP version is: ", version) major_minor := strings.Split(string(version), ".") exutil.By("Update graphFile with real version") err = updateFile(dest, "current_version", version) o.Expect(err).NotTo(o.HaveOccurred()) err = updateFile(dest, "major", major_minor[0]) o.Expect(err).NotTo(o.HaveOccurred()) err = updateFile(dest, "minor", major_minor[1]) o.Expect(err).NotTo(o.HaveOccurred()) next, _ := strconv.Atoi(major_minor[1]) next_minor := strconv.Itoa(next + 1) err = updateFile(dest, "next", next_minor) o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("New graph template file path: ", dest) exutil.By("Patch upstream and channel") projectID := "openshift-qe" ctx := context.Background() client, err := storage.NewClient(ctx) o.Expect(err).NotTo(o.HaveOccurred()) defer func() { o.Expect(client.Close()).NotTo(o.HaveOccurred()) }() graphURL, bucket, object, _, _, err := buildGraph( client, oc, projectID, dest) defer func() { o.Expect(DeleteBucket(client, bucket)).NotTo(o.HaveOccurred()) }() defer func() { o.Expect(DeleteObject(client, bucket, object)).NotTo(o.HaveOccurred()) }() o.Expect(err).NotTo(o.HaveOccurred()) _, err = ocJSONPatch(oc, "", "clusterversion/version", []JSONp{ {"add", "/spec/upstream", graphURL}, {"add", "/spec/channel", "channel-b"}, }) o.Expect(err).NotTo(o.HaveOccurred()) z_stream_version1 := fmt.Sprintf("%s.%s.998", major_minor[0], major_minor[1]) z_stream_version2 := fmt.Sprintf("%s.%s.999", major_minor[0], major_minor[1]) y_stream_version1 := fmt.Sprintf("%s.%s.997", major_minor[0], next_minor) y_stream_version2 := fmt.Sprintf("%s.%s.998", major_minor[0], next_minor) y_stream_version3 := fmt.Sprintf("%s.%s.999", major_minor[0], next_minor) exutil.By("Check oc adm upgrade recommend") // We need to wait some minutes for the first time to get recommend after patch upstream err = wait.Poll(10*time.Second, 1*time.Minute, func() (bool, error) { output, err := oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade", "recommend").Output() o.Expect(err).NotTo(o.HaveOccurred()) if !strings.Contains(output, "Upstream: "+graphURL) { return false, nil } if !strings.Contains(output, "Channel:") { return false, nil } if !strings.Contains(output, z_stream_version1+" no known issues relevant to this cluster") { return false, nil } if !strings.Contains(output, z_stream_version2+" no known issues relevant to this cluster") { return false, nil } if !strings.Contains(output, y_stream_version3+" no known issues relevant to this cluster") { return false, nil } if !strings.Contains(output, "MultipleReasons") { return false, nil } //major.next.997 is older than major.next.998 and major.next.999, so should not display it in output if strings.Contains(output, y_stream_version1) { return false, nil } return true, nil }) exutil.AssertWaitPollNoErr(err, "oc adm upgrade recommend fail") output, _ := oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade", "recommend").Output() e2e.Logf("output: \n", output) exutil.By("Check oc adm upgrade recommend --show-outdated-releases") output, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade", "recommend", "--show-outdated-releases").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("output: \n", output) o.Expect(output).Should(o.ContainSubstring("Upstream: " + graphURL)) o.Expect(output).Should(o.ContainSubstring("Channel")) o.Expect(output).Should(o.ContainSubstring(fmt.Sprintf("%s no known issues relevant to this cluster", z_stream_version1))) o.Expect(output).Should(o.ContainSubstring(fmt.Sprintf("%s no known issues relevant to this cluster", z_stream_version2))) o.Expect(output).Should(o.ContainSubstring(fmt.Sprintf("%s no known issues relevant to this cluster", y_stream_version1))) o.Expect(output).Should(o.ContainSubstring(fmt.Sprintf("%s MultipleReasons", y_stream_version2))) o.Expect(output).Should(o.ContainSubstring(fmt.Sprintf("%s no known issues relevant to this cluster", y_stream_version3))) exutil.By("Check oc adm upgrade recommend --version " + y_stream_version2) output, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade", "recommend", "--version", y_stream_version2).Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("output: \n", output) o.Expect(output).Should(o.ContainSubstring("Upstream: " + graphURL)) o.Expect(output).Should(o.ContainSubstring("Channel")) o.Expect(output).Should(o.ContainSubstring(fmt.Sprintf("Update to %s Recommended=False", y_stream_version2))) o.Expect(output).Should(o.ContainSubstring("Reason: MultipleReasons")) o.Expect(output).Should(o.ContainSubstring("On clusters on default invoker user, this imaginary bug can happen")) o.Expect(output).Should(o.ContainSubstring("Too many CI failures on this release, so do not update to it")) exutil.By("Check oc adm upgrade recommend --version " + y_stream_version3) output, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade", "recommend", "--version", y_stream_version3).Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("output: \n", output) o.Expect(output).Should(o.ContainSubstring("Upstream: " + graphURL)) o.Expect(output).Should(o.ContainSubstring("Channel")) expected_msg := fmt.Sprintf("Update to %s has no known issues relevant to this cluster.", y_stream_version3) o.Expect(output).Should(o.ContainSubstring(expected_msg)) o.Expect(output).Should(o.ContainSubstring("Image: quay.io/openshift-release-dev/ocp-release@sha256:d2d34aafe0adda79953dd928b946ecbda34673180ee9a80d2ee37c123a0f510c")) o.Expect(output).Should(o.ContainSubstring("Release URL: https://amd64.ocp.releases.ci.openshift.org/releasestream/4-dev-preview/release/4.y+1.0")) exutil.By("Check oc adm upgrade recommend --version 4.999.999") output, _ = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade", "recommend", "--version", "4.999.999").Output() e2e.Logf("output: \n", output) o.Expect(output).Should(o.ContainSubstring("Upstream: " + graphURL)) o.Expect(output).Should(o.ContainSubstring("Channel")) o.Expect(output).Should(o.ContainSubstring("error: no updates to 4.999 available, so cannot display context for the requested release 4.999.999")) }) })
package cvo
test case
openshift/openshift-tests-private
458defcb-84f8-4570-af81-bb7bacf8a12a
NonHyperShiftHOST-Author:dis-High-56072-CVO pod should not crash
['"reflect"', '"strings"']
github.com/openshift/openshift-tests-private/test/extended/ota/cvo/cvo.go
g.It("NonHyperShiftHOST-Author:dis-High-56072-CVO pod should not crash", func() { exutil.By("Get CVO container status") CVOStatus, err := getCVOPod(oc, ".status.containerStatuses[]") o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(CVOStatus).NotTo(o.BeNil()) exutil.By("Check ready is true") o.Expect(CVOStatus["ready"]).To(o.BeTrue(), "CVO is not ready: %v", CVOStatus) exutil.By("Check started is true") o.Expect(CVOStatus["started"]).To(o.BeTrue(), "CVO is not started: %v", CVOStatus) exutil.By("Check state is running") o.Expect(CVOStatus["state"]).NotTo(o.BeNil(), "CVO have no state: %v", CVOStatus) o.Expect(CVOStatus["state"].(map[string]interface{})["running"]).NotTo(o.BeNil(), "CVO state have no running: %v", CVOStatus) exutil.By("Check exitCode of lastState is 0 if lastState is not empty") lastState := CVOStatus["lastState"] o.Expect(lastState).NotTo(o.BeNil(), "CVO have no lastState: %v", CVOStatus) if reflect.ValueOf(lastState).Len() == 0 { e2e.Logf("lastState is empty which is expected") } else { o.Expect(lastState.(map[string]interface{})["terminated"]).NotTo(o.BeNil(), "no terminated for non-empty CVO lastState: %v", CVOStatus) exitCode := lastState.(map[string]interface{})["terminated"].(map[string]interface{})["exitCode"].(float64) if exitCode == 255 && strings.Contains( lastState.(map[string]interface{})["terminated"].(map[string]interface{})["message"].(string), "Failed to get FeatureGate from cluster") { e2e.Logf("detected a known issue OCPBUGS-13873, skipping lastState check") } else { o.Expect(exitCode).To(o.BeZero(), "CVO terminated with non-zero code: %v", CVOStatus) reason := lastState.(map[string]interface{})["terminated"].(map[string]interface{})["reason"] o.Expect(reason.(string)).To(o.Equal("Completed"), "CVO terminated with unexpected reason: %v", CVOStatus) } } })
test case
openshift/openshift-tests-private
ffeec54f-6337-4c8b-a72b-13267dd4bd4c
NonHyperShiftHOST-Author:dis-Medium-49508-disable capabilities by modifying the cv.spec.capabilities.baselineCapabilitySet [Serial]
['"strings"', '"github.com/tidwall/gjson"']
github.com/openshift/openshift-tests-private/test/extended/ota/cvo/cvo.go
g.It("NonHyperShiftHOST-Author:dis-Medium-49508-disable capabilities by modifying the cv.spec.capabilities.baselineCapabilitySet [Serial]", func() { orgBaseCap, err := getCVObyJP(oc, ".spec.capabilities.baselineCapabilitySet") o.Expect(err).NotTo(o.HaveOccurred()) if orgBaseCap == "None" { g.Skip("The test cannot run on baselineCapabilitySet None") } defer func() { if newBaseCap, _ := getCVObyJP(oc, ".spec.capabilities.baselineCapabilitySet"); orgBaseCap != newBaseCap { var out string var err error e2e.Logf("restoring original base caps to '%s'", orgBaseCap) if orgBaseCap == "" { out, err = changeCap(oc, true, nil) } else { out, err = changeCap(oc, true, orgBaseCap) } o.Expect(err).NotTo(o.HaveOccurred(), out) } else { e2e.Logf("defer baselineCapabilitySet skipped for original value already matching '%v'", newBaseCap) } }() exutil.By("Check cap status and condition prior to change") enabledCap, err := getCVObyJP(oc, ".status.capabilities.enabledCapabilities[*]") o.Expect(err).NotTo(o.HaveOccurred()) capSet := strings.Split(enabledCap, " ") o.Expect(verifyCaps(oc, capSet)).NotTo(o.HaveOccurred()) out, err := getCVObyJP(oc, ".status.conditions[?(.type=='ImplicitlyEnabledCapabilities')]") o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(gjson.Get(out, "status").Bool()).To(o.Equal(false), "unexpected status dumping implicit %s", out) o.Expect(gjson.Get(out, "reason").String()).To(o.Equal("AsExpected"), "unexpected reason dumping implicit %s", out) o.Expect(gjson.Get(out, "message").String()).To(o.ContainSubstring("Capabilities match configured spec"), "unexpected message dumping implicit %s", out) exutil.By("Disable capabilities by modifying the baselineCapabilitySet") _, err = changeCap(oc, true, "None") o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("Check cap status and condition after change") enabledCapPost, err := getCVObyJP(oc, ".status.capabilities.enabledCapabilities[*]") o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(enabledCapPost).To(o.Equal(enabledCap)) o.Expect(verifyCaps(oc, capSet)).NotTo(o.HaveOccurred(), "verifyCaps for enabled %v failed", capSet) exutil.By("Check implicitly enabled caps are correct") out, err = getCVObyJP(oc, ".status.conditions[?(.type=='ImplicitlyEnabledCapabilities')]") o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(gjson.Get(out, "status").Bool()).To(o.Equal(true), "unexpected status dumping implicit %s", out) o.Expect(gjson.Get(out, "reason").String()).To(o.Equal("CapabilitiesImplicitlyEnabled"), "unexpected reason dumping implicit %s", out) o.Expect(gjson.Get(out, "message").String()).To(o.ContainSubstring("The following capabilities could not be disabled"), "unexpected message dumping implicit %s", out) o.Expect(gjson.Get(out, "message").String()).To(o.ContainSubstring(strings.Join(capSet, ", ")), "unexpected message dumping implicit %s", out) })
test case
openshift/openshift-tests-private
154d5b4b-13d9-44a3-b7fa-7f68bfde6a5f
NonHyperShiftHOST-Author:dis-Low-49670-change spec.capabilities to invalid value
['"reflect"', '"strconv"', '"strings"']
github.com/openshift/openshift-tests-private/test/extended/ota/cvo/cvo.go
g.It("NonHyperShiftHOST-Author:dis-Low-49670-change spec.capabilities to invalid value", func() { orgCap, err := getCVObyJP(oc, ".spec.capabilities") o.Expect(err).NotTo(o.HaveOccurred()) if orgCap == "" { defer func() { out, err := ocJSONPatch(oc, "", "clusterversion/version", []JSONp{{"remove", "/spec/capabilities", nil}}) o.Expect(err).NotTo(o.HaveOccurred(), out) }() } else { orgBaseCap, err := getCVObyJP(oc, ".spec.capabilities.baselineCapabilitySet") o.Expect(err).NotTo(o.HaveOccurred()) orgAddCapstr, err := getCVObyJP(oc, ".spec.capabilities.additionalEnabledCapabilities[*]") o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("original baseline: '%s', original additional: '%s'", orgBaseCap, orgAddCapstr) orgAddCap := strings.Split(orgAddCapstr, " ") defer func() { if newBaseCap, _ := getCVObyJP(oc, ".spec.capabilities.baselineCapabilitySet"); orgBaseCap != newBaseCap { var out string var err error if orgBaseCap == "" { out, err = changeCap(oc, true, nil) } else { out, err = changeCap(oc, true, orgBaseCap) } o.Expect(err).NotTo(o.HaveOccurred(), out) } else { e2e.Logf("defer baselineCapabilitySet skipped for original value already matching '%v'", newBaseCap) } }() defer func() { if newAddCap, _ := getCVObyJP(oc, ".spec.capabilities.additionalEnabledCapabilities[*]"); !reflect.DeepEqual(orgAddCap, strings.Split(newAddCap, " ")) { var out string var err error if reflect.DeepEqual(orgAddCap, make([]string, 1)) { // need this cause strings.Split of an empty string creates len(1) slice which isn't nil out, err = changeCap(oc, false, nil) } else { out, err = changeCap(oc, false, orgAddCap) } o.Expect(err).NotTo(o.HaveOccurred(), out) } else { e2e.Logf("defer additionalEnabledCapabilities skipped for original value already matching '%v'", strings.Split(newAddCap, " ")) } }() } exutil.By("Set invalid baselineCapabilitySet") cmdOut, err := changeCap(oc, true, "Invalid") o.Expect(err).To(o.HaveOccurred()) clusterVersion, _, err := exutil.GetClusterVersion(oc) o.Expect(err).NotTo(o.HaveOccurred()) version := strings.Split(clusterVersion, ".") minor_version := version[1] latest_version, err := strconv.Atoi(minor_version) o.Expect(err).NotTo(o.HaveOccurred()) var versions []string for i := 11; i <= latest_version; i++ { versions = append(versions, "\"v4."+strconv.Itoa(i)+"\"") } versions = append(versions, "\"vCurrent\"") result := "Unsupported value: \"Invalid\": supported values: \"None\", " + strings.Join(versions, ", ") o.Expect(cmdOut).To(o.ContainSubstring(result)) // Important! this one should be updated each version with new capabilities, as they added to openshift. exutil.By("Set invalid additionalEnabledCapabilities") cmdOut, err = changeCap(oc, false, []string{"Invalid"}) o.Expect(err).To(o.HaveOccurred()) o.Expect(cmdOut).To(o.ContainSubstring("Unsupported value: \"Invalid\": supported values: \"openshift-samples\", \"baremetal\", \"marketplace\", \"Console\", \"Insights\", \"Storage\", \"CSISnapshot\", \"NodeTuning\", \"MachineAPI\", \"Build\", \"DeploymentConfig\", \"ImageRegistry\", \"OperatorLifecycleManager\", \"CloudCredential\", \"Ingress\", \"CloudControllerManager\", \"OperatorLifecycleManagerV1\"")) })
test case
openshift/openshift-tests-private
87299499-7d54-4783-9d8b-36849b831581
Longduration-NonPreRelease-ConnectedOnly-Author:jianl-Medium-45879-check update info with oc adm upgrade --include-not-recommended [Serial][Slow]
['"context"', '"encoding/json"', '"cloud.google.com/go/storage"']
github.com/openshift/openshift-tests-private/test/extended/ota/cvo/cvo.go
g.It("Longduration-NonPreRelease-ConnectedOnly-Author:jianl-Medium-45879-check update info with oc adm upgrade --include-not-recommended [Serial][Slow]", func() { exutil.By("Check if it's a GCP cluster") exutil.SkipIfPlatformTypeNot(oc, "gcp") orgUpstream, err := getCVObyJP(oc, ".spec.upstream") o.Expect(err).NotTo(o.HaveOccurred()) orgChannel, err := getCVObyJP(oc, ".spec.channel") o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("Original upstream: %s, original channel: %s", orgUpstream, orgChannel) exutil.By("Patch upstream and channel") projectID := "openshift-qe" ctx := context.Background() client, err := storage.NewClient(ctx) o.Expect(err).NotTo(o.HaveOccurred()) defer func() { o.Expect(client.Close()).NotTo(o.HaveOccurred()) }() graphURL, bucket, object, _, _, err := buildGraph(client, oc, projectID, "cincy-conditional-edge.json") defer func() { o.Expect(DeleteBucket(client, bucket)).NotTo(o.HaveOccurred()) }() defer func() { o.Expect(DeleteObject(client, bucket, object)).NotTo(o.HaveOccurred()) }() o.Expect(err).NotTo(o.HaveOccurred()) _, err = ocJSONPatch(oc, "", "clusterversion/version", []JSONp{ {"add", "/spec/upstream", graphURL}, {"add", "/spec/channel", "stable-a"}, }) o.Expect(err).NotTo(o.HaveOccurred()) defer restoreCVSpec(orgUpstream, orgChannel, oc) exutil.By("Check recommended update and notes about additional updates present on the output of oc adm upgrade") o.Expect(checkUpdates(oc, false, 1, 10, "Additional updates which are not recommended", //"based on your cluster configuration are available", //"or where the recommended status is \"Unknown\"", "for your cluster configuration are available", "to view those re-run the command with --include-not-recommended", "Recommended updates:", "4.99.999999 registry.ci.openshift.org/ocp/release@sha256:"+ "9999999999999999999999999999999999999999999999999999999999999999", )).To(o.BeTrue(), "recommended update and notes about additional updates") exutil.By("Check risk type=Always updates and 2 risks update present") o.Expect(checkUpdates(oc, true, 1, 3, "Updates with known issues", "Version: 4.88.888888", "Image: registry.ci.openshift.org/ocp/release@sha256:"+ "8888888888888888888888888888888888888888888888888888888888888888", "Reason: ExposedToRisks", "Message: Too many CI failures on this release, so do not update to it", "Version: 4.77.777777", "Image: registry.ci.openshift.org/ocp/release@sha256:"+ "7777777777777777777777777777777777777777777777777777777777777777", "Reason: MultipleReasons", "Message: On clusters on default invoker user, this imaginary bug can happen. "+ "https://bug.example.com/a", )).To(o.BeTrue(), "risk type=Always updates and 2 risks update") exutil.By("Check The reason for the multiple risks is changed to SomeInvokerThing") o.Expect(checkUpdates(oc, true, 60, 6*60, "Updates with known issues", "Version: 4.77.777777", "Image: registry.ci.openshift.org/ocp/release@sha256:"+ "7777777777777777777777777777777777777777777777777777777777777777", "Reason: SomeInvokerThing", "Message: On clusters on default invoker user, this imaginary bug can happen. "+ "https://bug.example.com/a", )).To(o.BeTrue(), "reason for the multiple risks is changed to SomeInvokerThing") exutil.By("Check multiple reason conditional update present") _, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade", "channel", "buggy").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(checkUpdates(oc, true, 300, 75*60, "Version: 4.77.777777", "Image: registry.ci.openshift.org/ocp/release@sha256:"+ "7777777777777777777777777777777777777777777777777777777777777777", "Reason: MultipleReasons", "Message: On clusters on default invoker user, this imaginary bug can happen. "+ "https://bug.example.com/a", "On clusters with the channel set to 'buggy', this imaginary bug can happen. "+ "https://bug.example.com/b", )).To(o.BeTrue(), "multiple reason conditional update present") })
test case
openshift/openshift-tests-private
0383294b-181c-4709-9cb7-f7dded95d73c
ConnectedOnly-Author:jianl-Low-46422-cvo drops invalid conditional edges [Serial]
['"context"', '"encoding/json"', '"fmt"', '"strings"', '"time"', '"cloud.google.com/go/storage"', '"k8s.io/apimachinery/pkg/util/wait"']
github.com/openshift/openshift-tests-private/test/extended/ota/cvo/cvo.go
g.It("ConnectedOnly-Author:jianl-Low-46422-cvo drops invalid conditional edges [Serial]", func() { exutil.By("Check if it's a GCP cluster") exutil.SkipIfPlatformTypeNot(oc, "gcp") orgUpstream, err := getCVObyJP(oc, ".spec.upstream") o.Expect(err).NotTo(o.HaveOccurred()) orgChannel, err := getCVObyJP(oc, ".spec.channel") o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("Original upstream: %s, original channel: %s", orgUpstream, orgChannel) exutil.By("Patch upstream") projectID := "openshift-qe" ctx := context.Background() client, err := storage.NewClient(ctx) o.Expect(err).NotTo(o.HaveOccurred()) defer func() { o.Expect(client.Close()).NotTo(o.HaveOccurred()) }() graphURL, bucket1, object1, _, _, err := buildGraph(client, oc, projectID, "cincy-conditional-edge-invalid-null-node.json") defer func() { o.Expect(DeleteBucket(client, bucket1)).NotTo(o.HaveOccurred()) }() defer func() { o.Expect(DeleteObject(client, bucket1, object1)).NotTo(o.HaveOccurred()) }() o.Expect(err).NotTo(o.HaveOccurred()) _, err = ocJSONPatch(oc, "", "clusterversion/version", []JSONp{ {"add", "/spec/upstream", graphURL}, {"add", "/spec/channel", "stable-a"}, }) o.Expect(err).NotTo(o.HaveOccurred()) defer restoreCVSpec(orgUpstream, orgChannel, oc) exutil.By("Check CVO prompts correct reason and message") expString := "warning: Cannot display available updates:\n" + " Reason: ResponseInvalid\n" + " Message: Unable to retrieve available updates: no node for conditional update" exutil.AssertWaitPollNoErr(wait.Poll(5*time.Second, 15*time.Second, func() (bool, error) { cmdOut, err := oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade").Output() e2e.Logf("oc adm upgrade returned:\n%s", cmdOut) if err != nil { return false, fmt.Errorf("oc adm upgrade returned error: %v", err) } return strings.Contains(cmdOut, expString), nil }), "Test on empty target node failed") graphURL, bucket2, object2, _, _, err := buildGraph(client, oc, projectID, "cincy-conditional-edge-invalid-multi-risks.json") defer func() { o.Expect(DeleteBucket(client, bucket2)).NotTo(o.HaveOccurred()) }() defer func() { o.Expect(DeleteObject(client, bucket2, object2)).NotTo(o.HaveOccurred()) }() o.Expect(err).NotTo(o.HaveOccurred()) _, err = ocJSONPatch(oc, "", "clusterversion/version", []JSONp{{"add", "/spec/upstream", graphURL}}) o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("Check no updates") exutil.AssertWaitPollNoErr(wait.Poll(5*time.Second, 15*time.Second, func() (bool, error) { cmdOut, err := oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade").Output() e2e.Logf("oc adm upgrade returned:\n%s", cmdOut) if err != nil { return false, fmt.Errorf("oc adm upgrade returned error: %v", err) } return strings.Contains(cmdOut, "No updates available"), nil }), "Test on multiple invalid risks failed") })
test case
openshift/openshift-tests-private
7c1fa572-c54e-4607-8151-512c99e78741
ConnectedOnly-Author:jianl-Low-47175-upgrade cluster when current version is in the upstream but there are not update paths [Serial]
['"context"', '"encoding/json"', '"fmt"', '"strings"', '"time"', '"cloud.google.com/go/storage"', '"k8s.io/apimachinery/pkg/util/wait"']
github.com/openshift/openshift-tests-private/test/extended/ota/cvo/cvo.go
g.It("ConnectedOnly-Author:jianl-Low-47175-upgrade cluster when current version is in the upstream but there are not update paths [Serial]", func() { exutil.By("Check if it's a GCP cluster") exutil.SkipIfPlatformTypeNot(oc, "gcp") orgUpstream, err := getCVObyJP(oc, ".spec.upstream") o.Expect(err).NotTo(o.HaveOccurred()) orgChannel, err := getCVObyJP(oc, ".spec.channel") o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("Original upstream: %s, original channel: %s", orgUpstream, orgChannel) exutil.By("Patch upstream") projectID := "openshift-qe" ctx := context.Background() client, err := storage.NewClient(ctx) o.Expect(err).NotTo(o.HaveOccurred()) defer func() { o.Expect(client.Close()).NotTo(o.HaveOccurred()) }() graphURL, bucket, object, _, _, err := buildGraph(client, oc, projectID, "cincy-conditional-edge-invalid-multi-risks.json") defer func() { o.Expect(DeleteBucket(client, bucket)).NotTo(o.HaveOccurred()) }() defer func() { o.Expect(DeleteObject(client, bucket, object)).NotTo(o.HaveOccurred()) }() o.Expect(err).NotTo(o.HaveOccurred()) _, err = ocJSONPatch(oc, "", "clusterversion/version", []JSONp{ {"add", "/spec/upstream", graphURL}, {"add", "/spec/channel", "stable-a"}, }) o.Expect(err).NotTo(o.HaveOccurred()) defer restoreCVSpec(orgUpstream, orgChannel, oc) var cmdOut string exutil.By("Check no updates but RetrievedUpdates=True") exutil.AssertWaitPollNoErr(wait.Poll(5*time.Second, 15*time.Second, func() (bool, error) { cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade").Output() e2e.Logf("oc adm upgrade returned:\n%s", cmdOut) if err != nil { return false, fmt.Errorf("oc adm upgrade returned error: %v", err) } return strings.Contains(cmdOut, "No updates available"), nil }), "failure: missing expected 'No updates available'") status, err := getCVObyJP(oc, ".status.conditions[?(.type=='RetrievedUpdates')].status") o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(status).To(o.Equal("True")) target := GenerateReleaseVersion(oc) o.Expect(target).NotTo(o.BeEmpty()) exutil.By("Upgrade with oc adm upgrade --to") cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade", "--to", target).Output() o.Expect(cmdOut).To(o.ContainSubstring( "no recommended updates, specify --to-image to conti" + "nue with the update or wait for new updates to be available")) o.Expect(err).To(o.HaveOccurred()) exutil.By("Upgrade with oc adm upgrade --to --allow-not-recommended") cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm"). Args("upgrade", "--allow-not-recommended", "--to", target).Output() o.Expect(cmdOut).To(o.ContainSubstring( "no recommended or conditional updates, specify --to-image to conti" + "nue with the update or wait for new updates to be available")) o.Expect(err).To(o.HaveOccurred()) targetPullspec := GenerateReleasePayload(oc) o.Expect(targetPullspec).NotTo(o.BeEmpty()) exutil.By("Upgrade with oc adm upgrade --to-image") cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm"). Args("upgrade", "--to-image", targetPullspec).Output() o.Expect(cmdOut).To(o.ContainSubstring( "no recommended updates, specify --allow-explicit-upgrade to conti" + "nue with the update or wait for new updates to be available")) o.Expect(err).To(o.HaveOccurred()) exutil.By("Upgrade with oc adm upgrade --to-image --allow-not-recommended") cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm"). Args("upgrade", "--allow-not-recommended", "--to-image", targetPullspec).Output() o.Expect(cmdOut).To(o.ContainSubstring( "no recommended or conditional updates, specify --allow-explicit-upgrade to conti" + "nue with the update or wait for new updates to be available")) o.Expect(err).To(o.HaveOccurred()) })
test case
openshift/openshift-tests-private
8b7bbba7-0c27-4d58-8368-3fd55c048313
NonHyperShiftHOST-Author:dis-Medium-41391-cvo serves metrics over only https not http
['"encoding/json"', '"fmt"', '"regexp"', '"time"']
github.com/openshift/openshift-tests-private/test/extended/ota/cvo/cvo.go
g.It("NonHyperShiftHOST-Author:dis-Medium-41391-cvo serves metrics over only https not http", func() { exutil.By("Check cvo delopyment config file...") cvoDeploymentYaml, err := GetDeploymentsYaml(oc, "cluster-version-operator", projectName) o.Expect(err).NotTo(o.HaveOccurred()) var keywords = []string{"--listen=0.0.0.0:9099", "--serving-cert-file=/etc/tls/serving-cert/tls.crt", "--serving-key-file=/etc/tls/serving-cert/tls.key"} for _, v := range keywords { o.Expect(cvoDeploymentYaml).Should(o.ContainSubstring(v)) } exutil.By("Check cluster-version-operator binary help") cvoPodsList, err := exutil.WaitForPods( oc.AdminKubeClient().CoreV1().Pods(projectName), exutil.ParseLabelsOrDie("k8s-app=cluster-version-operator"), exutil.CheckPodIsReady, 1, 3*time.Minute) o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("Get cvo pods: %v", cvoPodsList) output, err := PodExec(oc, "/usr/bin/cluster-version-operator start --help", projectName, cvoPodsList[0]) exutil.AssertWaitPollNoErr(err, fmt.Sprintf( "/usr/bin/cluster-version-operator start --help executs error on %v", cvoPodsList[0])) e2e.Logf("CVO help returned: %s", output) keywords = []string{"You must set both --serving-cert-file and --serving-key-file unless you set --listen empty"} for _, v := range keywords { o.Expect(output).Should(o.ContainSubstring(v)) } exutil.By("Verify cvo metrics is only exported via https") output, err = oc.AsAdmin().WithoutNamespace().Run("get"). Args("servicemonitor", "cluster-version-operator", "-n", projectName, "-o=json").Output() o.Expect(err).NotTo(o.HaveOccurred()) var result map[string]interface{} err = json.Unmarshal([]byte(output), &result) o.Expect(err).NotTo(o.HaveOccurred()) endpoints := result["spec"].(map[string]interface{})["endpoints"] e2e.Logf("Get cvo's spec.endpoints: %v", endpoints) o.Expect(endpoints).Should(o.HaveLen(1)) output, err = oc.AsAdmin().WithoutNamespace().Run("get"). Args("servicemonitor", "cluster-version-operator", "-n", projectName, "-o=jsonpath={.spec.endpoints[].scheme}").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("Get cvo's spec.endpoints scheme: %v", output) o.Expect(output).Should(o.Equal("https")) exutil.By("Get cvo endpoint URI") //output, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("endpoints", "cluster-version-operator", "-n", projectName, "-o=jsonpath='{.subsets[0].addresses[0].ip}:{.subsets[0].ports[0].port}'").Output() output, err = oc.AsAdmin().WithoutNamespace().Run("get"). Args("endpoints", "cluster-version-operator", "-n", projectName, "--no-headers").Output() o.Expect(err).NotTo(o.HaveOccurred()) re := regexp.MustCompile(`cluster-version-operator\s+([^\s]*)`) matchedResult := re.FindStringSubmatch(output) e2e.Logf("Regex mached result: %v", matchedResult) o.Expect(matchedResult).Should(o.HaveLen(2)) endpointURI := matchedResult[1] e2e.Logf("Get cvo endpoint URI: %v", endpointURI) o.Expect(endpointURI).ShouldNot(o.BeEmpty()) exutil.By("Check metric server is providing service https, but not http") cmd := fmt.Sprintf("curl http://%s/metrics", endpointURI) output, err = PodExec(oc, cmd, projectName, cvoPodsList[0]) exutil.AssertWaitPollNoErr(err, fmt.Sprintf("cmd %s executs error on %v", cmd, cvoPodsList[0])) keywords = []string{"Client sent an HTTP request to an HTTPS server"} for _, v := range keywords { o.Expect(output).Should(o.ContainSubstring(v)) } exutil.By("Check metric server is providing service via https correctly.") cmd = fmt.Sprintf("curl -k -I https://%s/metrics", endpointURI) output, err = PodExec(oc, cmd, projectName, cvoPodsList[0]) exutil.AssertWaitPollNoErr(err, fmt.Sprintf("cmd %s executs error on %v", cmd, cvoPodsList[0])) keywords = []string{"HTTP/1.1 200 OK"} for _, v := range keywords { o.Expect(output).Should(o.ContainSubstring(v)) } })
test case
openshift/openshift-tests-private
746fafbc-32b7-4856-8e32-25b00747fe69
Longduration-NonPreRelease-Author:dis-Medium-32138-cvo alert should not be fired when RetrievedUpdates failed due to nochannel [Serial][Slow]
github.com/openshift/openshift-tests-private/test/extended/ota/cvo/cvo.go
g.It("Longduration-NonPreRelease-Author:dis-Medium-32138-cvo alert should not be fired when RetrievedUpdates failed due to nochannel [Serial][Slow]", func() { orgChannel, err := getCVObyJP(oc, ".spec.channel") o.Expect(err).NotTo(o.HaveOccurred()) defer func() { o.Expect(oc.AsAdmin().WithoutNamespace().Run("adm"). Args("upgrade", "channel", orgChannel).Execute()).NotTo(o.HaveOccurred()) }() exutil.By("Enable alert by clearing channel") err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade", "channel").Execute() o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("Check RetrievedUpdates condition") reason, err := getCVObyJP(oc, ".status.conditions[?(.type=='RetrievedUpdates')].reason") o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(reason).To(o.Equal("NoChannel")) exutil.By("Alert CannotRetrieveUpdates does not appear within 60m") appeared, _, err := waitForAlert(oc, "CannotRetrieveUpdates", 600, 3600, "") o.Expect(appeared).NotTo(o.BeTrue(), "no CannotRetrieveUpdates within 60m") o.Expect(err.Error()).To(o.ContainSubstring("timed out waiting for the condition")) exutil.By("Alert CannotRetrieveUpdates does not appear after 60m") appeared, _, err = waitForAlert(oc, "CannotRetrieveUpdates", 300, 600, "") o.Expect(appeared).NotTo(o.BeTrue(), "no CannotRetrieveUpdates after 60m") o.Expect(err.Error()).To(o.ContainSubstring("timed out waiting for the condition")) })
test case
openshift/openshift-tests-private
2bf8d877-f70b-4403-89ea-93d572722925
ConnectedOnly-Author:jianl-Medium-43178-manage channel by using oc adm upgrade channel [Serial]
['"context"', '"encoding/json"', '"fmt"', '"time"', '"cloud.google.com/go/storage"']
github.com/openshift/openshift-tests-private/test/extended/ota/cvo/cvo.go
g.It("ConnectedOnly-Author:jianl-Medium-43178-manage channel by using oc adm upgrade channel [Serial]", func() { exutil.By("Check if it's a GCP cluster") exutil.SkipIfPlatformTypeNot(oc, "gcp") orgUpstream, err := getCVObyJP(oc, ".spec.upstream") o.Expect(err).NotTo(o.HaveOccurred()) orgChannel, err := getCVObyJP(oc, ".spec.channel") o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("Original upstream: %s, original channel: %s", orgUpstream, orgChannel) projectID := "openshift-qe" ctx := context.Background() client, err := storage.NewClient(ctx) o.Expect(err).NotTo(o.HaveOccurred()) defer func() { o.Expect(client.Close()).NotTo(o.HaveOccurred()) }() graphURL, bucket, object, _, _, err := buildGraph(client, oc, projectID, "cincy.json") defer func() { o.Expect(DeleteBucket(client, bucket)).NotTo(o.HaveOccurred()) }() defer func() { o.Expect(DeleteObject(client, bucket, object)).NotTo(o.HaveOccurred()) }() o.Expect(err).NotTo(o.HaveOccurred()) defer restoreCVSpec(orgUpstream, orgChannel, oc) // Prerequisite: the available channels are not present exutil.By("The test requires the available channels are not present as a prerequisite") cmdOut, err := oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(cmdOut).NotTo(o.ContainSubstring("available channels:")) version, err := getCVObyJP(oc, ".status.desired.version") o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("Set to an unknown channel when available channels are not present") cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade", "channel", "unknown-channel").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(cmdOut).To(o.ContainSubstring( fmt.Sprintf("warning: No channels known to be compatible with the current version \"%s\"; unable to vali"+ "date \"unknown-channel\". Setting the update channel to \"unknown-channel\" anyway.", version))) cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(cmdOut).To(o.ContainSubstring("Channel: unknown-channel")) exutil.By("Clear an unknown channel when available channels are not present") cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade", "channel").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(cmdOut).To(o.ContainSubstring( "warning: Clearing channel \"unknown-channel\"; cluster will no longer request available update recommendations.")) cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(cmdOut).To(o.ContainSubstring("NoChannel")) // Prerequisite: a dummy update server is ready and the available channels is present exutil.By("Change to a dummy update server") _, err = ocJSONPatch(oc, "", "clusterversion/version", []JSONp{ {"add", "/spec/upstream", graphURL}, {"add", "/spec/channel", "channel-a"}, }) o.Expect(err).NotTo(o.HaveOccurred()) time.Sleep(5 * time.Second) cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(cmdOut).To(o.ContainSubstring("Channel: channel-a (available channels: channel-a, channel-b)")) exutil.By("Specify multiple channels") cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade", "channel", "channel-a", "channel-b").Output() o.Expect(err).To(o.HaveOccurred()) o.Expect(cmdOut).To(o.ContainSubstring( "error: multiple positional arguments given\nSee 'oc adm upgrade channel -h' for help and examples")) exutil.By("Set a channel which is same as the current channel") cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade", "channel", "channel-a").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(cmdOut).To(o.ContainSubstring("info: Cluster is already in channel-a (no change)")) exutil.By("Clear a known channel which is in the available channels without --allow-explicit-channel") cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade", "channel").Output() o.Expect(err).To(o.HaveOccurred()) o.Expect(cmdOut).To(o.ContainSubstring( "error: You are requesting to clear the update channel. The current channel \"channel-a\" is " + "one of the available channels, you must pass --allow-explicit-channel to continue")) exutil.By("Clear a known channel which is in the available channels with --allow-explicit-channel") cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade", "channel", "--allow-explicit-channel").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(cmdOut).To(o.ContainSubstring( "warning: Clearing channel \"channel-a\"; cluster will no longer request available update recommendations.")) cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(cmdOut).To(o.ContainSubstring("NoChannel")) exutil.By("Re-clear the channel") cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade", "channel").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(cmdOut).To(o.ContainSubstring("info: Cluster channel is already clear (no change)")) exutil.By("Set to an unknown channel when the available channels are not present without --allow-explicit-channel") cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade", "channel", "channel-d").Output() o.Expect(err).NotTo(o.HaveOccurred()) time.Sleep(5 * time.Second) o.Expect(cmdOut).To(o.ContainSubstring( fmt.Sprintf("warning: No channels known to be compatible with the current version \"%s\"; unable to vali"+ "date \"channel-d\". Setting the update channel to \"channel-d\" anyway.", version))) cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(cmdOut).To(o.ContainSubstring("Channel: channel-d (available channels: channel-a, channel-b)")) exutil.By("Set to an unknown channel which is not in the available channels without --allow-explicit-channel") cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade", "channel", "channel-f").Output() o.Expect(err).To(o.HaveOccurred()) time.Sleep(5 * time.Second) o.Expect(cmdOut).To(o.ContainSubstring( "error: the requested channel \"channel-f\" is not one of the avail" + "able channels (channel-a, channel-b), you must pass --allow-explicit-channel to continue")) exutil.By("Set to an unknown channel which is not in the available channels with --allow-explicit-channel") cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm"). Args("upgrade", "channel", "channel-f", "--allow-explicit-channel").Output() o.Expect(err).NotTo(o.HaveOccurred()) time.Sleep(5 * time.Second) o.Expect(cmdOut).To(o.ContainSubstring( "warning: The requested channel \"channel-f\" is not one of the avail" + "able channels (channel-a, channel-b). You have used --allow-explicit-cha" + "nnel to proceed anyway. Setting the update channel to \"channel-f\".")) cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(cmdOut).To(o.ContainSubstring("Channel: channel-f (available channels: channel-a, channel-b)")) exutil.By("Clear an unknown channel which is not in the available channels without --allow-explicit-channel") cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade", "channel").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(cmdOut).To(o.ContainSubstring( "warning: Clearing channel \"channel-f\"; cluster will no longer request available update recommendations.")) cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(cmdOut).To(o.ContainSubstring("NoChannel")) exutil.By("Set to a known channel when the available channels are not present") cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade", "channel", "channel-a").Output() o.Expect(err).NotTo(o.HaveOccurred()) time.Sleep(5 * time.Second) o.Expect(cmdOut).To(o.ContainSubstring( fmt.Sprintf("warning: No channels known to be compatible with the current version \"%s\"; un"+ "able to validate \"channel-a\". Setting the update channel to \"channel-a\" anyway.", version))) cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(cmdOut).To(o.ContainSubstring("Channel: channel-a (available channels: channel-a, channel-b)")) exutil.By("Set to a known channel without --allow-explicit-channel") _, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade", "channel", "channel-b").Output() o.Expect(err).NotTo(o.HaveOccurred()) time.Sleep(5 * time.Second) cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(cmdOut).To(o.ContainSubstring("Channel: channel-b (available channels: channel-a, channel-b)")) })
test case
openshift/openshift-tests-private
389885db-ae09-44ec-9eb0-debb8b0313c8
Author:jianl-High-42543-the removed resources are not created in a fresh installed cluster
['"fmt"', '"os"', '"os/exec"', '"path/filepath"', '"strings"']
github.com/openshift/openshift-tests-private/test/extended/ota/cvo/cvo.go
g.It("Author:jianl-High-42543-the removed resources are not created in a fresh installed cluster", func() { exutil.By("Check the annotation delete:true for imagestream/hello-openshift is set in manifest") tempDataDir, err := extractManifest(oc) defer func() { o.Expect(os.RemoveAll(tempDataDir)).NotTo(o.HaveOccurred()) }() o.Expect(err).NotTo(o.HaveOccurred()) manifestDir := filepath.Join(tempDataDir, "manifest") cmd := fmt.Sprintf("grep -rl \"name: hello-openshift\" %s", manifestDir) out, err := exec.Command("bash", "-c", cmd).CombinedOutput() o.Expect(err).NotTo(o.HaveOccurred(), "Command: \"%s\" returned error: %s", cmd, string(out)) o.Expect(string(out)).NotTo(o.BeEmpty()) file := strings.TrimSpace(string(out)) cmd = fmt.Sprintf("grep -C5 'name: hello-openshift' %s | grep 'release.openshift.io/delete: \"true\"'", file) out, err = exec.Command("bash", "-c", cmd).CombinedOutput() o.Expect(err).NotTo(o.HaveOccurred(), "Command: \"%s\" returned error: %s", cmd, string(out)) o.Expect(string(out)).NotTo(o.BeEmpty()) exutil.By("Check imagestream hello-openshift not present in a fresh installed cluster") cmdOut, err := oc.AsAdmin().WithoutNamespace().Run("get"). Args("imagestream", "hello-openshift", "-n", "openshift").Output() o.Expect(err).To(o.HaveOccurred()) o.Expect(cmdOut).To(o.ContainSubstring( "Error from server (NotFound): imagestreams.image.openshift.io \"hello-openshift\" not found")) })
test case
openshift/openshift-tests-private
c4041612-1760-40a4-b445-390b18aee1a6
ConnectedOnly-Author:jianl-Medium-43172-get the upstream and channel info by using oc adm upgrade [Serial]
['"context"', '"encoding/json"', '"fmt"', '"strings"', '"time"', '"cloud.google.com/go/storage"']
github.com/openshift/openshift-tests-private/test/extended/ota/cvo/cvo.go
g.It("ConnectedOnly-Author:jianl-Medium-43172-get the upstream and channel info by using oc adm upgrade [Serial]", func() { exutil.By("Check if it's a GCP cluster") exutil.SkipIfPlatformTypeNot(oc, "gcp") orgUpstream, err := getCVObyJP(oc, ".spec.upstream") o.Expect(err).NotTo(o.HaveOccurred()) orgChannel, err := getCVObyJP(oc, ".spec.channel") o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("Original upstream: %s, original channel: %s", orgUpstream, orgChannel) defer restoreCVSpec(orgUpstream, orgChannel, oc) exutil.By("Check when upstream is unset") if orgUpstream != "" { _, err := ocJSONPatch(oc, "", "clusterversion/version", []JSONp{{"remove", "/spec/upstream", nil}}) o.Expect(err).NotTo(o.HaveOccurred()) } _, err = ocJSONPatch(oc, "", "clusterversion/version", []JSONp{{"add", "/spec/channel", "stable-a"}}) o.Expect(err).NotTo(o.HaveOccurred()) cmdOut, err := oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(cmdOut).To(o.ContainSubstring("Upstream is unset, so the cluster will use an appropriate default.")) o.Expect(cmdOut).To(o.ContainSubstring("Channel: stable-a")) desiredChannel, err := getCVObyJP(oc, ".status.desired.channels") o.Expect(err).NotTo(o.HaveOccurred()) if desiredChannel == "" { o.Expect(cmdOut).NotTo(o.ContainSubstring("available channels:")) } else { msg := "available channels: " desiredChannel = desiredChannel[1 : len(desiredChannel)-1] splits := strings.Split(desiredChannel, ",") for _, split := range splits { split = strings.Trim(split, "\"") msg = msg + split + ", " } msg = msg[:len(msg)-2] o.Expect(cmdOut).To(o.ContainSubstring(msg)) } exutil.By("Check when upstream is set") projectID := "openshift-qe" ctx := context.Background() client, err := storage.NewClient(ctx) o.Expect(err).NotTo(o.HaveOccurred()) defer func() { o.Expect(client.Close()).NotTo(o.HaveOccurred()) }() graphURL, bucket, object, targetVersion, targetPayload, err := buildGraph(client, oc, projectID, "cincy.json") defer func() { o.Expect(DeleteBucket(client, bucket)).NotTo(o.HaveOccurred()) }() defer func() { o.Expect(DeleteObject(client, bucket, object)).NotTo(o.HaveOccurred()) }() o.Expect(err).NotTo(o.HaveOccurred()) _, err = ocJSONPatch(oc, "", "clusterversion/version", []JSONp{ {"add", "/spec/upstream", graphURL}, {"add", "/spec/channel", "channel-a"}, }) o.Expect(err).NotTo(o.HaveOccurred()) time.Sleep(5 * time.Second) cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade").Output() o.Expect(err).NotTo(o.HaveOccurred()) expStr := []string{ fmt.Sprintf("Upstream: %s", graphURL), "Channel: channel-a (available channels: channel-a, channel-b)", "Recommended updates:", targetVersion, targetPayload} for _, v := range expStr { o.Expect(cmdOut).To(o.ContainSubstring(v)) } cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm"). Args("upgrade", "--include-not-recommended").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(cmdOut).To(o.ContainSubstring( "No updates which are not recommended based on your cluster configuration are available")) exutil.By("Check when channel is unset") _, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade", "channel", "--allow-explicit-channel").Output() o.Expect(err).NotTo(o.HaveOccurred()) cmdOut, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("upgrade").Output() o.Expect(err).NotTo(o.HaveOccurred()) expStr = []string{ "Upstream:", "Channel:", "Reason: NoChannel", "Message: The update channel has not been configured"} for _, v := range expStr[:2] { o.Expect(cmdOut).NotTo(o.ContainSubstring(v)) } for _, v := range expStr[2:] { o.Expect(cmdOut).To(o.ContainSubstring(v)) } })
test case
openshift/openshift-tests-private
86eb7eb9-da55-43fc-99c5-ea3b2f2f4436
Longduration-NonPreRelease-Author:jiajliu-Medium-41728-cvo alert ClusterOperatorDegraded on degraded operators [Disruptive][Slow]
['"fmt"', '"os"', '"os/exec"', '"path/filepath"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"', '"sigs.k8s.io/yaml"']
github.com/openshift/openshift-tests-private/test/extended/ota/cvo/cvo.go
g.It("Longduration-NonPreRelease-Author:jiajliu-Medium-41728-cvo alert ClusterOperatorDegraded on degraded operators [Disruptive][Slow]", func() { testDataDir := exutil.FixturePath("testdata", "ota/cvo") badOauthFile := filepath.Join(testDataDir, "bad-oauth.yaml") exutil.By("Get goodOauthFile from the initial oauth yaml file to oauth-41728.yaml") goodOauthFile, err := oc.AsAdmin().WithoutNamespace().Run("get"). Args("oauth", "cluster", "-o", "yaml").OutputToFile("oauth-41728.yaml") defer func() { o.Expect(os.RemoveAll(goodOauthFile)).NotTo(o.HaveOccurred()) }() o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("Prune goodOauthFile") cmd := fmt.Sprintf("sed -i \"/resourceVersion/d\" %s && cat %s", goodOauthFile, goodOauthFile) oauthfile, err := exec.Command("bash", "-c", cmd).CombinedOutput() o.Expect(err).NotTo(o.HaveOccurred(), "Command: \"%s\" returned error: %s", cmd, string(oauthfile)) o.Expect(string(oauthfile)).NotTo(o.ContainSubstring("resourceVersion")) exutil.By("Enable ClusterOperatorDegraded alert") err = oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", badOauthFile).Execute() defer func() { // after applying good auth, co is back to normal, while cvo condition failing is still present for up to ~2-4 minutes o.Expect(waitForCVOStatus(oc, 30, 4*60, "ClusterOperatorDegraded", ".status.conditions[?(.type=='Failing')].reason", false)).NotTo(o.HaveOccurred()) }() defer func() { o.Expect(oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", goodOauthFile).Execute()).NotTo(o.HaveOccurred()) }() o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("Check ClusterOperatorDegraded condition...") if err = waitForCondition(oc, 60, 480, "True", "get", "co", "authentication", "-o", "jsonpath={.status.conditions[?(@.type=='Degraded')].status}"); err != nil { //dump contents to log _ = oc.AsAdmin().WithoutNamespace().Run("get").Args("co", "authentication", "-o", "yaml").Execute() _ = oc.AsAdmin().WithoutNamespace().Run("get").Args("oauth", "cluster", "-o", "yaml").Execute() exutil.AssertWaitPollNoErr(err, "authentication operator is not degraded in 8m") } exutil.By("Check ClusterOperatorDown alert is not firing and ClusterOperatorDegraded alert is fired correctly.") var alertDown, alertDegraded map[string]interface{} err = wait.Poll(5*time.Minute, 35*time.Minute, func() (bool, error) { alertDown = getAlertByName(oc, "ClusterOperatorDown", "authentication") alertDegraded = getAlertByName(oc, "ClusterOperatorDegraded", "authentication") if alertDown != nil { return false, fmt.Errorf("alert ClusterOperatorDown is not nil: %v", alertDown) } if alertDegraded == nil || alertDegraded["state"] != "firing" { e2e.Logf("Waiting for alert ClusterOperatorDegraded to be triggered and fired...") return false, nil } o.Expect(alertDegraded["labels"].(map[string]interface{})["severity"].(string)).To(o.Equal("warning")) o.Expect(alertDegraded["labels"].(map[string]interface{})["namespace"].(string)).To(o.Equal("openshift-cluster-version")) o.Expect(alertDegraded["annotations"].(map[string]interface{})["summary"].(string)). To(o.ContainSubstring("Cluster operator has been degraded for 30 minutes.")) o.Expect(alertDegraded["annotations"].(map[string]interface{})["description"].(string)). To(o.ContainSubstring("The authentication operator is degraded")) return true, nil }) exutil.AssertWaitPollNoErr(err, fmt.Sprintf("ClusterOperatorDegraded alert is not fired in 30m: %v", alertDegraded)) exutil.By("Disable ClusterOperatorDegraded alert") err = oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", goodOauthFile).Execute() o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("Check alert is disabled") exutil.AssertWaitPollNoErr(wait.Poll(10*time.Second, 60*time.Second, func() (bool, error) { alertDegraded = getAlertByName(oc, "ClusterOperatorDegraded", "authentication") e2e.Logf("Waiting for alert being disabled...") return alertDegraded == nil, nil }), fmt.Sprintf("alert is not disabled: %v", alertDegraded)) })
test case
openshift/openshift-tests-private
9b1dc5b9-3211-4a59-ad82-982dcb79ef23
Longduration-NonPreRelease-Author:jiajliu-Medium-41778-ClusterOperatorDown and ClusterOperatorDegradedon alerts when unset conditions [Slow]
['"fmt"', '"path/filepath"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"', '"sigs.k8s.io/yaml"']
github.com/openshift/openshift-tests-private/test/extended/ota/cvo/cvo.go
g.It("Longduration-NonPreRelease-Author:jiajliu-Medium-41778-ClusterOperatorDown and ClusterOperatorDegradedon alerts when unset conditions [Slow]", func() { testDataDir := exutil.FixturePath("testdata", "ota/cvo") badOauthFile := filepath.Join(testDataDir, "co-test.yaml") exutil.By("Enable alerts") err := oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", badOauthFile).Execute() // if normal already deleted before. discarding error. defer func() { _ = oc.AsAdmin().WithoutNamespace().Run("delete").Args("co", "test").Execute() }() o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("Check operator's condition...") output, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("co", "test", "-o=jsonpath={.status}").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(output).To(o.Equal("")) exutil.By("Waiting for alerts triggered...") var alertDown, alertDegraded map[string]interface{} exutil.AssertWaitPollNoErr(wait.Poll(30*time.Second, 180*time.Second, func() (bool, error) { alertDown = getAlertByName(oc, "ClusterOperatorDown", "test") alertDegraded = getAlertByName(oc, "ClusterOperatorDegraded", "test") e2e.Logf("Waiting for alerts to be triggered...") return alertDown != nil && alertDegraded != nil, nil }), fmt.Sprintf("failed expecting both alerts triggered: Down=%v Degraded=%v", alertDown, alertDegraded)) exutil.By("Check alert ClusterOperatorDown fired.") exutil.AssertWaitPollNoErr(wait.Poll(5*time.Minute, 10*time.Minute, func() (bool, error) { alertDown = getAlertByName(oc, "ClusterOperatorDown", "test") e2e.Logf("Waiting for alert ClusterOperatorDown to be triggered and fired...") return alertDown["state"] == "firing", nil }), fmt.Sprintf("ClusterOperatorDown alert is not fired in 10m: %v", alertDown)) exutil.By("Check alert ClusterOperatorDegraded fired.") exutil.AssertWaitPollNoErr(wait.Poll(5*time.Minute, 20*time.Minute, func() (bool, error) { alertDegraded = getAlertByName(oc, "ClusterOperatorDegraded", "test") e2e.Logf("Waiting for alert ClusterOperatorDegraded to be triggered and fired...") return alertDegraded["state"] == "firing", nil }), fmt.Sprintf("ClusterOperatorDegraded alert is not fired in 30m: %v", alertDegraded)) exutil.By("Disable alerts") err = oc.AsAdmin().WithoutNamespace().Run("delete").Args("co", "test").Execute() o.Expect(err).NotTo(o.HaveOccurred()) exutil.By("Check alerts are disabled...") exutil.AssertWaitPollNoErr(wait.Poll(10*time.Second, 60*time.Second, func() (bool, error) { alertDown := getAlertByName(oc, "ClusterOperatorDown", "test") alertDegraded := getAlertByName(oc, "ClusterOperatorDegraded", "test") e2e.Logf("Waiting for alerts being disabled...") return alertDown == nil && alertDegraded == nil, nil }), fmt.Sprintf("alerts are not disabled: Down=%v Degraded=%v", alertDown, alertDegraded)) })
test case
openshift/openshift-tests-private
97649096-30bb-47df-8a67-d366d529b3a4
Longduration-NonPreRelease-Author:jiajliu-Medium-41736-cvo alert ClusterOperatorDown on unavailable operators [Disruptive][Slow]
['"context"', '"fmt"', '"regexp"', '"strings"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"', '"sigs.k8s.io/yaml"']
github.com/openshift/openshift-tests-private/test/extended/ota/cvo/cvo.go
g.It("Longduration-NonPreRelease-Author:jiajliu-Medium-41736-cvo alert ClusterOperatorDown on unavailable operators [Disruptive][Slow]", func() { operator := "image-registry" nodeLabel := "node-role.kubernetes.io/worker=" exutil.By("Cordon worker nodes") workerNodes, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("nodes", "--selector", nodeLabel, "-o=jsonpath={.items[*].metadata.name}").Output() o.Expect(err).NotTo(o.HaveOccurred(), "fail to get node list: %v", err) nodeList := strings.Fields(workerNodes) defer func() { e2e.Logf("Restore worker node in defer") oc.AsAdmin().WithoutNamespace().Run("adm").Args("uncordon", "-l", nodeLabel).Execute() for _, node := range nodeList { err = wait.PollUntilContextTimeout(context.Background(), 1*time.Minute, 5*time.Minute, true, func(context.Context) (bool, error) { nodeReady, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("node", node, "-o=jsonpath={.status.conditions[?(@.type==\"Ready\")].status}").Output() if err != nil || nodeReady != "True" { e2e.Logf("error: %v; node %s status: %s", err, node, nodeReady) return false, nil } return true, nil }) exutil.AssertWaitPollNoErr(err, "timeout to restore node!") } e2e.Logf("Ensure operator back to good status after uncordon") err = wait.PollUntilContextTimeout(context.Background(), 1*time.Minute, 5*time.Minute, true, func(context.Context) (bool, error) { output, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("co", operator).Output() matched, _ := regexp.MatchString("True.*False.*False", output) if err != nil || !matched { e2e.Logf("error:%; operator status: %s", err, output) return false, nil } return true, nil }) exutil.AssertWaitPollNoErr(err, "timeout to restore operator!") }() err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("cordon", "-l", nodeLabel).Execute() o.Expect(err).NotTo(o.HaveOccurred(), "fail to cordon worker node: %v", err) exutil.By("Delete namespace openshift-image-registry") err = oc.AsAdmin().WithoutNamespace().Run("delete").Args("namespace", "openshift-image-registry").Execute() o.Expect(err).NotTo(o.HaveOccurred(), "fail to delete namespace: %v", err) exutil.By("Check ClusterOperatorDown condition...") if err = waitForCondition(oc, 60, 900, "False", "get", "co", operator, "-o", "jsonpath={.status.conditions[?(@.type=='Available')].status}"); err != nil { //dump contents to log _ = oc.AsAdmin().WithoutNamespace().Run("get").Args("co", operator, "-o", "yaml").Execute() exutil.AssertWaitPollNoErr(err, fmt.Sprintf("%s operator is not down in 15m", operator)) } exutil.By("Check ClusterOperatorDown alert is fired correctly") var alertDown map[string]interface{} err = wait.Poll(2*time.Minute, 10*time.Minute, func() (bool, error) { alertDown = getAlertByName(oc, "ClusterOperatorDown", operator) if alertDown == nil || alertDown["state"] != "firing" { e2e.Logf("Waiting for alert ClusterOperatorDown to be triggered and fired...") return false, nil } o.Expect(alertDown["labels"].(map[string]interface{})["severity"].(string)).To(o.Equal("critical")) o.Expect(alertDown["labels"].(map[string]interface{})["namespace"].(string)).To(o.Equal("openshift-cluster-version")) o.Expect(alertDown["annotations"].(map[string]interface{})["summary"].(string)). To(o.ContainSubstring("Cluster operator has not been available for 10 minutes.")) o.Expect(alertDown["annotations"].(map[string]interface{})["description"].(string)). To(o.ContainSubstring(fmt.Sprintf("The %s operator may be down or disabled", operator))) return true, nil }) exutil.AssertWaitPollNoErr(err, fmt.Sprintf("ClusterOperatorDown alert is not fired in 10m: %v", alertDown)) exutil.By("Disable ClusterOperatorDown alert") e2e.Logf("Uncordon worker node") err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("uncordon", "-l", nodeLabel).Execute() o.Expect(err).NotTo(o.HaveOccurred(), "fail to uncordon worker node: %v", err) exutil.By("Check alert is disabled") exutil.AssertWaitPollNoErr(wait.Poll(1*time.Minute, 5*time.Minute, func() (bool, error) { alertDown = getAlertByName(oc, "ClusterOperatorDown", operator) e2e.Logf("Waiting for alert being disabled...") return alertDown == nil, nil }), fmt.Sprintf("alert is not disabled: %v", alertDown)) })
test case
openshift/openshift-tests-private
49c73d0c-b56b-4ad6-ac83-2195a9c5ee6e
NonHyperShiftHOST-Author:jiajliu-Low-46922-check runlevel in cvo ns
['"strings"']
github.com/openshift/openshift-tests-private/test/extended/ota/cvo/cvo.go
g.It("NonHyperShiftHOST-Author:jiajliu-Low-46922-check runlevel in cvo ns", func() { exutil.By("Check runlevel in cvo namespace.") runLevel, err := oc.AsAdmin().WithoutNamespace().Run("get"). Args("ns", "openshift-cluster-version", "-o=jsonpath={.metadata.labels.openshift\\.io/run-level}").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(runLevel).To(o.Equal("")) exutil.By("Check scc of cvo pod.") runningPodName, err := oc.AsAdmin().WithoutNamespace().Run("get"). Args("pod", "-n", "openshift-cluster-version", "-o=jsonpath='{.items[?(@.status.phase == \"Running\")].metadata.name}'").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(runningPodName).NotTo(o.Equal("''")) runningPodList := strings.Fields(runningPodName) if len(runningPodList) != 1 { e2e.Failf("Unexpected running cvo pods detected:" + runningPodName) } scc, err := oc.AsAdmin().WithoutNamespace().Run("get"). Args("pod", "-n", "openshift-cluster-version", strings.Trim(runningPodList[0], "'"), "-o=jsonpath={.metadata.annotations.openshift\\.io/scc}").Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(scc).To(o.Equal("hostaccess")) })