@@ -27,8 +27,10 @@ import (
2727)
2828
2929func init () {
30- if err := logging .SetLogLevel ("rpc" , "DEBUG" ); err != nil {
31- panic (err )
30+ if _ , exists := os .LookupEnv ("GOLOG_LOG_LEVEL" ); ! exists {
31+ if err := logging .SetLogLevel ("rpc" , "DEBUG" ); err != nil {
32+ panic (err )
33+ }
3234 }
3335
3436 debugTrace = true
@@ -497,15 +499,17 @@ func TestParallelRPC(t *testing.T) {
497499type CtxHandler struct {
498500 lk sync.Mutex
499501
500- cancelled bool
501- i int
502+ cancelled bool
503+ i int
504+ connectionType ConnectionType
502505}
503506
504507func (h * CtxHandler ) Test (ctx context.Context ) {
505508 h .lk .Lock ()
506509 defer h .lk .Unlock ()
507510 timeout := time .After (300 * time .Millisecond )
508511 h .i ++
512+ h .connectionType = GetConnectionType (ctx )
509513
510514 select {
511515 case <- timeout :
@@ -543,6 +547,9 @@ func TestCtx(t *testing.T) {
543547 if ! serverHandler .cancelled {
544548 t .Error ("expected cancellation on the server side" )
545549 }
550+ if serverHandler .connectionType != ConnectionTypeWS {
551+ t .Error ("wrong connection type" )
552+ }
546553
547554 serverHandler .cancelled = false
548555
@@ -564,6 +571,9 @@ func TestCtx(t *testing.T) {
564571 if serverHandler .cancelled || serverHandler .i != 2 {
565572 t .Error ("wrong serverHandler state" )
566573 }
574+ if serverHandler .connectionType != ConnectionTypeWS {
575+ t .Error ("wrong connection type" )
576+ }
567577
568578 serverHandler .lk .Unlock ()
569579 closer ()
@@ -598,6 +608,9 @@ func TestCtxHttp(t *testing.T) {
598608 if ! serverHandler .cancelled {
599609 t .Error ("expected cancellation on the server side" )
600610 }
611+ if serverHandler .connectionType != ConnectionTypeHTTP {
612+ t .Error ("wrong connection type" )
613+ }
601614
602615 serverHandler .cancelled = false
603616
@@ -619,6 +632,10 @@ func TestCtxHttp(t *testing.T) {
619632 if serverHandler .cancelled || serverHandler .i != 2 {
620633 t .Error ("wrong serverHandler state" )
621634 }
635+ // connection type should have switched to WS
636+ if serverHandler .connectionType != ConnectionTypeWS {
637+ t .Error ("wrong connection type" )
638+ }
622639
623640 serverHandler .lk .Unlock ()
624641 closer ()
@@ -1007,10 +1024,12 @@ func TestChanClientReceiveAll(t *testing.T) {
10071024}
10081025
10091026func TestControlChanDeadlock (t * testing.T ) {
1010- _ = logging .SetLogLevel ("rpc" , "error" )
1011- defer func () {
1012- _ = logging .SetLogLevel ("rpc" , "debug" )
1013- }()
1027+ if _ , exists := os .LookupEnv ("GOLOG_LOG_LEVEL" ); ! exists {
1028+ _ = logging .SetLogLevel ("rpc" , "error" )
1029+ defer func () {
1030+ _ = logging .SetLogLevel ("rpc" , "DEBUG" )
1031+ }()
1032+ }
10141033
10151034 for r := 0 ; r < 20 ; r ++ {
10161035 testControlChanDeadlock (t )
0 commit comments