Skip to content

Commit 2debfd2

Browse files
Merge remote-tracking branch 'origin/main' into fips-ech
2 parents 95dc6bb + f108618 commit 2debfd2

File tree

15 files changed

+361
-100
lines changed

15 files changed

+361
-100
lines changed

.buildkite/bk.integration.pipeline.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,65 @@ steps:
2828
image: "docker.elastic.co/ci-agent-images/platform-ingest/buildkite-agent-beats-ci-with-hooks:0.5"
2929
useCustomGlobalHooks: true
3030

31+
- group: "Extended runtime leak tests"
32+
key: extended-integration-tests
33+
depends_on:
34+
- integration-ess
35+
steps:
36+
- label: "Windows:2022:amd64:sudo"
37+
depends_on:
38+
- packaging-windows
39+
env:
40+
TEST_LONG_RUNNING: "true"
41+
command: |
42+
buildkite-agent artifact download build/distributions/** . --step 'packaging-windows'
43+
.buildkite/scripts/integration-tests.ps1 fleet true TestLongRunningAgentForLeaks
44+
artifact_paths:
45+
- build/**
46+
- build/diagnostics/**
47+
agents:
48+
provider: "gcp"
49+
machineType: "n1-standard-8"
50+
image: "${IMAGE_WIN_2022}"
51+
retry:
52+
automatic:
53+
limit: 1
54+
- label: "Windows:2025:amd64:sudo"
55+
depends_on:
56+
- packaging-windows
57+
env:
58+
TEST_LONG_RUNNING: "true"
59+
command: |
60+
buildkite-agent artifact download build/distributions/** . --step 'packaging-windows'
61+
.buildkite/scripts/integration-tests.ps1 fleet true TestLongRunningAgentForLeaks
62+
artifact_paths:
63+
- build/**
64+
- build/diagnostics/**
65+
retry:
66+
automatic:
67+
limit: 1
68+
agents:
69+
provider: "gcp"
70+
machineType: "n1-standard-8"
71+
image: "${IMAGE_WIN_2025}"
72+
- label: "Ubuntu:2404:amd64:sudo"
73+
depends_on: packaging-ubuntu-x86-64
74+
env:
75+
TEST_LONG_RUNNING: "true"
76+
command: |
77+
buildkite-agent artifact download build/distributions/** . --step 'packaging-ubuntu-x86-64'
78+
.buildkite/scripts/steps/integration_tests_tf.sh fleet true TestLongRunningAgentForLeaks
79+
artifact_paths:
80+
- build/**
81+
- build/diagnostics/**
82+
retry:
83+
automatic:
84+
limit: 1
85+
agents:
86+
provider: "gcp"
87+
machineType: "n1-standard-8"
88+
image: "${IMAGE_UBUNTU_2404_X86_64}"
89+
3190
- group: "Stateful: Windows"
3291
key: integration-tests-win
3392
depends_on:
@@ -362,6 +421,7 @@ steps:
362421
- integration-tests-win
363422
- integration-tests-rhel8
364423
- integration-tests-kubernetes
424+
- extended-integration-tests
365425
allow_dependency_failure: true
366426
command: |
367427
buildkite-agent artifact download "test_infra/ess/**" . --step "integration-ess"

.buildkite/integration.pipeline.yml

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -173,30 +173,6 @@ steps:
173173
- github_commit_status:
174174
context: "buildkite/elastic-agent-extended-testing - Serverless integration test"
175175

176-
- label: "Extended runtime leak tests"
177-
key: "extended-integration-tests"
178-
depends_on:
179-
- int-packaging
180-
concurrency_group: elastic-agent-extended-testing/leak-tests
181-
concurrency: 8
182-
env:
183-
TEST_INTEG_AUTH_GCP_DATACENTER: "us-central1-b"
184-
command: |
185-
buildkite-agent artifact download "build/distributions/**" . $BUILDKITE_BUILD_ID
186-
.buildkite/scripts/steps/integration_tests.sh stateful integration:TestForResourceLeaks
187-
artifact_paths:
188-
- "build/TEST-**"
189-
- "build/diagnostics/*"
190-
agents:
191-
provider: "gcp"
192-
machineType: "n2-standard-8"
193-
retry:
194-
automatic:
195-
limit: 1
196-
notify:
197-
- github_commit_status:
198-
context: "buildkite/elastic-agent-extended-testing - Extended runtime leak tests"
199-
200176
- label: "Triggering Integration tests"
201177
depends_on:
202178
- int-packaging

.buildkite/scripts/buildkite-integration-tests.sh

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
GROUP_NAME=$1
55
TEST_SUDO=$2
6+
TEST_NAME_PATTERN=${3:-""}
67

78
if [ -z "$GROUP_NAME" ]; then
89
echo "Error: Specify the group name: sudo-integration-tests.sh [group_name]" >&2
@@ -51,19 +52,15 @@ outputXML="build/${fully_qualified_group_name}.integration.xml"
5152
outputJSON="build/${fully_qualified_group_name}.integration.out.json"
5253

5354
echo "~~~ Integration tests: ${GROUP_NAME}"
55+
GOTEST_ARGS=(-tags integration -test.shuffle on -test.timeout 2h0m0s)
56+
if [ -n "$TEST_NAME_PATTERN" ]; then
57+
GOTEST_ARGS+=(-run="${TEST_NAME_PATTERN}")
58+
fi
59+
GOTEST_ARGS+=("github.com/elastic/elastic-agent/testing/integration" -v -args "-integration.groups=${GROUP_NAME}" "-integration.sudo=${TEST_SUDO}" "-integration.fips=${FIPS:-false}")
5460

5561
set +e
5662
TEST_BINARY_NAME="elastic-agent" AGENT_VERSION="${AGENT_VERSION}" SNAPSHOT=true \
57-
gotestsum --no-color -f standard-quiet \
58-
--junitfile-hide-skipped-tests \
59-
--junitfile "${outputXML}" \
60-
--jsonfile "${outputJSON}" \
61-
-- \
62-
-tags integration -test.shuffle on -test.timeout 2h0m0s \
63-
github.com/elastic/elastic-agent/testing/integration \
64-
-v \
65-
-args -integration.groups="${GROUP_NAME}" -integration.sudo="${TEST_SUDO}" -integration.fips="${FIPS:-false}"
66-
63+
gotestsum --no-color -f standard-quiet --junitfile-hide-skipped-tests --junitfile "${outputXML}" --jsonfile "${outputJSON}" -- "${GOTEST_ARGS[@]}"
6764
TESTS_EXIT_STATUS=$?
6865
set -e
6966

.buildkite/scripts/integration-tests.ps1

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
param (
22
[string]$GROUP_NAME,
3-
[string]$TEST_SUDO
3+
[string]$TEST_SUDO,
4+
[string]$TEST_NAME_PATTERN = ""
45
)
56

67
echo "~~~ Preparing environment"
@@ -45,7 +46,12 @@ $TestsExitCode = 0
4546
try {
4647
Get-Ess-Stack -StackVersion $PACKAGE_VERSION
4748
Write-Output "~~~ Running integration test group: $GROUP_NAME as user: $env:USERNAME"
48-
& gotestsum --no-color -f standard-quiet --junitfile-hide-skipped-tests --junitfile "${outputXML}" --jsonfile "${outputJSON}" -- -tags=integration -shuffle=on -timeout=2h0m0s "github.com/elastic/elastic-agent/testing/integration" -v -args "-integration.groups=$GROUP_NAME" "-integration.sudo=$TEST_SUDO"
49+
$gotestArgs = @("-tags=integration", "-shuffle=on", "-timeout=2h0m0s")
50+
if ($TEST_NAME_PATTERN -ne "") {
51+
$gotestArgs += "-run=${TEST_NAME_PATTERN}"
52+
}
53+
$gotestArgs += @("github.com/elastic/elastic-agent/testing/integration", "-v", "-args", "-integration.groups=$GROUP_NAME", "-integration.sudo=$TEST_SUDO")
54+
& gotestsum --no-color -f standard-quiet --junitfile-hide-skipped-tests --junitfile "${outputXML}" --jsonfile "${outputJSON}" -- @gotestArgs
4955
$TestsExitCode = $LASTEXITCODE
5056
} finally {
5157
ess_down

.buildkite/scripts/steps/integration_tests_tf.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ asdf install
1111

1212
GROUP_NAME=$1
1313
TEST_SUDO=$2
14+
# NOTE: This argument is not used in this script, but is declared to show that it can be set
15+
# and passed down to downstream scripts where it may be used.
16+
TEST_NAME_PATTERN=${3:-""}
1417
if [ -z "$GROUP_NAME" ]; then
1518
echo "Error: Specify the group name: integration_tests_tf.sh [group_name]" >&2
1619
exit 1

.ci/scripts/otel-update.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ sed -i.bak "s/\(go\.opentelemetry\.io\/collector.*\) $current_stable_core/\1 $ne
3535
sed -i.bak "s/\(github\.com\/open-telemetry\/opentelemetry\-collector\-contrib\/.*\) $current_contrib/\1 $next_contrib/" go.mod
3636
rm go.mod.bak
3737

38-
echo "=> Running go mod tidy"
39-
go mod tidy
4038
echo "=> Running mage notice"
4139
mage notice
4240
echo "=> Running mage otel:readme"

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,12 @@ rules implemented on our `Makefile` as well as CI will use the
258258
locally before submitting any PRs to have a quicker feedback instead
259259
of waiting for a CI failure.
260260

261+
### Keeping Go module files tidy
262+
The Elastic Agent repository includes additional Go modules (e.g. `wrapper/windows/archive-proxy`) that import the main `elastic-agent` module. This requires keeping all `go.mod` files in sync whenever dependencies change. There is a dedicated `mage tidy` target that recursively runs `go mod tidy` across the entire repo. This is now handled automatically in the following targets:
263+
- `mage check`
264+
- `mage notice`
265+
- `mage update`
266+
261267
### Generating the `NOTICE.txt` and `NOTICE-fips.txt` when updating/adding dependencies
262268
To do so, just run `mage notice`, this is also part of the `make
263269
check-ci` and is the same check our CI will do.

dev-tools/mage/target/common/check.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ func Check() {
2323
deps := make([]interface{}, 0, len(checkDeps)+2)
2424
deps = append(deps, devtools.Format)
2525
deps = append(deps, checkDeps...)
26+
deps = append(deps, Tidy)
2627
deps = append(deps, devtools.Check)
2728
mg.SerialDeps(deps...)
2829
}

dev-tools/mage/target/common/notice.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,13 @@ func Notice() (err error) {
4444
// generateNotice generates a generateNotice file with the name outputFilename.
4545
// see getDependentModules for use of additionalTags.
4646
func generateNotice(outputFilename string, additionalTags ...string) error {
47-
fmt.Printf("Generating %s...\n", outputFilename)
48-
if err := runCommand("go", "mod", "tidy"); err != nil {
47+
// NOTE: this is not invoked through mg.Deps because
48+
// we want to always invoke it and guarantee that it runs
49+
// as mg.Deps does memoization
50+
if err := Tidy(); err != nil {
4951
return err
5052
}
53+
fmt.Printf("Generating %s...\n", outputFilename)
5154
if err := runCommand("go", "mod", "download"); err != nil {
5255
return err
5356
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
2+
// or more contributor license agreements. Licensed under the Elastic License 2.0;
3+
// you may not use this file except in compliance with the Elastic License 2.0.
4+
5+
package common
6+
7+
import (
8+
"fmt"
9+
"os"
10+
"os/exec"
11+
"path/filepath"
12+
13+
"github.com/magefile/mage/mg"
14+
15+
devtools "github.com/elastic/elastic-agent/dev-tools/mage"
16+
)
17+
18+
// Tidy runs go mod tidy on all go.mod recursively inside the elastic-agent repository.
19+
func Tidy() error {
20+
goModFiles, err := devtools.FindFilesRecursive(func(path string, _ os.FileInfo) bool {
21+
return filepath.Base(path) == "go.mod"
22+
})
23+
if err != nil {
24+
return err
25+
}
26+
for _, file := range goModFiles {
27+
dir, err := filepath.Abs(filepath.Dir(file))
28+
if err != nil {
29+
return fmt.Errorf("tidy: error getting absolute dir: %w", err)
30+
}
31+
fmt.Printf(">> tidy: Running go mod tidy inside %s\n", dir)
32+
cmd := exec.Command(mg.GoCmd(), "mod", "tidy", "-v") // #nosec G204 -- Need to pass in name of package
33+
cmd.Dir = dir
34+
cmd.Stdout = os.Stdout
35+
cmd.Stderr = os.Stderr
36+
err = cmd.Run()
37+
if err != nil {
38+
return fmt.Errorf("tidy: error running go mod tidy: %w", err)
39+
}
40+
}
41+
return nil
42+
}

0 commit comments

Comments
 (0)