Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OTEL-2125] Add E2E test for no dd exporter case #30069

Merged
merged 9 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion cmd/otel-agent/subcommands/run/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/DataDog/datadog-agent/comp/core/hostname/hostnameinterface"
"github.com/DataDog/datadog-agent/comp/core/hostname/remotehostnameimpl"
log "github.com/DataDog/datadog-agent/comp/core/log/def"
logfx "github.com/DataDog/datadog-agent/comp/core/log/fx"
logtracefx "github.com/DataDog/datadog-agent/comp/core/log/fx-trace"
"github.com/DataDog/datadog-agent/comp/core/secrets"
tagger "github.com/DataDog/datadog-agent/comp/core/tagger/def"
Expand Down Expand Up @@ -106,8 +107,20 @@ func runOTelAgentCommand(ctx context.Context, params *subcommands.GlobalParams,
fx.Provide(func() coreconfig.Component {
return acfg
}),
fx.Provide(func(_ coreconfig.Component) log.Params {
return log.ForDaemon(params.LoggerName, "log_file", pkgconfigsetup.DefaultOTelAgentLogFile)
}),
logfx.Module(),
fetchonlyimpl.Module(),
// TODO: don't rely on this pattern; remove this `OptionalModuleWithParams` thing
// and instead adapt OptionalModule to allow parameter passing naturally.
// See: https://github.com/DataDog/datadog-agent/pull/28386
configsyncimpl.OptionalModuleWithParams(),
fx.Provide(func() configsyncimpl.Params {
return configsyncimpl.NewParams(params.SyncTimeout, params.SyncDelay, true)
}),
converterfx.Module(),
fx.Provide(func(cp converter.Component) confmap.Converter {
fx.Provide(func(cp converter.Component, _ optional.Option[configsync.Component]) confmap.Converter {
songy23 marked this conversation as resolved.
Show resolved Hide resolved
return cp
}),
collectorcontribFx.Module(),
Expand Down
2 changes: 1 addition & 1 deletion comp/otelcol/ddflareextension/impl/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func newServer(endpoint string, handler http.Handler, auth bool) (*server, error
// no easy way currently to pass required bearer auth token to OSS collector;
// skip the validation if running inside a separate collector
// TODO: determine way to allow OSS collector to authenticate with agent, OTEL-2226
if auth {
if auth && util.GetAuthToken() != "" {
r.Use(validateToken)
}

Expand Down
23 changes: 23 additions & 0 deletions test/new-e2e/tests/otel/otel-agent/config/no-dd-exporter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317
http:
endpoint: 0.0.0.0:4318

exporters:
debug:
verbosity: detailed

service:
pipelines:
traces:
receivers: [otlp]
exporters: [debug]
metrics:
receivers: [otlp]
exporters: [debug]
logs:
receivers: [otlp]
exporters: [debug]
6 changes: 3 additions & 3 deletions test/new-e2e/tests/otel/otel-agent/minimal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ var minimalProvidedConfig string
//go:embed testdata/minimal-full-config.yml
var minimalFullConfig string

//go:embed testdata/minimal-sources.json
var minimalSources string
//go:embed testdata/sources.json
var sources string

func TestOTelAgentMinimal(t *testing.T) {
values := `
Expand Down Expand Up @@ -82,7 +82,7 @@ func (s *minimalTestSuite) TestOTelAgentInstalled() {
}

func (s *minimalTestSuite) TestOTelFlareExtensionResponse() {
utils.TestOTelFlareExtensionResponse(s, minimalProvidedConfig, minimalFullConfig, minimalSources)
utils.TestOTelFlareExtensionResponse(s, minimalProvidedConfig, minimalFullConfig, sources)
}

func (s *minimalTestSuite) TestOTelFlareFiles() {
Expand Down
58 changes: 58 additions & 0 deletions test/new-e2e/tests/otel/otel-agent/no_dd_exporter_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.

// Package otelagent contains e2e otel agent tests
package otelagent

import (
_ "embed"
"testing"

"github.com/DataDog/test-infra-definitions/components/datadog/kubernetesagentparams"

"github.com/DataDog/datadog-agent/test/new-e2e/pkg/e2e"
"github.com/DataDog/datadog-agent/test/new-e2e/pkg/environments"
awskubernetes "github.com/DataDog/datadog-agent/test/new-e2e/pkg/environments/aws/kubernetes"
"github.com/DataDog/datadog-agent/test/new-e2e/tests/otel/utils"
)

type noDDExporterTestSuite struct {
e2e.BaseSuite[environments.Kubernetes]
}

//go:embed config/no-dd-exporter.yml
var noDDExporterConfig string

//go:embed testdata/no-dd-exporter-provided-config.yml
var noDDExporterProvidedConfig string

//go:embed testdata/no-dd-exporter-full-config.yml
var noDDExporterFullConfig string

func TestOTelAgentWithNoDDExporter(t *testing.T) {
values := `
datadog:
logs:
containerCollectAll: false
containerCollectUsingFiles: false
`
t.Parallel()
e2e.Run(t, &noDDExporterTestSuite{},
e2e.WithProvisioner(
awskubernetes.KindProvisioner(
awskubernetes.WithAgentOptions(
kubernetesagentparams.WithHelmValues(values),
kubernetesagentparams.WithOTelAgent(),
kubernetesagentparams.WithOTelConfig(noDDExporterConfig),
))))
}

func (s *noDDExporterTestSuite) TestOTelAgentInstalled() {
utils.TestOTelAgentInstalled(s)
}

func (s *noDDExporterTestSuite) TestOTelFlareExtensionResponse() {
utils.TestOTelFlareExtensionResponse(s, noDDExporterProvidedConfig, noDDExporterFullConfig, sources)
}
Loading
Loading