mirror of
https://github.com/hanzoai/otel-collector.git
synced 2026-10-30 18:26:25 +00:00
- add metadata.yaml for all relevant components and use metadata - fix the go routine leaks in component code and tests - add TODO for handling errors wherever they are unchecked or not handled so the behaviour doesn't change - address lint for the most part (so we can enable it soon) except the metricexporter that is due to be deleted and semconv which I don't want to touch right now - other changes required for bump breaking changes to pay attention to - telemetry config, address and level removed and readers should be used - change in attributes for telemetry - metrics at detailed level - failures in embedded config (addressed) --------- Co-authored-by: Nityananda Gohain <[email protected]>
72 lines
2.2 KiB
Go
72 lines
2.2 KiB
Go
// Code generated by mdatagen. DO NOT EDIT.
|
|
|
|
package httplogreceiver
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
"go.opentelemetry.io/collector/component"
|
|
"go.opentelemetry.io/collector/component/componenttest"
|
|
"go.opentelemetry.io/collector/confmap/confmaptest"
|
|
"go.opentelemetry.io/collector/consumer/consumertest"
|
|
"go.opentelemetry.io/collector/receiver"
|
|
"go.opentelemetry.io/collector/receiver/receivertest"
|
|
)
|
|
|
|
var typ = component.MustNewType("httplogreceiver")
|
|
|
|
func TestComponentFactoryType(t *testing.T) {
|
|
require.Equal(t, typ, NewFactory().Type())
|
|
}
|
|
|
|
func TestComponentConfigStruct(t *testing.T) {
|
|
require.NoError(t, componenttest.CheckConfigStruct(NewFactory().CreateDefaultConfig()))
|
|
}
|
|
|
|
func TestComponentLifecycle(t *testing.T) {
|
|
factory := NewFactory()
|
|
|
|
tests := []struct {
|
|
createFn func(ctx context.Context, set receiver.Settings, cfg component.Config) (component.Component, error)
|
|
name string
|
|
}{
|
|
|
|
{
|
|
name: "logs",
|
|
createFn: func(ctx context.Context, set receiver.Settings, cfg component.Config) (component.Component, error) {
|
|
return factory.CreateLogs(ctx, set, cfg, consumertest.NewNop())
|
|
},
|
|
},
|
|
}
|
|
|
|
cm, err := confmaptest.LoadConf("metadata.yaml")
|
|
require.NoError(t, err)
|
|
cfg := factory.CreateDefaultConfig()
|
|
sub, err := cm.Sub("tests::config")
|
|
require.NoError(t, err)
|
|
require.NoError(t, sub.Unmarshal(&cfg))
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name+"-shutdown", func(t *testing.T) {
|
|
c, err := tt.createFn(context.Background(), receivertest.NewNopSettings(typ), cfg)
|
|
require.NoError(t, err)
|
|
err = c.Shutdown(context.Background())
|
|
require.NoError(t, err)
|
|
})
|
|
t.Run(tt.name+"-lifecycle", func(t *testing.T) {
|
|
firstRcvr, err := tt.createFn(context.Background(), receivertest.NewNopSettings(typ), cfg)
|
|
require.NoError(t, err)
|
|
host := componenttest.NewNopHost()
|
|
require.NoError(t, err)
|
|
require.NoError(t, firstRcvr.Start(context.Background(), host))
|
|
require.NoError(t, firstRcvr.Shutdown(context.Background()))
|
|
secondRcvr, err := tt.createFn(context.Background(), receivertest.NewNopSettings(typ), cfg)
|
|
require.NoError(t, err)
|
|
require.NoError(t, secondRcvr.Start(context.Background(), host))
|
|
require.NoError(t, secondRcvr.Shutdown(context.Background()))
|
|
})
|
|
}
|
|
}
|