Skip to content

Commit ec3cc62

Browse files
committed
Move tls handshake errors to debug
This turned out to be a much bigger undertaking due to how the logs are used in tests Signed-off-by: R.I.Pienaar <[email protected]>
1 parent e9ee2a0 commit ec3cc62

11 files changed

+125
-127
lines changed

server/client.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -5910,9 +5910,9 @@ func (c *client) doTLSHandshake(typ string, solicit bool, url *url.URL, tlsConfi
59105910

59115911
if err != nil {
59125912
if kind == CLIENT {
5913-
c.Errorf("TLS handshake error: %v", err)
5913+
c.Debugf("TLS handshake error: %v", err)
59145914
} else {
5915-
c.Errorf("TLS %s handshake error: %v", typ, err)
5915+
c.Debugf("TLS %s handshake error: %v", typ, err)
59165916
}
59175917
c.closeConnection(TLSHandshakeError)
59185918

server/client_test.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package server
1616
import (
1717
"bufio"
1818
"bytes"
19+
"crypto/tls"
1920
"encoding/json"
2021
"fmt"
2122
"io"
@@ -31,8 +32,6 @@ import (
3132
"testing"
3233
"time"
3334

34-
"crypto/tls"
35-
3635
"github.com/nats-io/jwt/v2"
3736
"github.com/nats-io/nats.go"
3837
"github.com/nats-io/nkeys"
@@ -2444,7 +2443,7 @@ func TestClientClampMaxSubsErrReport(t *testing.T) {
24442443
s1 := RunServer(o1)
24452444
defer s1.Shutdown()
24462445

2447-
l := &captureErrorLogger{errCh: make(chan string, 10)}
2446+
l := &captureLogger{logCh: make(chan string, 10)}
24482447
s1.SetLogger(l, false, false)
24492448

24502449
o2 := DefaultOptions()
@@ -2467,7 +2466,7 @@ func TestClientClampMaxSubsErrReport(t *testing.T) {
24672466
t.Helper()
24682467
for i := 0; i < 2; i++ {
24692468
select {
2470-
case errStr := <-l.errCh:
2469+
case errStr := <-l.logCh:
24712470
if i > 0 {
24722471
t.Fatalf("Should not have logged a second time: %s", errStr)
24732472
}

server/gateway_test.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -6675,7 +6675,7 @@ func TestGatewayDuplicateServerName(t *testing.T) {
66756675
oa1.Gateway.RejectUnknown = true
66766676
sa1 := RunServer(oa1)
66776677
defer sa1.Shutdown()
6678-
sa1l := &captureErrorLogger{errCh: make(chan string, 100)}
6678+
sa1l := &captureLogger{logCh: make(chan string, 100)}
66796679
sa1.SetLogger(sa1l, false, false)
66806680

66816681
oa2 := testGatewayOptionsFromToWithServers(t, "A", "B", sb1)
@@ -6685,7 +6685,7 @@ func TestGatewayDuplicateServerName(t *testing.T) {
66856685
oa2.Routes = RoutesFromStr(fmt.Sprintf("nats://127.0.0.1:%d", oa1.Cluster.Port))
66866686
sa2 := RunServer(oa2)
66876687
defer sa2.Shutdown()
6688-
sa2l := &captureErrorLogger{errCh: make(chan string, 100)}
6688+
sa2l := &captureLogger{logCh: make(chan string, 100)}
66896689
sa2.SetLogger(sa2l, false, false)
66906690

66916691
checkClusterFormed(t, sa1, sa2)
@@ -6707,7 +6707,7 @@ func TestGatewayDuplicateServerName(t *testing.T) {
67076707

67086708
// Since only servers from "A" have configured outbound to
67096709
// cluster "B", only servers on "A" are expected to report error.
6710-
for _, errCh := range []chan string{sa1l.errCh, sa2l.errCh} {
6710+
for _, errCh := range []chan string{sa1l.logCh, sa2l.logCh} {
67116711
checkForDupError(errCh)
67126712
}
67136713

@@ -6716,7 +6716,7 @@ func TestGatewayDuplicateServerName(t *testing.T) {
67166716
sa1.Shutdown()
67176717

67186718
// Drain the error channels
6719-
for _, errCh := range []chan string{sa1l.errCh, sa2l.errCh} {
6719+
for _, errCh := range []chan string{sa1l.logCh, sa2l.logCh} {
67206720
for done := false; !done; {
67216721
select {
67226722
case <-errCh:
@@ -6749,13 +6749,13 @@ func TestGatewayDuplicateServerName(t *testing.T) {
67496749
ob3.Routes = RoutesFromStr(fmt.Sprintf("nats://127.0.0.1:%d", ob2.Cluster.Port))
67506750
sb3 := RunServer(ob3)
67516751
defer sb3.Shutdown()
6752-
sb3l := &captureErrorLogger{errCh: make(chan string, 100)}
6752+
sb3l := &captureLogger{logCh: make(chan string, 100)}
67536753
sb3.SetLogger(sb3l, false, false)
67546754

67556755
checkClusterFormed(t, sb1, sb2, sb3)
67566756

67576757
// It should report the error when trying to create the GW connection
6758-
checkForDupError(sb3l.errCh)
6758+
checkForDupError(sb3l.logCh)
67596759

67606760
// Stop this node
67616761
sb3.Shutdown()
@@ -6772,12 +6772,12 @@ func TestGatewayDuplicateServerName(t *testing.T) {
67726772
oc.Accounts = []*Account{NewAccount("sys")}
67736773
sc := RunServer(oc)
67746774
defer sc.Shutdown()
6775-
scl := &captureErrorLogger{errCh: make(chan string, 100)}
6775+
scl := &captureLogger{logCh: make(chan string, 100)}
67766776
sc.SetLogger(scl, false, false)
67776777

67786778
// It should report the error when trying to create the GW connection
67796779
// to cluster "A"
6780-
checkForDupError(scl.errCh)
6780+
checkForDupError(scl.logCh)
67816781
}
67826782

67836783
func TestGatewayNoPanicOnStartupWithMonitoring(t *testing.T) {

server/jwt_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2560,7 +2560,7 @@ func TestJWTAccountImportWrongIssuerAccount(t *testing.T) {
25602560
defer s.Shutdown()
25612561
buildMemAccResolver(s)
25622562

2563-
l := &captureErrorLogger{errCh: make(chan string, 2)}
2563+
l := &captureLogger{logCh: make(chan string, 2)}
25642564
s.SetLogger(l, false, false)
25652565

25662566
okp, _ := nkeys.FromSeed(oSeed)

0 commit comments

Comments
 (0)