[run-bundle] Test example scenarios for run bundle#3844
[run-bundle] Test example scenarios for run bundle#3844varshaprasad96 wants to merge 1 commit intooperator-framework:masterfrom
Conversation
| ) | ||
| BeforeEach(func() { | ||
| By("creating a new context") | ||
| // For this test suite, the bundle image name is equal to tc.ImageName |
There was a problem hiding this comment.
I think the comment is. not. required since the TestContext has the ImageName attribute to store that. So, shows that it is implicit.
There was a problem hiding this comment.
I had written it explicitly to specify that tc.ImageName is not operator image but bundle image instead.
| i := bundle.NewInstall(cfg) | ||
| i.BundleImage = tc.ImageName |
There was a problem hiding this comment.
You are running the make bundle for he image. what the NewInstall does? Why it is required?
There was a problem hiding this comment.
The bundle image is an argument to the run bundle command. When the command is passed, the Install struct is populated. It is referenced here: https://github.com/operator-framework/operator-sdk/blob/master/internal/olm/operator/bundle/install.go#L42
There was a problem hiding this comment.
why not we do not use operator-sdk run bundle here? IMO : It is an e2e test so we should use the CLI commands otherwise we could cover these scenarios with unit tests.
| cfg := &operator.Configuration{KubeconfigPath: kubeconfigPath} | ||
| err := cfg.Load() | ||
| Expect(err).NotTo(HaveOccurred()) |
There was a problem hiding this comment.
Why it is rerquired?
There was a problem hiding this comment.
These are a part of run bundle arguments. The kubecfg (specifying the namespace if needed), and the bundle image is passed to the run bundle.
For reference: It is similar to how testing is done in packagemanifests-> https://github.com/operator-framework/operator-sdk/blob/master/test/integration/operator_olm_test.go#L106
| err = doInstall(i) | ||
| Expect(err).NotTo(HaveOccurred()) |
There was a problem hiding this comment.
What the doinstall does?
There was a problem hiding this comment.
Same above. we need to use the CLI command instead.
There was a problem hiding this comment.
IMO we should NOT create the test in the "integration" dir.
We need to check the command to run the bundle in the e2e tests which would be called at the same that the users will use it. See that in the e2e test the bundle is generated all in the same way for Ansible/Helm/GO. So we need to run operator-sdk run bundle for the projects instead of it. See https://github.com/operator-framework/operator-sdk/blob/master/test/e2e-helm/e2e_helm_olm_test.go#L51-L63
| uninstallConfig.DeleteAll = true | ||
| uninstallConfig.DeleteOperatorGroupNames = []string{tc.Group} | ||
| uninstallConfig.Package = defaultOperatorName | ||
| uninstallConfig.Logf = logrus.Infof |
There was a problem hiding this comment.
what should be uninstalled here? Is the bundle?
There was a problem hiding this comment.
Yes, it is the bundle. As you said, after creating a new test context for the entire suite, before each test we uninstall the previous bundle (csv, crd and other created objects).
There was a problem hiding this comment.
Will not the tool provide a command to uninstall?
| func TestRunBundle(t *testing.T) { | ||
| RegisterFailHandler(Fail) | ||
| RunSpecs(t, "Operator SDK run bundle test suite") | ||
| } |
There was a problem hiding this comment.
in order to follow up a standard each dir should have 1 suite test and the tests that will be called by it. IMO we need re-check if is really required to keep this dir.
There was a problem hiding this comment.
As discussed with @jmrodri and @estroz, this PR was structured to follow the run packagemanifests format. We add the generic run bundle test to operator e2e test suite which is done here: #3831 and the tests to check various scenarios in the olm integration suite. Similar to how package manifests does: test/integration/operator_olm_test.go.
I am not sure if these tests would be run when the user calls run bundle, because we are using a pre-generated bundle specific for this tests.
There was a problem hiding this comment.
OK. See that :
- we cover the features with unit test
- we have e2e tests for each type of project where we will test the run bundle with ALL Namespaces.
So, this e2e test would just make sense if we would like to cover all possible scenarios. Is this the goal? If yes, OK. However, note that test/integration/operator_olm_test.go is old and is NOT follow the conventions and standards defined so far.
So, if we will add tests to cover all options of the run bundle command with e2e then:
- we should use the libs defined and then follow the standards and conventions defined by them and applied in the ansible/helm tests already. (we have pr to cleanup go implementation waiting for reviews feat: cleanup go e2e tests and perform improvements )
- the integration tests need to be in
test/e2e-<name>. I suggest we have a dirtest/e2e-olm. (we can leave for this integration dir, however, I'd like to see the new tests following the same standard and convections) - The directory requires an
e2e_<name>_suite_testwhich will have the suite and then we have the files tests. Note that it is the standard of the libs adopted.
NOTE: You can create the dir and run the command
$ ginkgo bootstrap** and then, you will check the files in this way.
- we should not re-create the project for each test. the project can be created in the before of the suite and used by all test and the removed on the after of the suite instead. See Ansible/Helm suite tests.
- the go e2e test should have the suffix _test which has special meaning for the Go compiler
This PR adds additional olm integration tests to test the run bundle command for various example UX scenarios.
727dc50 to
d0e3f33
Compare
| func TestRunBundle(t *testing.T) { | ||
| RegisterFailHandler(Fail) | ||
| RunSpecs(t, "Operator SDK run bundle test suite") | ||
| } |
There was a problem hiding this comment.
All integration tests in this package should be converted to ginkgo/gomega tests eventually like this integration test is, so the suite runner should be in a separate file and look like so:
| func TestRunBundle(t *testing.T) { | |
| RegisterFailHandler(Fail) | |
| RunSpecs(t, "Operator SDK run bundle test suite") | |
| } | |
| func TestIntegration(t *testing.T) { | |
| RegisterFailHandler(Fail) | |
| RunSpecs(t, "Integration Suite") | |
| } |
There was a problem hiding this comment.
IMO we need to create the dir /test/e2e-olm/ in order to follow the project standard. The tests here are old and are not following the new definitions. Then, we should run ginkgo bootstrap. It will generated the files with the names following the lib convention. See: https://onsi.github.io/ginkgo/
| Skip("Run bundle not yet implemented") | ||
| } | ||
|
|
||
| cfg := &operator.Configuration{KubeconfigPath: kubeconfigPath} |
There was a problem hiding this comment.
This may not be testing OwnNamespace since the default namespace used might not be the one created for this test (tc.Kubectl.Namespace).
| Skip("Run bundle not yet implemented") | ||
| } | ||
|
|
||
| cfg := &operator.Configuration{KubeconfigPath: kubeconfigPath, Namespace: tc.Kubectl.Namespace} |
There was a problem hiding this comment.
If tc.Kubectl.Namespace == i.InstallMode.TargetNamespaces then you're actually using the OwnNamespace install mode.
There was a problem hiding this comment.
It is an e2e test and we are creating the project. So, we need to test it as users would be performing this action. Have we a flag to define the run bundle is single namespace or it users need to update the manifest generated?
| uninstall(kubeconfigPath, tc) | ||
| }) | ||
|
|
||
| It("Run Bundle - watching the specified namesapce", func() { |
There was a problem hiding this comment.
What do you mean by "watching the specified namespace"? This case is testing SingleNamespace. I suggest you get rid of the above It() and just use this one.
| }) | ||
|
|
||
| var _ = Describe("run bundle", func() { | ||
| It("Run Bundle Basic", func() { |
There was a problem hiding this comment.
| It("Run Bundle Basic", func() { | |
| It("AllNamespaces (default)", func() { |
|
|
||
| // Modified from https://github.com/kubernetes-sigs/kubebuilder/tree/39224f0/test/e2e/v3 | ||
|
|
||
| package e2e |
There was a problem hiding this comment.
// should be the name of the dir with _test
Assuming that it will be in /tests/e2e_olm as suggested:
| package e2e | |
| package e2e_olm_test |
| By("implementing the API") | ||
| Expect(kbtestutils.InsertCode( | ||
| filepath.Join(tc.Dir, "api", tc.Version, fmt.Sprintf("%s_types.go", strings.ToLower(tc.Kind))), | ||
| fmt.Sprintf(`type %sSpec struct { | ||
| `, tc.Kind), | ||
| ` // +optional | ||
| Count int `+"`"+`json:"count,omitempty"`+"`"+` | ||
| `)).Should(Succeed()) |
There was a problem hiding this comment.
It shows not required for the test at all. Why we need to add an value in the types? Could we not use the foo?
| corev1 "k8s.io/api/core/v1" | ||
| wait "k8s.io/apimachinery/pkg/util/wait" | ||
| "sigs.k8s.io/controller-runtime/pkg/client" | ||
| kbtestutils "sigs.k8s.io/kubebuilder/test/e2e/utils" |
There was a problem hiding this comment.
the imports need to be sorted.
| By("push the bundle to a remote repository") | ||
| err = tc.Make("docker-push", "IMG="+tc.ImageName) | ||
| Expect(err).NotTo(HaveOccurred()) |
There was a problem hiding this comment.
| By("push the bundle to a remote repository") | |
| err = tc.Make("docker-push", "IMG="+tc.ImageName) | |
| Expect(err).NotTo(HaveOccurred()) |
we should not use the docker-push here. The tests are executed using Kind. We build the images and then we load them. See:
|
Closing this PR as this would be tested in unit tests. |
Description of the change:
This PR adds additional olm integration tests to test the run bundle
command for various example UX scenarios.
Motivation for the change:
Follow up of #3831
c/c: @jmrodri
Checklist
If the pull request includes user-facing changes, extra documentation is required:
changelog/fragments(seechangelog/fragments/00-template.yaml)website/content/en/docs