Skip to content

Commit

Permalink
upstream: imp more
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneOne1 committed Dec 12, 2022
1 parent e4a2374 commit 6c8b28c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions upstream/upstream_dot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ func TestUpstream_dnsOverTLS_race(t *testing.T) {
wg.Wait()
}

// TODO(e.burkov, a.garipov): Add to golibs and use here some kind of helper
// for type assertion of interface types.
func TestUpstream_dnsOverTLS_poolReconnect(t *testing.T) {
srv := startDoTServer(t, func(w dns.ResponseWriter, req *dns.Msg) {
resp := respondToTestMessage(req)
Expand Down Expand Up @@ -119,7 +121,8 @@ func TestUpstream_dnsOverTLS_poolReconnect(t *testing.T) {

// Now let's close the pooled connection.
conn := p.conns.Get()
usedConn = testutil.RequireTypeAssert[net.Conn](t, conn)
require.Implements(t, (*net.Conn)(nil), conn)
usedConn, _ = conn.(net.Conn)

require.NoError(t, usedConn.Close())

Expand All @@ -134,7 +137,7 @@ func TestUpstream_dnsOverTLS_poolReconnect(t *testing.T) {

// Now assert that the number of connections in the pool is not changed.
conn = p.conns.Get()
_ = testutil.RequireTypeAssert[net.Conn](t, conn)
require.Implements(t, (*net.Conn)(nil), conn)

require.Nil(t, p.conns.Get())
assert.NotSame(t, usedConn, conn)
Expand Down Expand Up @@ -174,7 +177,8 @@ func TestUpstream_dnsOverTLS_poolDeadline(t *testing.T) {

// Now let's get connection from the pool and use it again.
conn := p.conns.Get()
usedConn := testutil.RequireTypeAssert[net.Conn](t, conn)
require.Implements(t, (*net.Conn)(nil), conn)
usedConn := conn.(net.Conn)

response, err = p.exchangeWithConn(usedConn, req)
require.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion upstream/upstream_dot_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"golang.org/x/sys/windows"
)

// isConnBroken always returns false.
// isConnBroken returns true if err means that a connection is broken.
func isConnBroken(err error) (ok bool) {
return errors.Is(err, windows.WSAECONNABORTED)
}

0 comments on commit 6c8b28c

Please sign in to comment.