integration_test.go 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright The OpenTelemetry Authors
  2. // SPDX-License-Identifier: Apache-2.0
  3. //go:build integration
  4. // +build integration
  5. package apachesparkreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/apachesparkreceiver"
  6. import (
  7. "fmt"
  8. "path/filepath"
  9. "testing"
  10. "time"
  11. "github.com/testcontainers/testcontainers-go"
  12. "github.com/testcontainers/testcontainers-go/wait"
  13. "go.opentelemetry.io/collector/component"
  14. "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/scraperinttest"
  15. "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest/pmetrictest"
  16. )
  17. const sparkPort = "4040"
  18. func TestIntegration(t *testing.T) {
  19. scraperinttest.NewIntegrationTest(
  20. NewFactory(),
  21. scraperinttest.WithContainerRequest(
  22. testcontainers.ContainerRequest{
  23. FromDockerfile: testcontainers.FromDockerfile{
  24. Context: filepath.Join("testdata", "integration"),
  25. Dockerfile: "Dockerfile.apache-spark",
  26. },
  27. ExposedPorts: []string{sparkPort},
  28. WaitingFor: wait.ForListeningPort(sparkPort).WithStartupTimeout(2 * time.Minute),
  29. }),
  30. scraperinttest.WithCustomConfig(
  31. func(t *testing.T, cfg component.Config, ci *scraperinttest.ContainerInfo) {
  32. rCfg := cfg.(*Config)
  33. rCfg.ScraperControllerSettings.CollectionInterval = 3 * time.Second
  34. rCfg.Endpoint = fmt.Sprintf("http://%s:%s", ci.Host(t), ci.MappedPort(t, sparkPort))
  35. }),
  36. scraperinttest.WithCompareOptions(
  37. pmetrictest.IgnoreMetricValues(),
  38. pmetrictest.IgnoreStartTimestamp(),
  39. pmetrictest.IgnoreTimestamp(),
  40. pmetrictest.IgnoreResourceAttributeValue("spark.application.id"),
  41. pmetrictest.IgnoreResourceAttributeValue("spark.application.name"),
  42. pmetrictest.IgnoreMetricAttributeValue("active", "spark.stage.status"),
  43. pmetrictest.IgnoreMetricAttributeValue("complete", "spark.stage.status"),
  44. pmetrictest.IgnoreMetricAttributeValue("failed", "spark.stage.status"),
  45. pmetrictest.IgnoreMetricAttributeValue("pending", "spark.stage.status"),
  46. pmetrictest.IgnoreMetricDataPointsOrder(),
  47. ),
  48. ).Run(t)
  49. }