|
| 1 | +package operator |
| 2 | + |
| 3 | +import ( |
| 4 | + "context" |
| 5 | + "fmt" |
| 6 | + "strings" |
| 7 | + "time" |
| 8 | + |
| 9 | + g "github.com/onsi/ginkgo/v2" |
| 10 | + o "github.com/onsi/gomega" |
| 11 | + |
| 12 | + e2e "github.com/openshift/ingress-node-firewall/test/e2e" |
| 13 | +) |
| 14 | + |
| 15 | +var _ = g.Describe("[sig-network] INFW", func() { |
| 16 | + defer g.GinkgoRecover() |
| 17 | + |
| 18 | + var ( |
| 19 | + oc *e2e.OCClient |
| 20 | + ctx context.Context |
| 21 | + cancel context.CancelFunc |
| 22 | + opNamespace = "openshift-ingress-node-firewall" |
| 23 | + ) |
| 24 | + |
| 25 | + g.BeforeEach(func() { |
| 26 | + ctx, cancel = context.WithTimeout(context.Background(), 10*time.Minute) |
| 27 | + oc = e2e.NewOCClient("") |
| 28 | + }) |
| 29 | + |
| 30 | + g.AfterEach(func() { |
| 31 | + if cancel != nil { |
| 32 | + cancel() |
| 33 | + } |
| 34 | + }) |
| 35 | + |
| 36 | + // OCP-61481 - Ingress Node Firewall Operator Installation |
| 37 | + g.It("Author:anusaxen-High-61481-[LEVEL0][OTP]-StagerunBoth-Ingress Node Firewall Operator Installation [apigroup:ingressnodefirewall.openshift.io]", func() { |
| 38 | + g.By("Checking Ingress Node Firewall operator installation") |
| 39 | + |
| 40 | + // Check that the operator namespace exists |
| 41 | + output, err := oc.Get(ctx, "namespace", opNamespace, "") |
| 42 | + o.Expect(err).NotTo(o.HaveOccurred(), "Operator namespace should exist") |
| 43 | + o.Expect(output).To(o.ContainSubstring(opNamespace), "Namespace output should contain the operator namespace") |
| 44 | + |
| 45 | + g.By("Verifying CRDs are installed") |
| 46 | + crdOutput, err := oc.Run(ctx, "get", "crd") |
| 47 | + o.Expect(err).NotTo(o.HaveOccurred(), "Should be able to list CRDs") |
| 48 | + |
| 49 | + expectedCRDs := []string{ |
| 50 | + "ingressnodefirewallconfigs.ingressnodefirewall.openshift.io", |
| 51 | + "ingressnodefirewallnodestates.ingressnodefirewall.openshift.io", |
| 52 | + "ingressnodefirewalls.ingressnodefirewall.openshift.io", |
| 53 | + } |
| 54 | + |
| 55 | + for _, crd := range expectedCRDs { |
| 56 | + o.Expect(strings.Contains(crdOutput, crd)).To(o.BeTrue(), |
| 57 | + "CRD %s should be installed", crd) |
| 58 | + } |
| 59 | + |
| 60 | + g.By("Verifying operator deployment is running") |
| 61 | + // Check that the operator deployment exists and is ready |
| 62 | + deploymentOutput, err := oc.Run(ctx, "get", "deployment", "-n", opNamespace, "-o=jsonpath={.items[*].metadata.name}") |
| 63 | + o.Expect(err).NotTo(o.HaveOccurred(), "Should be able to list deployments in operator namespace") |
| 64 | + o.Expect(deploymentOutput).NotTo(o.BeEmpty(), "There should be at least one deployment in the operator namespace") |
| 65 | + |
| 66 | + // Wait for the operator deployment to be ready |
| 67 | + deploymentName := "ingress-node-firewall-controller-manager" |
| 68 | + _, err = oc.Run(ctx, "wait", "deployment/"+deploymentName, "-n", opNamespace, "--for=condition=Available", "--timeout=5m") |
| 69 | + o.Expect(err).NotTo(o.HaveOccurred(), "Operator deployment should be available") |
| 70 | + |
| 71 | + g.By("SUCCESS - Ingress Node Firewall operator and CRDs installed") |
| 72 | + fmt.Println("Operator install and CRDs check successful!") |
| 73 | + }) |
| 74 | +}) |
0 commit comments