ooni / probe

OONI Probe network measurement tool for detecting internet censorship
https://ooni.org/install
BSD 3-Clause "New" or "Revised" License
750 stars 142 forks source link

qaenv_test.go:169: Get "https://www.example.com/": generic_timeout_error #2527

Closed bassosimone closed 10 months ago

bassosimone commented 10 months ago

In https://github.com/ooni/probe-cli/pull/1224, there is a test (TestQAEnv/we_can_hijack_HTTP3_requests) that fails with generic_timeout_error when executed along with other tests, but works when run alone. I have read the diff a couple of times and I do not fully understand why this error happens only when run along with other tests. Ideally, one would say that there is some state across calls that create issues. However, I do not see such a state in our code. So, I think probably the error we have here is something subtle. Because having this test WAI is not a priority now, I am going to document the bug and mark the test as one that should be skipped. I will eventually figure out what is wrong here.

bassosimone commented 10 months ago

Uh, I did not notice it initially, but the logs also contain this error:

--- FAIL: TestHTTP3ServerFactory (7.68s)
    --- FAIL: TestHTTP3ServerFactory/when_using_an_incompatible_TLS_config (6.67s)
        http3_test.go:73: unexpected error generic_timeout_error
2023/09/04 19:37:58 http: TLS handshake error from 130.192.91.211:27865: EOF
2023/09/04 19:37:59  info TH_HANDLER      <#1> DNSLookup www.example.com... ok
2023/09/04 19:37:59  info TH_HANDLER      <#1> TCPConnect 93.184.216.34:443 EnableTLS=true SNI=www.example.com... ok
2023/09/04 19:37:59  info TH_HANDLER      <#1> GET https://www.example.com/... ok
2023/09/04 19:37:59  info TH_HANDLER      <#1> QUICConnect 93.184.216.34:443 SNI=www.example.com... in progress
2023/09/04 19:37:59  info TH_HANDLER      <#1> GET https://www.example.com:443... in progress
2023/09/04 19:38:04  info TH_HANDLER      <#1> QUICConnect 93.184.216.34:443 SNI=www.example.com... generic_timeout_error
2023/09/04 19:38:04  info TH_HANDLER      <#1> GET https://www.example.com:443... Get "[https://www.example.com:443](https://www.example.com/)": generic_timeout_error
--- FAIL: TestOOHelperDHandler (5.83s)
    oohelperd_test.go:123:   &model.THResponse{
            TCPConnect:   {"93.184.216.34:443": {Status: true}},
            TLSHandshake: {"93.184.216.34:443": {ServerName: "www.example.com", Status: true}},
            QUICHandshake: map[string]model.THTLSHandshakeResult{
                "93.184.216.34:443": {
                    ServerName: "www.example.com",
        -           Status:     true,
        +           Status:     false,
        -           Failure:    nil,
        +           Failure:    &"generic_timeout_error",
                },
            },
            HTTPRequest: {BodyLength: 194, DiscoveredH3Endpoint: "www.example.com:443", Title: "Default Web Page", Headers: {"Alt-Svc": `h3=":443"`, "Content-Length": "194", "Content-Type": "text/html; charset=utf-8", "Date": "Thu, 24 Aug 2023 14:35:29 GMT"}, ...},
            HTTP3Request: &model.THHTTPRequestResult{
        -       BodyLength:           194,
        +       BodyLength:           -1,
                DiscoveredH3Endpoint: "",
        -       Failure:              nil,
        +       Failure:              &"generic_timeout_error",
        -       Title:                "Default Web Page",
        +       Title:                "",
                Headers: map[string]string{
        -           "Alt-Svc":      `h3=":443"`,
        -           "Content-Type": "text/html; charset=utf-8",
        -           "Date":         "Thu, 24 Aug 2023 14:35:29 GMT",
                },
        -       StatusCode: 200,
        +       StatusCode: -1,
            },
            DNS:    {Addrs: {"93.184.216.34"}},
            IPInfo: {"93.184.216.34": &{ASN: 15133, Flags: 10}},
          }

2023/09/04 19:38:12 http: TLS handshake error from 130.192.91.211:52167: use of closed network connection
--- FAIL: TestQAEnv (9.25s)
    --- FAIL: TestQAEnv/we_can_hijack_HTTP3_requests (5.57s)
        qaenv_test.go:169: Get "https://www.example.com/": generic_timeout_error

So, another QUIC based test (TestOOHelperDHandler, checking oohelperd for HTTP/3) fails with timeout just because I have added another test using the same endpoint. This is certainly quite strange and unexpected 😅.

bassosimone commented 10 months ago

So, apparently I need to disable all the new tests I have added. One strange "thing" is that I can also make tests work if I am using different IP addresses for different tests (see https://github.com/ooni/probe-cli/pull/1224/commits/3145e55d5f83421f72a32710bb34e1b17d5865d2). I think I should discuss this issue with @kelmenhorst. For now, I think it's ~fine to merge the code with the ASCII ART "WTF" and tests working as intended notwithstanding the need to use different IP addresses to make it work. The issue should still be open, though.