Skip to content

Commit dd7c6dd

Browse files
committed
oblt-cli(hosted): support running ITs using oblt-cli
with OIDC support
1 parent 45217d0 commit dd7c6dd

File tree

12 files changed

+69
-394
lines changed

12 files changed

+69
-394
lines changed

.buildkite/bk.integration.pipeline.yml

Lines changed: 58 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ common:
2323
lifetime: 10800 # seconds
2424
project-id: "elastic-observability-ci"
2525
project-number: "911195782929"
26+
- google_oidc_observability_plugin: &google_oidc_observability_plugin
27+
# See https://github.com/elastic/oblt-infra/blob/main/conf/resources/repos/elastic-agent/01-gcp-oidc.tf
28+
# This plugin authenticates to Google Cloud using the OIDC token.
29+
elastic/oblt-google-auth#v1.3.0:
30+
lifetime: 10800 # seconds
2631
# see https://github.com/avaly/gcp-secret-manager-buildkite-plugin/pull/10
2732
# see https://github.com/avaly/gcp-secret-manager-buildkite-plugin/pull/11
2833
# - gcp_serverless_secrets_plugin: &gcp_serverless_secrets_plugin
@@ -37,24 +42,28 @@ common:
3742
KIBANA_HOST: ea-serverless-it-kibana-hostname
3843
KIBANA_USERNAME: ea-serverless-it-kibana-username
3944
KIBANA_PASSWORD: ea-serverless-it-kibana-password
45+
- gcp_hosted_secrets_plugin: &gcp_hosted_secrets_plugin
46+
elastic/gcp-secret-manager#v1.3.0-elastic:
47+
env:
48+
# These secrets are created in the step called Start ESS stack for integration tests
49+
# TODO: need to find a way to use dynamic names in the secrets
50+
ELASTICSEARCH_HOST: ea-hosted-it-elasticsearch-hostname
51+
ELASTICSEARCH_PASSWORD: ea-hosted-it-elasticsearch-password
52+
ELASTICSEARCH_USERNAME: ea-hosted-it-elasticsearch-username
53+
KIBANA_HOST: ea-hosted-it-kibana-hostname
54+
KIBANA_USERNAME: ea-hosted-it-kibana-username
55+
KIBANA_PASSWORD: ea-hosted-it-kibana-password
56+
INTEGRATIONS_SERVER_HOST: ea-hosted-it-integration-hostname
4057

4158
steps:
4259
- label: Start ESS stack for integration tests
4360
key: integration-ess
4461
notify:
4562
- github_commit_status:
46-
context: "buildkite/elastic-agent-extended-testing - ESS stack provision"
47-
env:
48-
ASDF_TERRAFORM_VERSION: 1.9.2
49-
command: |
50-
#!/usr/bin/env bash
51-
set -euo pipefail
52-
source .buildkite/scripts/steps/ess_start.sh
53-
artifact_paths:
54-
- test_infra/ess/*.tfstate
55-
- test_infra/ess/*.lock.hcl
63+
context: "buildkite/elastic-agent-extended-testing - ESS stack provision using oblt-cli"
64+
command: .buildkite/scripts/steps/ess_start.sh
5665
agents:
57-
image: "docker.elastic.co/ci-agent-images/platform-ingest/buildkite-agent-beats-ci-with-hooks:0.5"
66+
image: "docker.elastic.co/ci-agent-images/platform-ingest/oblt-cli:latest"
5867
useCustomGlobalHooks: true
5968

6069
- group: "Extended runtime leak tests"
@@ -152,6 +161,9 @@ steps:
152161
- upgrade
153162
- upgrade-flavor
154163
- install-uninstall
164+
plugins:
165+
- *google_oidc_observability_plugin
166+
- *gcp_hosted_secrets_plugin
155167

156168
- label: "Win2022:non-sudo:{{matrix}}"
157169
depends_on:
@@ -171,6 +183,9 @@ steps:
171183
limit: 1
172184
matrix:
173185
- default
186+
plugins:
187+
- *google_oidc_observability_plugin
188+
- *gcp_hosted_secrets_plugin
174189

175190
- label: "Win2025:sudo:{{matrix}}"
176191
depends_on:
@@ -197,6 +212,9 @@ steps:
197212
- upgrade
198213
- upgrade-flavor
199214
- install-uninstall
215+
plugins:
216+
- *google_oidc_observability_plugin
217+
- *gcp_hosted_secrets_plugin
200218

201219
- label: "Win2025:non-sudo:{{matrix}}"
202220
depends_on:
@@ -216,6 +234,9 @@ steps:
216234
image: "${IMAGE_WIN_2025}"
217235
matrix:
218236
- default
237+
plugins:
238+
- *google_oidc_observability_plugin
239+
- *gcp_hosted_secrets_plugin
219240

220241
- group: "Stateful:Ubuntu"
221242
key: integration-tests-ubuntu
@@ -242,6 +263,9 @@ steps:
242263
image: "${IMAGE_UBUNTU_2404_X86_64}"
243264
matrix:
244265
- default
266+
plugins:
267+
- *google_oidc_observability_plugin
268+
- *gcp_hosted_secrets_plugin
245269

246270
- label: "x86_64:sudo: {{matrix}}"
247271
depends_on:
@@ -275,6 +299,9 @@ steps:
275299
- fqdn
276300
- deb
277301
- container
302+
plugins:
303+
- *google_oidc_observability_plugin
304+
- *gcp_hosted_secrets_plugin
278305

279306
- label: "arm:sudo: {{matrix}}"
280307
depends_on:
@@ -308,6 +335,9 @@ steps:
308335
# - fqdn
309336
# - deb
310337
# - container
338+
plugins:
339+
- *google_oidc_observability_plugin
340+
- *gcp_hosted_secrets_plugin
311341

312342
- label: "arm:non-sudo: {{matrix}}"
313343
skip: true
@@ -328,6 +358,9 @@ steps:
328358
instanceType: "m6g.xlarge"
329359
matrix:
330360
- default
361+
plugins:
362+
- *google_oidc_observability_plugin
363+
- *gcp_hosted_secrets_plugin
331364

332365
- group: "Stateful:Debian"
333366
key: integration-tests-debian
@@ -354,6 +387,9 @@ steps:
354387
image: "${IMAGE_DEBIAN_12}"
355388
matrix:
356389
- default
390+
plugins:
391+
- *google_oidc_observability_plugin
392+
- *gcp_hosted_secrets_plugin
357393

358394
- label: "x86_64:sudo: {{matrix}}"
359395
depends_on:
@@ -388,6 +424,9 @@ steps:
388424
#- fqdn
389425
- deb
390426
- container
427+
plugins:
428+
- *google_oidc_observability_plugin
429+
- *gcp_hosted_secrets_plugin
391430

392431
- group: "Stateful(Sudo):RHEL8"
393432
key: integration-tests-rhel8
@@ -409,6 +448,9 @@ steps:
409448
retry:
410449
automatic:
411450
limit: 1
451+
plugins:
452+
- *google_oidc_observability_plugin
453+
- *gcp_hosted_secrets_plugin
412454
agents:
413455
provider: "gcp"
414456
machineType: "n2-standard-8"
@@ -444,6 +486,9 @@ steps:
444486
machineType: "n2-standard-4"
445487
image: "${IMAGE_UBUNTU_2404_X86_64}"
446488
diskSizeGb: 80
489+
plugins:
490+
- *google_oidc_observability_plugin
491+
- *gcp_hosted_secrets_plugin
447492
matrix:
448493
setup:
449494
variants:
@@ -540,12 +585,9 @@ steps:
540585
- integration-tests-kubernetes
541586
- extended-integration-tests
542587
allow_dependency_failure: true
543-
command: |
544-
buildkite-agent artifact download "test_infra/ess/**" . --step "integration-ess"
545-
ls -lah test_infra/ess
546-
.buildkite/scripts/steps/ess_down.sh
588+
command: .buildkite/scripts/steps/oblt-cli-teardown.sh
547589
agents:
548-
image: "docker.elastic.co/ci-agent-images/platform-ingest/buildkite-agent-beats-ci-with-hooks:0.5"
590+
image: "docker.elastic.co/ci-agent-images/platform-ingest/oblt-cli:latest"
549591
useCustomGlobalHooks: true
550592

551593
- label: Aggregate test reports

.buildkite/scripts/steps/ess.ps1

Lines changed: 3 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -5,84 +5,24 @@ function ess_up {
55
)
66

77
Write-Output "~~~ Starting ESS Stack"
8-
9-
$Workspace = & git rev-parse --show-toplevel
10-
$TfDir = Join-Path -Path $Workspace -ChildPath "test_infra/ess/"
118

129
if (-not $StackVersion) {
1310
Write-Error "Error: Specify stack version: ess_up [stack_version]"
1411
return 1
1512
}
1613

17-
$Env:EC_API_KEY = Retry-Command -ScriptBlock {
18-
vault kv get -field=apiKey kv/ci-shared/platform-ingest/platform-ingest-ec-prod
19-
}
20-
21-
if (-not $Env:EC_API_KEY) {
22-
Write-Error "Error: Failed to get EC API key from vault"
23-
exit 1
24-
}
25-
26-
$BuildkiteBuildCreator = if ($Env:BUILDKITE_BUILD_CREATOR) { $Env:BUILDKITE_BUILD_CREATOR } else { get_git_user_email }
27-
$BuildkiteBuildNumber = if ($Env:BUILDKITE_BUILD_NUMBER) { $Env:BUILDKITE_BUILD_NUMBER } else { "0" }
28-
$BuildkitePipelineSlug = if ($Env:BUILDKITE_PIPELINE_SLUG) { $Env:BUILDKITE_PIPELINE_SLUG } else { "elastic-agent-integration-tests" }
29-
30-
Push-Location -Path $TfDir
31-
& terraform init
32-
& terraform apply -auto-approve `
33-
-var="stack_version=$StackVersion" `
34-
-var="ess_region=$EssRegion" `
35-
-var="creator=$BuildkiteBuildCreator" `
36-
-var="buildkite_id=$BuildkiteBuildNumber" `
37-
-var="pipeline=$BuildkitePipelineSlug"
38-
39-
$Env:ELASTICSEARCH_HOST = & terraform output -raw es_host
40-
$Env:ELASTICSEARCH_USERNAME = & terraform output -raw es_username
41-
$Env:ELASTICSEARCH_PASSWORD = & terraform output -raw es_password
42-
$Env:KIBANA_HOST = & terraform output -raw kibana_endpoint
43-
$Env:KIBANA_USERNAME = $Env:ELASTICSEARCH_USERNAME
44-
$Env:KIBANA_PASSWORD = $Env:ELASTICSEARCH_PASSWORD
45-
$Env:INTEGRATIONS_SERVER_HOST = & terraform output -raw integrations_server_endpoint
46-
Pop-Location
14+
& oblt-cli
4715
}
4816

4917
function ess_down {
50-
$Workspace = & git rev-parse --show-toplevel
51-
$TfDir = Join-Path -Path $Workspace -ChildPath "test_infra/ess/"
52-
$stateFilePath = Join-Path -Path $TfDir -ChildPath "terraform.tfstate"
53-
54-
if (-not (Test-Path -Path $stateFilePath)) {
55-
Write-Output "Terraform state file not found. Skipping ESS destroy."
56-
return 0
57-
}
5818
Write-Output "~~~ Tearing down the ESS Stack(created for this step)"
5919
try {
60-
$Env:EC_API_KEY = Retry-Command -ScriptBlock {
61-
vault kv get -field=apiKey kv/ci-shared/platform-ingest/platform-ingest-ec-prod
62-
}
63-
Push-Location -Path $TfDir
64-
& terraform init
65-
& terraform destroy -auto-approve
66-
Pop-Location
20+
& oblt-cli
6721
} catch {
6822
Write-Output "Error: Failed to destroy ESS stack(it will be auto-deleted later): $_"
6923
}
7024
}
7125

72-
function get_git_user_email {
73-
if (!(git rev-parse --is-inside-work-tree *>&1)) {
74-
return "unknown"
75-
}
76-
77-
$email = & git config --get user.email
78-
79-
if (-not $email) {
80-
return "unknown"
81-
} else {
82-
return $email
83-
}
84-
}
85-
8626
function Retry-Command {
8727
param (
8828
[scriptblock]$ScriptBlock,
@@ -115,18 +55,7 @@ function Get-Ess-Stack {
11555
)
11656

11757
if ($Env:BUILDKITE_RETRY_COUNT -gt 0) {
118-
Write-Output "The step is retried, starting the ESS stack again"
58+
Write-Output "The step is retried, starting the ESS stack again"
11959
ess_up $StackVersion
120-
Write-Output "ESS stack is up. ES_HOST: $Env:ELASTICSEARCH_HOST"
121-
} else {
122-
# For the first run, we retrieve ESS stack metadata
123-
Write-Output "~~~ Receiving ESS stack metadata"
124-
$Env:ELASTICSEARCH_HOST = & buildkite-agent meta-data get "es.host"
125-
$Env:ELASTICSEARCH_USERNAME = & buildkite-agent meta-data get "es.username"
126-
$Env:ELASTICSEARCH_PASSWORD = & buildkite-agent meta-data get "es.pwd"
127-
$Env:KIBANA_HOST = & buildkite-agent meta-data get "kibana.host"
128-
$Env:KIBANA_USERNAME = & buildkite-agent meta-data get "kibana.username"
129-
$Env:KIBANA_PASSWORD = & buildkite-agent meta-data get "kibana.pwd"
130-
Write-Output "Received ESS stack data from previous step. ES_HOST: $Env:ELASTICSEARCH_HOST"
13160
}
13261
}

.buildkite/scripts/steps/ess.sh

Lines changed: 2 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ set -euo pipefail
33

44
function ess_up() {
55
echo "~~~ Starting ESS Stack"
6-
local WORKSPACE=$(git rev-parse --show-toplevel)
7-
local TF_DIR="${WORKSPACE}/test_infra/ess/"
86
local STACK_VERSION=$1
97
local ESS_REGION=${2:-"gcp-us-west2"}
108

@@ -13,64 +11,10 @@ function ess_up() {
1311
return 1
1412
fi
1513

16-
export EC_API_KEY=$(retry -t 5 -- vault kv get -field=apiKey kv/ci-shared/platform-ingest/platform-ingest-ec-prod)
17-
18-
if [[ -z "${EC_API_KEY}" ]]; then
19-
echo "Error: Failed to get EC API key from vault" >&2
20-
exit 1
21-
fi
22-
23-
BUILDKITE_BUILD_CREATOR="${BUILDKITE_BUILD_CREATOR:-"$(get_git_user_email)"}"
24-
BUILDKITE_BUILD_NUMBER="${BUILDKITE_BUILD_NUMBER:-"0"}"
25-
BUILDKITE_PIPELINE_SLUG="${BUILDKITE_PIPELINE_SLUG:-"elastic-agent-integration-tests"}"
26-
27-
pushd "${TF_DIR}"
28-
terraform init
29-
terraform apply \
30-
-auto-approve \
31-
-var="stack_version=${STACK_VERSION}" \
32-
-var="ess_region=${ESS_REGION}" \
33-
-var="creator=${BUILDKITE_BUILD_CREATOR}" \
34-
-var="buildkite_id=${BUILDKITE_BUILD_NUMBER}" \
35-
-var="pipeline=${BUILDKITE_PIPELINE_SLUG}"
36-
37-
export ELASTICSEARCH_HOST=$(terraform output -raw es_host)
38-
export ELASTICSEARCH_USERNAME=$(terraform output -raw es_username)
39-
export ELASTICSEARCH_PASSWORD=$(terraform output -raw es_password)
40-
export KIBANA_HOST=$(terraform output -raw kibana_endpoint)
41-
export KIBANA_USERNAME=$ELASTICSEARCH_USERNAME
42-
export KIBANA_PASSWORD=$ELASTICSEARCH_PASSWORD
43-
export INTEGRATIONS_SERVER_HOST=$(terraform output -raw integrations_server_endpoint)
44-
popd
14+
oblt-cli
4515
}
4616

4717
function ess_down() {
4818
echo "~~~ Tearing down the ESS Stack"
49-
local WORKSPACE=$(git rev-parse --show-toplevel)
50-
local TF_DIR="${WORKSPACE}/test_infra/ess/"
51-
if [ -z "${EC_API_KEY:-}" ]; then
52-
export EC_API_KEY=$(retry -t 5 -- vault kv get -field=apiKey kv/ci-shared/platform-ingest/platform-ingest-ec-prod)
53-
fi
54-
55-
pushd "${TF_DIR}"
56-
terraform init
57-
terraform destroy -auto-approve
58-
popd
59-
}
60-
61-
function get_git_user_email() {
62-
if ! git rev-parse --is-inside-work-tree &>/dev/null; then
63-
echo "unknown"
64-
return
65-
fi
66-
67-
local email
68-
email=$(git config --get user.email)
69-
70-
if [ -z "$email" ]; then
71-
echo "unknown"
72-
else
73-
echo "$email"
74-
fi
19+
oblt-cli
7520
}
76-

.buildkite/scripts/steps/ess_start.sh

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,3 @@ OVERRIDE_STACK_VERSION=${OVERRIDE_STACK_VERSION}"-SNAPSHOT"
1010
ess_up $OVERRIDE_STACK_VERSION
1111

1212
preinstall_fleet_packages
13-
14-
echo "ES_HOST: ${ELASTICSEARCH_HOST}"
15-
buildkite-agent meta-data set "es.host" $ELASTICSEARCH_HOST
16-
buildkite-agent meta-data set "es.username" $ELASTICSEARCH_USERNAME
17-
buildkite-agent meta-data set "es.pwd" $ELASTICSEARCH_PASSWORD
18-
buildkite-agent meta-data set "kibana.host" $KIBANA_HOST
19-
buildkite-agent meta-data set "kibana.username" $KIBANA_USERNAME
20-
buildkite-agent meta-data set "kibana.pwd" $KIBANA_PASSWORD
21-
buildkite-agent meta-data set "integrations_server.host" $INTEGRATIONS_SERVER_HOST

.buildkite/scripts/steps/integration_tests_tf.sh

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,6 @@ if [[ "${BUILDKITE_RETRY_COUNT}" -gt 0 ]]; then
3737
trap 'ess_down' EXIT
3838
ess_up $OVERRIDE_STACK_VERSION || (echo -e "^^^ +++\nFailed to start ESS stack")
3939
preinstall_fleet_packages
40-
else
41-
# For the first run, we start the stack in the start_ess.sh step and it sets the meta-data
42-
echo "~~~ Receiving ESS stack metadata"
43-
export ELASTICSEARCH_HOST=$(buildkite-agent meta-data get "es.host")
44-
export ELASTICSEARCH_USERNAME=$(buildkite-agent meta-data get "es.username")
45-
export ELASTICSEARCH_PASSWORD=$(buildkite-agent meta-data get "es.pwd")
46-
export KIBANA_HOST=$(buildkite-agent meta-data get "kibana.host")
47-
export KIBANA_USERNAME=$(buildkite-agent meta-data get "kibana.username")
48-
export KIBANA_PASSWORD=$(buildkite-agent meta-data get "kibana.pwd")
49-
export INTEGRATIONS_SERVER_HOST=$(buildkite-agent meta-data get "integrations_server.host")
5040
fi
5141

5242
# Run integration tests

0 commit comments

Comments
 (0)