@@ -27,8 +27,10 @@ import (
27
27
)
28
28
29
29
func 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
+ }
32
34
}
33
35
34
36
debugTrace = true
@@ -497,15 +499,17 @@ func TestParallelRPC(t *testing.T) {
497
499
type CtxHandler struct {
498
500
lk sync.Mutex
499
501
500
- cancelled bool
501
- i int
502
+ cancelled bool
503
+ i int
504
+ connectionType ConnectionType
502
505
}
503
506
504
507
func (h * CtxHandler ) Test (ctx context.Context ) {
505
508
h .lk .Lock ()
506
509
defer h .lk .Unlock ()
507
510
timeout := time .After (300 * time .Millisecond )
508
511
h .i ++
512
+ h .connectionType = GetConnectionType (ctx )
509
513
510
514
select {
511
515
case <- timeout :
@@ -543,6 +547,9 @@ func TestCtx(t *testing.T) {
543
547
if ! serverHandler .cancelled {
544
548
t .Error ("expected cancellation on the server side" )
545
549
}
550
+ if serverHandler .connectionType != ConnectionTypeWS {
551
+ t .Error ("wrong connection type" )
552
+ }
546
553
547
554
serverHandler .cancelled = false
548
555
@@ -564,6 +571,9 @@ func TestCtx(t *testing.T) {
564
571
if serverHandler .cancelled || serverHandler .i != 2 {
565
572
t .Error ("wrong serverHandler state" )
566
573
}
574
+ if serverHandler .connectionType != ConnectionTypeWS {
575
+ t .Error ("wrong connection type" )
576
+ }
567
577
568
578
serverHandler .lk .Unlock ()
569
579
closer ()
@@ -598,6 +608,9 @@ func TestCtxHttp(t *testing.T) {
598
608
if ! serverHandler .cancelled {
599
609
t .Error ("expected cancellation on the server side" )
600
610
}
611
+ if serverHandler .connectionType != ConnectionTypeHTTP {
612
+ t .Error ("wrong connection type" )
613
+ }
601
614
602
615
serverHandler .cancelled = false
603
616
@@ -619,6 +632,10 @@ func TestCtxHttp(t *testing.T) {
619
632
if serverHandler .cancelled || serverHandler .i != 2 {
620
633
t .Error ("wrong serverHandler state" )
621
634
}
635
+ // connection type should have switched to WS
636
+ if serverHandler .connectionType != ConnectionTypeWS {
637
+ t .Error ("wrong connection type" )
638
+ }
622
639
623
640
serverHandler .lk .Unlock ()
624
641
closer ()
@@ -1007,10 +1024,12 @@ func TestChanClientReceiveAll(t *testing.T) {
1007
1024
}
1008
1025
1009
1026
func 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
+ }
1014
1033
1015
1034
for r := 0 ; r < 20 ; r ++ {
1016
1035
testControlChanDeadlock (t )
0 commit comments