Skip to content

Commit

Permalink
[OTEL-2125] Add E2E test for no dd exporter case
Browse files Browse the repository at this point in the history
  • Loading branch information
songy23 committed Oct 30, 2024
1 parent 4991a56 commit 910f754
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 1 deletion.
4 changes: 3 additions & 1 deletion comp/otelcol/ddflareextension/impl/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ func newServer(endpoint string, handler http.Handler) (*server, error) {
r := mux.NewRouter()
r.Handle("/", handler)

r.Use(validateToken)
if util.GetAuthToken() != "" {
r.Use(validateToken)
}

s := &http.Server{
Addr: endpoint,
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:
metrics:
receivers: [otlp]
exporters: [debug]
traces:
receivers: [otlp]
exporters: [debug]
logs:
receivers: [otlp]
exporters: [debug]
62 changes: 62 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,62 @@
// 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

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.WithoutDualShipping(),
kubernetesagentparams.WithHelmValues(values),
kubernetesagentparams.WithOTelAgent(),
kubernetesagentparams.WithOTelConfig(noDDExporterConfig),
))))
}

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

func (s *noDDExporterTestSuite) TestFlare() {
expectedContents := []string{
"otel-agent",
"ddflare/dd-autoconfigured:",
"health_check/dd-autoconfigured:",
"pprof/dd-autoconfigured:",
"zpages/dd-autoconfigured:",
"infraattributes/dd-autoconfigured:",
"prometheus/dd-autoconfigured:",
}
utils.TestOTelFlare(s, expectedContents)
}

0 comments on commit 910f754

Please sign in to comment.