ingress-nginx-helm/internal/ingress
Thibault Jamet 27a98f2920
Fix race condition in metric process collector test
There was a goroutine started to log things upon a test that could be
ended at the time `cmd.Wait()` ends.

To solve the problem, when the sub-test ends, ensure we wait until the
command ends when ending the test

The output of `make test` before the fix shows:

```
=== RUN   TestNewUDPLogListener
==================
WARNING: DATA RACE
Read at 0x00c0002a8643 by goroutine 74:
  testing.(*common).logDepth()
      /usr/local/go/src/testing/testing.go:629 +0x132
  testing.(*common).Logf()
      /usr/local/go/src/testing/testing.go:614 +0x90
  k8s.io/ingress-nginx/internal/ingress/metric/collectors.TestProcessCollector.func1.1()
      /go/src/k8s.io/ingress-nginx/internal/ingress/metric/collectors/process_test.go:54 +0x140

Previous write at 0x00c0002a8643 by goroutine 72:
  testing.tRunner.func1()
      /usr/local/go/src/testing/testing.go:856 +0x33e
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:869 +0x17f

Goroutine 74 (running) created at:
  k8s.io/ingress-nginx/internal/ingress/metric/collectors.TestProcessCollector.func1()
      /go/src/k8s.io/ingress-nginx/internal/ingress/metric/collectors/process_test.go:50 +0x218
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:865 +0x163

Goroutine 72 (finished) created at:
  testing.(*T).Run()
      /usr/local/go/src/testing/testing.go:916 +0x699
  testing.runTests.func1()
      /usr/local/go/src/testing/testing.go:1157 +0xa8
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:865 +0x163
  testing.runTests()
      /usr/local/go/src/testing/testing.go:1155 +0x523
  testing.(*M).Run()
      /usr/local/go/src/testing/testing.go:1072 +0x2eb
  main.main()
      _testmain.go:52 +0x222
==================
--- PASS: TestNewUDPLogListener (0.00s)
```

after the patch:

```
=== RUN   TestNewUDPLogListener
--- PASS: TestNewUDPLogListener (0.01s)
```

Change-Id: I8ea246d14f5f80b330be19dd5b8299c6762f6d6b
2019-03-04 21:54:42 +01:00
..
annotations Remove session-cookie-hash annotation 2019-03-04 10:34:48 -05:00
controller Remove session-cookie-hash annotation 2019-03-04 10:34:48 -05:00
defaults fix: rename proxy-buffer-number to proxy-buffers-number 2019-02-22 10:21:17 +08:00
errors implement canary annotation and alternative backends 2018-11-06 13:13:14 -05:00
metric Fix race condition in metric process collector test 2019-03-04 21:54:42 +01:00
resolver Add e2e Tests for AuthTLS 2018-10-18 20:09:21 -05:00
status fix status updated: make sure ingress.status is copied 2018-12-17 16:19:02 +04:00
sslcert.go Add dynamic certificate feature to controller 2018-08-16 20:19:33 -04:00
sslcert_test.go Sync secrets (SSL certificates) on events 2018-04-13 16:14:29 +02:00
type_equals_test.go Rename package pkg to internal 2017-11-11 14:53:44 -03:00
types.go Remove session-cookie-hash annotation 2019-03-04 10:34:48 -05:00
types_equals.go Remove session-cookie-hash annotation 2019-03-04 10:34:48 -05:00
zz_generated.deepcopy.go Update generated code 2018-01-07 12:06:44 -03:00