elastic / elastic-agent

Elastic Agent - single, unified way to add monitoring for logs, metrics, and other types of data to a host.
Other
22 stars 144 forks source link

[Flaky Test]: TestHTTPSProxy – data race #5869

Closed mauri870 closed 3 weeks ago

mauri870 commented 1 month ago

Failing test case

TestHTTPSProxy

Error message

data race

Build

https://buildkite.com/elastic/elastic-agent/builds/13456#0192d3f2-11d6-4f7e-a646-9e5c48fa8463

OS

Mac

Stacktrace and notes

This was introduced in https://github.com/elastic/elastic-agent/pull/5802.

PASS
==================
WARNING: DATA RACE
Read at 0x00c00007c863 by goroutine 80:
  testing.(*common).logDepth()
      /Users/admin/.gvm/versions/go1.22.8.darwin.amd64/src/testing/testing.go:1017 +0xcd
  testing.(*common).log()
      /Users/admin/.gvm/versions/go1.22.8.darwin.amd64/src/testing/testing.go:1010 +0xa4
  testing.(*common).Logf()
      /Users/admin/.gvm/versions/go1.22.8.darwin.amd64/src/testing/testing.go:1061 +0x6a
  testing.(*common).Logf-fm()
      <autogenerated>:1 +0x69
  github.com/elastic/elastic-agent/testing/proxytest.prepareMTLSProxyAndTargetServer.WithRequestLog.func3.1()
      /Users/admin/builds/bk-agent-prod-orka-1730132740729123083/elastic/elastic-agent/testing/proxytest/proxytest.go:100 +0xc3
  github.com/elastic/elastic-agent/testing/proxytest.New.func2()
      /Users/admin/builds/bk-agent-prod-orka-1730132740729123083/elastic/elastic-agent/testing/proxytest/proxytest.go:191 +0x75c
  net/http.HandlerFunc.ServeHTTP()
      /Users/admin/.gvm/versions/go1.22.8.darwin.amd64/src/net/http/server.go:2171 +0x47
  net/http.serverHandler.ServeHTTP()
      /Users/admin/.gvm/versions/go1.22.8.darwin.amd64/src/net/http/server.go:3142 +0x2a1
  net/http.(*conn).serve()
      /Users/admin/.gvm/versions/go1.22.8.darwin.amd64/src/net/http/server.go:2044 +0x13c4
  net/http.(*Server).Serve.gowrap3()
      /Users/admin/.gvm/versions/go1.22.8.darwin.amd64/src/net/http/server.go:3290 +0x4f

Previous write at 0x00c00007c863 by goroutine 57:
  testing.tRunner.func1()
      /Users/admin/.gvm/versions/go1.22.8.darwin.amd64/src/testing/testing.go:1676 +0x8fa
  runtime.deferreturn()
      /Users/admin/.gvm/versions/go1.22.8.darwin.amd64/src/runtime/panic.go:602 +0x5d
  testing.(*T).Run.gowrap1()
      /Users/admin/.gvm/versions/go1.22.8.darwin.amd64/src/testing/testing.go:1742 +0x44

Goroutine 80 (running) created at:
  net/http.(*Server).Serve()
      /Users/admin/.gvm/versions/go1.22.8.darwin.amd64/src/net/http/server.go:3290 +0x8ec
  net/http/httptest.(*Server).goServe.func1()
      /Users/admin/.gvm/versions/go1.22.8.darwin.amd64/src/net/http/httptest/server.go:310 +0xbb

Goroutine 57 (finished) created at:
  testing.(*T).Run()
      /Users/admin/.gvm/versions/go1.22.8.darwin.amd64/src/testing/testing.go:1742 +0x825
  testing.runTests.func1()
      /Users/admin/.gvm/versions/go1.22.8.darwin.amd64/src/testing/testing.go:2161 +0x85
  testing.tRunner()
      /Users/admin/.gvm/versions/go1.22.8.darwin.amd64/src/testing/testing.go:1689 +0x21e
  testing.runTests()
      /Users/admin/.gvm/versions/go1.22.8.darwin.amd64/src/testing/testing.go:2159 +0x8be
  testing.(*M).Run()
      /Users/admin/.gvm/versions/go1.22.8.darwin.amd64/src/testing/testing.go:2027 +0xf17
  main.main()
      _testmain.go:83 +0x2e4
==================
2024/10/28 09:53:50 http: panic serving 127.0.0.1:49616: Log in goroutine after TestHTTPSProxy has completed: [proxy-https] [fbe7a5aa-a511-46e1-9e3a-c78c7ebb6bb1] DONE 0 - CONNECT //any.not.target.will.do:443 HTTP/1.1 127.0.0.1:49616

goroutine 62 [running]:
net/http.(*conn).serve.func1()
    /Users/admin/.gvm/versions/go1.22.8.darwin.amd64/src/net/http/server.go:1903 +0x10a
panic({0x66cb3c0?, 0xc00002e380?})
    /Users/admin/.gvm/versions/go1.22.8.darwin.amd64/src/runtime/panic.go:770 +0x132
testing.(*common).logDepth(0xc00007c820, {0xc0000d6900, 0x7c}, 0x3)
    /Users/admin/.gvm/versions/go1.22.8.darwin.amd64/src/testing/testing.go:1028 +0x6d4
testing.(*common).log(...)
    /Users/admin/.gvm/versions/go1.22.8.darwin.amd64/src/testing/testing.go:1010
testing.(*common).Logf(0xc00007c820, {0xc0000d6880, 0x7c}, {0x0, 0x0, 0x0})
    /Users/admin/.gvm/versions/go1.22.8.darwin.amd64/src/testing/testing.go:1061 +0xa5
github.com/elastic/elastic-agent/testing/proxytest.prepareMTLSProxyAndTargetServer.WithRequestLog.func3.1({0xc0000922a0, 0x6e}, {0x0, 0x0, 0x0})
    /Users/admin/builds/bk-agent-prod-orka-1730132740729123083/elastic/elastic-agent/testing/proxytest/proxytest.go:100 +0xc4
github.com/elastic/elastic-agent/testing/proxytest.New.func2({0x674c0a8, 0xc00029e1c0}, 0xc00029a120)
    /Users/admin/builds/bk-agent-prod-orka-1730132740729123083/elastic/elastic-agent/testing/proxytest/proxytest.go:191 +0x75d
net/http.HandlerFunc.ServeHTTP(0xc000164a20, {0x674c0a8, 0xc00029e1c0}, 0xc00029a120)
    /Users/admin/.gvm/versions/go1.22.8.darwin.amd64/src/net/http/server.go:2171 +0x48
net/http.serverHandler.ServeHTTP({0xc0001da780?}, {0x674c0a8, 0xc00029e1c0}, 0xc00029a120)
    /Users/admin/.gvm/versions/go1.22.8.darwin.amd64/src/net/http/server.go:3142 +0x2a2
net/http.(*conn).serve(0xc00028c000, {0x674c5f8, 0xc0001da630})
    /Users/admin/.gvm/versions/go1.22.8.darwin.amd64/src/net/http/server.go:2044 +0x13c5
created by net/http.(*Server).Serve in goroutine 13
    /Users/admin/.gvm/versions/go1.22.8.darwin.amd64/src/net/http/server.go:3290 +0x8ed
coverage: 79.4% of statements
Found 1 data race(s)
FAIL    github.com/elastic/elastic-agent/testing/proxytest  2.313s
elasticmachine commented 1 month ago

Pinging @elastic/elastic-agent (Team:Elastic-Agent)

AndersonQ commented 3 weeks ago

another instance of it https://buildkite.com/elastic/elastic-agent/builds/13765#0192fdb5-79d6-47c1-8e6c-6e195ac1d1f2 reopening the issue