Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
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
46 changes: 46 additions & 0 deletions .ci/updatecli/updatecli-bump-stack-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# update-cli configuration for automated go updates
---
name: Bump .stable-snapshot-version

scms:
githubConfig:
kind: github
spec:
user: '{{ requiredEnv "GITHUB_ACTOR" }}'
username: '{{ requiredEnv "GITHUB_ACTOR" }}'
owner: "{{ .scm.owner }}"
repository: "{{ .scm.repository }}"
token: '{{ requiredEnv "GITHUB_TOKEN" }}'
branch: '{{ requiredEnv "BRANCH_NAME" }}'
commitusingapi: true

sources:
lastStableStackSnapshot:
name: "Latest Stable ESS snapshot for current branch"
kind: json
spec:
file: 'https://storage.googleapis.com/artifacts-api/channels/{{ requiredEnv "BRANCH_NAME" }}.json'
key: "build"
targets:
updateStableSnapshotFile:
name: "Update .stable-snapshot-version"
sourceid: lastStableStackSnapshot
scmid: githubConfig
kind: file
spec:
file: "test_infra/ess/.stable-snapshot-version"
content: '{{ source "lastStableStackSnapshot" }}-SNAPSHOT'
actions:
elastic-agent:
kind: github/pullrequest
scmid: githubConfig
sourceid: lastStableStackSnapshot
spec:
automerge: false
labels:
- dependencies
- backport-skip
- skip-changelog
title: '[{{ requiredEnv "BRANCH_NAME" }}][Automation] Bump .stable-snapshot-version version to {{ source "lastStableStackSnapshot" }}'
description: |
Updates `.stable-snapshot-version`. It is used to pin stable stack version for integration tests.
55 changes: 55 additions & 0 deletions .github/workflows/bump-stable-snapshot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
name: update-stable-snapshot

on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *"

permissions:
contents: read

env:
JOB_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"

jobs:
filter:
runs-on: ubuntu-latest
timeout-minutes: 1
outputs:
matrix: ${{ steps.generator.outputs.matrix }}
permissions:
contents: read
steps:
- id: generator
uses: elastic/oblt-actions/elastic/active-branches@v1
with:
filter-branches: true

update-stable-snapshot:
runs-on: ubuntu-latest
needs: [filter]
permissions:
contents: write
pull-requests: write
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.filter.outputs.matrix) }}
steps:
# We have same behavior for all branches.
- uses: actions/checkout@v4

- name: Run UpdateCLI in Apply mode
uses: elastic/oblt-actions/updatecli/run@v1
with:
command: apply --config .ci/updatecli/updatecli-bump-stack-version.yml --values .ci/updatecli/values.d/scm.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH_NAME: ${{ matrix.branch }}

- if: ${{ failure() }}
uses: elastic/oblt-actions/slack/send@v1
with:
bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
channel-id: "#ingest-notifications"
message: ":traffic_cone: Update Stable snapshot: updatecli failed for `${{ github.repository }}@${{ github.ref_name }}`, `@agent-team` and @pavel.zorin please look what's going on <${{ env.JOB_URL }}|here>"
1 change: 1 addition & 0 deletions test_infra/ess/.stable-snapshot-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9.1.0-5affded5-SNAPSHOT
28 changes: 24 additions & 4 deletions test_infra/ess/deployment.tf
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,13 @@ locals {

ess_region = coalesce(var.ess_region, "gcp-us-east1")
deployment_template_id = coalesce(var.deployment_template_id, "gcp-storage-optimized")


stable_snapshot_version = trim(file("${path.module}/.stable-snapshot-version"), "\n")

default_integration_server_image = "docker.elastic.co/cloud-release/elastic-agent-cloud:${local.stable_snapshot_version}"
default_elasticsearch_image = "docker.elastic.co/cloud-release/elasticsearch-cloud-ess:${local.stable_snapshot_version}"
default_kibana_image = "docker.elastic.co/cloud-release/kibana-cloud:${local.stable_snapshot_version}"

ess_properties = merge(
{
docker = {
Expand All @@ -74,9 +80,23 @@ locals {
yamldecode(file("${path.module}/../../pkg/testing/ess/create_deployment_csp_configuration.yaml")))


integration_server_docker_image = coalesce(var.integration_server_docker_image, local.ess_properties.docker.integration_server_image, "docker.elastic.co/cloud-release/elastic-agent-cloud:${var.stack_version}")
elasticsearch_docker_image = coalesce(var.elasticsearch_docker_image, local.ess_properties.docker.elasticsearch_image, "docker.elastic.co/cloud-release/elasticsearch-cloud-ess:${var.stack_version}")
kibana_docker_image = coalesce(var.kibana_docker_image, local.ess_properties.docker.kibana_image, "docker.elastic.co/cloud-release/kibana-cloud:${var.stack_version}")
integration_server_docker_image = coalesce(
var.integration_server_docker_image,
local.ess_properties.docker.integration_server_image,
local.default_integration_server_image
)

elasticsearch_docker_image = coalesce(
var.elasticsearch_docker_image,
local.ess_properties.docker.elasticsearch_image,
local.default_elasticsearch_image
)

kibana_docker_image = coalesce(
var.kibana_docker_image,
local.ess_properties.docker.kibana_image,
local.default_kibana_image
)
}

# If we have defined a stack version, validate that this version exists on that region and return it.
Expand Down
24 changes: 24 additions & 0 deletions test_infra/ess/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
## Terraform-managed Elastic Stack deployment for integration tests

### Required variables
`stack_version` - The version of the Elastic Stack to deploy, e.g., `9.1.0-SNAPSHOT`.

### Stable snapshots and images override

Variables can be overridden to use stable snapshots or images instead of the latest snapshot. This is useful for testing against a specific version of the Elastic Stack.

* `integration_server_docker_image` - The Docker image for the integration server
* `elasticsearch_docker_image` - The Docker image for Elasticsearch
* `kibana_docker_image` - The Docker image for Kibana

#### The priority of the docker images is as follows:
example for `integration_server_docker_image`:
1) By default, the images version will be taken from the `test_infra/ess/.stable-snapshot-version`. For example: `docker.elastic.co/cloud-release/elastic-agent-cloud:[stable-snapshot-version]`
2) Variable override: `TF_VAR_integration_server_docker_image...` takes precedence over
3) `pkg/testing/ess/create_deployment_csp_configuration.yaml` - add `docker` section to pin , e.g.:
```yaml
docker:
integration_server_docker_image: "docker.elastic.co/cloud-release/elastic-agent-cloud:9.1.0-SNAPSHOT"
elasticsearch_docker_image: "..."
kibana_docker_image: "..."
```