-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[e2e-test] Add run bundle to e2e test #3831
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| entries: | ||
| - description: > | ||
| Enable `run bundle` command and include e2e tests. | ||
| kind: addition | ||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -17,6 +17,7 @@ package run | |||
| import ( | ||||
| "github.com/spf13/cobra" | ||||
|
|
||||
| "github.com/operator-framework/operator-sdk/internal/cmd/operator-sdk/run/bundle" | ||||
| "github.com/operator-framework/operator-sdk/internal/cmd/operator-sdk/run/packagemanifests" | ||||
| "github.com/operator-framework/operator-sdk/internal/olm/operator" | ||||
| ) | ||||
|
|
@@ -34,7 +35,7 @@ Currently only the package manifests format is supported via the 'packagemanifes | |||
|
|
||||
| cmd.AddCommand( | ||||
| // TODO(joelanford): enable bundle command when implementation is complete | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
| // bundle.NewCmd(cfg), | ||||
| bundle.NewCmd(cfg), | ||||
|
varshaprasad96 marked this conversation as resolved.
|
||||
| packagemanifests.NewCmd(cfg), | ||||
| ) | ||||
|
|
||||
|
|
||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,7 +18,6 @@ import ( | |
| "encoding/json" | ||
| "os/exec" | ||
| "path/filepath" | ||
| "strings" | ||
|
|
||
| . "github.com/onsi/ginkgo" | ||
| . "github.com/onsi/gomega" | ||
|
|
@@ -27,6 +26,10 @@ import ( | |
| testutils "github.com/operator-framework/operator-sdk/test/internal" | ||
| ) | ||
|
|
||
| var ( | ||
| runBundleImg = "quay.io/vnarsing/run-bundle-test-img:v1" | ||
| ) | ||
|
|
||
| var _ = Describe("Integrating Go Projects with OLM", func() { | ||
| Context("with operator-sdk", func() { | ||
| const operatorVersion = "0.0.1" | ||
|
|
@@ -44,24 +47,37 @@ var _ = Describe("Integrating Go Projects with OLM", func() { | |
| // Turn off interactive prompts for all generation tasks. | ||
| replace := "operator-sdk generate kustomize manifests" | ||
| testutils.ReplaceInFile(filepath.Join(tc.Dir, "Makefile"), replace, replace+" --interactive=false") | ||
| err := tc.Make("bundle", "IMG="+tc.ImageName) | ||
|
|
||
| // Specifying stable channel. | ||
| // work around for Bug 1883377 - opm fails with FOREIGN KEY constraint when bundle default channel is empty | ||
| replace = "operator-sdk generate bundle" | ||
| testutils.ReplaceInFile(filepath.Join(tc.Dir, "Makefile"), replace, replace+" --default-channel stable --channels stable") | ||
| err := tc.Make("bundle") | ||
| Expect(err).NotTo(HaveOccurred()) | ||
|
|
||
| By("building the operator bundle image") | ||
| // Use the existing image tag but with a "-bundle" suffix. | ||
| imageSplit := strings.SplitN(tc.ImageName, ":", 2) | ||
| bundleImage := imageSplit[0] + "-bundle" | ||
| if len(imageSplit) == 2 { | ||
| bundleImage += ":" + imageSplit[1] | ||
| } | ||
| err = tc.Make("bundle-build", "BUNDLE_IMG="+bundleImage) | ||
| err = tc.Make("bundle-build", "BUNDLE_IMG="+runBundleImg) | ||
| Expect(err).NotTo(HaveOccurred()) | ||
|
|
||
| if isRunningOnKind() { | ||
| By("loading the bundle image into Kind cluster") | ||
| err = tc.LoadImageToKindClusterWithName(bundleImage) | ||
| Expect(err).NotTo(HaveOccurred()) | ||
| } | ||
| _, err = tc.Kubectl.Command("create", "namespace", tc.Kubectl.Namespace) | ||
| Expect(err).NotTo(HaveOccurred()) | ||
|
|
||
| // bundle image should be present in the remote repository in run bundle | ||
| // implementation. | ||
| By("push the image to a remote repository") | ||
| err = tc.Make("docker-push", "IMG="+runBundleImg) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume you're reverting this change @varshaprasad96?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @estroz no, afaik the image has to be pushed otherwise |
||
| Expect(err).NotTo(HaveOccurred()) | ||
|
|
||
| By("running the operator bundle using `run bundle` command") | ||
| runBundleCmd := exec.Command(tc.BinaryName, "run", "bundle", runBundleImg, "--namespace", tc.Kubectl.Namespace, "--timeout", "4m") | ||
| _, err = tc.Run(runBundleCmd) | ||
| Expect(err).NotTo(HaveOccurred()) | ||
|
|
||
| By("destroying the Operator deployed with the 'run' subcommand") | ||
| cleanupPkgManCmd := exec.Command(tc.BinaryName, "cleanup", projectName, | ||
| "--timeout", "4m") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are running the bundle in a specific namespace. The ns that. is created for the operator (project-system). |
||
| _, err = tc.Run(cleanupPkgManCmd) | ||
| Expect(err).NotTo(HaveOccurred()) | ||
|
|
||
|
varshaprasad96 marked this conversation as resolved.
|
||
| By("adding the 'packagemanifests' rule to the Makefile") | ||
| err = tc.AddPackagemanifestsTarget() | ||
|
|
@@ -127,10 +143,13 @@ var _ = Describe("Integrating Go Projects with OLM", func() { | |
| } | ||
|
|
||
| By("destroying the deployed package manifests-formatted operator") | ||
| cleanupPkgManCmd := exec.Command(tc.BinaryName, "cleanup", projectName, | ||
| cleanupPkgManCmd = exec.Command(tc.BinaryName, "cleanup", projectName, | ||
| "--timeout", "4m") | ||
| _, err = tc.Run(cleanupPkgManCmd) | ||
| Expect(err).NotTo(HaveOccurred()) | ||
|
|
||
| _, err = tc.Kubectl.Command("delete", "namespace", tc.Kubectl.Namespace) | ||
| Expect(err).NotTo(HaveOccurred()) | ||
| }) | ||
| }) | ||
| }) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| --- | ||
| title: "operator-sdk run bundle" | ||
| --- | ||
| ## operator-sdk run bundle | ||
|
|
||
| Deploy an Operator in the bundle format with OLM | ||
|
|
||
| ### Synopsis | ||
|
|
||
| Deploy an Operator in the bundle format with OLM | ||
|
|
||
| ``` | ||
| operator-sdk run bundle <bundle-image> [flags] | ||
| ``` | ||
|
|
||
| ### Options | ||
|
|
||
| ``` | ||
| --index-image string index image in which to inject bundle (default "quay.io/operator-framework/upstream-opm-builder:latest") | ||
| --install-mode InstallModeValue install mode | ||
| --timeout duration install timeout (default 2m0s) | ||
| --kubeconfig string Path to the kubeconfig file to use for CLI requests. | ||
| -n, --namespace string If present, namespace scope for this CLI request | ||
| -h, --help help for bundle | ||
| ``` | ||
|
|
||
| ### Options inherited from parent commands | ||
|
|
||
| ``` | ||
| --verbose Enable verbose logging | ||
| ``` | ||
|
|
||
| ### SEE ALSO | ||
|
|
||
| * [operator-sdk run](../operator-sdk_run) - Run an Operator in a variety of environments | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The e2e are not relevant to end-users
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @camilamacedo86 rephrase it. I would change her suggestion a bit:
Added the
run bundlesubcommand which allows users to verify their operator's bundle integrates with OLM.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be sufficient: