22 lines
625 B
Go
22 lines
625 B
Go
package otelsetup
|
|||
|
|
|
||
|
|
import (
|
||
|
|
"net/http"
|
||
|
|
"testing"
|
||
|
|
"time"
|
||
|
|
)
|
||
|
|
|
||
|
|
func TestOTLPHTTPClient_ClosesIdleConnectionsBeforeTheCollector(t *testing.T) {
|
||
|
|
c := otlpHTTPClient()
|
||
|
|
tr, ok := c.Transport.(*http.Transport)
|
||
|
|
if !ok {
|
||
|
|
t.Fatalf("transport is %T, want *http.Transport", c.Transport)
|
||
|
|
}
|
||
|
|
// Alloy's OTLP receiver closes connections idle for 1m; the client must close first.
|
||
|
|
if tr.IdleConnTimeout <= 0 || tr.IdleConnTimeout >= time.Minute {
|
||
|
|
t.Errorf("IdleConnTimeout = %v, want in (0, 1m)", tr.IdleConnTimeout)
|
||
|
|
}
|
||
|
|
if c.Timeout != 10*time.Second {
|
||
|
|
t.Errorf("Timeout = %v, want 10s (the exporters' default)", c.Timeout)
|
||
|
|
}
|
||
|
|
}
|