|
15 | 15 | package e2e_helm_test
|
16 | 16 |
|
17 | 17 | import (
|
| 18 | + "fmt" |
| 19 | + "os/exec" |
| 20 | + "path" |
18 | 21 | "path/filepath"
|
| 22 | + "strings" |
19 | 23 |
|
20 | 24 | . "github.com/onsi/ginkgo" //nolint:golint
|
| 25 | + . "github.com/onsi/gomega" //nolint:golint |
21 | 26 |
|
22 | 27 | testutils "github.com/operator-framework/operator-sdk/test/internal"
|
23 | 28 | )
|
24 | 29 |
|
25 |
| -var _ = PDescribe("Integrating Helm Projects with OLM", func() { |
| 30 | +var _ = Describe("Integrating Helm Projects with OLM", func() { |
26 | 31 | Context("with operator-sdk", func() {
|
| 32 | + const operatorVersion = "0.0.1" |
| 33 | + |
27 | 34 | BeforeEach(func() {
|
28 |
| - By("Turning off interactive prompts for all generation tasks.") |
| 35 | + By("turning off interactive prompts for all generation tasks.") |
29 | 36 | replace := "operator-sdk generate kustomize manifests"
|
30 | 37 | testutils.ReplaceInFile(filepath.Join(tc.Dir, "Makefile"), replace, replace+" --interactive=false")
|
31 | 38 | })
|
32 | 39 |
|
33 | 40 | AfterEach(func() {
|
| 41 | + By("destroying the deployed package manifests-formatted operator") |
| 42 | + cleanupPkgManCmd := exec.Command(tc.BinaryName, "cleanup", "packagemanifests", |
| 43 | + "--operator-version", operatorVersion, |
| 44 | + "--timeout", "4m") |
| 45 | + _, _ = tc.Run(cleanupPkgManCmd) |
| 46 | + |
| 47 | + By("uninstalling CRD's") |
| 48 | + _ = tc.Make("uninstall") |
34 | 49 | })
|
35 | 50 |
|
36 |
| - It("Should allow generate the OLM bundle and run it", func() { |
| 51 | + It("should generate and run a valid OLM bundle and packagemanifests", func() { |
| 52 | + By("building the bundle") |
| 53 | + err := tc.Make("bundle") |
| 54 | + Expect(err).NotTo(HaveOccurred()) |
| 55 | + |
| 56 | + By("validating the bundle") |
| 57 | + bundleValidateCmd := exec.Command(tc.BinaryName, "bundle", "validate", "bundle") |
| 58 | + _, err = tc.Run(bundleValidateCmd) |
| 59 | + Expect(err).NotTo(HaveOccurred()) |
| 60 | + |
| 61 | + By("building the operator bundle image") |
| 62 | + // Use the existing image tag but with a "-bundle" suffix. |
| 63 | + imageSplit := strings.SplitN(tc.ImageName, ":", 2) |
| 64 | + bundleImage := path.Join("quay.io", imageSplit[0]+"-bundle") |
| 65 | + if len(imageSplit) == 2 { |
| 66 | + bundleImage += ":" + imageSplit[1] |
| 67 | + } |
| 68 | + err = tc.Make("bundle-build", "BUNDLE_IMG="+bundleImage) |
| 69 | + Expect(err).NotTo(HaveOccurred()) |
| 70 | + |
| 71 | + By("loading the project image into Kind cluster") |
| 72 | + err = tc.LoadImageToKindClusterWithName(bundleImage) |
| 73 | + Expect(err).Should(Succeed()) |
| 74 | + |
| 75 | + By("adding the 'packagemanifests' rule to the Makefile") |
| 76 | + err = tc.AddPackagemanifestsTarget() |
| 77 | + Expect(err).Should(Succeed()) |
| 78 | + |
| 79 | + By("generating the operator package manifests") |
| 80 | + err = tc.Make("packagemanifests") |
| 81 | + Expect(err).NotTo(HaveOccurred()) |
| 82 | + |
| 83 | + By("updating clusterserviceversion with the manager image") |
| 84 | + testutils.ReplaceInFile( |
| 85 | + filepath.Join(tc.Dir, "packagemanifests", operatorVersion, |
| 86 | + fmt.Sprintf("e2e-%s.clusterserviceversion.yaml", tc.TestSuffix)), |
| 87 | + "controller:latest", tc.ImageName) |
| 88 | + |
| 89 | + By("installing crds to run packagemanifests") |
| 90 | + err = tc.Make("install") |
| 91 | + Expect(err).NotTo(HaveOccurred()) |
| 92 | + |
| 93 | + By("running the package") |
| 94 | + runPkgManCmd := exec.Command(tc.BinaryName, "run", "packagemanifests", |
| 95 | + "--install-mode", "AllNamespaces", |
| 96 | + "--operator-version", operatorVersion, |
| 97 | + "--timeout", "4m") |
| 98 | + _, err = tc.Run(runPkgManCmd) |
| 99 | + Expect(err).NotTo(HaveOccurred()) |
37 | 100 | })
|
38 | 101 | })
|
39 | 102 | })
|
0 commit comments