Skip to content

Commit

Permalink
Add initial support for Elastic Stack 9.x (#2102)
Browse files Browse the repository at this point in the history
Add initial support in elastic-package for Elastic stack 9.x.
Reviewing the docker images used for stack and testing as well
as adding new steps in the CI Pipelines.
  • Loading branch information
mrodm authored Sep 19, 2024
1 parent 440c227 commit f64d3fc
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 23 deletions.
1 change: 1 addition & 0 deletions .buildkite/pipeline.trigger.integration.tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ STACK_COMMAND_TESTS=(
test-stack-command-7x
test-stack-command-86
test-stack-command-8x
test-stack-command-9x
test-stack-command-with-apm-server
)

Expand Down
2 changes: 1 addition & 1 deletion .buildkite/scripts/stack_tests_windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fixCRLF

withGolang $env:GO_VERSION
withDocker $env:DOCKER_VERSION
withDockerCompose $env:DOCKER_COMPOSE_VERSION
withDockerCompose $env:DOCKER_COMPOSE_VERSION.Substring(1)

Write-Host "--- Docker Info"
docker info
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: Bump latest elastic-stack test version
pipelineid: 'bump-latest-elastic-stack-version'
name: Bump latest 8.x-SNAPSHOT elastic-stack test version
pipelineid: 'bump-latest-8x-elastic-stack-version'

actions:
default:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
name: Bump latest 9.x-SNAPSHOT elastic-stack test version
pipelineid: 'bump-latest-9x-elastic-stack-version'

actions:
default:
title: '[updatecli] Update latest snapshot to {{ source "latestSnapshot" }}'
kind: github/pullrequest
scmid: default
spec:
labels:
- automation
- dependency

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

sources:
latestSnapshot:
name: Get latest snapshot build
kind: json
spec:
file: https://storage.googleapis.com/artifacts-api/snapshots/main.json
key: .build_id

targets:
update-snapshot:
name: '[updatecli] Update latest snapshot to {{ source "latestSnapshot" }}'
kind: file
sourceid: latestSnapshot
scmid: default
spec:
file: Makefile
matchpattern: '(./scripts/test-stack-command.sh) 9\.[^\s]+-SNAPSHOT'
replacepattern: '$1 {{ source "latestSnapshot" }}-SNAPSHOT'
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,16 @@ test-stack-command-86:
test-stack-command-8x:
./scripts/test-stack-command.sh 8.16.0-4b6c1c4e-SNAPSHOT

test-stack-command-9x:
./scripts/test-stack-command.sh 9.0.0-SNAPSHOT

test-stack-command-with-apm-server:
APM_SERVER_ENABLED=true ./scripts/test-stack-command.sh

test-stack-command-with-self-monitor:
SELF_MONITOR_ENABLED=true ./scripts/test-stack-command.sh

test-stack-command: test-stack-command-default test-stack-command-7x test-stack-command-800 test-stack-command-8x test-stack-command-with-apm-server
test-stack-command: test-stack-command-default test-stack-command-7x test-stack-command-800 test-stack-command-8x test-stack-command-9x test-stack-command-with-apm-server

test-check-packages: test-check-packages-with-kind test-check-packages-other test-check-packages-parallel test-check-packages-with-custom-agent test-check-packages-benchmarks test-check-packages-false-positives test-check-packages-with-logstash

Expand Down
6 changes: 3 additions & 3 deletions internal/install/application_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,13 @@ func (ac *ApplicationConfiguration) SetCurrentProfile(name string) {
// This is mandatory as "elastic-agent-complete" is available since 7.15.0-SNAPSHOT.
func selectElasticAgentImageName(version, agentBaseImage string) string {
if version == "" { // as version is optional and can be empty
return elasticAgentLegacyImageName
return elasticAgentWolfiImageName
}

v, err := semver.NewVersion(version)
if err != nil {
logger.Errorf("stack version not in semver format (value: %s): %v", v, err)
return elasticAgentLegacyImageName
logger.Errorf("stack version not in semver format (value: %s): %v", version, err)
return elasticAgentWolfiImageName
}

disableWolfiImages := false
Expand Down
32 changes: 16 additions & 16 deletions internal/install/application_configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,43 +14,43 @@ import (
func TestSelectElasticAgentImageName_NoVersion(t *testing.T) {
var version string
selected := selectElasticAgentImageName(version, "")
assert.Equal(t, selected, elasticAgentLegacyImageName)
assert.Equal(t, elasticAgentWolfiImageName, selected)
}

func TestSelectElasticAgentImageName_OlderStack(t *testing.T) {
version := "7.14.99-SNAPSHOT"
selected := selectElasticAgentImageName(version, "")
assert.Equal(t, selected, elasticAgentLegacyImageName)
assert.Equal(t, elasticAgentLegacyImageName, selected)
}

func TestSelectElasticAgentImageName_FirstStackWithCompleteAgent(t *testing.T) {
version := stackVersion715
selected := selectElasticAgentImageName(version, "")
assert.Equal(t, selected, elasticAgentCompleteLegacyImageName)
assert.Equal(t, elasticAgentCompleteLegacyImageName, selected)
}

func TestSelectElasticAgentImageName_NextStackWithAgentComplete(t *testing.T) {
version := "7.16.0-SNAPSHOT"
selected := selectElasticAgentImageName(version, "")
assert.Equal(t, selected, elasticAgentCompleteLegacyImageName)
assert.Equal(t, elasticAgentCompleteLegacyImageName, selected)
}

func TestSelectElasticAgentImageName_OwnNamespace(t *testing.T) {
version := "8.2.0-SNAPSHOT"
selected := selectElasticAgentImageName(version, "")
assert.Equal(t, selected, elasticAgentCompleteImageName)
assert.Equal(t, elasticAgentCompleteImageName, selected)
}

func TestSelectElasticAgentImageName_OwnNamespace_Release(t *testing.T) {
version := "8.2.0"
selected := selectElasticAgentImageName(version, "")
assert.Equal(t, selected, elasticAgentCompleteImageName)
assert.Equal(t, elasticAgentCompleteImageName, selected)
}

func TestSelectElasticAgentImageName_NextStackInOwnNamespace(t *testing.T) {
version := "8.4.0-SNAPSHOT"
selected := selectElasticAgentImageName(version, "")
assert.Equal(t, selected, elasticAgentCompleteImageName)
assert.Equal(t, elasticAgentCompleteImageName, selected)
}

func TestSelectElasticAgentImageName_DefaultImage816_WithoutEnvVar(t *testing.T) {
Expand All @@ -60,56 +60,56 @@ func TestSelectElasticAgentImageName_DefaultImage816_WithoutEnvVar(t *testing.T)
os.Unsetenv(disableElasticAgentWolfiEnvVar)

selected := selectElasticAgentImageName(version, "")
assert.Equal(t, selected, elasticAgentWolfiImageName)
assert.Equal(t, elasticAgentWolfiImageName, selected)
}

func TestSelectElasticAgentImageName_DisableWolfiImageEnvVar(t *testing.T) {
version := stackVersion8160
t.Setenv(disableElasticAgentWolfiEnvVar, "true")
selected := selectElasticAgentImageName(version, "")
assert.Equal(t, selected, elasticAgentCompleteImageName)
assert.Equal(t, elasticAgentCompleteImageName, selected)
}
func TestSelectElasticAgentImageName_EnableWolfiImageEnvVar(t *testing.T) {
version := stackVersion8160
t.Setenv(disableElasticAgentWolfiEnvVar, "false")
selected := selectElasticAgentImageName(version, "")
assert.Equal(t, selected, elasticAgentWolfiImageName)
assert.Equal(t, elasticAgentWolfiImageName, selected)
}

func TestSelectCompleteElasticAgentImageName_ForceCompleteImage(t *testing.T) {
version := stackVersion8160
selected := selectElasticAgentImageName(version, "complete")
assert.Equal(t, selected, elasticAgentCompleteImageName)
assert.Equal(t, elasticAgentCompleteImageName, selected)
}

func TestSelectCompleteElasticAgentImageName_ForceDefaultImage_DisabledEnvVar(t *testing.T) {
version := stackVersion8160
t.Setenv(disableElasticAgentWolfiEnvVar, "true")
selected := selectElasticAgentImageName(version, "default")
assert.Equal(t, selected, elasticAgentCompleteImageName)
assert.Equal(t, elasticAgentCompleteImageName, selected)
}

func TestSelectCompleteElasticAgentImageName_ForceDefaultImage_EnabledEnvVar(t *testing.T) {
version := stackVersion8160
t.Setenv(disableElasticAgentWolfiEnvVar, "false")
selected := selectElasticAgentImageName(version, "default")
assert.Equal(t, selected, elasticAgentWolfiImageName)
assert.Equal(t, elasticAgentWolfiImageName, selected)
}

func TestSelectCompleteElasticAgentImageName_ForceDefaultImageOldStack(t *testing.T) {
version := "8.15.0-SNAPSHOT"
selected := selectElasticAgentImageName(version, "default")
assert.Equal(t, selected, elasticAgentCompleteImageName)
assert.Equal(t, elasticAgentCompleteImageName, selected)
}

func TestSelectCompleteElasticAgentImageName_ForceSystemDImage(t *testing.T) {
version := stackVersion8160
selected := selectElasticAgentImageName(version, "systemd")
assert.Equal(t, selected, elasticAgentImageName)
assert.Equal(t, elasticAgentImageName, selected)
}

func TestSelectCompleteElasticAgentImageName_ForceSystemDImageOldStack(t *testing.T) {
version := stackVersion715
selected := selectElasticAgentImageName(version, "systemd")
assert.Equal(t, selected, elasticAgentLegacyImageName)
assert.Equal(t, elasticAgentLegacyImageName, selected)
}

0 comments on commit f64d3fc

Please sign in to comment.