test(httpclient): avoid race condition in TimeoutIsEnforced

Digging through net/http and squinting my eyes, it looks as though even when our deadline has passed the error we receive is not guaranteed to contain the word "timeout"

Instead we should try using netErr.Timeout() directly to determine if a timeout occurred.

# With MR changes
> go test ./httpclient/... -run TestClient_TimeoutIsEnforced -count 100
ok  	gitlab.com/gitlab-org/labkit/v2/httpclient	50.406s

# Previous master
> go test ./httpclient/... -run TestClient_TimeoutIsEnforced -count 100
--- FAIL: TestClient_TimeoutIsEnforced (0.50s)
    client_test.go:231: 
        	Error Trace:	/Users/lukehollinda/work/labkit/v2/httpclient/client_test.go:231
        	Error:      	"get \"http://127.0.0.1:53378\": context deadline exceeded" does not contain "timeout"
        	Test:       	TestClient_TimeoutIsEnforced
        	Messages:   	error should indicate timeout
FAIL
FAIL	gitlab.com/gitlab-org/labkit/v2/httpclient	50.557s

Merge request reports

Loading
Loading