diff --git a/exporter/alertmanagerexporter/config_test.go b/exporter/alertmanagerexporter/config_test.go index 07802fbc3e5a..0766c02704b6 100644 --- a/exporter/alertmanagerexporter/config_test.go +++ b/exporter/alertmanagerexporter/config_test.go @@ -4,7 +4,6 @@ package alertmanagerexporter import ( - "net/http" "path/filepath" "testing" "time" @@ -24,7 +23,6 @@ import ( ) func TestLoadConfig(t *testing.T) { - defaultTransport := http.DefaultTransport.(*http.Transport) t.Parallel() cm, err := confmaptest.LoadConf(filepath.Join("testdata", "config.yaml")) @@ -63,26 +61,24 @@ func TestLoadConfig(t *testing.T) { NumConsumers: 2, QueueSize: 10, }, - ClientConfig: confighttp.ClientConfig{ - Headers: map[string]configopaque.String{ + ClientConfig: func() confighttp.ClientConfig { + client := confighttp.NewDefaultClientConfig() + client.Headers = map[string]configopaque.String{ "can you have a . here?": "F0000000-0000-0000-0000-000000000000", "header1": "234", "another": "somevalue", - }, - Endpoint: "a.new.alertmanager.target:9093", - TLSSetting: configtls.ClientConfig{ + } + client.Endpoint = "a.new.alertmanager.target:9093" + client.TLSSetting = configtls.ClientConfig{ Config: configtls.Config{ CAFile: "/var/lib/mycert.pem", }, - }, - ReadBufferSize: 0, - WriteBufferSize: 524288, - Timeout: time.Second * 10, - MaxIdleConns: &defaultTransport.MaxIdleConns, - MaxIdleConnsPerHost: &defaultTransport.MaxIdleConnsPerHost, - MaxConnsPerHost: &defaultTransport.MaxConnsPerHost, - IdleConnTimeout: &defaultTransport.IdleConnTimeout, - }, + } + client.ReadBufferSize = 0 + client.WriteBufferSize = 524288 + client.Timeout = time.Second * 10 + return client + }(), }, }, } diff --git a/receiver/elasticsearchreceiver/config_test.go b/receiver/elasticsearchreceiver/config_test.go index 149f9bed0b1f..4d6974984246 100644 --- a/receiver/elasticsearchreceiver/config_test.go +++ b/receiver/elasticsearchreceiver/config_test.go @@ -4,7 +4,6 @@ package elasticsearchreceiver import ( - "net/http" "path/filepath" "testing" "time" @@ -140,11 +139,6 @@ func TestValidateEndpoint(t *testing.T) { } func TestLoadConfig(t *testing.T) { - defaultMaxIdleConns := http.DefaultTransport.(*http.Transport).MaxIdleConns - defaultMaxIdleConnsPerHost := http.DefaultTransport.(*http.Transport).MaxIdleConnsPerHost - defaultMaxConnsPerHost := http.DefaultTransport.(*http.Transport).MaxConnsPerHost - defaultIdleConnTimeout := http.DefaultTransport.(*http.Transport).IdleConnTimeout - t.Parallel() cm, err := confmaptest.LoadConf(filepath.Join("testdata", "config.yaml")) @@ -173,15 +167,13 @@ func TestLoadConfig(t *testing.T) { MetricsBuilderConfig: defaultMetrics, Username: "otel", Password: "password", - ClientConfig: confighttp.ClientConfig{ - Timeout: 10000000000, - Endpoint: "http://example.com:9200", - Headers: map[string]configopaque.String{}, - MaxIdleConns: &defaultMaxIdleConns, - MaxIdleConnsPerHost: &defaultMaxIdleConnsPerHost, - MaxConnsPerHost: &defaultMaxConnsPerHost, - IdleConnTimeout: &defaultIdleConnTimeout, - }, + ClientConfig: func() confighttp.ClientConfig { + client := confighttp.NewDefaultClientConfig() + client.Timeout = 10000000000 + client.Endpoint = "http://example.com:9200" + client.Headers = map[string]configopaque.String{} + return client + }(), }, }, }