Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
2fbec62
Use a custom image for the ECH deployment when running integration tests
michel-laterman Jun 4, 2025
4ee3fb3
Use per-step env vars
michel-laterman Jun 4, 2025
37d02bd
Update TF_VAR
michel-laterman Jun 5, 2025
48f3eff
Merge branch 'main' into integration-tests-custom-image
michel-laterman Jun 5, 2025
4f1bee1
remove extra FIPS var manipulation
michel-laterman Jun 6, 2025
1470af2
Merge branch 'main' into integration-tests-custom-image
michel-laterman Jun 6, 2025
dddab2e
Merge branch 'main' into integration-tests-custom-image
michel-laterman Jun 9, 2025
f6cb9aa
Merge branch 'main' into integration-tests-custom-image
michel-laterman Jun 10, 2025
97d97c4
Correct merge
michel-laterman Jun 10, 2025
d5b18dc
Merge branch 'main' into integration-tests-custom-image
michel-laterman Jun 12, 2025
d47df46
Use plugin instead of pre-command hook
michel-laterman Jun 12, 2025
d7e0190
Fix image tag
michel-laterman Jun 13, 2025
47121af
Merge branch 'main' into integration-tests-custom-image
michel-laterman Jun 17, 2025
ea0aad4
Merge branch 'main' into integration-tests-custom-image
michel-laterman Jun 18, 2025
7136397
Merge branch 'main' into integration-tests-custom-image
michel-laterman Jun 18, 2025
67a50d4
Use top level env vars
michel-laterman Jun 20, 2025
3adcb4c
Merge branch 'main' into integration-tests-custom-image
michel-laterman Jun 20, 2025
041fa59
Do not use top level env due to cross polution
michel-laterman Jun 20, 2025
1d11d9b
Call cloud:load and cloud:push from packaging step
michel-laterman Jun 23, 2025
3abc4c1
Add ECH test + group
michel-laterman Jun 27, 2025
04b9c1a
Remove extra depends on
michel-laterman Jun 27, 2025
c1d8f99
text fix
michel-laterman Jun 27, 2025
9c58a47
Fix typo in test
michel-laterman Jun 27, 2025
c371ff8
Merge branch 'main' into integration-tests-custom-image
michel-laterman Jun 30, 2025
954946a
Use dedicate script to provision and run ECH tests
michel-laterman Jul 3, 2025
900c3c2
Fix missing plugins
michel-laterman Jul 3, 2025
ab7795d
Fix packaging step
michel-laterman Jul 3, 2025
7618874
Fix package name
michel-laterman Jul 4, 2025
5776aa9
Merge branch 'main' into integration-tests-custom-image
michel-laterman Jul 4, 2025
be85989
bump tf version, fix group
michel-laterman Jul 7, 2025
cad8424
Fix package import
michel-laterman Jul 7, 2025
344f8c8
Merge branch 'main' into integration-tests-custom-image
michel-laterman Jul 8, 2025
ee3d32b
Review feedback
michel-laterman Jul 8, 2025
fde5126
Add vault plugin
michel-laterman Jul 8, 2025
6d90a53
remove extra line from packaging
michel-laterman Jul 8, 2025
641052a
Fix typo
michel-laterman Jul 8, 2025
d89c99d
revert ASDF_terraform_version
michel-laterman Jul 8, 2025
a6c10cc
fix asdf_terrafrom_version
michel-laterman Jul 8, 2025
0f30c34
Add missing args
michel-laterman Jul 8, 2025
7ed4952
Add TEST_PACKAGE env var
michel-laterman Jul 8, 2025
b380f63
Review feedback
michel-laterman Jul 9, 2025
a57debb
Merge branch 'main' into integration-tests-custom-image
michel-laterman Jul 9, 2025
fa88b18
Fix args
michel-laterman Jul 9, 2025
ea71e70
Merge branch 'main' into integration-tests-custom-image
michel-laterman Jul 10, 2025
68339f6
Review feedback
michel-laterman Jul 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 4 additions & 27 deletions .buildkite/bk.integration-fips.pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,8 @@ common:
env_var: "EC_API_KEY"

steps:
- label: Build and push custom elastic-agent image
depends_on:
- 'packaging-containers-x86-64-fips' # Reuse artifacts produced in .buildkite/integration.pipeline.yml
key: integration-fips-cloud-image
env:
FIPS: "true"
CUSTOM_IMAGE_TAG: "git-${BUILDKITE_COMMIT:0:12}"
CI_ELASTIC_AGENT_DOCKER_IMAGE: "docker.elastic.co/beats-ci/elastic-agent-cloud-fips"
TF_VAR_integration_server_docker_image: "docker.elastic.co/beats-ci/elastic-agent-cloud-fips:git-${BUILDKITE_COMMIT:0:12}"
command: |
buildkite-agent artifact download build/distributions/elastic-agent-cloud-fips-*-linux-amd64.docker.tar.gz . --step 'packaging-containers-x86-64-fips'
mage cloud:load
mage cloud:push
agents:
provider: "gcp"
machineType: "n1-standard-8"
image: "${IMAGE_UBUNTU_2404_X86_64}"
plugins:
- elastic/vault-docker-login#v0.5.2:
secret_path: 'kv/ci-shared/platform-ingest/elastic_docker_registry'

- label: Start ESS stack for FIPS integration tests
key: integration-fips-ess
depends_on:
- integration-fips-cloud-image
env:
ASDF_TERRAFORM_VERSION: 1.9.2
TF_VAR_integration_server_docker_image: "docker.elastic.co/beats-ci/elastic-agent-cloud-fips:git-${BUILDKITE_COMMIT:0:12}"
Expand All @@ -55,7 +32,7 @@ steps:
image: "docker.elastic.co/ci-agent-images/platform-ingest/buildkite-agent-beats-ci-with-hooks:0.5"
useCustomGlobalHooks: true
plugins:
- *vault_ec_key_prod
- *vault_ec_key_prod

- group: "fips:Stateful:Ubuntu"
key: integration-tests-ubuntu-fips
Expand Down Expand Up @@ -83,7 +60,7 @@ steps:
image: "${IMAGE_UBUNTU_X86_64_FIPS}"
instanceType: "m5.2xlarge"
plugins:
- *vault_ec_key_prod
- *vault_ec_key_prod
matrix:
setup:
sudo:
Expand Down Expand Up @@ -113,7 +90,7 @@ steps:
image: "${IMAGE_UBUNTU_ARM64_FIPS}"
instanceType: "m6g.2xlarge"
plugins:
- *vault_ec_key_prod
- *vault_ec_key_prod
matrix:
setup:
sudo:
Expand Down Expand Up @@ -153,7 +130,7 @@ steps:
image: "docker.elastic.co/ci-agent-images/platform-ingest/buildkite-agent-beats-ci-with-hooks:0.5"
useCustomGlobalHooks: true
plugins:
- *vault_ec_key_prod
- *vault_ec_key_prod

- label: Aggregate test reports
depends_on:
Expand Down
32 changes: 29 additions & 3 deletions .buildkite/bk.integration.pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,34 @@ common:
elastic/vault-secrets#v0.1.0:
path: "kv/ci-shared/platform-ingest/platform-ingest-ec-prod"
field: "apiKey"
env_var: "EC_API_KEY"
env_var: "EC_API_KEY"

steps:
- label: "Custom ECH Testing"
key: integration-tests-ech
depends_on:
- packaging-ubuntu-x86-64
env:
TEST_PACKAGE: "github.com/elastic/elastic-agent/testing/integration/ess"
TF_VAR_integration_server_docker_image: "docker.elastic.co/beats-ci/elastic-agent-cloud:git-${BUILDKITE_COMMIT:0:12}"
FORCE_ESS_CREATE: "true"
command: |
#!/usr/bin/env bash
buildkite-agent artifact download build/distributions/** . --step 'packaging-ubuntu-x86-64'
.buildkite/scripts/steps/integration_tests_tf.sh ech true
artifact_paths:
- build/**
- build/diagnostics/**
retry:
automatic:
limit: 1
agents:
provider: "gcp"
machineType: "n2-standard-8"
image: "${IMAGE_UBUNTU_2404_X86_64}"
plugins:
- *vault_ec_key_prod

- label: Start ESS stack for integration tests
key: integration-ess
notify:
Expand Down Expand Up @@ -113,7 +138,7 @@ steps:
image: "${IMAGE_WIN_2025}"
plugins:
- *vault_ec_key_prod

- label: "Ubuntu:2404:amd64:sudo"
depends_on: packaging-ubuntu-x86-64
env:
Expand Down Expand Up @@ -298,7 +323,7 @@ steps:
machineType: "n2-standard-8"
image: "${IMAGE_UBUNTU_2404_X86_64}"
plugins:
- *vault_ec_key_prod
- *vault_ec_key_prod
matrix:
- default
- upgrade
Expand Down Expand Up @@ -614,6 +639,7 @@ steps:
# Warning: The key has a hook in pre-command
key: aggregate-reports
depends_on:
- integration-tests-ech
- integration-tests-ubuntu
- integration-tests-win
- integration-tests-rhel8
Expand Down
25 changes: 23 additions & 2 deletions .buildkite/integration.pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
env:
VAULT_PATH: "kv/ci-shared/observability-ingest/cloud/gcp"

common:
- vault_docker_login: &vault_docker_login
elastic/vault-docker-login#v0.5.2:
secret_path: 'kv/ci-shared/platform-ingest/elastic_docker_registry'

steps:
- group: "Integration tests: packaging"
key: "int-packaging"
Expand Down Expand Up @@ -97,13 +102,21 @@ steps:
env:
PACKAGES: "docker"
PLATFORMS: "linux/amd64"
command: ".buildkite/scripts/steps/integration-package.sh"
CUSTOM_IMAGE_TAG: "git-${BUILDKITE_COMMIT:0:12}"
CI_ELASTIC_AGENT_DOCKER_IMAGE: "docker.elastic.co/beats-ci/elastic-agent-cloud"
command: |
source .buildkite/scripts/common.sh
.buildkite/scripts/steps/integration-package.sh
echo "~~~ Pushing cloud image"
mage cloud:push
artifact_paths:
- build/distributions/**
agents:
provider: "gcp"
machineType: "n2-standard-8"
diskSizeGb: 200
plugins:
- *vault_docker_login

- label: "Packaging: Containers linux/arm64"
key: packaging-containers-arm64
Expand All @@ -126,13 +139,21 @@ steps:
PACKAGES: "docker"
PLATFORMS: "linux/amd64"
FIPS: "true"
command: ".buildkite/scripts/steps/integration-package.sh"
CUSTOM_IMAGE_TAG: "git-${BUILDKITE_COMMIT:0:12}"
CI_ELASTIC_AGENT_DOCKER_IMAGE: "docker.elastic.co/beats-ci/elastic-agent-cloud-fips"
command: |
source .buildkite/scripts/common.sh
.buildkite/scripts/steps/integration-package.sh
echo "~~~ Pushing cloud image"
mage cloud:push
artifact_paths:
- build/distributions/**
agents:
provider: "gcp"
machineType: "n2-standard-8"
diskSizeGb: 200
plugins:
- *vault_docker_login

- label: "Packaging: Containers linux/arm64 FIPS"
key: packaging-containers-arm64-fips
Expand Down
2 changes: 1 addition & 1 deletion .buildkite/scripts/steps/integration_tests_tf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ mage build:testBinaries
# If the step is retried, we start the stack again.
# BUILDKITE_RETRY_COUNT == "0" for the first run
# BUILDKITE_RETRY_COUNT > 0 for the retries
if [[ "${BUILDKITE_RETRY_COUNT}" -gt 0 ]]; then
if [[ "${BUILDKITE_RETRY_COUNT}" -gt 0 || "${FORCE_ESS_CREATE:-false}" == "true" ]]; then
echo "~~~ The steps is retried, starting the ESS stack again"
trap 'ess_down' EXIT
ess_up $OVERRIDE_STACK_VERSION || (echo -e "^^^ +++\nFailed to start ESS stack")
Expand Down
5 changes: 1 addition & 4 deletions magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -991,14 +991,11 @@ func (Cloud) Load() error {

// Need to get the FIPS env var flag to see if we are using the normal source cloud image name, or the FIPS variant
fips := os.Getenv(fipsEnv)
defer os.Setenv(fipsEnv, fips)
fipsVal, err := strconv.ParseBool(fips)
if err != nil {
fipsVal = false
}
if err := os.Setenv(fipsEnv, strconv.FormatBool(fipsVal)); err != nil {
return fmt.Errorf("failed to set fips env var: %w", err)
}

devtools.FIPSBuild = fipsVal

source := "build/distributions/elastic-agent-cloud-" + agentVersion + "-SNAPSHOT-linux-" + runtime.GOARCH + ".docker.tar.gz"
Expand Down
125 changes: 125 additions & 0 deletions testing/integration/ess/ech_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
// or more contributor license agreements. Licensed under the Elastic License 2.0;
// you may not use this file except in compliance with the Elastic License 2.0.

//go:build integration

package ess

import (
"encoding/json"
"net/http"
"net/url"
"strings"
"testing"
"time"

"github.com/gofrs/uuid/v5"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/elastic/elastic-agent-libs/kibana"
"github.com/elastic/elastic-agent/pkg/control/v2/cproto"
atesting "github.com/elastic/elastic-agent/pkg/testing"
"github.com/elastic/elastic-agent/pkg/testing/define"
"github.com/elastic/elastic-agent/pkg/testing/tools/fleettools"
"github.com/elastic/elastic-agent/testing/integration"
)

func TestECH(t *testing.T) {
info := define.Require(t, define.Requirements{
Group: integration.ECH,
Stack: &define.Stack{},
Sudo: true,
Local: false,
OS: []define.OS{
{
Type: define.Linux,
},
},
})

// Check that the Fleet Server in the deployment is healthy
fleetServerHost, err := fleettools.DefaultURL(t.Context(), info.KibanaClient)
statusUrl, err := url.JoinPath(fleetServerHost, "/api/status")
require.NoError(t, err)

require.EventuallyWithT(t, func(c *assert.CollectT) {
resp, err := http.Get(statusUrl)
require.NoError(c, err)
defer resp.Body.Close()

require.Equal(c, http.StatusOK, resp.StatusCode)

var body struct {
Name string `json:"name"`
Status string `json:"status"`
}
err = json.NewDecoder(resp.Body).Decode(&body)
require.NoError(c, err)

t.Logf("body.status = %s", body.Status)
require.Equal(c, "HEALTHY", body.Status)
}, 5*time.Minute, 10*time.Second, "Fleet Server in ECH deployment is not healthy")

// Create a policy and install an agent
policyUUID := uuid.Must(uuid.NewV4()).String()
policy := kibana.AgentPolicy{
Name: "testloglevel-policy-" + policyUUID,
Namespace: "default",
Description: "Test Log Level Policy " + policyUUID,
MonitoringEnabled: []kibana.MonitoringEnabledOption{},
}
t.Log("Creating Agent policy...")
policyResp, err := info.KibanaClient.CreatePolicy(t.Context(), policy)
require.NoError(t, err, "failed creating policy")

t.Log("Creating Agent enrollment API key...")
createEnrollmentApiKeyReq := kibana.CreateEnrollmentAPIKeyRequest{
PolicyID: policyResp.ID,
}
enrollmentToken, err := info.KibanaClient.CreateEnrollmentAPIKey(t.Context(), createEnrollmentApiKeyReq)
require.NoError(t, err, "failed creating enrollment API key")
t.Logf("Created policy %+v", policyResp.AgentPolicy)

fixture, err := define.NewFixtureFromLocalBuild(t, define.Version())
require.NoError(t, err)
err = fixture.Prepare(t.Context())
require.NoError(t, err)

opts := &atesting.InstallOpts{
Force: true,
Privileged: true,
EnrollOpts: atesting.EnrollOpts{
URL: fleetServerHost,
EnrollmentToken: enrollmentToken.APIKey,
},
}
out, err := fixture.Install(t.Context(), opts)
if err != nil {
t.Logf("install output: %s", out)
require.NoError(t, err)
}

var agentID string
require.EventuallyWithT(t, func(c *assert.CollectT) {
status, err := fixture.ExecStatus(t.Context())
require.NoError(c, err)
statusBuffer := new(strings.Builder)
err = json.NewEncoder(statusBuffer).Encode(status)
require.NoError(c, err)
t.Logf("agent status: %v", statusBuffer.String())

require.Equal(c, int(cproto.State_HEALTHY), status.State, "agent state is not healthy")
require.Equal(c, int(cproto.State_HEALTHY), status.FleetState, "agent's fleet-server state is not healthy")
agentID = status.Info.ID
}, time.Minute, time.Second, "agent never became healthy or connected to Fleet")

require.EventuallyWithT(t, func(c *assert.CollectT) {
status, err := fleettools.GetAgentStatus(t.Context(), info.KibanaClient, agentID)
require.NoError(c, err)
require.Equal(c, "online", status)
}, time.Minute, time.Second, "agent does not show as online in fleet")

t.Run("run uninstall", testUninstallAuditUnenroll(t.Context(), fixture, info))
}
3 changes: 3 additions & 0 deletions testing/integration/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ const (
// Default group.
Default = define.Default

// ECH group of tests. Used to test against a custom integration server.
ECH = "ech"

// Fleet group of tests. Used for testing Elastic Agent with Fleet.
Fleet = "fleet"

Expand Down