Skip to content

Commit c7462f2

Browse files
authored
[chore] add k8sclusterreceiver e2e test (open-telemetry#23386)
Adds an e2e test for k8sclusterreceiver with a golden metrics file.
1 parent 1bf2547 commit c7462f2

File tree

19 files changed

+1718
-42
lines changed

19 files changed

+1718
-42
lines changed

.github/workflows/e2e-tests.yml

+46-4
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,45 @@ on:
99
pull_request:
1010

1111
jobs:
12+
docker-build:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v3
17+
- uses: actions/setup-go@v4
18+
with:
19+
go-version: 1.19
20+
cache: false
21+
- name: Cache Go
22+
id: go-cache
23+
uses: actions/cache@v3
24+
with:
25+
path: |
26+
~/go/bin
27+
~/go/pkg/mod
28+
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
29+
- name: Install dependencies
30+
if: steps.go-cache.outputs.cache-hit != 'true'
31+
run: make -j2 gomoddownload
32+
- name: Build Docker Image
33+
run: |
34+
make docker-otelcontribcol
35+
- name: export image to tar
36+
run: |
37+
docker save otelcontribcol:latest > /tmp/otelcontribcol.tar
38+
- name: Upload artifact
39+
uses: actions/upload-artifact@v2
40+
with:
41+
name: otelcontribcol
42+
path: /tmp/otelcontribcol.tar
1243
kubernetes-test:
1344
env:
1445
KUBECONFIG: /tmp/kube-config-otelcol-e2e-testing
1546
strategy:
1647
matrix:
1748
k8s-version: ["v1.26.0", "v1.25.3", "v1.24.7", "v1.23.13"]
1849
runs-on: ubuntu-latest
50+
needs: docker-build
1951
steps:
2052
- uses: actions/checkout@v3
2153
- uses: actions/setup-go@v4
@@ -33,19 +65,29 @@ jobs:
3365
- name: Install dependencies
3466
if: steps.go-cache.outputs.cache-hit != 'true'
3567
run: make -j2 gomoddownload
36-
- name: Build Docker Image
37-
run: |
38-
make docker-otelcontribcol
3968
- name: Create kind cluster
4069
uses: helm/[email protected]
4170
with:
4271
node_image: kindest/node:${{ matrix.k8s-version }}
4372
kubectl_version: ${{ matrix.k8s-version }}
4473
cluster_name: kind
74+
- name: Download artifact
75+
uses: actions/download-artifact@v2
76+
with:
77+
name: otelcontribcol
78+
path: /tmp
79+
- name: Load Docker image
80+
run: |
81+
docker load --input /tmp/otelcontribcol.tar
4582
- name: Kind load image
4683
run: |
4784
kind load docker-image otelcontribcol:latest --name kind
48-
- name: run e2e tests
85+
- name: run k8sclusterreceiver e2e tests
86+
run: |
87+
cd receiver/k8sclusterreceiver
88+
go test -v --tags=e2e
89+
- name: run k8sattributesprocessor e2e tests
4990
run: |
5091
cd processor/k8sattributesprocessor
5192
go test -v --tags=e2e
93+

cmd/configschema/go.mod

+4-4
Original file line numberDiff line numberDiff line change
@@ -626,13 +626,13 @@ require (
626626
go.uber.org/goleak v1.2.1 // indirect
627627
go.uber.org/multierr v1.11.0 // indirect
628628
go.uber.org/zap v1.24.0 // indirect
629-
golang.org/x/crypto v0.9.0 // indirect
629+
golang.org/x/crypto v0.10.0 // indirect
630630
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 // indirect
631-
golang.org/x/net v0.10.0 // indirect
632-
golang.org/x/oauth2 v0.8.0 // indirect
631+
golang.org/x/net v0.11.0 // indirect
632+
golang.org/x/oauth2 v0.9.0 // indirect
633633
golang.org/x/sync v0.2.0 // indirect
634634
golang.org/x/sys v0.9.0 // indirect
635-
golang.org/x/term v0.8.0 // indirect
635+
golang.org/x/term v0.9.0 // indirect
636636
golang.org/x/time v0.3.0 // indirect
637637
golang.org/x/tools v0.9.1 // indirect
638638
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect

cmd/configschema/go.sum

+8-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/otelcontribcol/go.mod

+4-4
Original file line numberDiff line numberDiff line change
@@ -639,13 +639,13 @@ require (
639639
go.uber.org/goleak v1.2.1 // indirect
640640
go.uber.org/multierr v1.11.0 // indirect
641641
go.uber.org/zap v1.24.0 // indirect
642-
golang.org/x/crypto v0.9.0 // indirect
642+
golang.org/x/crypto v0.10.0 // indirect
643643
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 // indirect
644644
golang.org/x/mod v0.10.0 // indirect
645-
golang.org/x/net v0.10.0 // indirect
646-
golang.org/x/oauth2 v0.8.0 // indirect
645+
golang.org/x/net v0.11.0 // indirect
646+
golang.org/x/oauth2 v0.9.0 // indirect
647647
golang.org/x/sync v0.2.0 // indirect
648-
golang.org/x/term v0.8.0 // indirect
648+
golang.org/x/term v0.9.0 // indirect
649649
golang.org/x/text v0.10.0 // indirect
650650
golang.org/x/time v0.3.0 // indirect
651651
golang.org/x/tools v0.9.1 // indirect

cmd/otelcontribcol/go.sum

+8-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go.mod

+4-4
Original file line numberDiff line numberDiff line change
@@ -623,14 +623,14 @@ require (
623623
go.uber.org/goleak v1.2.1 // indirect
624624
go.uber.org/multierr v1.11.0 // indirect
625625
go.uber.org/zap v1.24.0 // indirect
626-
golang.org/x/crypto v0.9.0 // indirect
626+
golang.org/x/crypto v0.10.0 // indirect
627627
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 // indirect
628628
golang.org/x/mod v0.10.0 // indirect
629-
golang.org/x/net v0.10.0 // indirect
630-
golang.org/x/oauth2 v0.8.0 // indirect
629+
golang.org/x/net v0.11.0 // indirect
630+
golang.org/x/oauth2 v0.9.0 // indirect
631631
golang.org/x/sync v0.2.0 // indirect
632632
golang.org/x/sys v0.9.0 // indirect
633-
golang.org/x/term v0.8.0 // indirect
633+
golang.org/x/term v0.9.0 // indirect
634634
golang.org/x/text v0.10.0 // indirect
635635
golang.org/x/time v0.3.0 // indirect
636636
golang.org/x/tools v0.9.1 // indirect

go.sum

+8-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/pdatatest/internal/util.go

+8
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ func MaskResourceAttributeValue(res pcommon.Resource, attr string) {
1717
}
1818
}
1919

20+
func ChangeResourceAttributeValue(res pcommon.Resource, attr string, changeFn func(string) string) {
21+
if _, ok := res.Attributes().Get(attr); ok {
22+
if v, ok := res.Attributes().Get(attr); ok {
23+
res.Attributes().PutStr(attr, changeFn(v.Str()))
24+
}
25+
}
26+
}
27+
2028
// AddErrPrefix adds a prefix to every multierr error.
2129
func AddErrPrefix(prefix string, in error) error {
2230
var out error

pkg/pdatatest/pmetrictest/options.go

+14
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,20 @@ func maskMetricsResourceAttributeValue(metrics pmetric.Metrics, attributeName st
249249
}
250250
}
251251

252+
func ChangeResourceAttributeValue(attributeName string, changeFn func(string) string) CompareMetricsOption {
253+
return compareMetricsOptionFunc(func(expected, actual pmetric.Metrics) {
254+
changeMetricsResourceAttributeValue(expected, attributeName, changeFn)
255+
changeMetricsResourceAttributeValue(actual, attributeName, changeFn)
256+
})
257+
}
258+
259+
func changeMetricsResourceAttributeValue(metrics pmetric.Metrics, attributeName string, changeFn func(string) string) {
260+
rms := metrics.ResourceMetrics()
261+
for i := 0; i < rms.Len(); i++ {
262+
internal.ChangeResourceAttributeValue(rms.At(i).Resource(), attributeName, changeFn)
263+
}
264+
}
265+
252266
// IgnoreSubsequentDataPoints is a CompareMetricsOption that ignores data points after the first.
253267
func IgnoreSubsequentDataPoints(metricNames ...string) CompareMetricsOption {
254268
return compareMetricsOptionFunc(func(expected, actual pmetric.Metrics) {

0 commit comments

Comments
 (0)