cleanup go e2e tests and perform improvements#3499
cleanup go e2e tests and perform improvements#3499camilamacedo86 merged 4 commits intooperator-framework:masterfrom camilamacedo86:golang-cleanup-test
Conversation
estroz
left a comment
There was a problem hiding this comment.
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
|
Hi @estroz,
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. |
|
@joelanford wdyt? Can we move forward with this one? |
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. |
|
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 |
| close(done) | ||
| }, 360) | ||
|
|
||
| // AfterSuite run after all the specs have run, regardless of whether any tests have failed to ensures that |
There was a problem hiding this comment.
Nice use of testing suite.
|
|
||
| # Generate package manifests. | ||
| packagemanifests: kustomize | ||
| operator-sdk generate kustomize manifests -q --interactive=false |
There was a problem hiding this comment.
Why do we specify --interactive=false here, but not for Go?
There was a problem hiding this comment.
Because, the packagemanifests will calls interactive mode:
$ make packagemanifests
operator-sdk generate kustomize manifests -q
Display name for the operator (required):
>
joelanford
left a comment
There was a problem hiding this comment.
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.
| 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)) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
| makefilePackagemanifestsFragment = strings.Replace(makefilePackagemanifestsFragment, | ||
| "packagemanifests: kustomize manifests", "packagemanifests: kustomize", 1) |
There was a problem hiding this comment.
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, " "))There was a problem hiding this comment.
It is good always check. You are right here. Done.
| 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) |
There was a problem hiding this comment.
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.
joelanford
left a comment
There was a problem hiding this comment.
Looks good overall. One more nit about the packagemanifests templating.
Otherwise
/lgtm
|
New changes are detected. LGTM label has been removed. |
**Description of the change:** - only move the scorecard tests to e2e_<type>_scorecard_test **Motivation for the change:** - (+) maintainable and readable. - #3499 (comment)
Description of the change:
_testwhich has special meaning for the Go compiler.$(KUSTOMIZE)instead of kustomize directly.Motivation for the change:
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.