linkerd2/testutil
Alejandro Pedraza 2cd48bc488
Go test failure message wrappers to create GH Annotations (#4292)
* Go test failure message wrappers to create GH Annotations

First part of #4176

## Problem

Failures in go tests need to be properly formatted as Github annotations
so that we can fetch them through Github's API for aggregation and
analysis.

## Solution

A wrapper for error messages has been created in `testutil/annotations.go`.
The idea is that instead of throwing test failures like this:

```go
t.Failf("error retrieving data;\nExpected: %#v\nActual: %#v", expected,
actual)
```

We'd throw them like this:
```go
testutil.AnnotationFatalf("error retrieving data", "error retrieving data;\nExpected: %#v\nActual: %#v", expected,
actual)
```

That will continue reporting the error as before (when using `go test`
or another test runner), but as a side-effect it will also send to
stdout something like:

```
::error file=pkg/inject_test.go,line=133::error retrieving data
```
Which becomes a GH annotation, visible in the CI run summary screen.

The fist string art is used to have the GH annotation be a generic error message
that can be aggregated and counted across multiple test runs. If `testutil.Fatalf(str, args...)`
is called instead, the original error message will be used.

Note that that the output will be produced only when the env var
`GH_ANNOTATION` is set (which will when tests are triggered from a
Github Actions workflow).

Besides `testutil/annotation.go` and its accompanying unit test file,
other changes were made in other tests as examples, the plan being that
in a further PR _all_ the tests will use these wrappers.
2020-05-01 16:16:06 -05:00
..
annotations.go Go test failure message wrappers to create GH Annotations (#4292) 2020-05-01 16:16:06 -05:00
annotations_test.go Go test failure message wrappers to create GH Annotations (#4292) 2020-05-01 16:16:06 -05:00
doc.go Introduce script to test multiple cloud providers (#2592) 2019-03-29 16:22:30 -07:00
kubernetes_helper.go Update control-plane-namespace label (#4061) 2020-02-24 12:57:28 -08:00
stream.go Add integration tests for tap (#1152) 2018-06-19 14:05:36 -07:00
test_helper.go `linkerd uninstall` errors when attempting to delete PSP (#4234) 2020-04-07 11:01:11 -05:00