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
Run integration tests with ginkgo instead of go test and ensure logs go to GinkgoWriter instead of stdout #1726
Conversation
@@ -152,7 +152,7 @@ test.unit: ## Run unit tests. | |||
.PHONY: test.integration | |||
test.integration: envtest ## Run integration tests located in the tests/integration directory. | |||
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" \ | |||
go test --tags=integration $(VERBOSE_FLAG) ./tests/integration/... | |||
go run github.com/onsi/ginkgo/v2/ginkgo --tags=integration $(VERBOSE_FLAG) ./tests/integration/... |
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.
just tried this locally and the output is too much verbose. :(
also, does this run ginkgo from master? This might break us at some point? Should we stick to a released version instead?
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.
Yup, too much output due to a bug: https://issues.redhat.com/browse/OSSM-6159
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.
As for running ginkgo from master. We use the same approach in the e2e tests. So if this need to be fixed, we should do it in both places (in a follow up PR).
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.
Actually, it looks like go run
honors whatever is in go.mod, so we're actually running v2.15.0:
[luksa@p1 sail-operator]$ go run github.com/onsi/ginkgo/v2/ginkgo version
Ginkgo Version 2.15.0
[luksa@p1 sail-operator]$ cd ..
[luksa@p1 maistra]$ go run github.com/onsi/ginkgo/v2/ginkgo version
no required module provides package github.com/onsi/ginkgo/v2/ginkgo: go.mod file not found in current directory or any parent directory; see 'go help modules'
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.
@jwendell I've just pushed another commit that fixes the logs.
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.
Yeah, I agree, but as you say: "it is what it is" :)
Ginkgo has "specs" not tests. The list of specs gets built from a hierarchy of test "nodes". These specs are then executed (in a single test function that you must write). Unlike functions that are organized into packages, the specs are just one giant sequential list. And they are all executed by your test function.
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 see. Is there a way to show the progress a little more verbose, instead of just showing small dots?
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 don't think so. There's only -v
, but this displays everything that is logged by the test. I don't see any other option that would e.g. only print the specs with nothing else.
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.
ok. It is what it is, should we revert to using plain old go tests then? /me runs :D
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.
We wouldn't be reverting. We had ginkgo tests from the very start. :)
Ginkgo displays progress, whereas go test doesn't.
func SetupEnv() (*envtest.Environment, client.Client, *rest.Config) { | ||
logf.SetLogger(zap.New(zap.UseDevMode(true))) | ||
func SetupEnv(logWriter io.Writer) (*envtest.Environment, client.Client, *rest.Config) { | ||
logf.SetLogger(zap.New(zap.WriteTo(logWriter), zap.UseDevMode(true))) |
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.
Funny story, in Brazil, "zap" is a short for "Whatsapp", the messenger app.
/retest |
21d66b7
into
maistra:maistra-3.0
Ginkgo displays progress, whereas go test doesn't.