Skip to content

cleanup go e2e tests and perform improvements#3499

Merged
camilamacedo86 merged 4 commits intooperator-framework:masterfrom
camilamacedo86:golang-cleanup-test
Sep 15, 2020
Merged

cleanup go e2e tests and perform improvements#3499
camilamacedo86 merged 4 commits intooperator-framework:masterfrom
camilamacedo86:golang-cleanup-test

Conversation

@camilamacedo86
Copy link
Copy Markdown
Contributor

@camilamacedo86 camilamacedo86 commented Jul 23, 2020

Description of the change:

Motivation for the change:

  • maintainability, readability and reusability
  • ensure that our e2e tests are using the targets commands as we suggested to the users in the docs

NOTE: The first goal is to keep all tests following the same standard. However, it still has a hall for improvements that ought to make horizontally in follow-ups.

Copy link
Copy Markdown
Member

@estroz estroz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m not so sure we want to do this, at least not yet. Go e2e tests, while they could test more functionality, are fine as-is for v1.0. We can prioritize improving them after release.

/hold

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 23, 2020
@camilamacedo86
Copy link
Copy Markdown
Contributor Author

camilamacedo86 commented Jul 23, 2020

Hi @estroz,

I’m not so sure we want to do this, at least not yet. Go e2e tests, while they could test more functionality, are fine as-is for v1.0. We can prioritize improving them after release.

I do not agree with first because I do not see why it affects the v1.0 release. Also, we are applying here the changes/discussions made in the helm and then, I do not think that the tests are fine now because they are not using the makefile as we suggest to in the docs and we are unable to run them locally with any env for example.

@camilamacedo86
Copy link
Copy Markdown
Contributor Author

@joelanford wdyt? Can we move forward with this one?

@joelanford
Copy link
Copy Markdown
Member

fix the target in the doc master.sdk.operatorframework.io/docs/olm-integration/generation/#package-manifests-format. Users should use $(KUSTOMIZE) instead of kustomize directly.

This is the only thing from this PR that I think would be better to get in before 1.0. Everything else is nice to have, but can merge before 1.0 (if we get time to review, etc.)

I agree with @estroz that 1.0 blockers are the priority at the moment.

@camilamacedo86
Copy link
Copy Markdown
Contributor Author

Removing the /hold since has I understand according to above comments that have no reason to hold that besides we are not prioritizing it for 1.0.0.

/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 23, 2020
@camilamacedo86 camilamacedo86 changed the title feat: cleanup go e2e tests and perform improvements WIP: feat: cleanup go e2e tests and perform improvements Jul 24, 2020
@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 24, 2020
@camilamacedo86 camilamacedo86 changed the title WIP: feat: cleanup go e2e tests and perform improvements feat: cleanup go e2e tests and perform improvements Jul 28, 2020
@camilamacedo86 camilamacedo86 removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 28, 2020
@camilamacedo86 camilamacedo86 requested a review from estroz July 28, 2020 11:06
Comment thread hack/tests/e2e-go.sh Outdated
@openshift-ci-robot openshift-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Aug 2, 2020
@camilamacedo86 camilamacedo86 requested a review from estroz August 2, 2020 11:54
@openshift-ci-robot openshift-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Aug 9, 2020
Comment thread test/e2e/e2e_go_olm_test.go Outdated
close(done)
}, 360)

// AfterSuite run after all the specs have run, regardless of whether any tests have failed to ensures that
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice use of testing suite.

Comment thread test/e2e/e2e_go_cluster_test.go
@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 9, 2020
@camilamacedo86 camilamacedo86 changed the title WIP: feat: cleanup go e2e tests and perform improvements WIP: feat: cleanup go e2e tests and perform improvements (need to update with master) Sep 9, 2020
@camilamacedo86 camilamacedo86 changed the title WIP: feat: cleanup go e2e tests and perform improvements (need to update with master) cleanup go e2e tests and perform improvements (need to update with master) Sep 10, 2020
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 10, 2020
@camilamacedo86 camilamacedo86 changed the title cleanup go e2e tests and perform improvements (need to update with master) cleanup go e2e tests and perform improvements Sep 10, 2020
Copy link
Copy Markdown
Member

@jmrodri jmrodri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 13, 2020
Comment thread test/internal/packagemanifests.go Outdated
Comment thread test/internal/packagemanifests.go Outdated
@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Sep 14, 2020
Comment thread test/internal/packagemanifests.go
Comment thread test/internal/packagemanifests.go Outdated

# Generate package manifests.
packagemanifests: kustomize
operator-sdk generate kustomize manifests -q --interactive=false
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we specify --interactive=false here, but not for Go?

Copy link
Copy Markdown
Contributor Author

@camilamacedo86 camilamacedo86 Sep 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because, the packagemanifests will calls interactive mode:

$ make packagemanifests 
operator-sdk generate kustomize manifests -q

Display name for the operator (required): 
> 

@estroz estroz removed the ci label Sep 14, 2020
Copy link
Copy Markdown
Member

@joelanford joelanford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more round now that I had more time to look at it.

Looks great overall, but a I have a few more comments and suggestions.

Comment thread test/e2e-go/e2e_go_cluster_test.go
Comment thread test/e2e-go/e2e_go_cluster_test.go
Comment thread test/e2e-go/e2e_go_cluster_test.go
Comment on lines +96 to +105
By("running custom scorecard tests")
runScorecardCmd = exec.Command(tc.BinaryName, "scorecard", "bundle",
"--selector=suite=custom",
"--output=json",
"--wait-time=40s")
scorecardOutputBytes, err = tc.Run(runScorecardCmd)
Expect(err).NotTo(HaveOccurred())
err = json.Unmarshal(scorecardOutputBytes, &scorecardOutput)
Expect(err).NotTo(HaveOccurred())
Expect(len(scorecardOutput.Items)).To(Equal(2))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We talked about not running these tests as part of the Go e2e. Can we remove from here and do a follow-up to add them to the test/integration tests?

Copy link
Copy Markdown
Contributor Author

@camilamacedo86 camilamacedo86 Sep 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to discuss that before to do a follow. These tests were added via tasks planned in the sprint which means that was discussed before to get done. Also, I think we should keep them at least for now. See that when we split the repos will make sense we have only the e2e tests to ensure the SDK features ( scorecard and olm ) on this repo.

Also, see that the test/integration is not following the standards define so far and with them, we will NOT test it end to end and then, we will not able to ensure that the commands work with the project layout and with the makefile targets suggested in the docs.

In this way, before we decide to change the scorecard tests I think we need to discuss how the tests will be after the slit as what is the best approach for we do not spend time changing it many times.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see now that this is just copied over from the existing file. Seems reasonable to keep for now, but we should add a TODO comment to split the scorecard custom test testing out.

We should also discuss if there's really a need for the custom test example at all. After all, the basic and olm tests are probably reasonable examples on their own.

Copy link
Copy Markdown
Contributor Author

@camilamacedo86 camilamacedo86 Sep 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/operator-framework/operator-sdk/blob/master/test/e2e-helm/e2e_helm_suite_test.go#L117-L121

I will push soon the PR to split the scorecard.

We should also discuss if there's really a need for the custom test example at all. After all, the basic and olm tests are probably reasonable examples on their own.

we have a task/issue for that already: #3839

Comment thread test/e2e-go/e2e_go_suite_test.go Outdated
Comment thread test/e2e-go/e2e_go_suite_test.go Outdated
Comment thread test/e2e-go/e2e_go_cluster_test.go Outdated
Comment thread test/internal/packagemanifests.go Outdated
Comment on lines +68 to +69
makefilePackagemanifestsFragment = strings.Replace(makefilePackagemanifestsFragment,
"packagemanifests: kustomize manifests", "packagemanifests: kustomize", 1)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is brittle. If we change the packagemanifests target to something slightly different, this replacement will silently fail.

Instead, what if we make the fragment a format string that we pass to fmt.Sprintf(). e.g.

makefilePackagemanifestsFragment := `
# Options for "packagemanifests".
ifneq ($(origin FROM_VERSION), undefined)
PKG_FROM_VERSION := --from-version=$(FROM_VERSION)
endif
ifneq ($(origin CHANNEL), undefined)
PKG_CHANNELS := --channel=$(CHANNEL)
endif
ifeq ($(IS_CHANNEL_DEFAULT), 1)
PKG_IS_DEFAULT_CHANNEL := --default-channel
endif
PKG_MAN_OPTS ?= $(FROM_VERSION) $(PKG_CHANNELS) $(PKG_IS_DEFAULT_CHANNEL)
# Generate package manifests.
packagemanifests: %s
	operator-sdk generate kustomize manifests -q --interactive=false
	cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
	$(KUSTOMIZE) build config/manifests | operator-sdk generate packagemanifests -q --version $(VERSION) $(PKG_MAN_OPTS)
`

pmDeps := []string{"kustomize"}
if strings.HasPrefix(c.Layout, "go") {
	pmDeps = append(pmDeps, "manifests")
}
fragment := fmt.Sprintf(makefilePackagemanifestsFragment, strings.Join(pmDeps, " "))

Copy link
Copy Markdown
Contributor Author

@camilamacedo86 camilamacedo86 Sep 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is good always check. You are right here. Done.

Comment thread test/internal/packagemanifests.go Outdated
Comment on lines +69 to +74
manifestsTarget := "packagemanifests: kustomize manifests"
if !strings.Contains(makefilePackagemanifestsFragment, manifestsTarget) {
return errors.New("unable to find the manifests target to be replaced")
}
makefilePackagemanifestsFragment = strings.Replace(makefilePackagemanifestsFragment,
"packagemanifests: kustomize manifests", "packagemanifests: kustomize", 1)
manifestsTarget, "packagemanifests: kustomize", 1)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: string comparison and replacement seems more complex than the fmt.Sprintf idea, and it is still prone to accidental breakage. At least now the test would fail, but it seems more efficient and less error prone to build the string instead of search/replace it.

With this, it is possible that we'll make a change and not see that we accidentally broke something until 20-30 minutes into a CI run.

Copy link
Copy Markdown
Member

@joelanford joelanford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall. One more nit about the packagemanifests templating.

Otherwise
/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 15, 2020
@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Sep 15, 2020
@openshift-ci-robot
Copy link
Copy Markdown

New changes are detected. LGTM label has been removed.

@camilamacedo86 camilamacedo86 merged commit 838ed74 into operator-framework:master Sep 15, 2020
@camilamacedo86 camilamacedo86 deleted the golang-cleanup-test branch September 15, 2020 16:28
camilamacedo86 added a commit that referenced this pull request Oct 6, 2020
**Description of the change:**
- only move the scorecard tests to e2e_<type>_scorecard_test

**Motivation for the change:**
- (+) maintainable and readable.  
- #3499 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants