@@ -23,6 +23,7 @@ import (
23
23
"path"
24
24
"path/filepath"
25
25
"runtime"
26
+ "strconv"
26
27
"strings"
27
28
"sync/atomic"
28
29
"testing"
@@ -431,33 +432,38 @@ func TestSupervisorStartsCollectorWithRemoteConfigAndExecParams(t *testing.T) {
431
432
require .NoError (t , err )
432
433
t .Cleanup (func () { outputFile .Close () })
433
434
435
+ secondHealthcheckPort , err := findRandomPort ()
436
+ require .NoError (t , err )
437
+
434
438
// fill env variables passed via parameters which are used in the collector config passed via config_files param
435
439
s := newSupervisor (t , "exec_config" , map [string ]string {
436
- "url" : server .addr ,
437
- "storage_dir" : storageDir ,
438
- "inputLogFile" : inputFile .Name (),
439
- "outputLogFile" : outputFile .Name (),
440
+ "url" : server .addr ,
441
+ "storage_dir" : storageDir ,
442
+ "inputLogFile" : inputFile .Name (),
443
+ "outputLogFile" : outputFile .Name (),
444
+ "healthcheckPort" : strconv .Itoa (secondHealthcheckPort ),
440
445
})
441
446
442
447
require .Nil (t , s .Start ())
443
448
defer s .Shutdown ()
444
449
445
450
waitForSupervisorConnection (server .supervisorConnected , true )
446
451
447
- // check health
448
- require .Eventually (t , func () bool {
449
- resp , err := http .DefaultClient .Get (fmt .Sprintf ("http://localhost:%d" , healthcheckPort ))
450
- if err != nil {
451
- t .Logf ("Failed healthcheck: %s" , err )
452
- return false
453
- }
454
- require .NoError (t , resp .Body .Close ())
455
- if resp .StatusCode >= 300 || resp .StatusCode < 200 {
456
- t .Logf ("Got non-2xx status code: %d" , resp .StatusCode )
457
- return false
458
- }
459
- return true
460
- }, 3 * time .Second , 100 * time .Millisecond )
452
+ for _ , port := range []int {healthcheckPort , secondHealthcheckPort } {
453
+ require .Eventually (t , func () bool {
454
+ resp , err := http .DefaultClient .Get (fmt .Sprintf ("http://localhost:%d" , port ))
455
+ if err != nil {
456
+ t .Logf ("Failed healthcheck: %s" , err )
457
+ return false
458
+ }
459
+ require .NoError (t , resp .Body .Close ())
460
+ if resp .StatusCode >= 300 || resp .StatusCode < 200 {
461
+ t .Logf ("Got non-2xx status code: %d" , resp .StatusCode )
462
+ return false
463
+ }
464
+ return true
465
+ }, 3 * time .Second , 100 * time .Millisecond )
466
+ }
461
467
462
468
// check that collector uses filelog receiver and file exporter from config passed via config_files param
463
469
n , err := inputFile .WriteString ("{\" body\" :\" hello, world\" }\n " )
0 commit comments