Skip to content

Commit

Permalink
integration_test: add integration test for the collector
Browse files Browse the repository at this point in the history
This change does the following:
- Adds skeleton for integration testing the collector
- Add integration test for prometheus metrics
- Add integration test for short lived collector
- Use prometheus branch that allows skipping wait in discovery and
  scrape managers

Change-Id: I0fa7034602ef1616a2316f2facf204075bec3a16
Signed-off-by: Ridwan Sharif <[email protected]>
  • Loading branch information
ridwanmsharif committed Nov 24, 2023
1 parent b78d95b commit 3b1bbb9
Show file tree
Hide file tree
Showing 6 changed files with 458 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
integration_test/results/
bin/
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ build:

.PHONY: test
test:
go test -tags=$(GO_BUILD_TAGS) $(GO_TEST_VERBOSE) -race ./...
$(MAKE) build-collector
go test -tags=$(GO_BUILD_TAGS) $(GO_TEST_VERBOSE) -p 1 -race ./...

.PHONY: test_quiet
test_verbose:
Expand Down
4 changes: 2 additions & 2 deletions collector/receiver/prometheusreceiver/metrics_receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ func (r *pReceiver) applyCfg(cfg *config.Config) error {
}

func (r *pReceiver) initPrometheusComponents(ctx context.Context, host component.Host, logger log.Logger) error {
r.discoveryManager = discovery.NewManager(ctx, logger)
r.discoveryManager = discovery.NewManager(ctx, logger, discovery.SkipInitialWait())

go func() {
r.settings.Logger.Info("Starting discovery manager")
Expand Down Expand Up @@ -287,7 +287,7 @@ func (r *pReceiver) initPrometheusComponents(ctx context.Context, host component

// For the sidecar, use a 10s offset from the start before scraping the targets.
tenSecondOffSet := 10 * time.Second
r.scrapeManager = scrape.NewManager(&scrape.Options{PassMetadataInContext: true, InitialScrapeOffset: &tenSecondOffSet}, logger, store)
r.scrapeManager = scrape.NewManager(&scrape.Options{PassMetadataInContext: true, InitialScrapeOffset: &tenSecondOffSet, DiscoveryReloadOnStartup: true}, logger, store)

go func() {
// The scrape manager needs to wait for the configuration to be loaded before beginning
Expand Down
29 changes: 25 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor v0.81.0
github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourceprocessor v0.81.0
github.com/open-telemetry/opentelemetry-collector-contrib/processor/transformprocessor v0.81.0
github.com/open-telemetry/opentelemetry-collector-contrib/testbed v0.81.0
github.com/shirou/gopsutil v3.21.11+incompatible
github.com/stretchr/testify v1.8.4
go.opentelemetry.io/collector v0.81.0
Expand Down Expand Up @@ -49,25 +50,45 @@ require (
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect
github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0 // indirect
github.com/apache/thrift v0.18.1 // indirect
github.com/census-instrumentation/opencensus-proto v0.4.1 // indirect
github.com/go-playground/validator/v10 v10.15.5 // indirect
github.com/gogo/googleapis v1.4.1 // indirect
github.com/google/s2a-go v0.1.4 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hetznercloud/hcloud-go/v2 v2.0.0 // indirect
github.com/jaegertracing/jaeger v1.41.0 // indirect
github.com/knadh/koanf/v2 v2.0.1 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/observiq/ctimefmt v1.0.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/jaegerexporter v0.81.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/opencensusexporter v0.81.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/zipkinexporter v0.81.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/internal/filter v0.81.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/resourcetotelemetry v0.81.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/jaeger v0.81.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/opencensus v0.81.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheusremotewrite v0.81.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/zipkin v0.81.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/jaegerreceiver v0.81.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/opencensusreceiver v0.81.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zipkinreceiver v0.81.0 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/openzipkin/zipkin-go v0.4.1 // indirect
github.com/ovh/go-ovh v1.4.1 // indirect
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/soheilhy/cmux v0.1.5 // indirect
github.com/tidwall/gjson v1.10.2 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
github.com/tidwall/tinylru v1.1.0 // indirect
github.com/tidwall/wal v1.1.7 // indirect
github.com/uber/jaeger-client-go v2.30.0+incompatible // indirect
github.com/uber/jaeger-lib v2.4.1+incompatible // indirect
go.opentelemetry.io/collector/config/configauth v0.81.0 // indirect
go.opentelemetry.io/collector/config/configcompression v0.81.0 // indirect
go.opentelemetry.io/collector/config/configgrpc v0.81.0 // indirect
Expand Down Expand Up @@ -186,7 +207,7 @@ require (
github.com/knadh/koanf v1.5.0 // indirect
github.com/kolo/xmlrpc v0.0.0-20220921171641-a4b6fa1dd06b // indirect
github.com/linode/linodego v1.19.0 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/lufia/plan9stats v0.0.0-20220913051719-115f729f3c8c // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
Expand All @@ -211,8 +232,8 @@ require (
github.com/opencontainers/image-spec v1.1.0-rc2 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/prometheus/client_golang v1.16.0 // indirect
github.com/power-devops/perfstat v0.0.0-20220216144756-c35f1ee13d7c // indirect
github.com/prometheus/client_golang v1.16.0
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.44.0
github.com/prometheus/common/sigv4 v0.1.0 // indirect
Expand Down Expand Up @@ -274,4 +295,4 @@ require (
// Currently causes build issues on windows. Downgrading to previous version.
replace github.com/mattn/go-ieproxy v0.0.9 => github.com/mattn/go-ieproxy v0.0.1

replace github.com/prometheus/prometheus => github.com/GoogleCloudPlatform/prometheus v0.0.0-20231020122117-842a79123338
replace github.com/prometheus/prometheus => github.com/googleCloudPlatform/prometheus v0.0.0-20231122180802-b918f749a5b8
Loading

0 comments on commit 3b1bbb9

Please sign in to comment.