diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index d836b60b19..49046ab647 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -392,3 +392,56 @@ jobs: run: make integration-test-${{ matrix.SERVICE }}-discovery env: SPLUNK_OTEL_COLLECTOR_IMAGE: 'otelcol:latest' + + integration-test-discovery-k8s-matrix: + runs-on: ubuntu-24.04 + outputs: + matrix: ${{ steps.get-matrix-k8s.outputs.matrix }} + steps: + - name: Get matrix for Kubernetes + id: get-matrix-k8s + run: | + includes="" + for service in "envoy"; do + for arch in "amd64"; do + includes="${includes},{\"SERVICE\": \"${service}\", \"ARCH\": \"${arch}\"}" + done + done + matrix="{\"include\": [${includes#,}]}" + echo "$matrix" | jq + echo "matrix=${matrix}" >> $GITHUB_OUTPUT + + integration-test-discovery-k8s: + name: integration-test-discovery-k8s + runs-on: ubuntu-24.04 + needs: [ "docker-otelcol", "otelcol", "integration-test-discovery-k8s-matrix" ] + strategy: + matrix: ${{ fromJSON(needs.integration-test-discovery-k8s-matrix.outputs.matrix) }} + fail-fast: false + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Create kind cluster + uses: helm/kind-action@v1.12.0 + with: + node_image: kindest/node:v1.30.0 + kubectl_version: v1.30.0 + cluster_name: kind + - name: Deploy service under test + run: | + kubectl apply -f k8s/${{ matrix.SERVICE }}/*.yaml + - uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + cache-dependency-path: '**/go.sum' + - uses: actions/download-artifact@v4 + with: + name: docker-otelcol-${{ matrix.ARCH }} + path: ./docker-otelcol/${{ matrix.ARCH }} + - run: docker load -i ./docker-otelcol/${{ matrix.ARCH }}/image.tar + - name: Load Docker image in kind + run: | + kind load docker-image otelcol:latest --name kind + - name: Run ${{ matrix.SERVICE }} Discovery Kubernetes Integration Test + run: make integration-test-${{ matrix.SERVICE }}-discovery-k8s diff --git a/Makefile b/Makefile index 53bcf36138..1447eb5496 100644 --- a/Makefile +++ b/Makefile @@ -127,6 +127,10 @@ integration-test-oracledb-discovery: smartagent-integration-test: @set -e; cd tests && $(GOTEST_SERIAL) $(BUILD_INFO_TESTS) --tags=smartagent_integration -v -timeout 5m -count 1 ./... +.PHONY: integration-test-envoy-discovery-k8s +integration-test-envoy-discovery-k8s: + @set -e; cd tests && $(GOTEST_SERIAL) $(BUILD_INFO_TESTS) --tags=discovery_integration_envoy_k8s -v -timeout 5m -count 1 ./... + .PHONY: test-with-cover test-with-cover: @echo Verifying that all packages have test files to count in coverage diff --git a/k8s/envoy/envoy.yaml b/k8s/envoy/envoy.yaml new file mode 100644 index 0000000000..2c4e263081 --- /dev/null +++ b/k8s/envoy/envoy.yaml @@ -0,0 +1,26 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: envoy-test +spec: + replicas: 1 + selector: + matchLabels: + app: envoy-test + template: + metadata: + name: envoy-test + labels: + app: envoy-test + spec: + automountServiceAccountToken: false + containers: + - image: quay.io/splunko11ytest/envoy:latest + name: envoy-test + imagePullPolicy: IfNotPresent + ports: + - containerPort: 10000 + name: envoy + - containerPort: 9901 + name: admin + diff --git a/tests/go.mod b/tests/go.mod index ce1c32d655..5f5afa3a90 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -30,6 +30,9 @@ require ( golang.org/x/exp v0.0.0-20230711023510-fffb14384f22 golang.org/x/sys v0.29.0 gopkg.in/yaml.v2 v2.4.0 + k8s.io/api v0.31.3 + k8s.io/apimachinery v0.31.3 + k8s.io/client-go v0.31.3 ) require ( @@ -43,23 +46,35 @@ require ( github.com/containerd/log v0.1.0 // indirect github.com/containerd/platforms v0.2.1 // indirect github.com/cpuguy83/dockercfg v0.3.2 // indirect - github.com/davecgh/go-spew v1.1.1 // indirect + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/distribution/reference v0.6.0 // indirect github.com/docker/go-units v0.5.0 // indirect + github.com/emicklei/go-restful/v3 v3.11.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/fsnotify/fsnotify v1.8.0 // indirect + github.com/fxamacker/cbor/v2 v2.7.0 // indirect github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.2.6 // indirect + github.com/go-openapi/jsonpointer v0.19.6 // indirect + github.com/go-openapi/jsonreference v0.20.2 // indirect + github.com/go-openapi/swag v0.22.4 // indirect github.com/go-viper/mapstructure/v2 v2.2.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/protobuf v1.5.4 // indirect github.com/golang/snappy v0.0.4 // indirect + github.com/google/gnostic-models v0.6.8 // indirect + github.com/google/go-cmp v0.6.0 // indirect + github.com/google/gofuzz v1.2.0 // indirect + github.com/imdario/mergo v0.3.6 // indirect + github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/compress v1.17.11 // indirect github.com/knadh/koanf v1.5.0 // indirect github.com/knadh/koanf/v2 v2.1.2 // indirect github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect github.com/magiconair/properties v1.8.7 // 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/moby/docker-image-spec v1.3.1 // indirect @@ -72,18 +87,21 @@ require ( github.com/modern-go/reflect2 v1.0.2 // indirect github.com/morikuni/aec v1.0.0 // indirect github.com/mostynb/go-grpc-compression v1.2.3 // indirect + github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.117.0 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.0 // indirect github.com/pierrec/lz4/v4 v4.1.22 // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/pmezard/go-difflib v1.0.0 // 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/rs/cors v1.11.1 // indirect github.com/shoenig/go-m1cpu v0.1.6 // indirect github.com/sirupsen/logrus v1.9.3 // indirect + github.com/spf13/pflag v1.0.5 // indirect github.com/tklauser/go-sysconf v0.3.12 // indirect github.com/tklauser/numcpus v0.6.1 // indirect + github.com/x448/float16 v0.8.4 // indirect github.com/yusufpapurcu/wmi v1.2.4 // indirect go.opentelemetry.io/collector v0.117.0 // indirect go.opentelemetry.io/collector/client v1.23.0 // indirect @@ -113,11 +131,20 @@ require ( go.uber.org/multierr v1.11.0 // indirect golang.org/x/crypto v0.32.0 // indirect golang.org/x/net v0.34.0 // indirect + golang.org/x/oauth2 v0.23.0 // indirect + golang.org/x/term v0.28.0 // indirect golang.org/x/text v0.21.0 // indirect - golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect + golang.org/x/time v0.3.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20241015192408-796eee8c2d53 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20241104194629-dd2ea8efbc28 // indirect google.golang.org/grpc v1.69.2 // indirect google.golang.org/protobuf v1.36.2 // indirect + gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect + k8s.io/klog/v2 v2.130.1 // indirect + k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect + k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // 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.4.0 // indirect ) diff --git a/tests/go.sum b/tests/go.sum index efea1f9394..20f4f0a9d6 100644 --- a/tests/go.sum +++ b/tests/go.sum @@ -52,11 +52,13 @@ github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3Ee github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/dockercfg v0.3.2 h1:DlJTyZGBDlXqUZ2Dk2Q3xHs/FtnooJJVaad2S9GKorA= github.com/cpuguy83/dockercfg v0.3.2/go.mod h1:sugsbF4//dDlL/i+S+rtpIWp+5h0BHJHfjj5/jFyUJc= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk= github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= github.com/docker/docker v27.4.0+incompatible h1:I9z7sQ5qyzO0BfAb9IMOawRkAGxhYsidKiTMcm0DU+A= @@ -66,6 +68,8 @@ github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6 github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g= +github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= @@ -79,6 +83,8 @@ github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSw github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M= github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= +github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E= +github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= @@ -94,9 +100,18 @@ github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE= +github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= +github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE= +github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k= +github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= +github.com/go-openapi/swag v0.22.4 h1:QLMzNJnMGPRNDCbySlcj1x01tzU8/9LTTL9hZZZogBU= +github.com/go-openapi/swag v0.22.4/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y= github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= +github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= github.com/go-test/deep v1.0.2-0.20181118220953-042da051cf31/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/go-viper/mapstructure/v2 v2.2.1 h1:ZAaOCxANMuZx5RCeg0mBdEZk7DZasvvZIxtHqx8aGss= github.com/go-viper/mapstructure/v2 v2.2.1/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= @@ -126,6 +141,8 @@ github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEW github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I= +github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -135,9 +152,14 @@ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= +github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/pprof v0.0.0-20240525223248-4bfdf5a9a2af h1:kmjWCqn2qkEml422C2Rrd27c3VGxi6a/6HNq8QmHRKM= +github.com/google/pprof v0.0.0-20240525223248-4bfdf5a9a2af/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -180,9 +202,13 @@ github.com/hashicorp/vault/sdk v0.1.13/go.mod h1:B+hVj7TpuQY1Y/GPbCpffmgd+tSEwvh github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= github.com/hjson/hjson-go/v4 v4.0.0/go.mod h1:KaYt3bTw3zhBjYqnXkYywcYctk0A2nxeEFTse3rH13E= +github.com/imdario/mergo v0.3.6 h1:xTNEAn+kxVO7dTZGu0CegyqKZmoWFI0rF8UxjlB2d28= +github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= +github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= +github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= @@ -204,6 +230,7 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxv github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -214,6 +241,8 @@ github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= +github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= +github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= @@ -263,10 +292,16 @@ github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= github.com/mostynb/go-grpc-compression v1.2.3 h1:42/BKWMy0KEJGSdWvzqIyOZ95YcR9mLPqKctH7Uo//I= github.com/mostynb/go-grpc-compression v1.2.3/go.mod h1:AghIxF3P57umzqM9yz795+y1Vjs47Km/Y2FE6ouQ7Lg= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/npillmayer/nestext v0.1.3/go.mod h1:h2lrijH8jpicr25dFY+oAJLyzlya6jhnuG+zWp9L0Uk= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= +github.com/onsi/ginkgo/v2 v2.19.0 h1:9Cnnf7UHo57Hy3k6/m5k3dRfGTMXGvxhHFvkDTCTpvA= +github.com/onsi/ginkgo/v2 v2.19.0/go.mod h1:rlwLi9PilAFJ8jCg9UE1QP6VBpd6/xj3SRC0d6TU0To= +github.com/onsi/gomega v1.19.0 h1:4ieX6qQjPP/BfC3mpsAtIGGlxTWPeA3Inl/7DtXw1tw= +github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro= github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden v0.117.0 h1:tOJFUIZaAU4zm5CilqZN1/AuKQa7diTrcEhgQIYly6k= github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden v0.117.0/go.mod h1:PJ2FGCS+Hw+tlHUNNWVHNo3IXtEsb9RKgl/ssSi3Z98= github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest v0.117.0 h1:/wMNk8w1UEHKpKoNk1jA2aifHgfGZE+WelGNrCf0CJ0= @@ -287,8 +322,9 @@ github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw= @@ -329,9 +365,12 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= @@ -339,6 +378,9 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/testcontainers/testcontainers-go v0.35.0 h1:uADsZpTKFAtp8SLK+hMwSaa+X+JiERHtd4sQAFmXeMo= @@ -347,6 +389,8 @@ github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFA github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= +github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= +github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= @@ -486,6 +530,8 @@ golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs= +golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -545,8 +591,8 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 h1:vVKdlvoWBphwdxWKrFZEuM0kGgGLxUOYcY4U/2Vjg44= -golang.org/x/time v0.0.0-20220210224613-90d013bbcef8/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= +golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= @@ -558,6 +604,8 @@ golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapK golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -603,6 +651,8 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= +gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/square/go-jose.v2 v2.3.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= @@ -621,4 +671,22 @@ gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU= gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +k8s.io/api v0.31.3 h1:umzm5o8lFbdN/hIXbrK9oRpOproJO62CV1zqxXrLgk8= +k8s.io/api v0.31.3/go.mod h1:UJrkIp9pnMOI9K2nlL6vwpxRzzEX5sWgn8kGQe92kCE= +k8s.io/apimachinery v0.31.3 h1:6l0WhcYgasZ/wk9ktLq5vLaoXJJr5ts6lkaQzgeYPq4= +k8s.io/apimachinery v0.31.3/go.mod h1:rsPdaZJfTfLsNJSQzNHQvYoTmxhoOEofxtOsF3rtsMo= +k8s.io/client-go v0.31.3 h1:CAlZuM+PH2cm+86LOBemaJI/lQ5linJ6UFxKX/SoG+4= +k8s.io/client-go v0.31.3/go.mod h1:2CgjPUTpv3fE5dNygAr2NcM8nhHzXvxB8KL5gYc3kJs= +k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= +k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= +k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 h1:BZqlfIlq5YbRMFko6/PM7FjZpUb45WallggurYhKGag= +k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340/go.mod h1:yD4MZYeKMBwQKVht279WycxKyM84kkAx2DPrTXaeb98= +k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 h1:pUdcCO1Lk/tbT5ztQWOBi5HBgbBP1J8+AsQnQCKsi8A= +k8s.io/utils v0.0.0-20240711033017-18e509b52bc8/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= +sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= +sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4= +sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08= sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= +sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= +sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/tests/receivers/envoy/bundled_k8s_test.go b/tests/receivers/envoy/bundled_k8s_test.go new file mode 100644 index 0000000000..472c31d24d --- /dev/null +++ b/tests/receivers/envoy/bundled_k8s_test.go @@ -0,0 +1,147 @@ +// Copyright Splunk, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build discovery_integration_envoy_k8s + +package tests + +import ( + "context" + "fmt" + "net" + "os" + "path/filepath" + "runtime" + "strings" + "testing" + "time" + + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden" + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest/pmetrictest" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + appsv1 "k8s.io/api/apps/v1" + v1 "k8s.io/api/core/v1" + rbacv1 "k8s.io/api/rbac/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/client-go/kubernetes" + "k8s.io/client-go/kubernetes/scheme" + "k8s.io/client-go/tools/clientcmd" + + "github.com/signalfx/splunk-otel-collector/tests/testutils" +) + +func TestEnvoyK8sObserver(t *testing.T) { + + tc := testutils.NewTestcase(t) + defer tc.PrintLogsOnFailure() + defer tc.ShutdownOTLPReceiverSink() + + _, port, err := net.SplitHostPort(tc.OTLPEndpoint) + require.NoError(t, err) + dockerHost := "0.0.0.0" + if runtime.GOOS == "darwin" { + dockerHost = "host.docker.internal" + } + + kubeConfig, err := clientcmd.BuildConfigFromFlags("", os.Getenv("KUBECONFIG")) + require.NoError(t, err) + client, err := kubernetes.NewForConfig(kubeConfig) + + decode := scheme.Codecs.UniversalDeserializer().Decode + // Cluster role, role binding, and service account + stream, err := os.ReadFile(filepath.Join("testdata", "k8s", "clusterRole.yaml")) + require.NoError(t, err) + clusterRole, _, err := decode(stream, nil, nil) + require.NoError(t, err) + cr, err := client.RbacV1().ClusterRoles().Create(context.Background(), clusterRole.(*rbacv1.ClusterRole), metav1.CreateOptions{}) + + stream, err = os.ReadFile(filepath.Join("testdata", "k8s", "clusterRoleBinding.yaml")) + require.NoError(t, err) + clusterRoleBinding, _, err := decode(stream, nil, nil) + require.NoError(t, err) + crb, err := client.RbacV1().ClusterRoleBindings().Create(context.Background(), clusterRoleBinding.(*rbacv1.ClusterRoleBinding), metav1.CreateOptions{}) + require.NoError(t, err) + + stream, err = os.ReadFile(filepath.Join("testdata", "k8s", "serviceAccount.yaml")) + require.NoError(t, err) + serviceAccount, _, err := decode(stream, nil, nil) + require.NoError(t, err) + sa, err := client.CoreV1().ServiceAccounts("default").Create(context.Background(), serviceAccount.(*v1.ServiceAccount), metav1.CreateOptions{}) + require.NoError(t, err) + // Configmap + stream, err = os.ReadFile(filepath.Join("testdata", "k8s", "config.yaml")) + require.NoError(t, err) + cfgMap, _, err := decode(stream, nil, nil) + require.NoError(t, err) + + c, err := client.CoreV1().ConfigMaps("default").Create(context.Background(), cfgMap.(*v1.ConfigMap), metav1.CreateOptions{}) + require.NoError(t, err) + // Collector: + stream, err = os.ReadFile(filepath.Join("testdata", "k8s", "collector.yaml")) + require.NoError(t, err) + streamStr := strings.Replace(string(stream), "$OTLP_ENDPOINT", fmt.Sprintf("%s:%s", dockerHost, port), 1) + collectorDeployment, _, err := decode([]byte(streamStr), nil, nil) + require.NoError(t, err) + + d, err := client.AppsV1().Deployments("default").Create(context.Background(), collectorDeployment.(*appsv1.Deployment), metav1.CreateOptions{}) + require.NoError(t, err) + + t.Cleanup(func() { + require.NoError(t, client.CoreV1().ConfigMaps("default").Delete(context.Background(), c.Name, metav1.DeleteOptions{})) + require.NoError(t, client.AppsV1().Deployments("default").Delete(context.Background(), d.Name, metav1.DeleteOptions{})) + + require.NoError(t, client.CoreV1().ServiceAccounts("default").Delete(context.Background(), sa.Name, metav1.DeleteOptions{})) + require.NoError(t, client.RbacV1().ClusterRoleBindings().Delete(context.Background(), crb.Name, metav1.DeleteOptions{})) + require.NoError(t, client.RbacV1().ClusterRoles().Delete(context.Background(), cr.Name, metav1.DeleteOptions{})) + }) + + expected, err := golden.ReadMetrics(filepath.Join("testdata", "expected_k8s.yaml")) + require.NoError(t, err) + + i := 0 + require.EventuallyWithT(t, func(tt *assert.CollectT) { + if len(tc.OTLPReceiverSink.AllMetrics()) == 0 { + assert.Fail(tt, "No metrics collected") + return + } + + i++ + err := pmetrictest.CompareMetrics(expected, tc.OTLPReceiverSink.AllMetrics()[len(tc.OTLPReceiverSink.AllMetrics())-1], + pmetrictest.IgnoreResourceAttributeValue("service.instance.id"), + pmetrictest.IgnoreResourceAttributeValue("net.host.port"), + pmetrictest.IgnoreResourceAttributeValue("net.host.name"), + pmetrictest.IgnoreResourceAttributeValue("server.address"), + pmetrictest.IgnoreResourceAttributeValue("container.name"), + pmetrictest.IgnoreResourceAttributeValue("server.port"), + pmetrictest.IgnoreResourceAttributeValue("service.name"), + pmetrictest.IgnoreResourceAttributeValue("service_instance_id"), + pmetrictest.IgnoreResourceAttributeValue("service_version"), + pmetrictest.IgnoreMetricAttributeValue("service_version"), + pmetrictest.IgnoreMetricAttributeValue("service_instance_id"), + pmetrictest.IgnoreResourceAttributeValue("server.address"), + pmetrictest.IgnoreResourceAttributeValue("k8s.pod.name"), + pmetrictest.IgnoreResourceAttributeValue("k8s.pod.uid"), + pmetrictest.IgnoreTimestamp(), + pmetrictest.IgnoreStartTimestamp(), + pmetrictest.IgnoreMetricDataPointsOrder(), + pmetrictest.IgnoreScopeMetricsOrder(), + pmetrictest.IgnoreScopeVersion(), + pmetrictest.IgnoreResourceMetricsOrder(), + pmetrictest.IgnoreMetricsOrder(), + pmetrictest.IgnoreMetricValues(), + ) + assert.NoError(tt, err) + }, 60*time.Second, 1*time.Second) +} diff --git a/tests/receivers/envoy/testdata/expected_k8s.yaml b/tests/receivers/envoy/testdata/expected_k8s.yaml new file mode 100644 index 0000000000..867523fb6a --- /dev/null +++ b/tests/receivers/envoy/testdata/expected_k8s.yaml @@ -0,0 +1,343 @@ +resourceMetrics: + - resource: + attributes: + - key: http.scheme + value: + stringValue: http + - key: k8s.namespace.name + value: + stringValue: default + - key: k8s.pod.name + value: + stringValue: envoy-test-99f9b6dd5-jh5fb + - key: k8s.pod.uid + value: + stringValue: 482e0c29-123b-4c8c-9ee7-bd9d0d137d0c + - key: net.host.name + value: + stringValue: 10.244.0.6 + - key: net.host.port + value: + stringValue: "9901" + - key: server.address + value: + stringValue: 10.244.0.6 + - key: server.port + value: + stringValue: "9901" + - key: service.instance.id + value: + stringValue: 10.244.0.6:9901 + - key: service.name + value: + stringValue: envoy + - key: url.scheme + value: + stringValue: http + scopeMetrics: + - metrics: + - metadata: + - key: prometheus.type + value: + stringValue: counter + name: envoy_cluster_upstream_cx_total + sum: + aggregationTemporality: 2 + dataPoints: + - asDouble: 1 + attributes: + - key: envoy_cluster_name + value: + stringValue: service_envoyproxy_io + startTimeUnixNano: "1000000" + timeUnixNano: "1000000" + isMonotonic: true + - metadata: + - key: prometheus.type + value: + stringValue: counter + name: envoy_listener_downstream_cx_overflow + sum: + aggregationTemporality: 2 + dataPoints: + - asDouble: 0 + attributes: + - key: envoy_listener_address + value: + stringValue: 0.0.0.0_10000 + startTimeUnixNano: "1000000" + timeUnixNano: "1000000" + isMonotonic: true + - gauge: + dataPoints: + - asDouble: 0 + attributes: + - key: envoy_cluster_name + value: + stringValue: service_envoyproxy_io + timeUnixNano: "1000000" + metadata: + - key: prometheus.type + value: + stringValue: gauge + name: envoy_cluster_upstream_rq_active + - gauge: + dataPoints: + - asDouble: 0 + attributes: + - key: envoy_listener_address + value: + stringValue: 0.0.0.0_10000 + timeUnixNano: "1000000" + metadata: + - key: prometheus.type + value: + stringValue: gauge + name: envoy_listener_downstream_cx_active + - description: The number of samples the target exposed + gauge: + dataPoints: + - asDouble: 751 + timeUnixNano: "1000000" + metadata: + - key: prometheus.type + value: + stringValue: gauge + name: scrape_samples_scraped + - description: The number of samples remaining after metric relabeling was applied + gauge: + dataPoints: + - asDouble: 17 + timeUnixNano: "1000000" + metadata: + - key: prometheus.type + value: + stringValue: gauge + name: scrape_samples_post_metric_relabeling + - metadata: + - key: prometheus.type + value: + stringValue: counter + name: envoy_cluster_upstream_rq_timeout + sum: + aggregationTemporality: 2 + dataPoints: + - asDouble: 0 + attributes: + - key: envoy_cluster_name + value: + stringValue: service_envoyproxy_io + startTimeUnixNano: "1000000" + timeUnixNano: "1000000" + isMonotonic: true + - metadata: + - key: prometheus.type + value: + stringValue: counter + name: envoy_listener_downstream_cx_total + sum: + aggregationTemporality: 2 + dataPoints: + - asDouble: 1 + attributes: + - key: envoy_listener_address + value: + stringValue: 0.0.0.0_10000 + startTimeUnixNano: "1000000" + timeUnixNano: "1000000" + isMonotonic: true + - gauge: + dataPoints: + - asDouble: 1 + attributes: + - key: envoy_cluster_name + value: + stringValue: service_envoyproxy_io + timeUnixNano: "1000000" + metadata: + - key: prometheus.type + value: + stringValue: gauge + name: envoy_cluster_membership_total + - description: The scraping was successful + gauge: + dataPoints: + - asDouble: 1 + timeUnixNano: "1000000" + metadata: + - key: prometheus.type + value: + stringValue: gauge + name: up + - metadata: + - key: prometheus.type + value: + stringValue: counter + name: envoy_cluster_upstream_cx_connect_fail + sum: + aggregationTemporality: 2 + dataPoints: + - asDouble: 0 + attributes: + - key: envoy_cluster_name + value: + stringValue: service_envoyproxy_io + startTimeUnixNano: "1000000" + timeUnixNano: "1000000" + isMonotonic: true + - metadata: + - key: prometheus.type + value: + stringValue: counter + name: envoy_cluster_upstream_rq_total + sum: + aggregationTemporality: 2 + dataPoints: + - asDouble: 1 + attributes: + - key: envoy_cluster_name + value: + stringValue: service_envoyproxy_io + startTimeUnixNano: "1000000" + timeUnixNano: "1000000" + isMonotonic: true + - metadata: + - key: prometheus.type + value: + stringValue: counter + name: envoy_listener_downstream_cx_overload_reject + sum: + aggregationTemporality: 2 + dataPoints: + - asDouble: 0 + attributes: + - key: envoy_listener_address + value: + stringValue: 0.0.0.0_10000 + startTimeUnixNano: "1000000" + timeUnixNano: "1000000" + isMonotonic: true + - gauge: + dataPoints: + - asDouble: 0 + attributes: + - key: envoy_cluster_name + value: + stringValue: service_envoyproxy_io + timeUnixNano: "1000000" + metadata: + - key: prometheus.type + value: + stringValue: gauge + name: envoy_cluster_membership_degraded + - gauge: + dataPoints: + - asDouble: 1 + attributes: + - key: envoy_cluster_name + value: + stringValue: service_envoyproxy_io + timeUnixNano: "1000000" + metadata: + - key: prometheus.type + value: + stringValue: gauge + name: envoy_cluster_upstream_cx_active + - description: The approximate number of new series in this scrape + gauge: + dataPoints: + - asDouble: 17 + timeUnixNano: "1000000" + metadata: + - key: prometheus.type + value: + stringValue: gauge + name: scrape_series_added + - metadata: + - key: prometheus.type + value: + stringValue: counter + name: envoy_cluster_upstream_rq_pending_overflow + sum: + aggregationTemporality: 2 + dataPoints: + - asDouble: 0 + attributes: + - key: envoy_cluster_name + value: + stringValue: service_envoyproxy_io + startTimeUnixNano: "1000000" + timeUnixNano: "1000000" + isMonotonic: true + - metadata: + - key: prometheus.type + value: + stringValue: counter + name: envoy_listener_downstream_cx_transport_socket_connect_timeout + sum: + aggregationTemporality: 2 + dataPoints: + - asDouble: 0 + attributes: + - key: envoy_listener_address + value: + stringValue: 0.0.0.0_10000 + startTimeUnixNano: "1000000" + timeUnixNano: "1000000" + isMonotonic: true + - metadata: + - key: prometheus.type + value: + stringValue: counter + name: envoy_listener_downstream_global_cx_overflow + sum: + aggregationTemporality: 2 + dataPoints: + - asDouble: 0 + attributes: + - key: envoy_listener_address + value: + stringValue: 0.0.0.0_10000 + startTimeUnixNano: "1000000" + timeUnixNano: "1000000" + isMonotonic: true + - gauge: + dataPoints: + - asDouble: 0 + attributes: + - key: envoy_cluster_name + value: + stringValue: service_envoyproxy_io + timeUnixNano: "1000000" + metadata: + - key: prometheus.type + value: + stringValue: gauge + name: envoy_cluster_membership_excluded + - gauge: + dataPoints: + - asDouble: 0 + attributes: + - key: envoy_cluster_name + value: + stringValue: service_envoyproxy_io + timeUnixNano: "1000000" + metadata: + - key: prometheus.type + value: + stringValue: gauge + name: envoy_cluster_upstream_rq_pending_active + - description: Duration of the scrape + gauge: + dataPoints: + - asDouble: 0.007504292 + timeUnixNano: "1000000" + metadata: + - key: prometheus.type + value: + stringValue: gauge + name: scrape_duration_seconds + unit: s + scope: + name: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver + version: v0.116.0-28-g370fcc9f diff --git a/tests/receivers/envoy/testdata/k8s/clusterRole.yaml b/tests/receivers/envoy/testdata/k8s/clusterRole.yaml new file mode 100644 index 0000000000..ce03c2f818 --- /dev/null +++ b/tests/receivers/envoy/testdata/k8s/clusterRole.yaml @@ -0,0 +1,15 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: collector + labels: + app: collector +rules: + - apiGroups: + - "" + resources: + - pods + verbs: + - get + - list + - watch diff --git a/tests/receivers/envoy/testdata/k8s/clusterRoleBinding.yaml b/tests/receivers/envoy/testdata/k8s/clusterRoleBinding.yaml new file mode 100644 index 0000000000..8dce14a9bf --- /dev/null +++ b/tests/receivers/envoy/testdata/k8s/clusterRoleBinding.yaml @@ -0,0 +1,14 @@ +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: collector + labels: + app: collector +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: collector +subjects: + - kind: ServiceAccount + name: collector + namespace: default diff --git a/tests/receivers/envoy/testdata/k8s/collector.yaml b/tests/receivers/envoy/testdata/k8s/collector.yaml new file mode 100644 index 0000000000..e07571870b --- /dev/null +++ b/tests/receivers/envoy/testdata/k8s/collector.yaml @@ -0,0 +1,43 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: otelcol +spec: + replicas: 1 + selector: + matchLabels: + app: otelcol + template: + metadata: + name: otelcol + labels: + app: otelcol + spec: + serviceAccountName: collector + containers: + - image: otelcol:latest + command: + - /otelcol + - --config + - /opt/config/config.yaml + - --discovery + - --set + - splunk.discovery.extensions.docker_observer.enabled=false + - --set + - splunk.discovery.extensions.host_observer.enabled=false + name: otelcol + imagePullPolicy: IfNotPresent + volumeMounts: + - name: config-volume + mountPath: /opt/config + env: + - name: OTLP_ENDPOINT + value: $OTLP_ENDPOINT + - name: SPLUNK_DISCOVERY_DURATION + value: 20s + - name: SPLUNK_DISCOVERY_LOG_LEVEL + value: debug + volumes: + - name: config-volume + configMap: + name: config diff --git a/tests/receivers/envoy/testdata/k8s/config.yaml b/tests/receivers/envoy/testdata/k8s/config.yaml new file mode 100644 index 0000000000..0c05b588a3 --- /dev/null +++ b/tests/receivers/envoy/testdata/k8s/config.yaml @@ -0,0 +1,21 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: config + namespace: default +data: + config.yaml: | + exporters: + otlp: + endpoint: "${env:OTLP_ENDPOINT}" + tls: + insecure: true + + service: + telemetry: + logs: + level: debug + pipelines: + metrics: + exporters: [otlp] + diff --git a/tests/receivers/envoy/testdata/k8s/serviceAccount.yaml b/tests/receivers/envoy/testdata/k8s/serviceAccount.yaml new file mode 100644 index 0000000000..20f5c553e3 --- /dev/null +++ b/tests/receivers/envoy/testdata/k8s/serviceAccount.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: ServiceAccount +automountServiceAccountToken: true +metadata: + name: collector + namespace: default + labels: + app: collector \ No newline at end of file