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

circleci: record junit test results #959

Merged
merged 9 commits into from
Jun 30, 2021

Conversation

felixge
Copy link
Member

@felixge felixge commented Jun 28, 2021

This PR enables circle CI's Collecting Test Metadata feature by producing JUnit XML. It's modeled after their Language Guide: Go docs.

The motivation behind this is to get insights into flaky tests and to avoid having to scroll through the huge test result log output when a test fails. An example of this can be seen below or by following this link.

2021-06-28 Google Chrome test-core (10249) - DataDogdd-trace-go - 18-53-10

2021-06-28 Google Chrome test-core (10249) - DataDogdd-trace-go - 18-53-24

FWIW the Insights don't seem to work yet. I don't know if this will fix itself once we merge this or if there is another problem.

2021-06-28 Google Chrome Insights - DataDogdd-trace-goworkflowsbuild-and-test - 19-18-04

@felixge felixge marked this pull request as ready for review June 28, 2021 17:15
@felixge
Copy link
Member Author

felixge commented Jun 28, 2021

@knusbaum @gbbr as discussed in slack. See PR description for more details. PTAL 🙏

@knusbaum knusbaum added this to the 1.32.0 milestone Jun 28, 2021
Copy link
Member Author

@felixge felixge left a comment

Choose a reason for hiding this comment

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

Some comments to help review.

@@ -43,7 +43,7 @@ func Middleware(opts ...Option) func(c *fiber.Ctx) error {
opts = append(opts, cfg.spanOpts...)
span, _ := tracer.StartSpanFromContext(c.Context(), "http.request", opts...)

fmt.Printf("Starting Span")
fmt.Printf("Starting Span\n")
Copy link
Member Author

Choose a reason for hiding this comment

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

This is needed to make gotestsum happy. Otherwise we get failures parsing the test output.

Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably just remove this line.

Copy link
Member Author

Choose a reason for hiding this comment

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

DONE. 4732d34

destination: raw-test-output

- store_test_results: # upload test results for display in Test Summary
path: /tmp/test-results
Copy link
Member Author

Choose a reason for hiding this comment

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

The boilerplate above is duplicated for our two main jobs: test-core and test-contrib. We could probably try to eliminate it via some YAML anchors, but given the existing duplication I'm not sure it's worth it?

@@ -198,7 +224,20 @@ jobs:
- run:
name: Testing integrations
command: |
INTEGRATION=1 go test -v -race -coverprofile=coverage.txt -covermode=atomic `go list ./contrib/... | grep -v -e grpc.v12 -e google.golang.org/api`
PACKAGE_NAMES=$(go list ./contrib/... | grep -v -e grpc.v12 -e google.golang.org/api | circleci tests split --split-by=timings --timings-type=classname)
gotestsum --junitfile ${TEST_RESULTS}/gotestsum-report.xml -- $PACKAGE_NAMES -v -race -coverprofile=coverage.txt -covermode=atomic
Copy link
Member Author

Choose a reason for hiding this comment

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

This doesn't cover our special Testing outlier google.golang.org/api and Testing outlier gRPC v1.2 steps right now. Not sure if this can be done easily given the way CircleCI handles JUnit XML results, but I could try to look into it if you think it's critical.

- run: mkdir -p $TEST_RESULTS
- restore_cache: # restores saved cache if no changes are detected since last run
keys:
- go-mod-v4-{{ checksum "go.sum" }}
Copy link
Member Author

Choose a reason for hiding this comment

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

The extra restore_cache and save_cache are documented in the Go language guide. It's not clear if they are needed for capturing the test results, it seems to work without, but in theory it might speed up our tests a little.

I'm also not sure if it's working correctly, given the presence of this in the CI logs. So we could also omit it from this PR for now as far as I'm concerned.

2021-06-28 Google Chrome test-core (10270) - DataDogdd-trace-go - 19-15-14

@felixge felixge requested review from knusbaum and gbbr June 29, 2021 07:24
Copy link
Contributor

@knusbaum knusbaum left a comment

Choose a reason for hiding this comment

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

Just a nit.

@@ -43,7 +43,7 @@ func Middleware(opts ...Option) func(c *fiber.Ctx) error {
opts = append(opts, cfg.spanOpts...)
span, _ := tracer.StartSpanFromContext(c.Context(), "http.request", opts...)

fmt.Printf("Starting Span")
fmt.Printf("Starting Span\n")
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably just remove this line.

@felixge
Copy link
Member Author

felixge commented Jun 29, 2021

@knusbaum thanks for reviewing, I addressed the nit. PTAL

@felixge felixge requested a review from knusbaum June 29, 2021 13:24
Copy link
Contributor

@knusbaum knusbaum left a comment

Choose a reason for hiding this comment

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

LGTM. Looks like an improvement.

@felixge felixge merged commit 37b76b6 into v1 Jun 30, 2021
@felixge felixge deleted the felix.geisendoerfer/circle-ci-test-results branch June 30, 2021 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants