Skip to content

Commit 3f160ea

Browse files
rogercollatoulme
andauthored
[chore] Add cgroupruntime extension integration tests (#39017)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Reverts #37224 with a few additional changes: - Decouple `sudo` integration tests from non-privileged ones from the makefile. -> **prevent sudo promp when running integration tests** - Adds a specific `intengration-sudo-tests` check in the CI that only targets the cgroupruntime extension as being the only component that currently requires this setup. - Sets darwin and windows as unsupported platforms (it requires cgroup file system). <!-- Issue number (e.g. #1234) or full URL to issue, if applicable. --> #### Link to tracking issue [Fixes](#36545) <!--Describe what testing was performed and which tests were added.--> #### Testing Adds the integration tests required for is addition into the contrib binary. <!--Describe the documentation added.--> #### Documentation <!--Please delete paragraphs that you did not use before submitting.--> --------- Co-authored-by: Antoine Toulme <[email protected]> Co-authored-by: Antoine Toulme <[email protected]>
1 parent f4c0600 commit 3f160ea

File tree

9 files changed

+456
-3
lines changed

9 files changed

+456
-3
lines changed

.github/workflows/build-and-test.yml

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,10 +394,44 @@ jobs:
394394
- name: Run Integration Tests
395395
run: make gointegration-test GROUP=${{ matrix.group }}
396396

397+
integration-sudo-tests-matrix:
398+
strategy:
399+
fail-fast: false
400+
matrix:
401+
group:
402+
# list of components that require privileged (sudo) access for
403+
# its integration tests `go test -exec sudo -run Sudo -tags=integration`
404+
- extension/cgroupruntimeextension
405+
runs-on: ubuntu-24.04
406+
needs: [setup-environment]
407+
steps:
408+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
409+
- uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5
410+
with:
411+
go-version: "1.23.7"
412+
cache: false
413+
- name: Cache Go
414+
id: go-cache
415+
timeout-minutes: 5
416+
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4
417+
with:
418+
path: |
419+
~/go/bin
420+
~/go/pkg/mod
421+
./.tools
422+
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
423+
- name: Cache Docker images.
424+
uses: ScribeMD/docker-cache@fb28c93772363301b8d0a6072ce850224b73f74e # 0.5.0
425+
with:
426+
key: docker-${{ matrix.group }}
427+
- name: Run Integration Tests
428+
run: make --no-print-directory -C ${{ matrix.group }} mod-integration-sudo-test
429+
430+
397431
integration-tests:
398432
if: ${{ github.actor != 'dependabot[bot]' && always() }}
399433
runs-on: ubuntu-24.04
400-
needs: [setup-environment, integration-tests-matrix]
434+
needs: [setup-environment, integration-tests-matrix, integration-sudo-tests-matrix]
401435
steps:
402436
- name: Print result
403437
run: echo ${{ needs.integration-tests-matrix.result }}

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,10 @@ gorunbuilttest:
199199
gointegration-test:
200200
$(MAKE) $(FOR_GROUP_TARGET) TARGET="mod-integration-test"
201201

202+
.PHONY: gointegration-sudo-test
203+
gointegration-sudo-test:
204+
$(MAKE) $(FOR_GROUP_TARGET) TARGET="mod-integration-sudo-test"
205+
202206
.PHONY: gofmt
203207
gofmt:
204208
$(MAKE) $(FOR_GROUP_TARGET) TARGET="fmt"

Makefile.Common

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ GO_BUILD_TAGS=""
1616
GO_BUILD_LDFLAGS="-s -w"
1717
GOTEST_TIMEOUT?= 600s
1818
GOTEST_OPT?= -race -timeout $(GOTEST_TIMEOUT) -parallel 4 --tags=$(GO_BUILD_TAGS)
19-
GOTEST_INTEGRATION_OPT?= -race -timeout 360s -parallel 4
19+
GOTEST_INTEGRATION_OPT?= -race -timeout 360s -parallel 4 -skip Sudo
20+
GOTEST_INTEGRATION_OPT_SUDO?= -race -timeout 360s -parallel 4 -exec sudo -run Sudo
2021
GOTEST_OPT_WITH_COVERAGE = $(GOTEST_OPT) -coverprofile=coverage.txt -covermode=atomic
2122
GOTEST_OPT_WITH_INTEGRATION=$(GOTEST_INTEGRATION_OPT) -tags=integration,$(GO_BUILD_TAGS)
23+
GOTEST_OPT_WITH_INTEGRATION_SUDO=$(GOTEST_INTEGRATION_OPT_SUDO) -tags=integration,$(GO_BUILD_TAGS)
2224
GOTEST_OPT_WITH_INTEGRATION_COVERAGE=$(GOTEST_OPT_WITH_INTEGRATION) -coverprofile=integration-coverage.txt -covermode=atomic
2325
GOCMD?= go
2426
GOOS=$(shell $(GOCMD) env GOOS)
@@ -142,6 +144,11 @@ mod-integration-test: $(GOTESTSUM)
142144
$(GOCMD) tool cover -html=integration-coverage.txt -o integration-coverage.html; \
143145
fi
144146

147+
.PHONY: mod-integration-sudo-test
148+
mod-integration-sudo-test: $(GOTESTSUM)
149+
@echo "running $(GOCMD) integration sudo (root/privileged) test ./... in `pwd`"
150+
$(GOTESTSUM) $(GOTESTSUM_OPT) --format standard-verbose --packages="./..." -- $(GOTEST_OPT_WITH_INTEGRATION_SUDO)
151+
145152
.PHONY: do-integration-tests-with-cover
146153
do-integration-tests-with-cover: $(GOTESTSUM)
147154
@echo "running $(GOCMD) integration test ./... + coverage in `pwd`"

extension/cgroupruntimeextension/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
| Status | |
66
| ------------- |-----------|
77
| Stability | [development] |
8+
| Unsupported Platforms | darwin, windows |
89
| Distributions | [contrib] |
910
| Issues | [![Open issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aopen%20label%3Aextension%2Fcgroupruntime%20&label=open&color=orange&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aopen+is%3Aissue+label%3Aextension%2Fcgroupruntime) [![Closed issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aclosed%20label%3Aextension%2Fcgroupruntime%20&label=closed&color=blue&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aclosed+is%3Aissue+label%3Aextension%2Fcgroupruntime) |
1011
| [Code Owners](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#becoming-a-code-owner) | [@mx-psi](https://www.github.com/mx-psi), [@rogercoll](https://www.github.com/rogercoll) |

extension/cgroupruntimeextension/generated_component_test.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extension/cgroupruntimeextension/go.mod

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ go 1.23.0
44

55
require (
66
github.com/KimMachineGun/automemlimit v0.7.1
7+
github.com/containerd/cgroups/v3 v3.0.5
78
github.com/rdforte/gomaxecs v1.1.1
89
github.com/stretchr/testify v1.10.0
910
go.opentelemetry.io/collector/component v1.29.1-0.20250402200755-cb5c3f4fb9dc
@@ -15,13 +16,18 @@ require (
1516
go.uber.org/automaxprocs v1.6.0
1617
go.uber.org/goleak v1.3.0
1718
go.uber.org/zap v1.27.0
19+
golang.org/x/sys v0.31.0
1820
)
1921

2022
require (
23+
github.com/cilium/ebpf v0.16.0 // indirect
24+
github.com/containerd/log v0.1.0 // indirect
25+
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
2126
github.com/davecgh/go-spew v1.1.1 // indirect
2227
github.com/go-logr/logr v1.4.2 // indirect
2328
github.com/go-logr/stdr v1.2.2 // indirect
2429
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
30+
github.com/godbus/dbus/v5 v5.1.0 // indirect
2531
github.com/gogo/protobuf v1.3.2 // indirect
2632
github.com/google/uuid v1.6.0 // indirect
2733
github.com/hashicorp/go-version v1.7.0 // indirect
@@ -30,8 +36,10 @@ require (
3036
github.com/knadh/koanf/v2 v2.1.2 // indirect
3137
github.com/mitchellh/copystructure v1.2.0 // indirect
3238
github.com/mitchellh/reflectwalk v1.0.2 // indirect
39+
github.com/opencontainers/runtime-spec v1.2.0 // indirect
3340
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect
3441
github.com/pmezard/go-difflib v1.0.0 // indirect
42+
github.com/sirupsen/logrus v1.9.3 // indirect
3543
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
3644
go.opentelemetry.io/collector/featuregate v1.29.1-0.20250402200755-cb5c3f4fb9dc // indirect
3745
go.opentelemetry.io/collector/internal/telemetry v0.123.1-0.20250402200755-cb5c3f4fb9dc // indirect
@@ -44,8 +52,8 @@ require (
4452
go.opentelemetry.io/otel/sdk/metric v1.35.0 // indirect
4553
go.opentelemetry.io/otel/trace v1.35.0 // indirect
4654
go.uber.org/multierr v1.11.0 // indirect
55+
golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f // indirect
4756
golang.org/x/net v0.37.0 // indirect
48-
golang.org/x/sys v0.31.0 // indirect
4957
golang.org/x/text v0.23.0 // indirect
5058
google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f // indirect
5159
google.golang.org/grpc v1.71.1 // indirect

extension/cgroupruntimeextension/go.sum

Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)