|
| 1 | +package operators |
| 2 | + |
| 3 | +import ( |
| 4 | + "context" |
| 5 | + "fmt" |
| 6 | + "path/filepath" |
| 7 | + "time" |
| 8 | + |
| 9 | + g "github.com/onsi/ginkgo/v2" |
| 10 | + o "github.com/onsi/gomega" |
| 11 | + "k8s.io/apimachinery/pkg/util/wait" |
| 12 | + |
| 13 | + exutil "github.com/openshift/origin/test/extended/util" |
| 14 | +) |
| 15 | + |
| 16 | +var _ = g.Describe("[sig-olmv1][OCPFeatureGate:NewOLMOwnSingleNamespace][Skipped:Disconnected] OLMv1 operator installation support for singleNamespace watch mode with quay-operator", g.Serial, func() { |
| 17 | + defer g.GinkgoRecover() |
| 18 | + |
| 19 | + oc := exutil.NewCLI("openshift-operator-controller") |
| 20 | + |
| 21 | + g.BeforeEach(func() { |
| 22 | + exutil.PreTestDump() |
| 23 | + }) |
| 24 | + |
| 25 | + g.AfterEach(func() { |
| 26 | + if g.CurrentSpecReport().Failed() { |
| 27 | + exutil.DumpPodLogsStartingWith("", oc) |
| 28 | + } |
| 29 | + }) |
| 30 | + |
| 31 | + g.It("should install a cluster extension successfully", func(ctx g.SpecContext) { |
| 32 | + runSingleOwnNamespaceTest(ctx, oc, "install-quay-operator-singlens.yaml", false) |
| 33 | + }) |
| 34 | +}) |
| 35 | + |
| 36 | +var _ = g.Describe("[sig-olmv1][OCPFeatureGate:NewOLMOwnSingleNamespace][Skipped:Disconnected] OLMv1 operator installation support for ownNamespace watch mode with quay-operator", g.Serial, func() { |
| 37 | + defer g.GinkgoRecover() |
| 38 | + |
| 39 | + oc := exutil.NewCLI("openshift-operator-controller") |
| 40 | + |
| 41 | + g.BeforeEach(func() { |
| 42 | + exutil.PreTestDump() |
| 43 | + }) |
| 44 | + |
| 45 | + g.AfterEach(func() { |
| 46 | + if g.CurrentSpecReport().Failed() { |
| 47 | + exutil.DumpPodLogsStartingWith("", oc) |
| 48 | + } |
| 49 | + }) |
| 50 | + |
| 51 | + g.It("should install a cluster extension successfully", func(ctx g.SpecContext) { |
| 52 | + runSingleOwnNamespaceTest(ctx, oc, "install-quay-operator-ownns.yaml", false) |
| 53 | + }) |
| 54 | +}) |
| 55 | + |
| 56 | +var _ = g.Describe("[sig-olmv1][OCPFeatureGate:NewOLMOwnSingleNamespace][Skipped:Disconnected] OLMv1 operator installation support for ownNamespace watch mode with an operator that does not support ownNamespace installation mode", func() { |
| 57 | + defer g.GinkgoRecover() |
| 58 | + |
| 59 | + oc := exutil.NewCLI("openshift-operator-controller") |
| 60 | + |
| 61 | + g.BeforeEach(func() { |
| 62 | + exutil.PreTestDump() |
| 63 | + }) |
| 64 | + |
| 65 | + g.AfterEach(func() { |
| 66 | + if g.CurrentSpecReport().Failed() { |
| 67 | + exutil.DumpPodLogsStartingWith("", oc) |
| 68 | + } |
| 69 | + }) |
| 70 | + |
| 71 | + g.It("should fail to install a cluster extension successfully", func(ctx g.SpecContext) { |
| 72 | + runSingleOwnNamespaceTest(ctx, oc, "install-openshift-pipelines-operator-ownns.yaml", true) |
| 73 | + }) |
| 74 | +}) |
| 75 | + |
| 76 | +//TODO: Need to add two more tests before this feature is GA. |
| 77 | + |
| 78 | +func runSingleOwnNamespaceTest(ctx g.SpecContext, oc *exutil.CLI, fileName string, expectFailure bool) { |
| 79 | + checkFeatureCapability(oc) |
| 80 | + |
| 81 | + var ( |
| 82 | + baseDir = exutil.FixturePath("testdata", "olmv1") |
| 83 | + ceFile = filepath.Join(baseDir, fileName) |
| 84 | + ) |
| 85 | + |
| 86 | + cleanup, unique := applyResourceFile(oc, "", "", "", ceFile) |
| 87 | + ceName := "install-test-ce-" + unique |
| 88 | + g.DeferCleanup(cleanup) |
| 89 | + |
| 90 | + g.By("waiting for the ClusterExtention to be installed") |
| 91 | + var lastReason string |
| 92 | + err := wait.PollUntilContextTimeout(ctx, time.Second, 5*time.Minute, true, |
| 93 | + func(ctx context.Context) (bool, error) { |
| 94 | + b, err, s := waitForClusterExtensionReady(oc, ceName) |
| 95 | + if lastReason != s { |
| 96 | + g.GinkgoLogr.Info(fmt.Sprintf("waitForClusterExtensionReady: %q", s)) |
| 97 | + lastReason = s |
| 98 | + } |
| 99 | + return b, err |
| 100 | + }) |
| 101 | + if expectFailure { |
| 102 | + o.Expect(err).To(o.HaveOccurred()) |
| 103 | + } else { |
| 104 | + o.Expect(lastReason).To(o.BeEmpty()) |
| 105 | + o.Expect(err).NotTo(o.HaveOccurred()) |
| 106 | + } |
| 107 | +} |
0 commit comments