@@ -18,6 +18,7 @@ import (
1818 "flag"
1919 "io/ioutil"
2020 "net/http"
21+ "strings"
2122 "testing"
2223)
2324
@@ -42,22 +43,31 @@ func TestSamplingIdempotency(t *testing.T) {
4243func TestPrometheusConfiguration (t * testing.T ) {
4344 flag .Set ("logger-debug" , "all" )
4445
46+ if opt .HTTPEndpoint == "" {
47+ opt .HTTPEndpoint = ":0"
48+ }
49+
4550 s := newService ()
4651 s .Start ()
4752
48- checkPrometheus (t , opt .HTTPEndpoint , ! opt .PrometheusExport )
53+ address := s .http .GetAddress ()
54+ if strings .HasSuffix (opt .HTTPEndpoint , ":0" ) {
55+ opt .HTTPEndpoint = address
56+ }
57+
58+ checkPrometheus (t , address , ! opt .PrometheusExport )
4959
5060 opt .PrometheusExport = ! opt .PrometheusExport
5161 s .reconfigure ()
52- checkPrometheus (t , opt . HTTPEndpoint , ! opt .PrometheusExport )
62+ checkPrometheus (t , address , ! opt .PrometheusExport )
5363
5464 opt .PrometheusExport = ! opt .PrometheusExport
5565 s .reconfigure ()
56- checkPrometheus (t , opt . HTTPEndpoint , ! opt .PrometheusExport )
66+ checkPrometheus (t , address , ! opt .PrometheusExport )
5767
5868 opt .PrometheusExport = ! opt .PrometheusExport
5969 s .reconfigure ()
60- checkPrometheus (t , opt . HTTPEndpoint , ! opt .PrometheusExport )
70+ checkPrometheus (t , address , ! opt .PrometheusExport )
6171
6272 s .http .Shutdown (true )
6373 s .Stop ()
0 commit comments