dunglas / vulcain

🔨 Fast and idiomatic client-driven REST APIs.
https://vulcain.rocks
GNU Affero General Public License v3.0
3.5k stars 106 forks source link

Flaky test #116

Open dunglas opened 1 year ago

dunglas commented 1 year ago

Enabling the race detector in tests sometimes breaks the test suite:

Run go test -race -covermode atomic -coverprofile=cover.out github.com/dunglas/vulcain
2023-08-03T13:24:26.605Z    INFO    vulcain/server.go:155   vulcain started {"protocol": "https", "addr": "127.0.0.1:4343"}
127.0.0.1 - - [03/Aug/2023:13:24:26 +0000] "GET /forwarded HTTP/2.0" 200 84 "" "Go-http-client/2.0"
2023-08-03T13:24:27.725Z    INFO    vulcain/server.go:155   vulcain started {"protocol": "https", "addr": "127.0.0.1:4343"}
2023-08-03T13:24:27.759Z    DEBUG   vulcain/vulcain.go:244  link preload header added   {"relation": "/books/1.jsonld?preload=%22%2Fauthor%22"}
2023-08-03T13:24:27.759Z    DEBUG   vulcain/vulcain.go:288  failed to push  {"node": "/hydra:member/*", "relation": "/books/1.jsonld?preload=%22%2Fauthor%22", "error": "feature not supported"}
2023-08-03T13:24:27.759Z    DEBUG   vulcain/vulcain.go:244  link preload header added   {"relation": "/books/2.jsonld?preload=%22%2Fauthor%22"}
2023-08-03T13:24:27.759Z    DEBUG   vulcain/vulcain.go:288  failed to push  {"node": "/hydra:member/*", "relation": "/books/2.jsonld?preload=%22%2Fauthor%22", "error": "feature not supported"}
127.0.0.1 - - [03/Aug/2023:13:24:27 +0000] "GET /books.jsonld?fields=\"/hydra:member/*\"&preload=\"/hydra:member/*/author\" HTTP/2.0" 200 102 "" "Go-http-client/2.0"
2023-08-03T13:24:28.811Z    INFO    vulcain/server.go:155   vulcain started {"protocol": "https", "addr": "127.0.0.1:4343"}
2023-08-03T13:24:28.839Z    DEBUG   vulcain/vulcain.go:244  link preload header added   {"relation": "/authors/1.jsonld"}
2023-08-03T13:24:28.839Z    DEBUG   vulcain/vulcain.go:288  failed to push  {"node": "/author", "relation": "/authors/1.jsonld", "error": "feature not supported"}
2023-08-03T13:24:28.839Z    DEBUG   vulcain/vulcain.go:244  link preload header added   {"relation": "/books/99.jsonld"}
2023-08-03T13:24:28.840Z    DEBUG   vulcain/vulcain.go:288  failed to push  {"node": "/related", "relation": "/books/99.jsonld", "error": "feature not supported"}
127.0.0.1 - - [03/Aug/2023:13:24:28 +0000] "GET /books/1.jsonld HTTP/2.0" 200 59 "" "Go-http-client/2.0"
2023-08-03T13:24:29.906Z    INFO    vulcain/server.go:155   vulcain started {"protocol": "https", "addr": "127.0.0.1:4343"}
127.0.0.1 - - [03/Aug/2023:13:24:30 +0000] "GET /books.jsonld?fields=%22/hydra:member/*/author%22 HTTP/2.0" 200 100 "" "Symfony HttpClient/Amp"
127.0.0.1 - - [03/Aug/2023:13:24:30 +0000] "GET /books/1.jsonld?fields=%22%2Fauthor%22 HTTP/2.0" 200 30 "" "Symfony HttpClient/Amp"
2023-08-03T13:24:30.274Z    DEBUG   vulcain/pusher.go:134   pusher not found    {"url": "/books.jsonld", "explicitRequestID": "attack"}
127.0.0.1 - - [03/Aug/2023:13:24:30 +0000] "GET /books.jsonld HTTP/2.0" 200 54 "" "Symfony HttpClient/Amp"
127.0.0.1 - - [03/Aug/2023:13:24:30 +0000] "GET /books/1.jsonld HTTP/2.0" 200 30 "" "Symfony HttpClient/Amp"
2023-08-03T13:24:30.473Z    DEBUG   vulcain/vulcain.go:293  relation pushed {"relation": "/books/1.jsonld?preload=%22%2Fauthor%22"}
2023-08-03T13:24:30.474Z    DEBUG   vulcain/vulcain.go:293  relation pushed {"relation": "/books/2.jsonld?preload=%22%2Fauthor%22"}
127.0.0.1 - - [03/Aug/2023:13:24:30 +0000] "GET /books/2.jsonld?preload=%22%2Fauthor%22 HTTP/2.0" 200 145 "" "Symfony HttpClient/Amp"
2023-08-03T13:24:30.476Z    DEBUG   vulcain/vulcain.go:293  relation pushed {"relation": "/authors/1.jsonld"}
127.0.0.1 - - [03/Aug/2023:13:24:30 +0000] "GET /books/1.jsonld?preload=%22%2Fauthor%22 HTTP/2.0" 200 145 "" "Symfony HttpClient/Amp"
127.0.0.1 - - [03/Aug/2023:13:24:30 +0000] "GET /books.jsonld?preload=%22/hydra:member/*/author%22 HTTP/2.0" 200 256 "" "Symfony HttpClient/Amp"
127.0.0.1 - - [03/Aug/2023:13:24:30 +0000] "GET /authors/1.jsonld HTTP/2.0" 200 51 "" "Symfony HttpClient/Amp"
2023-08-03T13:24:30.672Z    DEBUG   vulcain/vulcain.go:293  relation pushed {"relation": "/books/1.jsonld"}
2023-08-03T13:24:30.673Z    DEBUG   vulcain/vulcain.go:293  relation pushed {"relation": "/books/2.jsonld"}
127.0.0.1 - - [03/Aug/2023:13:24:30 +0000] "GET /books/2.jsonld HTTP/2.0" 200 145 "" "Symfony HttpClient/Amp"
2023-08-03T13:24:30.674Z    DEBUG   vulcain/vulcain.go:293  relation pushed {"relation": "/authors/1.jsonld"}
127.0.0.1 - - [03/Aug/2023:13:24:30 +0000] "GET /books/1.jsonld HTTP/2.0" 200 145 "" "Symfony HttpClient/Amp"
127.0.0.1 - - [03/Aug/2023:13:24:30 +0000] "GET /authors/1.jsonld HTTP/2.0" 200 51 "" "Symfony HttpClient/Amp"
127.0.0.1 - - [03/Aug/2023:13:24:30 +0000] "GET /books.jsonld HTTP/2.0" 200 208 "" "Symfony HttpClient/Amp"
2023-08-03T13:24:30.861Z    DEBUG   vulcain/vulcain.go:293  relation pushed {"relation": "/books/1.jsonld?fields=%22%2Fauthor%22&preload=%22%2Fauthor%22"}
2023-08-03T13:24:30.861Z    DEBUG   vulcain/vulcain.go:293  relation pushed {"relation": "/books/2.jsonld?fields=%22%2Fauthor%22&preload=%22%2Fauthor%22"}
127.0.0.1 - - [03/Aug/2023:13:24:30 +0000] "GET /books/2.jsonld?fields=%22%2Fauthor%22&preload=%22%2Fauthor%22 HTTP/2.0" 200 30 "" "Symfony HttpClient/Amp"
2023-08-03T13:24:30.862Z    DEBUG   vulcain/vulcain.go:293  relation pushed {"relation": "/authors/1.jsonld"}
127.0.0.1 - - [03/Aug/2023:13:24:30 +0000] "GET /books/1.jsonld?fields=%22%2Fauthor%22&preload=%22%2Fauthor%22 HTTP/2.0" 200 30 "" "Symfony HttpClient/Amp"
127.0.0.1 - - [03/Aug/2023:13:24:30 +0000] "GET /authors/1.jsonld HTTP/2.0" 200 51 "" "Symfony HttpClient/Amp"
127.0.0.1 - - [03/Aug/2023:13:24:30 +0000] "GET /books.jsonld?fields=%22/hydra:member/*/author%22&preload=%22/hydra:member/*/author%22 HTTP/2.0" 200 158 "" "Symfony HttpClient/Amp"
127.0.0.1 - - [03/Aug/2023:13:24:30 +0000] "GET /books/1.jsonld?fields=%22%2Fauthor%22 HTTP/2.0" 200 30 "" "Symfony HttpClient/Amp"
2023-08-03T13:24:31.055Z    DEBUG   vulcain/vulcain.go:293  relation pushed {"relation": "/books/1.jsonld"}
2023-08-03T13:24:31.055Z    DEBUG   vulcain/vulcain.go:293  relation pushed {"relation": "/books/2.jsonld"}
  net/http.(*http2serverConn).startPush.func1.1()
      /opt/hostedtoolcache/go/1.20.6/x64/src/net/http/h2_bundle.go:6889 +0x64

Goroutine 310 (running) created at:
  net/http.(*http2serverConn).processHeaders()
      /opt/hostedtoolcache/go/1.20.6/x64/src/net/http/h2_bundle.go:5762 +0xdf5
  net/http.(*http2serverConn).processFrame()
      /opt/hostedtoolcache/go/1.20.6/x64/src/net/http/h2_bundle.go:5262 +0x45e
  net/http.(*http2serverConn).processFrameFromReader()
      /opt/hostedtoolcache/go/1.20.6/x64/src/net/http/h2_bundle.go:5205 +0x2ed
  net/http.(*http2serverConn).serve()
      /opt/hostedtoolcache/go/1.20.6/x64/src/net/http/h2_bundle.go:4694 +0x15d5
  net/http.(*http2Server).ServeConn()
      /opt/hostedtoolcache/go/1.20.6/x64/src/net/http/h2_bundle.go:4270 +0x1804
  net/http.http2ConfigureServer.func1()
      /opt/hostedtoolcache/go/1.20.6/x64/src/net/http/h2_bundle.go:4060 +0x124
  net/http.(*conn).serve()
      /opt/hostedtoolcache/go/1.20.6/x64/src/net/http/server.go:1903 +0x1c41
  net/http.(*Server).Serve.func3()
      /opt/hostedtoolcache/go/1.20.6/x64/src/net/http/server.go:3089 +0x58

Goroutine 317 (running) created at:
  net/http.(*http2serverConn).startPush.func1()
      /opt/hostedtoolcache/go/1.20.6/x64/src/net/http/h2_bundle.go:6889 +0x8d5
  net/http.(*http2serverConn).startFrameWrite()
      /opt/hostedtoolcache/go/1.20.6/x64/src/net/http/h2_bundle.go:4984 +0x219
  net/http.(*http2serverConn).scheduleFrameWrite()
      /opt/hostedtoolcache/go/1.20.6/x64/src/net/http/h2_bundle.go:5102 +0x3c8
  net/http.(*http2serverConn).writeFrame()
      /opt/hostedtoolcache/go/1.20.6/x64/src/net/http/h2_bundle.go:4955 +0x3c7
  net/http.(*http2serverConn).startPush()
      /opt/hostedtoolcache/go/1.20.6/x64/src/net/http/h2_bundle.go:6893 +0x491
  net/http.(*http2serverConn).serve()
      /opt/hostedtoolcache/go/1.20.6/x64/src/net/http/h2_bundle.go:4725 +0x12a9
  net/http.(*http2Server).ServeConn()
      /opt/hostedtoolcache/go/1.20.6/x64/src/net/http/h2_bundle.go:4270 +0x1804
  net/http.http2ConfigureServer.func1()
      /opt/hostedtoolcache/go/1.20.6/x64/src/net/http/h2_bundle.go:4060 +0x124
  net/http.(*conn).serve()
      /opt/hostedtoolcache/go/1.20.6/x64/src/net/http/server.go:1903 +0x1c41
  net/http.(*Server).Serve.func3()
      /opt/hostedtoolcache/go/1.20.6/x64/src/net/http/server.go:3089 +0x58
==================
2023-08-03T13:24:31.252Z    DEBUG   vulcain/vulcain.go:293  relation pushed {"relation": "/authors/1.jsonld"}
2023-08-03T13:24:31.254Z    DEBUG   vulcain/vulcain.go:244  link preload header added   {"relation": "/books/2.jsonld"}
127.0.0.1 - - [03/Aug/2023:13:24:31 +0000] "GET /books/1.jsonld HTTP/2.0" 200 145 "" "Symfony HttpClient/Amp"
2023-08-03T13:24:31.254Z    DEBUG   vulcain/vulcain.go:288  failed to push  {"node": "/hydra:member/*", "relation": "/books/2.jsonld", "error": "Maximum allowed pushes (2) reached"}
127.0.0.1 - - [03/Aug/2023:13:24:31 +0000] "GET /authors/1.jsonld HTTP/2.0" 200 51 "" "Symfony HttpClient/Amp"
127.0.0.1 - - [03/Aug/2023:13:24:31 +0000] "GET /books.jsonld HTTP/2.0" 200 208 "" "Symfony HttpClient/Amp"
--- FAIL: TestH2PushLimit (0.20s)
    testing.go:1446: race detected during execution of test
2023-08-03T13:24:31.276Z    INFO    vulcain/server.go:155   vulcain started {"protocol": "https", "addr": "127.0.0.1:4343"}
2023-08-03T13:24:31.458Z    DEBUG   vulcain/vulcain.go:293  relation pushed {"relation": "/oa/books/1"}
2023-08-03T13:24:31.459Z    DEBUG   vulcain/vulcain.go:293  relation pushed {"relation": "/oa/books/2"}
127.0.0.1 - - [03/Aug/2023:13:24:31 +0000] "GET /oa/books/1 HTTP/2.0" 200 77 "" "Symfony HttpClient/Amp"
127.0.0.1 - - [03/Aug/2023:13:24:31 +0000] "GET /oa/books/2 HTTP/2.0" 200 77 "" "Symfony HttpClient/Amp"
127.0.0.1 - - [03/Aug/2023:13:24:31 +0000] "GET /oa/books.json HTTP/2.0" 200 28 "" "Symfony HttpClient/Amp"
{"level":"error","ts":1691069071.5171943,"caller":"vulcain/server.go:89","msg":"http: proxy error","error":"dial tcp: lookup test.invalid on 127.0.0.53:53: no such host","stacktrace":"github.com/dunglas/vulcain.(*server).ServeHTTP.func3\n\t/home/runner/work/vulcain/vulcain/server.go:89\nnet/http/httputil.(*ReverseProxy).ServeHTTP\n\t/opt/hostedtoolcache/go/1.20.6/x64/src/net/http/httputil/reverseproxy.go:475\ngithub.com/dunglas/vulcain.(*server).ServeHTTP\n\t/home/runner/work/vulcain/vulcain/server.go:102\nnet/http.serverHandler.ServeHTTP\n\t/opt/hostedtoolcache/go/1.20.6/x64/src/net/http/server.go:2936\nnet/http.(*conn).serve\n\t/opt/hostedtoolcache/go/1.20.6/x64/src/net/http/server.go:1995"}
FAIL
    github.com/dunglas/vulcain  coverage: 93.5% of statements
FAIL    github.com/dunglas/vulcain  4.980s