@@ -224,7 +224,7 @@ var simpleConnectTests = []struct {
224224
225225func TestSimpleConnect (t * testing.T ) {
226226 for _ , tt := range simpleConnectTests {
227- ctx , cancel := context .WithTimeout (context .Background (), 5 * time .Second )
227+ ctx , cancel := context .WithTimeout (context .Background (), 5 * time .Second )
228228 defer cancel ()
229229 args , cmd := prepareCommand (tt .user + "gateway1" , tt .port , "hostname" )
230230 _ , stdout , stderr , err := runCommand (ctx , "ssh" , args , nil , nil )
@@ -250,7 +250,7 @@ var environmentTests = []struct {
250250
251251func TestEnvironment (t * testing.T ) {
252252 for _ , tt := range environmentTests {
253- ctx , cancel := context .WithTimeout (context .Background (), 5 * time .Second )
253+ ctx , cancel := context .WithTimeout (context .Background (), 5 * time .Second )
254254 defer cancel ()
255255 args , cmd := prepareCommand (tt .user + "gateway1" , tt .port , "echo $XMODIFIERS" )
256256 _ , stdout , stderr , err := runCommand (ctx , "ssh" , args , nil , nil )
@@ -265,7 +265,7 @@ func TestEnvironment(t *testing.T) {
265265
266266func TestReturnCode (t * testing.T ) {
267267 for _ , exitCode := range []int {0 , 3 } {
268- ctx , cancel := context .WithTimeout (context .Background (), 5 * time .Second )
268+ ctx , cancel := context .WithTimeout (context .Background (), 5 * time .Second )
269269 defer cancel ()
270270 args , cmd := prepareCommand ("gateway1" , 2023 , fmt .Sprintf ("exit %d" , exitCode ))
271271 rc , _ , _ , _ := runCommand (ctx , "ssh" , args , nil , nil )
@@ -276,7 +276,7 @@ func TestReturnCode(t *testing.T) {
276276}
277277
278278func TestMainSSHDied (t * testing.T ) {
279- ctx , cancel := context .WithTimeout (context .Background (), 120 * time .Second )
279+ ctx , cancel := context .WithTimeout (context .Background (), 120 * time .Second )
280280 defer cancel ()
281281 args , _ := prepareCommand ("gateway1" , 2023 , "sleep 60" )
282282 ch := make (chan * os.Process , 1 )
@@ -295,7 +295,7 @@ func TestEtcdConnections(t *testing.T) {
295295 // remove old connections stored in etcd
296296 time .Sleep (4 * time .Second )
297297
298- ctx , cancel := context .WithTimeout (context .Background (), 30 * time .Second )
298+ ctx , cancel := context .WithTimeout (context .Background (), 30 * time .Second )
299299 defer cancel ()
300300 args , _ := prepareCommand ("gateway1" , 2023 , "sleep 20" )
301301 ch := make (chan * os.Process )
@@ -349,7 +349,7 @@ func TestStickyConnections(t *testing.T) {
349349 disableHost ("server1" )
350350 checkHostState (t , "server1" , "disabled" )
351351
352- ctx , cancel := context .WithTimeout (context .Background (), 30 * time .Second )
352+ ctx , cancel := context .WithTimeout (context .Background (), 30 * time .Second )
353353 defer cancel ()
354354 args , _ := prepareCommand ("gateway1" , 2022 , "sleep 20" )
355355 ch := make (chan * os.Process )
@@ -381,7 +381,7 @@ func TestNotLongStickyConnections(t *testing.T) {
381381 disableHost ("server1" )
382382 checkHostState (t , "server1" , "disabled" )
383383
384- ctx , cancel := context .WithTimeout (context .Background (), 30 * time .Second )
384+ ctx , cancel := context .WithTimeout (context .Background (), 30 * time .Second )
385385 defer cancel ()
386386 args , _ := prepareCommand ("gateway1" , 2022 , "hostname" )
387387 _ , _ , _ , err := runCommand (ctx , "ssh" , args , nil , nil )
@@ -412,7 +412,7 @@ func TestLongStickyConnections(t *testing.T) {
412412 disableHost ("server1" )
413413 checkHostState (t , "server1" , "disabled" )
414414
415- ctx , cancel := context .WithTimeout (context .Background (), 30 * time .Second )
415+ ctx , cancel := context .WithTimeout (context .Background (), 30 * time .Second )
416416 defer cancel ()
417417 args , _ := prepareCommand ("gateway1" , 2022 , "hostname" )
418418 _ , _ , _ , err := runCommand (ctx , "ssh" , args , nil , nil )
@@ -440,7 +440,7 @@ func TestBalancedConnections(t *testing.T) {
440440 // remove old connections stored in etcd
441441 time .Sleep (4 * time .Second )
442442
443- ctx , cancel := context .WithTimeout (context .Background (), 30 * time .Second )
443+ ctx , cancel := context .WithTimeout (context .Background (), 30 * time .Second )
444444 defer cancel ()
445445 args , _ := prepareCommand ("gateway1" , 2022 , "sleep 20" )
446446 ch := make (chan * os.Process )
@@ -468,7 +468,7 @@ func TestBalancedConnections(t *testing.T) {
468468}
469469
470470func checkHostCheck (t * testing.T , host string , check time.Time ) time.Time {
471- ctx , cancel := context .WithTimeout (context .Background (), 5 * time .Second )
471+ ctx , cancel := context .WithTimeout (context .Background (), 5 * time .Second )
472472 defer cancel ()
473473 args , _ := prepareCommand ("gateway1" , 2023 , "hostname" )
474474 want := time .Now ()
@@ -482,7 +482,7 @@ func checkHostCheck(t *testing.T, host string, check time.Time) time.Time {
482482 found = true
483483 lastCheck = h .Ts
484484 if check .IsZero () {
485- if lastCheck .Sub (want ) > 1 * time .Second {
485+ if lastCheck .Sub (want ) > 1 * time .Second {
486486 t .Errorf ("%s %s check at %s, want near %s" , jsonStr , host , lastCheck , want )
487487 }
488488 } else {
@@ -534,7 +534,7 @@ func checkHostState(t *testing.T, host, state string) {
534534
535535func TestEnableDisableHost (t * testing.T ) {
536536 args , cmdStr := prepareCommand ("gateway1" , 2022 , "hostname" )
537- ctx , cancel := context .WithTimeout (context .Background (), 60 * time .Second )
537+ ctx , cancel := context .WithTimeout (context .Background (), 60 * time .Second )
538538 defer cancel ()
539539
540540 _ , stdout , _ , err := runCommand (ctx , "ssh" , args , nil , nil )
@@ -611,7 +611,7 @@ func TestEtcdUsers(t *testing.T) {
611611 // remove old connections stored in etcd
612612 time .Sleep (4 * time .Second )
613613
614- ctx , cancel := context .WithTimeout (context .Background (), 60 * time .Second )
614+ ctx , cancel := context .WithTimeout (context .Background (), 60 * time .Second )
615615 defer cancel ()
616616
617617 ch := make (chan * os.Process )
@@ -654,7 +654,7 @@ func TestEtcdGroups(t *testing.T) {
654654 // remove old connections stored in etcd
655655 time .Sleep (4 * time .Second )
656656
657- ctx , cancel := context .WithTimeout (context .Background (), 60 * time .Second )
657+ ctx , cancel := context .WithTimeout (context .Background (), 60 * time .Second )
658658 defer cancel ()
659659
660660 ch := make (chan * os.Process )
@@ -734,7 +734,7 @@ func TestSFTP(t *testing.T) {
734734 downloadFile := fmt .Sprintf ("/tmp/passwd.%d" , i )
735735 prepareSFTPBatchCommands (batchFile , downloadFile )
736736
737- ctx , cancel := context .WithTimeout (context .Background (), 20 * time .Second )
737+ ctx , cancel := context .WithTimeout (context .Background (), 20 * time .Second )
738738 defer cancel ()
739739 ch := make (chan * os.Process , 1 )
740740 go func () {
@@ -765,7 +765,7 @@ func TestOnlySFTP(t *testing.T) {
765765 downloadFile := "/tmp/passwd.onlySFTP"
766766 prepareSFTPBatchCommands (batchFile , downloadFile )
767767
768- ctx , cancel := context .WithTimeout (context .Background (), 25 * time .Second )
768+ ctx , cancel := context .WithTimeout (context .Background (), 25 * time .Second )
769769 defer cancel ()
770770 ch := make (chan * os.Process , 1 )
771771 go func () {
@@ -819,7 +819,7 @@ func TestSCP(t *testing.T) {
819819 defer removeLineSSHProxyConf (line )
820820 }
821821 for _ , tt := range scpTests {
822- ctx , cancel := context .WithTimeout (context .Background (), 5 * time .Second )
822+ ctx , cancel := context .WithTimeout (context .Background (), 5 * time .Second )
823823 defer cancel ()
824824 _ , _ , _ , err := runCommand (ctx , "scp" , []string {"-P" , strconv .Itoa (tt .port ), tt .source , tt .dest }, nil , nil )
825825 if err != nil {
0 commit comments