Skip to content

Commit

Permalink
Add k8s enrichment and prometheus e2e tests (Dynatrace#171)
Browse files Browse the repository at this point in the history
* WIP

* WIP

* wip

* Refactor e2e workflow

* Fix kind versions

* Fix image

* Fix kubeconfig

* Add docs

* Only test traces

* Re-add test label

* Add prometheus scrape test

* Refine message

* Add prometheus test to workflow

* go mod tidy

* go mod tidy

* PR suggestions

* Assert node exporter metrics

* Add comment
  • Loading branch information
joaopgrassi authored May 3, 2024
1 parent 122b666 commit 9232724
Show file tree
Hide file tree
Showing 31 changed files with 1,842 additions and 575 deletions.
113 changes: 77 additions & 36 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
name: E2E-Test
on: workflow_dispatch


on:
pull_request:
branches: [main]

defaults:
run:
shell: bash

jobs:
run-e2e-test:
name: Run E2E Tests

docker-build:
runs-on: ubuntu-22.04
steps:
- name: Check out code
Expand All @@ -19,7 +22,7 @@ jobs:
go-version: "~1.21.3"
check-latest: true
cache-dependency-path: internal/tools/go.sum

- name: Cache tools
uses: actions/cache@v4
with:
Expand All @@ -39,51 +42,89 @@ jobs:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: network=host

- name: Build and push to local registry
uses: docker/build-push-action@v5
with:
context: ./bin
file: Dockerfile
push: false
load: true
tags: localhost:5000/collector:e2e-test
tags: dynatrace-otel-collector:e2e-test

- name: Install Chainsaw
uses: kyverno/[email protected]
- name: export image to tar
run: |
docker save dynatrace-otel-collector:e2e-test > /tmp/dynatrace-otel-collector.tar
- name: Create Kind Cluster
uses: ./.github/actions/create-cluster
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
kind-version: "v0.18.0"
k8s-version: "v1.27.3"
runtime_tag: "latest"
cluster-name: "test-cluster"

- name: Load Image into Kind
shell: bash
name: dynatrace-otel-collector
path: /tmp/dynatrace-otel-collector.tar

k8s-e2e-test-matrix:
env:
KUBECONFIG: /tmp/kube-config-collector-e2e-testing
strategy:
fail-fast: false
matrix:
usecase:
- testbed/integration/k8senrichment
- testbed/integration/prometheus
runs-on: ubuntu-latest
needs: docker-build
steps:
- name: Check out code
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "~1.21.3"
check-latest: true
cache-dependency-path: internal/tools/go.sum

- name: Cache tools
uses: actions/cache@v4
with:
path: .tools
key: ci-tools-${{ runner.os }}-${{ hashFiles('internal/tools/go.sum') }}

- name: Touch tools
run: |
echo "Loading image into Kind"
kind load docker-image localhost:5000/collector:e2e-test --name test-cluster
mkdir -p .tools
touch .tools/*
- name: Setup Prometheus Node Exporter
uses: ./.github/actions/deploy-prometheus
- name: Create kind cluster
uses: helm/[email protected]
with:
node_image: "kindest/node:v1.27.11"
kubectl_version: "v1.27.11"
cluster_name: kind

- name: Deploy Collector
uses: ./.github/actions/deploy-collector
- name: Download artifact
uses: actions/download-artifact@v4
with:
collector-version: "latest"
DT_API_ENDPOINT: ${{ secrets.DT_API_ENDPOINT }}
DT_API_TOKEN: ${{ secrets.DT_API_TOKEN }}

- name: Run E2E Tests
env:
DT_API_ENDPOINT: ${{ secrets.DT_API_ENDPOINT }}
DT_API_TOKEN: ${{ secrets.DT_API_TOKEN }}
name: dynatrace-otel-collector
path: /tmp

- name: Load Docker image
run: |
docker load --input /tmp/dynatrace-otel-collector.tar
- name: Kind load image
run: |
kind load docker-image dynatrace-otel-collector:e2e-test --name kind
- name: Load Image into Kind
shell: bash
run: |
kind load docker-image dynatrace-otel-collector:e2e-test --name kind
- name: Run e2e tests
run: |
echo "Running E2E Tests"
chainsaw version
chainsaw test --test-dir ./testbed/chainsaw/ --config ./.chainsaw.yaml
cd ${{ matrix.usecase }}
go test -v --tags=e2e
114 changes: 76 additions & 38 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,56 +5,75 @@ go 1.21.0
toolchain go1.22.2

require (
github.com/Dynatrace/dynatrace-otel-collector/internal/k8stest v0.0.0
github.com/google/uuid v1.6.0
github.com/open-telemetry/opentelemetry-collector-contrib/testbed v0.99.0
github.com/stretchr/testify v1.9.0
go.opentelemetry.io/collector/component v0.99.0
go.opentelemetry.io/collector/consumer v0.99.0
go.opentelemetry.io/collector/pdata v1.6.0
go.opentelemetry.io/collector/receiver v0.99.0
go.opentelemetry.io/collector/receiver/otlpreceiver v0.99.0
go.opentelemetry.io/collector/semconv v0.99.0
go.uber.org/multierr v1.11.0
gopkg.in/yaml.v3 v3.0.1
)

require (
github.com/DataDog/datadog-agent/pkg/trace/exportable v0.0.0-20201016145401-4646cf596b02 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/apache/thrift v0.20.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/census-instrumentation/opencensus-proto v0.4.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/distribution/reference v0.5.0 // indirect
github.com/docker/docker v25.0.5+incompatible // indirect
github.com/docker/go-connections v0.5.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/expr-lang/expr v1.16.5 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fluent/fluent-logger-golang v1.9.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/go-openapi/jsonpointer v0.20.2 // indirect
github.com/go-openapi/jsonreference v0.20.4 // indirect
github.com/go-openapi/swag v0.22.9 // indirect
github.com/go-viper/mapstructure/v2 v2.0.0-alpha.1 // indirect
github.com/gobwas/glob v0.2.3 // indirect
github.com/gogo/googleapis v1.4.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/gorilla/mux v1.8.1 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 // indirect
github.com/haimrubinstein/go-syslog/v3 v3.0.0 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/influxdata/go-syslog/v3 v3.0.1-0.20230911200830-875f5bc594a4 // indirect
github.com/jaegertracing/jaeger v1.56.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/jpillora/backoff v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.8 // indirect
github.com/knadh/koanf v1.5.0 // indirect
github.com/knadh/koanf/v2 v2.1.1 // indirect
github.com/leodido/ragel-machinery v0.0.0-20181214104525-299bdde78165 // indirect
github.com/lufia/plan9stats v0.0.0-20220913051719-115f729f3c8c // indirect
github.com/leodido/ragel-machinery v0.0.0-20190525184631-5f46317e436b // indirect
github.com/lufia/plan9stats v0.0.0-20240408141607-282e7b5d6b74 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/mostynb/go-grpc-compression v1.2.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/carbonexporter v0.99.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/opencensusexporter v0.99.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/prometheusexporter v0.99.0 // indirect
Expand Down Expand Up @@ -82,15 +101,18 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/syslogreceiver v0.99.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zipkinreceiver v0.99.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/testbed/mockdatasenders/mockdatadogagentexporter v0.99.0 // indirect
github.com/openzipkin/zipkin-go v0.4.2 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/openzipkin/zipkin-go v0.4.3 // indirect
github.com/philhofer/fwd v1.1.2 // 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-20220216144756-c35f1ee13d7c // indirect
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
github.com/prometheus/client_golang v1.19.0 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.52.3 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/rs/cors v1.10.1 // indirect
github.com/prometheus/common v0.53.0 // indirect
github.com/prometheus/procfs v0.14.0 // indirect
github.com/rs/cors v1.11.0 // indirect
github.com/shirou/gopsutil/v3 v3.24.3 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/signalfx/com_signalfx_metrics_protobuf v0.0.3 // indirect
Expand All @@ -99,8 +121,8 @@ require (
github.com/spf13/cobra v1.8.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/tinylib/msgp v1.1.9 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/tklauser/go-sysconf v0.3.14 // indirect
github.com/tklauser/numcpus v0.8.0 // indirect
github.com/valyala/fastjson v1.6.4 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
go.opencensus.io v0.24.0 // indirect
Expand All @@ -123,7 +145,6 @@ require (
go.opentelemetry.io/collector/confmap/provider/httpsprovider v0.99.0 // indirect
go.opentelemetry.io/collector/confmap/provider/yamlprovider v0.99.0 // indirect
go.opentelemetry.io/collector/connector v0.99.0 // indirect
go.opentelemetry.io/collector/consumer v0.99.0 // indirect
go.opentelemetry.io/collector/exporter v0.99.0 // indirect
go.opentelemetry.io/collector/exporter/debugexporter v0.99.0 // indirect
go.opentelemetry.io/collector/exporter/otlpexporter v0.99.0 // indirect
Expand All @@ -137,40 +158,57 @@ require (
go.opentelemetry.io/collector/processor v0.99.0 // indirect
go.opentelemetry.io/collector/processor/batchprocessor v0.99.0 // indirect
go.opentelemetry.io/collector/processor/memorylimiterprocessor v0.99.0 // indirect
go.opentelemetry.io/collector/receiver v0.99.0 // indirect
go.opentelemetry.io/collector/receiver/otlpreceiver v0.99.0 // indirect
go.opentelemetry.io/collector/service v0.99.0 // indirect
go.opentelemetry.io/contrib/config v0.5.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.50.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.50.0 // indirect
go.opentelemetry.io/contrib/propagators/b3 v1.25.0 // indirect
go.opentelemetry.io/contrib/zpages v0.50.0 // indirect
go.opentelemetry.io/otel v1.25.0 // indirect
go.opentelemetry.io/otel/bridge/opencensus v1.25.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.25.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.25.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.25.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.25.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.25.0 // indirect
go.opentelemetry.io/otel/exporters/prometheus v0.47.0 // indirect
go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.25.0 // indirect
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.25.0 // indirect
go.opentelemetry.io/otel/metric v1.25.0 // indirect
go.opentelemetry.io/otel/sdk v1.25.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.25.0 // indirect
go.opentelemetry.io/otel/trace v1.25.0 // indirect
go.opentelemetry.io/contrib/config v0.6.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.51.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.51.0 // indirect
go.opentelemetry.io/contrib/propagators/b3 v1.26.0 // indirect
go.opentelemetry.io/contrib/zpages v0.51.0 // indirect
go.opentelemetry.io/otel v1.26.0 // indirect
go.opentelemetry.io/otel/bridge/opencensus v1.26.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.26.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.26.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.26.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.26.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.26.0 // indirect
go.opentelemetry.io/otel/exporters/prometheus v0.48.0 // indirect
go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.26.0 // indirect
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.26.0 // indirect
go.opentelemetry.io/otel/metric v1.26.0 // indirect
go.opentelemetry.io/otel/sdk v1.26.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.26.0 // indirect
go.opentelemetry.io/otel/trace v1.26.0 // indirect
go.opentelemetry.io/proto/otlp v1.2.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a // indirect
golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/oauth2 v0.18.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/term v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.20.0 // indirect
gonum.org/v1/gonum v0.15.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240314234333-6e1732d8331c // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240415180920-8c6c420018be // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be // indirect
google.golang.org/grpc v1.63.2 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
k8s.io/api v0.29.3 // indirect
k8s.io/apimachinery v0.29.3 // indirect
k8s.io/client-go v0.29.3 // indirect
k8s.io/klog/v2 v2.120.1 // indirect
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)

replace cloud.google.com/go => cloud.google.com/go v0.112.2

replace github.com/Dynatrace/dynatrace-otel-collector/internal/k8stest v0.0.0 => ./internal/k8stest
Loading

0 comments on commit 9232724

Please sign in to comment.