test(kuberuntime): deflake TestRecordOperation

Avoid using hard-coded port

Signed-off-by: knight42 <anonymousknight96@gmail.com>
This commit is contained in:
knight42 2020-09-05 13:36:20 +08:00
parent 0f466ba177
commit c6f9b402fb
No known key found for this signature in database
GPG Key ID: 1040B69865E7D86C

View File

@ -34,17 +34,16 @@ func TestRecordOperation(t *testing.T) {
legacyregistry.MustRegister(metrics.RuntimeOperationsDuration)
legacyregistry.MustRegister(metrics.RuntimeOperationsErrors)
temporalServer := "127.0.0.1:1234"
l, err := net.Listen("tcp", temporalServer)
l, err := net.Listen("tcp", "127.0.0.1:0")
assert.NoError(t, err)
defer l.Close()
prometheusURL := "http://" + temporalServer + "/metrics"
prometheusURL := "http://" + l.Addr().String() + "/metrics"
mux := http.NewServeMux()
//lint:ignore SA1019 ignore deprecated warning until we move off of global registries
mux.Handle("/metrics", legacyregistry.Handler())
server := &http.Server{
Addr: temporalServer,
Addr: l.Addr().String(),
Handler: mux,
}
go func() {