solo-io / go-utils

golang utilities
Apache License 2.0
110 stars 18 forks source link

Test-utils should make getting http response code easier #328

Closed kdorosh closed 4 years ago

kdorosh commented 4 years ago

We've had regression tests pass that shouldn't have passed, e.g. the following rate limit test (looking for response code 429):

"Fri, 25 Oct 2019 13:51:10 EDT: github.com/solo-io/solo-projects/vendor/github.com/solo-io/go-utils/testutils/helper/curl.go:163"   running: "curl -v --connect-timeout 10 --max-time 10 -H Host: gateway-proxy-v2 http://gateway-proxy-v2:80/test"
"Fri, 25 Oct 2019 13:51:11 EDT: github.com/solo-io/solo-projects/vendor/github.com/solo-io/go-utils/testutils/helper/curl.go:163"   running: "curl -v --connect-timeout 10 --max-time 10 -H Host: gateway-proxy-v2 http://gateway-proxy-v2:80/test"
"Fri, 25 Oct 2019 13:51:12 EDT: github.com/solo-io/solo-projects/vendor/github.com/solo-io/go-utils/testutils/helper/curl.go:163"   running: "curl -v --connect-timeout 10 --max-time 10 -H Host: gateway-proxy-v2 http://gateway-proxy-v2:80/test"
Fri, 25 Oct 2019 13:51:13 EDT: reflect/value.go:460 success: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html>
<title>Directory listing for /</title>
<body>
<h2>Directory listing for /</h2>
<hr>
<ul>
<li><a href="bin/">bin/</a>
<li><a href="pkg/">pkg/</a>
<li><a href="protoc-3.3.0-linux-x86_64.zip">protoc-3.3.0-linux-x86_64.zip</a>
<li><a href="protoc3/">protoc3/</a>
<li><a href="src/">src/</a>
</ul>
<hr>
</body>
</html>
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*   Trying 10.15.255.253...
* TCP_NODELAY set
* Connected to gateway-proxy-v2 (10.15.255.253) port 80 (#0)
> GET /test HTTP/1.1
> Host: gateway-proxy-v2
> User-Agent: curl/7.52.1
> Accept: */*
> 
< HTTP/1.1 200 OK
< server: envoy
< date: Fri, 25 Oct 2019 17:51:13 GMT
< content-type: text/html; charset=ANSI_X3.4-1968
< content-length: 376
< x-envoy-upstream-service-time: 1
< 
{ [376 bytes data]
* Curl_http_done: called premature == 0
100   376  100   376    0     0  24290      0 --:--:-- --:--:-- --:--:-- 25066
* Connection #0 to host gateway-proxy-v2 left intact

------------------------------
• [SLOW TEST:50.075 seconds]
RateLimit tests
/Users/kdorosh/go/src/github.com/solo-io/solo-projects/test/regressions/gateway/ratelimit_test.go:32
  raw rate limit
  /Users/kdorosh/go/src/github.com/solo-io/solo-projects/test/regressions/gateway/ratelimit_test.go:116
    can rate limit to upstream vhost
    /Users/kdorosh/go/src/github.com/solo-io/solo-projects/test/regressions/gateway/ratelimit_test.go:157
------------------------------
SSSSSSSSSSSS"Fri, 25 Oct 2019 13:51:29 EDT: github.com/solo-io/solo-projects/vendor/github.com/solo-io/go-utils/testutils/helper/install.go:198"    uninstalling gloo...

Ran 1 of 16 Specs in 216.489 seconds
SUCCESS! -- 1 Passed | 0 Failed | 0 Pending | 15 Skipped
PASS | FOCUSED

Notice that the response code is 200, yet the test passed because (by chance) the return string had 429 within it.

kdorosh commented 4 years ago

Also, it shouldn't take 5 minutes for these tests to get the desired response code -- these high timeouts likely only further exasperated the problem.

kdorosh commented 4 years ago

closing issue to open in closed-source, we can just be better about the substrings we send to the helper