Skip to content

Commit

Permalink
Merge branch 'main' into hybrid-agent-test
Browse files Browse the repository at this point in the history
  • Loading branch information
mauri870 authored Jan 31, 2025
2 parents db4caef + cdb574a commit 0d77c63
Show file tree
Hide file tree
Showing 90 changed files with 4,582 additions and 350 deletions.
6 changes: 4 additions & 2 deletions .buildkite/pipeline.elastic-agent-binary-dra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ steps:
if: build.branch =~ /^[0-9]+\.[0-9x]+\$/ || build.env("RUN_STAGING") == "true" || build.env('VERSION_QUALIFIER') != null
steps:
- label: ":package: Build Elastic-Agent Core staging"
commands:
- .buildkite/scripts/steps/build-agent-core.sh
commands: |
source .buildkite/scripts/version_qualifier.sh
.buildkite/scripts/steps/build-agent-core.sh
key: "build-dra-staging"
artifact_paths:
- "build/distributions/**/*"
Expand All @@ -62,6 +63,7 @@ steps:

- label: ":hammer: DRA Publish Elastic-Agent Core staging"
command: |
source .buildkite/scripts/version_qualifier.sh
echo "+++ Restoring Artifacts"
buildkite-agent artifact download "build/**/*" .
echo "+++ Changing permissions for the release manager"
Expand Down
15 changes: 9 additions & 6 deletions .buildkite/scripts/buildkite-integration-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ fi
asdf install

echo "~~~ Running integration tests as $USER"
echo "~~~ Integration tests: ${GROUP_NAME}"

go install gotest.tools/gotestsum
gotestsum --version

PACKAGE_VERSION="$(cat .package-version)"
if [[ -n "$PACKAGE_VERSION" ]]; then
PACKAGE_VERSION=${PACKAGE_VERSION}"-SNAPSHOT"
fi
# Parsing version.go. Will be simplified here: https://github.com/elastic/ingest-dev/issues/4925
AGENT_VERSION=$(grep "const defaultBeatVersion =" version/version.go | cut -d\" -f2)
AGENT_VERSION="${AGENT_VERSION}-SNAPSHOT"
export AGENT_VERSION
echo "~~~ Agent version: ${AGENT_VERSION}"

os_data=$(uname -spr | tr ' ' '_')
root_suffix=""
Expand All @@ -44,8 +44,11 @@ fi
fully_qualified_group_name="${GROUP_NAME}${root_suffix}_${os_data}"
outputXML="build/${fully_qualified_group_name}.integration.xml"
outputJSON="build/${fully_qualified_group_name}.integration.out.json"

echo "~~~ Integration tests: ${GROUP_NAME}"

set +e
TEST_BINARY_NAME="elastic-agent" AGENT_VERSION="${PACKAGE_VERSION}" SNAPSHOT=true gotestsum --no-color -f standard-quiet --junitfile "${outputXML}" --jsonfile "${outputJSON}" -- -tags integration -test.shuffle on -test.timeout 2h0m0s github.com/elastic/elastic-agent/testing/integration -v -args -integration.groups="${GROUP_NAME}" -integration.sudo="${TEST_SUDO}"
TEST_BINARY_NAME="elastic-agent" AGENT_VERSION="${AGENT_VERSION}" SNAPSHOT=true gotestsum --no-color -f standard-quiet --junitfile "${outputXML}" --jsonfile "${outputJSON}" -- -tags integration -test.shuffle on -test.timeout 2h0m0s github.com/elastic/elastic-agent/testing/integration -v -args -integration.groups="${GROUP_NAME}" -integration.sudo="${TEST_SUDO}"
TESTS_EXIT_STATUS=$?
set -e

Expand Down
9 changes: 6 additions & 3 deletions .buildkite/scripts/integration-tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ if ($PACKAGE_VERSION) {
$PACKAGE_VERSION = "${PACKAGE_VERSION}-SNAPSHOT"
}
$env:TEST_BINARY_NAME = "elastic-agent"
$env:AGENT_VERSION = $PACKAGE_VERSION
# Parsing version.go. Will be simplified here: https://github.com/elastic/ingest-dev/issues/4925
$AGENT_VERSION = (Get-Content version/version.go | Select-String -Pattern 'const defaultBeatVersion =' | ForEach-Object { $_ -replace '.*?"(.*?)".*', '$1' })
$env:AGENT_VERSION = $AGENT_VERSION + "-SNAPSHOT"
echo "~~~ Agent version: $env:AGENT_VERSION"
$env:SNAPSHOT = $true

echo "~~~ Building test binaries"
Expand All @@ -32,9 +35,9 @@ $fully_qualified_group_name="${GROUP_NAME}${root_suffix}_${osInfo}"
$outputXML = "build/${fully_qualified_group_name}.integration.xml"
$outputJSON = "build/${fully_qualified_group_name}.integration.out.json"
try {
Get-Ess-Stack -StackVersion $PACKAGE_VERSION
Get-Ess-Stack -StackVersion $PACKAGE_VERSION
Write-Output "~~~ Running integration test group: $GROUP_NAME as user: $env:USERNAME"
gotestsum --no-color -f standard-quiet --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"
gotestsum --no-color -f standard-quiet --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"
} finally {
ess_down

Expand Down
2 changes: 1 addition & 1 deletion .buildkite/scripts/steps/dra-publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function run_release_manager_collect() {
--workflow "${_workflow}" \
--version "${_version}" \
--artifact-set "${_artifact_set}" \
--qualifier "${VERSION_QUALIFIER}"
--qualifier "${VERSION_QUALIFIER}" \
${_dry_run}
}

Expand Down
22 changes: 22 additions & 0 deletions .buildkite/scripts/version_qualifier.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

# An opinionated approach to managing the Elastic Qualifier for the DRA in a Google Bucket
# instead of using a Buildkite env variable.

if [[ -n "$VERSION_QUALIFIER" ]]; then
echo "~~~ VERSION_QUALIFIER externally set to [$VERSION_QUALIFIER]"
return 0
fi

# DRA_BRANCH can be used for manually testing packaging with PRs
# e.g. define `DRA_BRANCH="main"` under Options/Environment Variables in the Buildkite UI after clicking new Build
BRANCH="${DRA_BRANCH:="${BUILDKITE_BRANCH:=""}"}"

qualifier=""
URL="https://storage.googleapis.com/dra-qualifier/${BRANCH}"
if curl -sf -o /dev/null "$URL" ; then
qualifier=$(curl -s "$URL")
fi

export VERSION_QUALIFIER="$qualifier"
echo "~~~ VERSION_QUALIFIER set to [$VERSION_QUALIFIER]"
22 changes: 16 additions & 6 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ linters:
- noctx # noctx finds sending http request without context.Context
- unconvert # Remove unnecessary type conversions
- wastedassign # wastedassign finds wasted assignment statements.
- gomodguard # check for blocked dependencies
- depguard # check for blocked imports from Go files
- gomodguard # check for blocked imports from go.mod
- gomoddirectives

# all available settings of specific linters
Expand Down Expand Up @@ -88,9 +89,9 @@ linters-settings:
goimports:
local-prefixes: github.com/elastic

# Check for blocked dependencies in go.mod.
gomodguard:
blocked:
# List of blocked modules.
modules:
# Blocked module.
- github.com/pkg/errors:
Expand All @@ -105,6 +106,15 @@ linters-settings:
- github.com/gofrs/uuid/v5
reason: "Use one uuid library consistently across the codebase"

# Check for blocked imports in Go files.
depguard:
rules:
main:
list-mode: lax
deny:
- pkg: "math/rand$"
desc: "superseded by math/rand/v2"

gomoddirectives:
# Forbid local `replace` directives
replace-local: false
Expand All @@ -120,7 +130,7 @@ linters-settings:

gosimple:
# Select the Go version to target. The default is '1.13'.
go: "1.22.10"
go: "1.22.11"

nolintlint:
# Enable to ensure that nolint directives are all used. Default is true.
Expand All @@ -136,17 +146,17 @@ linters-settings:

staticcheck:
# Select the Go version to target. The default is '1.13'.
go: "1.22.10"
go: "1.22.11"
checks: ["all"]

stylecheck:
# Select the Go version to target. The default is '1.13'.
go: "1.22.10"
go: "1.22.11"
checks: ["all"]

unused:
# Select the Go version to target. The default is '1.13'.
go: "1.22.10"
go: "1.22.11"

gosec:
excludes:
Expand Down
27 changes: 13 additions & 14 deletions .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,20 +123,6 @@ pull_request_rules:
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:
* `backport-./d./d` is the label to automatically backport to the `8./d` branch. `/d` is the digit
- name: add backport-8.x label for main only if no skipped or assigned already
conditions:
- -label~=^(backport-skip|backport-8.x)$
- base=main
- -merged
- -closed
actions:
comment:
message: |
`backport-v8.x` has been added to help with the transition to the new branch `8.x`.
If you don't need it please use `backport-skip` label and remove the `backport-8.x` label.
label:
add:
- backport-8.x
- name: backport patches to 7.17 branch
conditions:
- merged
Expand Down Expand Up @@ -371,3 +357,16 @@ pull_request_rules:
labels:
- "backport"
title: "[{{ destination_branch }}](backport #{{ number }}) {{ title }}"
- name: backport patches to 8.18 branch
conditions:
- merged
- label=backport-8.18
actions:
backport:
assignees:
- "{{ author }}"
branches:
- "8.18"
labels:
- "backport"
title: "[{{ destination_branch }}](backport #{{ number }}) {{ title }}"
8 changes: 7 additions & 1 deletion .mockery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ packages:
github.com/elastic/elastic-agent/pkg/control/v2/client:
interfaces:
Client:
github.com/elastic/elastic-agent/internal/pkg/fleetapi/client:
interfaces:
Sender:
github.com/elastic/elastic-agent/internal/pkg/agent/storage:
interfaces:
Storage:
github.com/elastic/elastic-agent/internal/pkg/agent/application/actions/handlers:
interfaces:
Uploader:
Expand All @@ -22,4 +28,4 @@ packages:
Acker:
github.com/elastic/elastic-agent/internal/pkg/agent/application/info:
interfaces:
Agent:
Agent:
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG GO_VERSION=1.22.10
ARG GO_VERSION=1.22.11
FROM circleci/golang:${GO_VERSION}


Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.skaffold
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG GO_VERSION=1.22.10
ARG GO_VERSION=1.22.11
ARG crossbuild_image="docker.elastic.co/beats-dev/golang-crossbuild"
ARG AGENT_VERSION=8.9.0-SNAPSHOT
ARG AGENT_IMAGE="docker.elastic.co/beats/elastic-agent"
Expand Down
Loading

0 comments on commit 0d77c63

Please sign in to comment.