From a3286b40f13975f6c9f9469ccc57dc81d8a041de Mon Sep 17 00:00:00 2001 From: Bogdan Date: Wed, 10 Aug 2022 13:36:26 -0700 Subject: [PATCH] [chore] change config tests to unmarshal only the config for that component The main motivation for this is to allow components (including tests) to not depend on the "service" configuration and be reusable without the otelcol service. Signed-off-by: Bogdan --- exporter/loggingexporter/config_test.go | 32 ++- exporter/loggingexporter/testdata/config.yaml | 25 +- exporter/otlpexporter/config_test.go | 33 ++- exporter/otlpexporter/testdata/config.yaml | 70 ++---- exporter/otlphttpexporter/config_test.go | 41 ++-- .../otlphttpexporter/testdata/config.yaml | 61 ++--- extension/ballastextension/config_test.go | 52 ++-- .../ballastextension/testdata/config.yaml | 23 +- .../testdata/config_invalid.yaml | 19 -- extension/zpagesextension/config_test.go | 36 ++- .../zpagesextension/testdata/config.yaml | 21 +- processor/batchprocessor/config_test.go | 45 ++-- processor/batchprocessor/testdata/config.yaml | 22 +- .../memorylimiterprocessor/config_test.go | 38 ++- .../testdata/config.yaml | 44 +--- receiver/otlpreceiver/config_test.go | 225 ++++++++---------- .../testdata/bad_empty_config.yaml | 15 -- .../testdata/bad_no_proto_config.yaml | 17 +- .../testdata/bad_proto_config.yaml | 21 +- receiver/otlpreceiver/testdata/config.yaml | 152 +++--------- receiver/otlpreceiver/testdata/default.yaml | 5 + receiver/otlpreceiver/testdata/only_grpc.yaml | 3 + receiver/otlpreceiver/testdata/only_http.yaml | 3 + .../testdata/only_http_empty_map.yaml | 3 + .../otlpreceiver/testdata/only_http_null.yaml | 3 + .../testdata/typo_default_proto_config.yaml | 21 +- receiver/otlpreceiver/testdata/uds.yaml | 8 + 27 files changed, 358 insertions(+), 680 deletions(-) delete mode 100644 extension/ballastextension/testdata/config_invalid.yaml delete mode 100644 receiver/otlpreceiver/testdata/bad_empty_config.yaml create mode 100644 receiver/otlpreceiver/testdata/default.yaml create mode 100644 receiver/otlpreceiver/testdata/only_grpc.yaml create mode 100644 receiver/otlpreceiver/testdata/only_http.yaml create mode 100644 receiver/otlpreceiver/testdata/only_http_empty_map.yaml create mode 100644 receiver/otlpreceiver/testdata/only_http_null.yaml create mode 100644 receiver/otlpreceiver/testdata/uds.yaml diff --git a/exporter/loggingexporter/config_test.go b/exporter/loggingexporter/config_test.go index cbc6f137327..ab7fdc86240 100644 --- a/exporter/loggingexporter/config_test.go +++ b/exporter/loggingexporter/config_test.go @@ -22,31 +22,29 @@ import ( "github.com/stretchr/testify/require" "go.uber.org/zap/zapcore" - "go.opentelemetry.io/collector/component/componenttest" "go.opentelemetry.io/collector/config" - "go.opentelemetry.io/collector/service/servicetest" + "go.opentelemetry.io/collector/confmap" + "go.opentelemetry.io/collector/confmap/confmaptest" ) -func TestLoadConfig(t *testing.T) { - factories, err := componenttest.NopFactories() - assert.NoError(t, err) - +func TestUnmarshalDefaultConfig(t *testing.T) { factory := NewFactory() - factories.Exporters[typeStr] = factory - cfg, err := servicetest.LoadConfigAndValidate(filepath.Join("testdata", "config.yaml"), factories) + cfg := factory.CreateDefaultConfig() + assert.NoError(t, config.UnmarshalExporter(confmap.New(), cfg)) + assert.Equal(t, factory.CreateDefaultConfig(), cfg) +} +func TestUnmarshalConfig(t *testing.T) { + cm, err := confmaptest.LoadConf(filepath.Join("testdata", "config.yaml")) require.NoError(t, err) - require.NotNil(t, cfg) - - e0 := cfg.Exporters[config.NewComponentID(typeStr)] - assert.Equal(t, e0, factory.CreateDefaultConfig()) - - e1 := cfg.Exporters[config.NewComponentIDWithName(typeStr, "2")] - assert.Equal(t, e1, + factory := NewFactory() + cfg := factory.CreateDefaultConfig() + assert.NoError(t, config.UnmarshalExporter(cm, cfg)) + assert.Equal(t, &Config{ - ExporterSettings: config.NewExporterSettings(config.NewComponentIDWithName(typeStr, "2")), + ExporterSettings: config.NewExporterSettings(config.NewComponentID(typeStr)), LogLevel: zapcore.DebugLevel, SamplingInitial: 10, SamplingThereafter: 50, - }) + }, cfg) } diff --git a/exporter/loggingexporter/testdata/config.yaml b/exporter/loggingexporter/testdata/config.yaml index 5d825f3e526..ffe8a0df593 100644 --- a/exporter/loggingexporter/testdata/config.yaml +++ b/exporter/loggingexporter/testdata/config.yaml @@ -1,22 +1,3 @@ -receivers: - nop: - -processors: - nop: - -exporters: - logging: - logging/2: - loglevel: debug - sampling_initial: 10 - sampling_thereafter: 50 - -service: - pipelines: - traces: - receivers: [nop] - processors: [nop] - exporters: [logging] - metrics: - receivers: [nop] - exporters: [logging,logging/2] +loglevel: debug +sampling_initial: 10 +sampling_thereafter: 50 diff --git a/exporter/otlpexporter/config_test.go b/exporter/otlpexporter/config_test.go index c1a30171ad7..6bd76301aba 100644 --- a/exporter/otlpexporter/config_test.go +++ b/exporter/otlpexporter/config_test.go @@ -22,34 +22,31 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/component/componenttest" "go.opentelemetry.io/collector/config" "go.opentelemetry.io/collector/config/configauth" "go.opentelemetry.io/collector/config/configgrpc" "go.opentelemetry.io/collector/config/configtls" + "go.opentelemetry.io/collector/confmap" + "go.opentelemetry.io/collector/confmap/confmaptest" "go.opentelemetry.io/collector/exporter/exporterhelper" - "go.opentelemetry.io/collector/service/servicetest" ) -func TestLoadConfig(t *testing.T) { - factories, err := componenttest.NopFactories() - assert.NoError(t, err) - +func TestUnmarshalDefaultConfig(t *testing.T) { factory := NewFactory() - factories.Exporters[typeStr] = factory - - cfg, err := servicetest.LoadConfigAndValidate(filepath.Join("testdata", "config.yaml"), factories) + cfg := factory.CreateDefaultConfig() + assert.NoError(t, config.UnmarshalExporter(confmap.New(), cfg)) + assert.Equal(t, factory.CreateDefaultConfig(), cfg) +} +func TestUnmarshalConfig(t *testing.T) { + cm, err := confmaptest.LoadConf(filepath.Join("testdata", "config.yaml")) require.NoError(t, err) - require.NotNil(t, cfg) - - e0 := cfg.Exporters[config.NewComponentID(typeStr)] - assert.Equal(t, e0, factory.CreateDefaultConfig()) - - e1 := cfg.Exporters[config.NewComponentIDWithName(typeStr, "2")] - assert.Equal(t, e1, + factory := NewFactory() + cfg := factory.CreateDefaultConfig() + assert.NoError(t, config.UnmarshalExporter(cm, cfg)) + assert.Equal(t, &Config{ - ExporterSettings: config.NewExporterSettings(config.NewComponentIDWithName(typeStr, "2")), + ExporterSettings: config.NewExporterSettings(config.NewComponentID(typeStr)), TimeoutSettings: exporterhelper.TimeoutSettings{ Timeout: 10 * time.Second, }, @@ -87,5 +84,5 @@ func TestLoadConfig(t *testing.T) { BalancerName: "round_robin", Auth: &configauth.Authentication{AuthenticatorID: config.NewComponentID("nop")}, }, - }) + }, cfg) } diff --git a/exporter/otlpexporter/testdata/config.yaml b/exporter/otlpexporter/testdata/config.yaml index 02858766429..918f20be233 100644 --- a/exporter/otlpexporter/testdata/config.yaml +++ b/exporter/otlpexporter/testdata/config.yaml @@ -1,45 +1,25 @@ -extensions: - nop: - -receivers: - nop: - -processors: - nop: - -exporters: - otlp: - otlp/2: - endpoint: "1.2.3.4:1234" - compression: "gzip" - tls: - ca_file: /var/lib/mycert.pem - timeout: 10s - sending_queue: - enabled: true - num_consumers: 2 - queue_size: 10 - retry_on_failure: - enabled: true - initial_interval: 10s - max_interval: 60s - max_elapsed_time: 10m - auth: - authenticator: nop - headers: - "can you have a . here?": "F0000000-0000-0000-0000-000000000000" - header1: 234 - another: "somevalue" - keepalive: - time: 20s - timeout: 30s - permit_without_stream: true - balancer_name: "round_robin" - -service: - extensions: [nop] - pipelines: - traces: - receivers: [nop] - processors: [nop] - exporters: [otlp] +endpoint: "1.2.3.4:1234" +compression: "gzip" +tls: + ca_file: /var/lib/mycert.pem +timeout: 10s +sending_queue: + enabled: true + num_consumers: 2 + queue_size: 10 +retry_on_failure: + enabled: true + initial_interval: 10s + max_interval: 60s + max_elapsed_time: 10m +auth: + authenticator: nop +headers: + "can you have a . here?": "F0000000-0000-0000-0000-000000000000" + header1: 234 + another: "somevalue" +keepalive: + time: 20s + timeout: 30s + permit_without_stream: true +balancer_name: "round_robin" diff --git a/exporter/otlphttpexporter/config_test.go b/exporter/otlphttpexporter/config_test.go index c751cf2c7c6..8cb9c4ed16e 100644 --- a/exporter/otlphttpexporter/config_test.go +++ b/exporter/otlphttpexporter/config_test.go @@ -22,39 +22,32 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/component/componenttest" "go.opentelemetry.io/collector/config" "go.opentelemetry.io/collector/config/confighttp" "go.opentelemetry.io/collector/config/configtls" + "go.opentelemetry.io/collector/confmap" + "go.opentelemetry.io/collector/confmap/confmaptest" "go.opentelemetry.io/collector/exporter/exporterhelper" - "go.opentelemetry.io/collector/service/servicetest" ) -func TestLoadConfig(t *testing.T) { - factories, err := componenttest.NopFactories() - assert.NoError(t, err) - +func TestUnmarshalDefaultConfig(t *testing.T) { factory := NewFactory() - factories.Exporters[typeStr] = factory - - // Bad config - cfg, err := servicetest.LoadConfigAndValidate(filepath.Join("testdata", "bad_empty_config.yaml"), factories) - - require.Error(t, err) - - e0 := cfg.Exporters[config.NewComponentID(typeStr)] - assert.Equal(t, e0, factory.CreateDefaultConfig()) - - // Good config - cfg, err = servicetest.LoadConfigAndValidate(filepath.Join("testdata", "config.yaml"), factories) + cfg := factory.CreateDefaultConfig() + assert.NoError(t, config.UnmarshalExporter(confmap.New(), cfg)) + assert.Equal(t, factory.CreateDefaultConfig(), cfg) + // Default/Empty config is invalid. + assert.Error(t, cfg.Validate()) +} +func TestUnmarshalConfig(t *testing.T) { + cm, err := confmaptest.LoadConf(filepath.Join("testdata", "config.yaml")) require.NoError(t, err) - require.NotNil(t, cfg) - - e1 := cfg.Exporters[config.NewComponentIDWithName(typeStr, "2")] - assert.Equal(t, e1, + factory := NewFactory() + cfg := factory.CreateDefaultConfig() + assert.NoError(t, config.UnmarshalExporter(cm, cfg)) + assert.Equal(t, &Config{ - ExporterSettings: config.NewExporterSettings(config.NewComponentIDWithName(typeStr, "2")), + ExporterSettings: config.NewExporterSettings(config.NewComponentID(typeStr)), RetrySettings: exporterhelper.RetrySettings{ Enabled: true, InitialInterval: 10 * time.Second, @@ -86,5 +79,5 @@ func TestLoadConfig(t *testing.T) { Timeout: time.Second * 10, Compression: "gzip", }, - }) + }, cfg) } diff --git a/exporter/otlphttpexporter/testdata/config.yaml b/exporter/otlphttpexporter/testdata/config.yaml index 3d48e47f57a..83a3619bc12 100644 --- a/exporter/otlphttpexporter/testdata/config.yaml +++ b/exporter/otlphttpexporter/testdata/config.yaml @@ -1,38 +1,23 @@ -receivers: - nop: - -processors: - nop: - -exporters: - otlphttp/2: - endpoint: "https://1.2.3.4:1234" - tls: - ca_file: /var/lib/mycert.pem - cert_file: certfile - key_file: keyfile - insecure: true - timeout: 10s - read_buffer_size: 123 - write_buffer_size: 345 - sending_queue: - enabled: true - num_consumers: 2 - queue_size: 10 - retry_on_failure: - enabled: true - initial_interval: 10s - max_interval: 60s - max_elapsed_time: 10m - headers: - "can you have a . here?": "F0000000-0000-0000-0000-000000000000" - header1: 234 - another: "somevalue" - compression: gzip - -service: - pipelines: - traces: - receivers: [nop] - processors: [nop] - exporters: [otlphttp/2] +endpoint: "https://1.2.3.4:1234" +tls: + ca_file: /var/lib/mycert.pem + cert_file: certfile + key_file: keyfile + insecure: true +timeout: 10s +read_buffer_size: 123 +write_buffer_size: 345 +sending_queue: + enabled: true + num_consumers: 2 + queue_size: 10 +retry_on_failure: + enabled: true + initial_interval: 10s + max_interval: 60s + max_elapsed_time: 10m +headers: + "can you have a . here?": "F0000000-0000-0000-0000-000000000000" + header1: 234 + another: "somevalue" +compression: gzip diff --git a/extension/ballastextension/config_test.go b/extension/ballastextension/config_test.go index f62043fedf2..ca87d7c1cfc 100644 --- a/extension/ballastextension/config_test.go +++ b/extension/ballastextension/config_test.go @@ -21,47 +21,35 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/component/componenttest" "go.opentelemetry.io/collector/config" - "go.opentelemetry.io/collector/service/servicetest" + "go.opentelemetry.io/collector/confmap" + "go.opentelemetry.io/collector/confmap/confmaptest" ) -func TestLoadConfig(t *testing.T) { - factories, err := componenttest.NopFactories() - assert.NoError(t, err) - +func TestUnmarshalDefaultConfig(t *testing.T) { factory := NewFactory() - factories.Extensions[typeStr] = factory - cfg, err := servicetest.LoadConfigAndValidate(filepath.Join("testdata", "config.yaml"), factories) - - require.Nil(t, err) - require.NotNil(t, cfg) - - ext0 := cfg.Extensions[config.NewComponentID(typeStr)] - assert.Equal(t, factory.CreateDefaultConfig(), ext0) + cfg := factory.CreateDefaultConfig() + assert.NoError(t, config.UnmarshalExtension(confmap.New(), cfg)) + assert.Equal(t, factory.CreateDefaultConfig(), cfg) +} - ext1 := cfg.Extensions[config.NewComponentIDWithName(typeStr, "1")] +func TestUnmarshalConfig(t *testing.T) { + cm, err := confmaptest.LoadConf(filepath.Join("testdata", "config.yaml")) + require.NoError(t, err) + factory := NewFactory() + cfg := factory.CreateDefaultConfig() + assert.NoError(t, config.UnmarshalExtension(cm, cfg)) assert.Equal(t, &Config{ - ExtensionSettings: config.NewExtensionSettings(config.NewComponentIDWithName(typeStr, "1")), + ExtensionSettings: config.NewExtensionSettings(config.NewComponentID(typeStr)), SizeMiB: 123, SizeInPercentage: 20, - }, - ext1) - - assert.Equal(t, 1, len(cfg.Service.Extensions)) - assert.Equal(t, config.NewComponentIDWithName(typeStr, "1"), cfg.Service.Extensions[0]) + }, cfg) } -func TestLoadInvalidConfig(t *testing.T) { - factories, err := componenttest.NopFactories() - assert.NoError(t, err) - - factory := NewFactory() - factories.Extensions[typeStr] = factory - _, err = servicetest.LoadConfigAndValidate(filepath.Join("testdata", "config_invalid.yaml"), factories) - - require.NotNil(t, err) - assert.Equal(t, err.Error(), "extension \"memory_ballast\" has invalid configuration: size_in_percentage is not in range 0 to 100") - +func TestConfigValidate(t *testing.T) { + cfg := &Config{SizeInPercentage: 200} + err := cfg.Validate() + require.Error(t, err) + assert.Equal(t, "size_in_percentage is not in range 0 to 100", err.Error()) } diff --git a/extension/ballastextension/testdata/config.yaml b/extension/ballastextension/testdata/config.yaml index d7cf835602d..7d58cd6bcc4 100644 --- a/extension/ballastextension/testdata/config.yaml +++ b/extension/ballastextension/testdata/config.yaml @@ -1,21 +1,2 @@ -extensions: - memory_ballast: - memory_ballast/1: - size_mib: 123 - size_in_percentage: 20 - -# Data pipeline is required to load the config. -receivers: - nop: -processors: - nop: -exporters: - nop: - -service: - extensions: [memory_ballast/1] - pipelines: - traces: - receivers: [nop] - processors: [nop] - exporters: [nop] +size_mib: 123 +size_in_percentage: 20 diff --git a/extension/ballastextension/testdata/config_invalid.yaml b/extension/ballastextension/testdata/config_invalid.yaml deleted file mode 100644 index c73a7a9975c..00000000000 --- a/extension/ballastextension/testdata/config_invalid.yaml +++ /dev/null @@ -1,19 +0,0 @@ -extensions: - memory_ballast: - size_in_percentage: 200 - -# Data pipeline is required to load the config. -receivers: - nop: -processors: - nop: -exporters: - nop: - -service: - extensions: [memory_ballast] - pipelines: - traces: - receivers: [nop] - processors: [nop] - exporters: [nop] diff --git a/extension/zpagesextension/config_test.go b/extension/zpagesextension/config_test.go index cb1b8406bef..109783b7463 100644 --- a/extension/zpagesextension/config_test.go +++ b/extension/zpagesextension/config_test.go @@ -21,36 +21,30 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/component/componenttest" "go.opentelemetry.io/collector/config" "go.opentelemetry.io/collector/config/confignet" - "go.opentelemetry.io/collector/service/servicetest" + "go.opentelemetry.io/collector/confmap" + "go.opentelemetry.io/collector/confmap/confmaptest" ) -func TestLoadConfig(t *testing.T) { - factories, err := componenttest.NopFactories() - assert.NoError(t, err) - +func TestUnmarshalDefaultConfig(t *testing.T) { factory := NewFactory() - factories.Extensions[typeStr] = factory - cfg, err := servicetest.LoadConfigAndValidate(filepath.Join("testdata", "config.yaml"), factories) - - require.Nil(t, err) - require.NotNil(t, cfg) - - ext0 := cfg.Extensions[config.NewComponentID(typeStr)] - assert.Equal(t, factory.CreateDefaultConfig(), ext0) + cfg := factory.CreateDefaultConfig() + assert.NoError(t, config.UnmarshalExtension(confmap.New(), cfg)) + assert.Equal(t, factory.CreateDefaultConfig(), cfg) +} - ext1 := cfg.Extensions[config.NewComponentIDWithName(typeStr, "1")] +func TestUnmarshalConfig(t *testing.T) { + cm, err := confmaptest.LoadConf(filepath.Join("testdata", "config.yaml")) + require.NoError(t, err) + factory := NewFactory() + cfg := factory.CreateDefaultConfig() + assert.NoError(t, config.UnmarshalExtension(cm, cfg)) assert.Equal(t, &Config{ - ExtensionSettings: config.NewExtensionSettings(config.NewComponentIDWithName(typeStr, "1")), + ExtensionSettings: config.NewExtensionSettings(config.NewComponentID(typeStr)), TCPAddr: confignet.TCPAddr{ Endpoint: "localhost:56888", }, - }, - ext1) - - assert.Equal(t, 1, len(cfg.Service.Extensions)) - assert.Equal(t, config.NewComponentIDWithName(typeStr, "1"), cfg.Service.Extensions[0]) + }, cfg) } diff --git a/extension/zpagesextension/testdata/config.yaml b/extension/zpagesextension/testdata/config.yaml index 8213a5b9730..e80ed6bacdb 100644 --- a/extension/zpagesextension/testdata/config.yaml +++ b/extension/zpagesextension/testdata/config.yaml @@ -1,20 +1 @@ -extensions: - zpages: - zpages/1: - endpoint: "localhost:56888" - -service: - extensions: [zpages/1] - pipelines: - traces: - receivers: [nop] - processors: [nop] - exporters: [nop] - -# Data pipeline is required to load the config. -receivers: - nop: -processors: - nop: -exporters: - nop: +endpoint: "localhost:56888" diff --git a/processor/batchprocessor/config_test.go b/processor/batchprocessor/config_test.go index bd37f394188..d3414fc05eb 100644 --- a/processor/batchprocessor/config_test.go +++ b/processor/batchprocessor/config_test.go @@ -22,38 +22,31 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/component/componenttest" "go.opentelemetry.io/collector/config" - "go.opentelemetry.io/collector/service/servicetest" + "go.opentelemetry.io/collector/confmap" + "go.opentelemetry.io/collector/confmap/confmaptest" ) -func TestLoadConfig(t *testing.T) { - factories, err := componenttest.NopFactories() - assert.NoError(t, err) - +func TestUnmarshalDefaultConfig(t *testing.T) { factory := NewFactory() - factories.Processors[typeStr] = factory - cfg, err := servicetest.LoadConfigAndValidate(filepath.Join("testdata", "config.yaml"), factories) - - require.Nil(t, err) - require.NotNil(t, cfg) - - p0 := cfg.Processors[config.NewComponentID(typeStr)] - assert.Equal(t, p0, factory.CreateDefaultConfig()) - - p1 := cfg.Processors[config.NewComponentIDWithName(typeStr, "2")] - - timeout := time.Second * 10 - sendBatchSize := uint32(10000) - sendBatchMaxSize := uint32(11000) + cfg := factory.CreateDefaultConfig() + assert.NoError(t, config.UnmarshalProcessor(confmap.New(), cfg)) + assert.Equal(t, factory.CreateDefaultConfig(), cfg) +} - assert.Equal(t, p1, +func TestUnmarshalConfig(t *testing.T) { + cm, err := confmaptest.LoadConf(filepath.Join("testdata", "config.yaml")) + require.NoError(t, err) + factory := NewFactory() + cfg := factory.CreateDefaultConfig() + assert.NoError(t, config.UnmarshalProcessor(cm, cfg)) + assert.Equal(t, &Config{ - ProcessorSettings: config.NewProcessorSettings(config.NewComponentIDWithName(typeStr, "2")), - SendBatchSize: sendBatchSize, - SendBatchMaxSize: sendBatchMaxSize, - Timeout: timeout, - }) + ProcessorSettings: config.NewProcessorSettings(config.NewComponentID(typeStr)), + SendBatchSize: uint32(10000), + SendBatchMaxSize: uint32(11000), + Timeout: time.Second * 10, + }, cfg) } func TestValidateConfig_DefaultBatchMaxSize(t *testing.T) { diff --git a/processor/batchprocessor/testdata/config.yaml b/processor/batchprocessor/testdata/config.yaml index 95ace7436ef..3ed4c8db8cf 100644 --- a/processor/batchprocessor/testdata/config.yaml +++ b/processor/batchprocessor/testdata/config.yaml @@ -1,19 +1,3 @@ -receivers: - nop: - -processors: - batch: - batch/2: - timeout: 10s - send_batch_size: 10000 - send_batch_max_size: 11000 - -exporters: - nop: - -service: - pipelines: - traces: - receivers: [nop] - processors: [batch/2] - exporters: [nop] +timeout: 10s +send_batch_size: 10000 +send_batch_max_size: 11000 diff --git a/processor/memorylimiterprocessor/config_test.go b/processor/memorylimiterprocessor/config_test.go index b847db464af..c1aa79f99a3 100644 --- a/processor/memorylimiterprocessor/config_test.go +++ b/processor/memorylimiterprocessor/config_test.go @@ -22,35 +22,29 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/component/componenttest" "go.opentelemetry.io/collector/config" - "go.opentelemetry.io/collector/service/servicetest" + "go.opentelemetry.io/collector/confmap" + "go.opentelemetry.io/collector/confmap/confmaptest" ) -func TestLoadConfig(t *testing.T) { - factories, err := componenttest.NopFactories() - require.NoError(t, err) +func TestUnmarshalDefaultConfig(t *testing.T) { factory := NewFactory() - factories.Processors[typeStr] = factory - require.NoError(t, err) - - cfg, err := servicetest.LoadConfigAndValidate(filepath.Join("testdata", "config.yaml"), factories) - - require.Nil(t, err) - require.NotNil(t, cfg) - - p0 := cfg.Processors[config.NewComponentID(typeStr)] - assert.Equal(t, p0, - &Config{ - ProcessorSettings: config.NewProcessorSettings(config.NewComponentID(typeStr)), - }) + cfg := factory.CreateDefaultConfig() + assert.NoError(t, config.UnmarshalProcessor(confmap.New(), cfg)) + assert.Equal(t, factory.CreateDefaultConfig(), cfg) +} - p1 := cfg.Processors[config.NewComponentIDWithName(typeStr, "with-settings")] - assert.Equal(t, p1, +func TestUnmarshalConfig(t *testing.T) { + cm, err := confmaptest.LoadConf(filepath.Join("testdata", "config.yaml")) + require.NoError(t, err) + factory := NewFactory() + cfg := factory.CreateDefaultConfig() + assert.NoError(t, config.UnmarshalProcessor(cm, cfg)) + assert.Equal(t, &Config{ - ProcessorSettings: config.NewProcessorSettings(config.NewComponentIDWithName(typeStr, "with-settings")), + ProcessorSettings: config.NewProcessorSettings(config.NewComponentID(typeStr)), CheckInterval: 5 * time.Second, MemoryLimitMiB: 4000, MemorySpikeLimitMiB: 500, - }) + }, cfg) } diff --git a/processor/memorylimiterprocessor/testdata/config.yaml b/processor/memorylimiterprocessor/testdata/config.yaml index a82ee7f727e..fa2a9975bd6 100644 --- a/processor/memorylimiterprocessor/testdata/config.yaml +++ b/processor/memorylimiterprocessor/testdata/config.yaml @@ -1,31 +1,13 @@ -receivers: - nop: - -processors: - memory_limiter: - # empty config - - memory_limiter/with-settings: - # check_interval is the time between measurements of memory usage for the - # purposes of avoiding going over the limits. Defaults to zero, so no - # checks will be performed. Values below 1 second are not recommended since - # it can result in unnecessary CPU consumption. - check_interval: 5s - - # Maximum amount of memory, in MiB, targeted to be allocated by the process heap. - # Note that typically the total memory usage of process will be about 50MiB higher - # than this value. - limit_mib: 4000 - - # The maximum, in MiB, spike expected between the measurements of memory usage. - spike_limit_mib: 500 - -exporters: - nop: - -service: - pipelines: - traces: - receivers: [nop] - processors: [memory_limiter/with-settings] - exporters: [nop] +# check_interval is the time between measurements of memory usage for the +# purposes of avoiding going over the limits. Defaults to zero, so no +# checks will be performed. Values below 1 second are not recommended since +# it can result in unnecessary CPU consumption. +check_interval: 5s + +# Maximum amount of memory, in MiB, targeted to be allocated by the process heap. +# Note that typically the total memory usage of process will be about 50MiB higher +# than this value. +limit_mib: 4000 + +# The maximum, in MiB, spike expected between the measurements of memory usage. +spike_limit_mib: 500 diff --git a/receiver/otlpreceiver/config_test.go b/receiver/otlpreceiver/config_test.go index f519ddf0456..54d0973ecce 100644 --- a/receiver/otlpreceiver/config_test.go +++ b/receiver/otlpreceiver/config_test.go @@ -22,74 +22,97 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/component/componenttest" "go.opentelemetry.io/collector/config" "go.opentelemetry.io/collector/config/configgrpc" "go.opentelemetry.io/collector/config/confighttp" "go.opentelemetry.io/collector/config/confignet" "go.opentelemetry.io/collector/config/configtls" - "go.opentelemetry.io/collector/service/servicetest" + "go.opentelemetry.io/collector/confmap" + "go.opentelemetry.io/collector/confmap/confmaptest" ) -func TestLoadConfig(t *testing.T) { - factories, err := componenttest.NopFactories() - assert.NoError(t, err) - +func TestUnmarshalDefaultConfig(t *testing.T) { + cm, err := confmaptest.LoadConf(filepath.Join("testdata", "default.yaml")) + require.NoError(t, err) factory := NewFactory() - factories.Receivers[typeStr] = factory - cfg, err := servicetest.LoadConfigAndValidate(filepath.Join("testdata", "config.yaml"), factories) + cfg := factory.CreateDefaultConfig() + assert.NoError(t, config.UnmarshalReceiver(cm, cfg)) + assert.Equal(t, factory.CreateDefaultConfig(), cfg) +} +func TestUnmarshalConfigOnlyGRPC(t *testing.T) { + cm, err := confmaptest.LoadConf(filepath.Join("testdata", "only_grpc.yaml")) require.NoError(t, err) - require.NotNil(t, cfg) - - assert.Equal(t, len(cfg.Receivers), 12) - - assert.Equal(t, cfg.Receivers[config.NewComponentID(typeStr)], factory.CreateDefaultConfig()) + factory := NewFactory() + cfg := factory.CreateDefaultConfig() + assert.NoError(t, config.UnmarshalReceiver(cm, cfg)) defaultOnlyGRPC := factory.CreateDefaultConfig().(*Config) - defaultOnlyGRPC.SetIDName("only_grpc") defaultOnlyGRPC.HTTP = nil - assert.Equal(t, cfg.Receivers[config.NewComponentIDWithName(typeStr, "only_grpc")], defaultOnlyGRPC) + assert.Equal(t, defaultOnlyGRPC, cfg) +} + +func TestUnmarshalConfigOnlyHTTP(t *testing.T) { + cm, err := confmaptest.LoadConf(filepath.Join("testdata", "only_http.yaml")) + require.NoError(t, err) + factory := NewFactory() + cfg := factory.CreateDefaultConfig() + assert.NoError(t, config.UnmarshalReceiver(cm, cfg)) defaultOnlyHTTP := factory.CreateDefaultConfig().(*Config) - defaultOnlyHTTP.SetIDName("only_http") defaultOnlyHTTP.GRPC = nil - assert.Equal(t, cfg.Receivers[config.NewComponentIDWithName(typeStr, "only_http")], defaultOnlyHTTP) + assert.Equal(t, defaultOnlyHTTP, cfg) +} - defaultOnlyHTTPNull := factory.CreateDefaultConfig().(*Config) - defaultOnlyHTTPNull.SetIDName("only_http_null") - defaultOnlyHTTPNull.GRPC = nil - assert.Equal(t, cfg.Receivers[config.NewComponentIDWithName(typeStr, "only_http_null")], defaultOnlyHTTPNull) +func TestUnmarshalConfigOnlyHTTPNull(t *testing.T) { + cm, err := confmaptest.LoadConf(filepath.Join("testdata", "only_http_null.yaml")) + require.NoError(t, err) + factory := NewFactory() + cfg := factory.CreateDefaultConfig() + assert.NoError(t, config.UnmarshalReceiver(cm, cfg)) - defaultOnlyHTTPEmptyMap := factory.CreateDefaultConfig().(*Config) - defaultOnlyHTTPEmptyMap.SetIDName("only_http_empty_map") - defaultOnlyHTTPEmptyMap.GRPC = nil - assert.Equal(t, cfg.Receivers[config.NewComponentIDWithName(typeStr, "only_http_empty_map")], defaultOnlyHTTPEmptyMap) + defaultOnlyHTTP := factory.CreateDefaultConfig().(*Config) + defaultOnlyHTTP.GRPC = nil + assert.Equal(t, defaultOnlyHTTP, cfg) +} - assert.Equal(t, cfg.Receivers[config.NewComponentIDWithName(typeStr, "customname")], - &Config{ - ReceiverSettings: config.NewReceiverSettings(config.NewComponentIDWithName(typeStr, "customname")), - Protocols: Protocols{ - GRPC: &configgrpc.GRPCServerSettings{ - NetAddr: confignet.NetAddr{ - Endpoint: "localhost:9090", - Transport: "tcp", - }, - ReadBufferSize: 512 * 1024, - }, - }, - }) +func TestUnmarshalConfigOnlyHTTPEmptyMap(t *testing.T) { + cm, err := confmaptest.LoadConf(filepath.Join("testdata", "only_http_empty_map.yaml")) + require.NoError(t, err) + factory := NewFactory() + cfg := factory.CreateDefaultConfig() + assert.NoError(t, config.UnmarshalReceiver(cm, cfg)) - assert.Equal(t, cfg.Receivers[config.NewComponentIDWithName(typeStr, "keepalive")], + defaultOnlyHTTP := factory.CreateDefaultConfig().(*Config) + defaultOnlyHTTP.GRPC = nil + assert.Equal(t, defaultOnlyHTTP, cfg) +} + +func TestUnmarshalConfig(t *testing.T) { + cm, err := confmaptest.LoadConf(filepath.Join("testdata", "config.yaml")) + require.NoError(t, err) + factory := NewFactory() + cfg := factory.CreateDefaultConfig() + assert.NoError(t, config.UnmarshalReceiver(cm, cfg)) + assert.Equal(t, &Config{ - ReceiverSettings: config.NewReceiverSettings(config.NewComponentIDWithName(typeStr, "keepalive")), + ReceiverSettings: config.NewReceiverSettings(config.NewComponentID(typeStr)), Protocols: Protocols{ GRPC: &configgrpc.GRPCServerSettings{ NetAddr: confignet.NetAddr{ Endpoint: "0.0.0.0:4317", Transport: "tcp", }, - ReadBufferSize: 512 * 1024, + TLSSetting: &configtls.TLSServerSetting{ + TLSSetting: configtls.TLSSetting{ + CertFile: "test.crt", + KeyFile: "test.key", + }, + }, + MaxRecvMsgSizeMiB: 32, + MaxConcurrentStreams: 16, + ReadBufferSize: 1024, + WriteBufferSize: 1024, Keepalive: &configgrpc.KeepaliveServerConfig{ ServerParameters: &configgrpc.KeepaliveServerParameters{ MaxConnectionIdle: 11 * time.Second, @@ -104,50 +127,6 @@ func TestLoadConfig(t *testing.T) { }, }, }, - }, - }) - - assert.Equal(t, cfg.Receivers[config.NewComponentIDWithName(typeStr, "msg-size-conc-connect-max-idle")], - &Config{ - ReceiverSettings: config.NewReceiverSettings(config.NewComponentIDWithName(typeStr, "msg-size-conc-connect-max-idle")), - Protocols: Protocols{ - GRPC: &configgrpc.GRPCServerSettings{ - NetAddr: confignet.NetAddr{ - Endpoint: "0.0.0.0:4317", - Transport: "tcp", - }, - MaxRecvMsgSizeMiB: 32, - MaxConcurrentStreams: 16, - ReadBufferSize: 1024, - WriteBufferSize: 1024, - Keepalive: &configgrpc.KeepaliveServerConfig{ - ServerParameters: &configgrpc.KeepaliveServerParameters{ - MaxConnectionIdle: 10 * time.Second, - }, - }, - }, - }, - }) - - // NOTE: Once the config loader checks for the files existence, this test may fail and require - // use of fake cert/key for test purposes. - assert.Equal(t, cfg.Receivers[config.NewComponentIDWithName(typeStr, "tlscredentials")], - &Config{ - ReceiverSettings: config.NewReceiverSettings(config.NewComponentIDWithName(typeStr, "tlscredentials")), - Protocols: Protocols{ - GRPC: &configgrpc.GRPCServerSettings{ - NetAddr: confignet.NetAddr{ - Endpoint: "0.0.0.0:4317", - Transport: "tcp", - }, - TLSSetting: &configtls.TLSServerSetting{ - TLSSetting: configtls.TLSSetting{ - CertFile: "test.crt", - KeyFile: "test.key", - }, - }, - ReadBufferSize: 512 * 1024, - }, HTTP: &confighttp.HTTPServerSettings{ Endpoint: "0.0.0.0:4318", TLSSetting: &configtls.TLSServerSetting{ @@ -156,41 +135,25 @@ func TestLoadConfig(t *testing.T) { KeyFile: "test.key", }, }, - }, - }, - }) - - assert.Equal(t, cfg.Receivers[config.NewComponentIDWithName(typeStr, "cors")], - &Config{ - ReceiverSettings: config.NewReceiverSettings(config.NewComponentIDWithName(typeStr, "cors")), - Protocols: Protocols{ - HTTP: &confighttp.HTTPServerSettings{ - Endpoint: "0.0.0.0:4318", CORS: &confighttp.CORSSettings{ AllowedOrigins: []string{"https://*.test.com", "https://test.com"}, MaxAge: 7200, }, }, }, - }) + }, cfg) - assert.Equal(t, cfg.Receivers[config.NewComponentIDWithName(typeStr, "corsheader")], - &Config{ - ReceiverSettings: config.NewReceiverSettings(config.NewComponentIDWithName(typeStr, "corsheader")), - Protocols: Protocols{ - HTTP: &confighttp.HTTPServerSettings{ - Endpoint: "0.0.0.0:4318", - CORS: &confighttp.CORSSettings{ - AllowedOrigins: []string{"https://*.test.com", "https://test.com"}, - AllowedHeaders: []string{"ExampleHeader"}, - }, - }, - }, - }) +} - assert.Equal(t, cfg.Receivers[config.NewComponentIDWithName(typeStr, "uds")], +func TestUnmarshalConfigUnix(t *testing.T) { + cm, err := confmaptest.LoadConf(filepath.Join("testdata", "uds.yaml")) + require.NoError(t, err) + factory := NewFactory() + cfg := factory.CreateDefaultConfig() + assert.NoError(t, config.UnmarshalReceiver(cm, cfg)) + assert.Equal(t, &Config{ - ReceiverSettings: config.NewReceiverSettings(config.NewComponentIDWithName(typeStr, "uds")), + ReceiverSettings: config.NewReceiverSettings(config.NewComponentID(typeStr)), Protocols: Protocols{ GRPC: &configgrpc.GRPCServerSettings{ NetAddr: confignet.NetAddr{ @@ -204,24 +167,36 @@ func TestLoadConfig(t *testing.T) { // Transport: "unix", }, }, - }) + }, cfg) } -func TestFailedLoadConfig(t *testing.T) { - factories, err := componenttest.NopFactories() - assert.NoError(t, err) - +func TestUnmarshalConfigTypoDefaultProtocol(t *testing.T) { + cm, err := confmaptest.LoadConf(filepath.Join("testdata", "typo_default_proto_config.yaml")) + require.NoError(t, err) factory := NewFactory() - factories.Receivers[typeStr] = factory - _, err = servicetest.LoadConfigAndValidate(filepath.Join("testdata", "typo_default_proto_config.yaml"), factories) - assert.EqualError(t, err, "error reading receivers configuration for \"otlp\": 1 error(s) decoding:\n\n* 'protocols' has invalid keys: htttp") + cfg := factory.CreateDefaultConfig() + assert.EqualError(t, config.UnmarshalReceiver(cm, cfg), "1 error(s) decoding:\n\n* 'protocols' has invalid keys: htttp") +} - _, err = servicetest.LoadConfigAndValidate(filepath.Join("testdata", "bad_proto_config.yaml"), factories) - assert.EqualError(t, err, "error reading receivers configuration for \"otlp\": 1 error(s) decoding:\n\n* 'protocols' has invalid keys: thrift") +func TestUnmarshalConfigInvalidProtocol(t *testing.T) { + cm, err := confmaptest.LoadConf(filepath.Join("testdata", "bad_proto_config.yaml")) + require.NoError(t, err) + factory := NewFactory() + cfg := factory.CreateDefaultConfig() + assert.EqualError(t, config.UnmarshalReceiver(cm, cfg), "1 error(s) decoding:\n\n* 'protocols' has invalid keys: thrift") +} - _, err = servicetest.LoadConfigAndValidate(filepath.Join("testdata", "bad_no_proto_config.yaml"), factories) - assert.EqualError(t, err, "receiver \"otlp\" has invalid configuration: must specify at least one protocol when using the OTLP receiver") +func TestUnmarshalConfigEmptyProtocols(t *testing.T) { + cm, err := confmaptest.LoadConf(filepath.Join("testdata", "bad_no_proto_config.yaml")) + require.NoError(t, err) + factory := NewFactory() + cfg := factory.CreateDefaultConfig() + assert.NoError(t, config.UnmarshalReceiver(cm, cfg)) + assert.EqualError(t, cfg.Validate(), "must specify at least one protocol when using the OTLP receiver") +} - _, err = servicetest.LoadConfigAndValidate(filepath.Join("testdata", "bad_empty_config.yaml"), factories) - assert.EqualError(t, err, "error reading receivers configuration for \"otlp\": empty config for OTLP receiver") +func TestUnmarshalConfigEmpty(t *testing.T) { + factory := NewFactory() + cfg := factory.CreateDefaultConfig() + assert.EqualError(t, config.UnmarshalReceiver(confmap.New(), cfg), "empty config for OTLP receiver") } diff --git a/receiver/otlpreceiver/testdata/bad_empty_config.yaml b/receiver/otlpreceiver/testdata/bad_empty_config.yaml deleted file mode 100644 index a204b9998ed..00000000000 --- a/receiver/otlpreceiver/testdata/bad_empty_config.yaml +++ /dev/null @@ -1,15 +0,0 @@ -receivers: - otlp: - -processors: - nop: - -exporters: - nop: - -service: - pipelines: - traces: - receivers: [otlp] - processors: [nop] - exporters: [nop] diff --git a/receiver/otlpreceiver/testdata/bad_no_proto_config.yaml b/receiver/otlpreceiver/testdata/bad_no_proto_config.yaml index cd1ffd31a35..96ae057a37a 100644 --- a/receiver/otlpreceiver/testdata/bad_no_proto_config.yaml +++ b/receiver/otlpreceiver/testdata/bad_no_proto_config.yaml @@ -1,16 +1 @@ -receivers: - otlp: - protocols: - -processors: - nop: - -exporters: - nop: - -service: - pipelines: - traces: - receivers: [otlp] - processors: [nop] - exporters: [nop] +protocols: diff --git a/receiver/otlpreceiver/testdata/bad_proto_config.yaml b/receiver/otlpreceiver/testdata/bad_proto_config.yaml index 2191f7bb7ad..9be62602f5b 100644 --- a/receiver/otlpreceiver/testdata/bad_proto_config.yaml +++ b/receiver/otlpreceiver/testdata/bad_proto_config.yaml @@ -1,18 +1,3 @@ -receivers: - otlp: - protocols: - thrift: - endpoint: "127.0.0.1:1234" - -processors: - nop: - -exporters: - nop: - -service: - pipelines: - traces: - receivers: [otlp] - processors: [nop] - exporters: [nop] +protocols: + thrift: + endpoint: "127.0.0.1:1234" diff --git a/receiver/otlpreceiver/testdata/config.yaml b/receiver/otlpreceiver/testdata/config.yaml index db79718fe66..84c658d4f28 100644 --- a/receiver/otlpreceiver/testdata/config.yaml +++ b/receiver/otlpreceiver/testdata/config.yaml @@ -1,115 +1,41 @@ -receivers: - # The following entry initializes the default OTLP receiver. - # The full name of this receiver is `otlp` and can be referenced in pipelines by 'otlp'. - otlp: - protocols: - grpc: - http: - # The following entry initializes the default OTLP receiver with only gRPC support. - otlp/only_grpc: - protocols: - grpc: - # The following entry initializes the default OTLP receiver with only http support. - otlp/only_http: - protocols: - http: - # The following entry initializes the default OTLP receiver with only http support by setting it explicitly to null. - otlp/only_http_null: - protocols: - http: null - # The following entry initializes the default OTLP receiver with only http support by setting it explicitly to an empty map. - otlp/only_http_empty_map: - protocols: - http: {} - # The following entry demonstrates configuring the common receiver settings: - # - endpoint - # This configuration is of type 'otlp' and has the name 'customname' with a full name of 'otlp/customname' - # ('/'. To reference this configuration in a pipeline, use the full name `otlp/customname`. - otlp/customname: - protocols: - grpc: - # The receiver will listen on endpoint: "localhost:9090". - endpoint: localhost:9090 - # The following entry configures all of the keep alive settings. These settings are used to configure the receiver. - otlp/keepalive: - protocols: - grpc: - keepalive: - server_parameters: - max_connection_idle: 11s - max_connection_age: 12s - max_connection_age_grace: 13s - time: 30s - timeout: 5s - enforcement_policy: - min_time: 10s - permit_without_stream: true - # The following demonstrates how to set maximum limits on stream, message size and connection idle time. - # Note: The test yaml has demonstrated configuration on a grouped by their structure; however, all of the settings can - # be mix and matched like adding the maximum connection idle setting in this example. - otlp/msg-size-conc-connect-max-idle: - protocols: - grpc: - max_recv_msg_size_mib: 32 - max_concurrent_streams: 16 - read_buffer_size: 1024 - write_buffer_size: 1024 - keepalive: - server_parameters: - max_connection_idle: 10s - # The following entry demonstrates how to specify TLS credentials for the server. - # Note: These files do not exist. If the receiver is started with this configuration, it will fail. - otlp/tlscredentials: - protocols: - grpc: - tls: - cert_file: test.crt - key_file: test.key - http: - tls: - cert_file: test.crt - key_file: test.key - # The following entry demonstrates how to specify a Unix Domain Socket for the server. - otlp/uds: - protocols: - grpc: - transport: unix - endpoint: /tmp/grpc_otlp.sock - http: - # transport: unix - endpoint: /tmp/http_otlp.sock - # The following entry demonstrates how to configure the OTLP receiver to allow Cross-Origin Resource Sharing (CORS). - # Both fully qualified domain names and the use of wildcards are supported. - otlp/cors: - protocols: - http: - cors: - allowed_origins: - - https://*.test.com # Wildcard subdomain. Allows domains like https://www.test.com and https://foo.test.com but not https://wwwtest.com. - - https://test.com # Fully qualified domain name. Allows https://test.com only. - max_age: 7200 - # The following entry demonstrates how to use CORS Header configuration. - otlp/corsheader: - protocols: - http: - cors: - allowed_origins: - - https://*.test.com # Wildcard subdomain. Allows domains like https://www.test.com and https://foo.test.com but not https://wwwtest.com. - - https://test.com # Fully qualified domain name. Allows https://test.com only. - allowed_headers: - - ExampleHeader -processors: - nop: +protocols: + grpc: + # The following entry demonstrates how to specify TLS credentials for the server. + # Note: These files do not exist. If the receiver is started with this configuration, it will fail. + tls: + cert_file: test.crt + key_file: test.key -exporters: - nop: + # The following demonstrates how to set maximum limits on stream, message size and connection idle time. + # Note: The test yaml has demonstrated configuration on a grouped by their structure; however, all of the settings can + # be mix and matched like adding the maximum connection idle setting in this example. + max_recv_msg_size_mib: 32 + max_concurrent_streams: 16 + read_buffer_size: 1024 + write_buffer_size: 1024 -service: - pipelines: - traces: - receivers: [otlp/customname] - processors: [nop] - exporters: [nop] - metrics: - receivers: [otlp] - exporters: [nop] + # The following entry configures all of the keep alive settings. These settings are used to configure the receiver. + keepalive: + server_parameters: + max_connection_idle: 11s + max_connection_age: 12s + max_connection_age_grace: 13s + time: 30s + timeout: 5s + enforcement_policy: + min_time: 10s + permit_without_stream: true + http: + # The following entry demonstrates how to specify TLS credentials for the server. + # Note: These files do not exist. If the receiver is started with this configuration, it will fail. + tls: + cert_file: test.crt + key_file: test.key + + # The following entry demonstrates how to configure the OTLP receiver to allow Cross-Origin Resource Sharing (CORS). + # Both fully qualified domain names and the use of wildcards are supported. + cors: + allowed_origins: + - https://*.test.com # Wildcard subdomain. Allows domains like https://www.test.com and https://foo.test.com but not https://wwwtest.com. + - https://test.com # Fully qualified domain name. Allows https://test.com only. + max_age: 7200 diff --git a/receiver/otlpreceiver/testdata/default.yaml b/receiver/otlpreceiver/testdata/default.yaml new file mode 100644 index 00000000000..af0e1f51cb5 --- /dev/null +++ b/receiver/otlpreceiver/testdata/default.yaml @@ -0,0 +1,5 @@ +# The following entry initializes the default OTLP receiver. +# The full name of this receiver is `otlp` and can be referenced in pipelines by 'otlp'. +protocols: + grpc: + http: diff --git a/receiver/otlpreceiver/testdata/only_grpc.yaml b/receiver/otlpreceiver/testdata/only_grpc.yaml new file mode 100644 index 00000000000..98f01598719 --- /dev/null +++ b/receiver/otlpreceiver/testdata/only_grpc.yaml @@ -0,0 +1,3 @@ +# The following entry initializes the default OTLP receiver with only gRPC support. +protocols: + grpc: diff --git a/receiver/otlpreceiver/testdata/only_http.yaml b/receiver/otlpreceiver/testdata/only_http.yaml new file mode 100644 index 00000000000..bf1a240f70b --- /dev/null +++ b/receiver/otlpreceiver/testdata/only_http.yaml @@ -0,0 +1,3 @@ +# The following entry initializes the default OTLP receiver with only http support. +protocols: + http: diff --git a/receiver/otlpreceiver/testdata/only_http_empty_map.yaml b/receiver/otlpreceiver/testdata/only_http_empty_map.yaml new file mode 100644 index 00000000000..d3313f4f07c --- /dev/null +++ b/receiver/otlpreceiver/testdata/only_http_empty_map.yaml @@ -0,0 +1,3 @@ +# The following entry initializes the default OTLP receiver with only http support by setting it explicitly to an empty map. +protocols: + http: {} diff --git a/receiver/otlpreceiver/testdata/only_http_null.yaml b/receiver/otlpreceiver/testdata/only_http_null.yaml new file mode 100644 index 00000000000..3f16f6d52e8 --- /dev/null +++ b/receiver/otlpreceiver/testdata/only_http_null.yaml @@ -0,0 +1,3 @@ +# The following entry initializes the default OTLP receiver with only http support by setting it explicitly to null. +protocols: + http: null diff --git a/receiver/otlpreceiver/testdata/typo_default_proto_config.yaml b/receiver/otlpreceiver/testdata/typo_default_proto_config.yaml index 841eac51f55..61ffd2b7a5d 100644 --- a/receiver/otlpreceiver/testdata/typo_default_proto_config.yaml +++ b/receiver/otlpreceiver/testdata/typo_default_proto_config.yaml @@ -1,18 +1,3 @@ -receivers: - otlp: - protocols: - grpc: - htttp: - -processors: - nop: - -exporters: - nop: - -service: - pipelines: - traces: - receivers: [otlp] - processors: [nop] - exporters: [nop] +protocols: + grpc: + htttp: diff --git a/receiver/otlpreceiver/testdata/uds.yaml b/receiver/otlpreceiver/testdata/uds.yaml new file mode 100644 index 00000000000..d1d70bff7df --- /dev/null +++ b/receiver/otlpreceiver/testdata/uds.yaml @@ -0,0 +1,8 @@ +# The following entry demonstrates how to specify a Unix Domain Socket for the server. +protocols: + grpc: + transport: unix + endpoint: /tmp/grpc_otlp.sock + http: + # transport: unix + endpoint: /tmp/http_otlp.sock