Skip to content
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

Merged
merged 2 commits into from Mar 22, 2024

Conversation

luksa
Copy link
Contributor

@luksa luksa commented Mar 22, 2024

Ginkgo displays progress, whereas go test doesn't.

@luksa luksa requested a review from fjglira March 22, 2024 17:13
@openshift-ci openshift-ci bot added the size/XS label Mar 22, 2024
@@ -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/...
Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Contributor Author

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).

Copy link
Contributor Author

@luksa luksa Mar 22, 2024

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'

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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

Copy link
Contributor Author

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. :)

@luksa luksa added the tide/merge-method-rebase Denotes a PR that should be rebased by tide when it merges. label Mar 22, 2024
@openshift-ci openshift-ci bot added size/S and removed size/XS labels Mar 22, 2024
@luksa luksa changed the title Run integration tests with ginkgo instead of go test Run integration tests with ginkgo instead of go test and ensure logs go to GinkgoWriter instead of stdout Mar 22, 2024
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)))
Copy link
Member

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.

@luksa
Copy link
Contributor Author

luksa commented Mar 22, 2024

/retest

@openshift-merge-bot openshift-merge-bot bot merged commit 21d66b7 into maistra:maistra-3.0 Mar 22, 2024
11 checks passed
@luksa luksa deleted the OSSM-6158 branch March 26, 2024 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
okay to merge size/S tide/merge-method-rebase Denotes a PR that should be rebased by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants