perf(cmpp): isolate inbound transport capacity
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package inbound
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestNewAPIHTTPClientMatchesBoundedSubmitConcurrency(t *testing.T) {
|
||||
client := NewAPIHTTPClient(48)
|
||||
transport, ok := client.Transport.(*http.Transport)
|
||||
if !ok {
|
||||
t.Fatalf("expected *http.Transport, got %T", client.Transport)
|
||||
}
|
||||
if transport.MaxConnsPerHost != 48 || transport.MaxIdleConnsPerHost != 48 {
|
||||
t.Fatalf("unexpected host connection bounds: max=%d idle=%d", transport.MaxConnsPerHost, transport.MaxIdleConnsPerHost)
|
||||
}
|
||||
if client.Timeout != defaultHTTPTimeout {
|
||||
t.Fatalf("unexpected client timeout: %s", client.Timeout)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewAPIHTTPClientUsesSafeDefault(t *testing.T) {
|
||||
client := NewAPIHTTPClient(0)
|
||||
transport := client.Transport.(*http.Transport)
|
||||
if transport.MaxConnsPerHost != 64 {
|
||||
t.Fatalf("expected default max connections 64, got %d", transport.MaxConnsPerHost)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user