Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

chore: improve the automation for the stack version bump #1351

Merged
merged 8 commits into from
Jul 22, 2021

Conversation

mdelapenya
Copy link
Contributor

What does this PR do?

This PR does a few things:

  • adds Jenkinsfile to the automated bump
  • adds .stack-version to the automated bump
  • adds Go files including the BeatsBaseVersion, which is the one responsible of defining versions for the stack. This variable is overriden on CI by the Jenkinsfile. (For the record, I double checked that the hashed version is equals for the stack and for elastic-agent/Beats).
  • simplified unit tests: they contained multiple occurrences of the current version (8.0.0-SNAPSHOT in master, 7.x-SNAPSHOT in 7.x, etc), and now they use a PLACEHOLDER (BEATS_VERSION). All unit test resources have been renamed in consequence.

Why is it important?

Automate for the Win!

The change in the unit tests is important for the sake of maintainability: whenever a new version branch is created, we have to bump the tests files affected in this PR. For that reason, after backporting (and resolving conflicts in) this PR, the tests will be agnostic to the version branch where they live.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have run the Unit tests (make unit-test), and they are passing locally
  • I have run the End-2-End tests for the suite I'm working on, and they are passing locally
  • I have noticed new Go dependencies (run make notice in the proper directory)

Author's Checklist

  • @v1v, as creator of the automated bump, I'd like to receive your always awesome review here 🙏

How to test this PR locally

Run the automated bump with a fake bump: .ci/bump-stack-version.sh FOO

The created branch will contain a commit affecting versions files, Jenkinsfile and compose files.

@mdelapenya mdelapenya self-assigned this Jul 22, 2021
@mdelapenya mdelapenya requested a review from a team July 22, 2021 07:06
@elasticmachine
Copy link
Contributor

elasticmachine commented Jul 22, 2021

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2021-07-22T09:54:04.814+0000

  • Duration: 36 min 42 sec

  • Commit: fe83a86

Test stats 🧪

Test Results
Failed 0
Passed 229
Skipped 0
Total 229

Trends 🧪

Image of Build Times

Image of Tests

💚 Flaky test report

Tests succeeded.

Expand to view the summary

Test stats 🧪

Test Results
Failed 0
Passed 229
Skipped 0
Total 229

@mdelapenya mdelapenya marked this pull request as ready for review July 22, 2021 08:27
@kuisathaverat
Copy link
Contributor

there are some binaries pushed, Is that correct?

@v1v
Copy link
Member

v1v commented Jul 22, 2021

I've just tested it out locally with .ci/bump-stack-version.sh 8.0.0-3beeb19e

Console output:

Update stack with version 8.0.0-3beeb19e in .stack-version
Update stack with version 8.0.0-3beeb19e in Go files
Update stack with version 8.0.0-3beeb19e in Jenkinsfile
Update stack with version 8.0.0-3beeb19e in docker-compose.yml
Update stack with version 8.0.0-3beeb19e in deployment.yaml
Commit changes
Switched to a new branch 'update-stack-version-20210722104155'
[update-stack-version-20210722104155 1001dd2] bump stack version 8.0.0-3beeb19e
 8 files changed, 11 insertions(+), 11 deletions(-)
commit 1001dd2ac3dd8b9df5c30b3c71dc60d6aa050eb5 (HEAD -> update-stack-version-20210722104155)
Author: Victor Martinez <VictorMartinezRubio@gmail.com>
Date:   Thu Jul 22 10:41:55 2021 +0100

    bump stack version 8.0.0-3beeb19e
You can now push and create a Pull Request

Git status:

git diff HEAD^1..HEAD --name-only
.ci/Jenkinsfile
.stack-version
cli/config/compose/profiles/fleet/docker-compose.yml
cli/config/compose/profiles/metricbeat/docker-compose.yml
cli/config/kubernetes/base/elasticsearch/deployment.yaml
cli/config/kubernetes/base/fleet-server/deployment.yaml
cli/config/kubernetes/base/kibana/deployment.yaml
internal/common/defaults.go

Git diff:

diff --git a/.ci/Jenkinsfile b/.ci/Jenkinsfile
index 39a6064..1235187 100644
--- a/.ci/Jenkinsfile
+++ b/.ci/Jenkinsfile
@@ -42,13 +42,13 @@ pipeline {
     booleanParam(name: "notifyOnGreenBuilds", defaultValue: false, description: "If it's needed to notify to Slack with green builds.")
     string(name: 'SLACK_CHANNEL', defaultValue: 'observablt-bots', description: 'The Slack channel(s) where errors will be posted. For multiple channels, use a comma-separated list of channels')
     string(name: 'ELASTIC_AGENT_DOWNLOAD_URL', defaultValue: '', description: 'If present, it will override the download URL for the Elastic agent artifact. (I.e. https://snapshots.elastic.co/8.0.0-59098054/downloads/beats/elastic-agent/elastic-agent-8.0.0-SNAPSHOT-linux-x86_64.tar.gz')
-    string(name: 'BEAT_VERSION', defaultValue: '8.0.0-SNAPSHOT', description: 'SemVer version of the Beat to be used for the tests. You can use here the tag of your PR to test your changes')
+    string(name: 'BEAT_VERSION', defaultValue: '8.0.0-3beeb19e-SNAPSHOT', description: 'SemVer version of the Beat to be used for the tests. You can use here the tag of your PR to test your changes')
     string(name: 'ELASTIC_AGENT_STALE_VERSION', defaultValue: '7.13-SNAPSHOT', description: 'SemVer version of the stale stand-alone elastic-agent to be used for Fleet upgrade tests.')
     booleanParam(name: "BEATS_USE_CI_SNAPSHOTS", defaultValue: false, description: "If it's needed to use the binary snapshots produced by Beats CI instead of the official releases")
     choice(name: 'LOG_LEVEL', choices: ['DEBUG', 'TRACE', 'INFO'], description: 'Log level to be used')
     choice(name: 'TIMEOUT_FACTOR', choices: ['5', '3', '7', '11'], description: 'Max number of minutes for timeout backoff strategies')
     string(name: 'KIBANA_VERSION', defaultValue: '', description: 'Docker tag of the kibana to be used for the tests. It will refer to an image related to a Kibana PR, under the Observability-CI namespace')
-    string(name: 'STACK_VERSION', defaultValue: '8.0.0-SNAPSHOT', description: 'SemVer version of the stack to be used for the tests.')
+    string(name: 'STACK_VERSION', defaultValue: '8.0.0-3beeb19e-SNAPSHOT', description: 'SemVer version of the stack to be used for the tests.')
     string(name: 'HELM_CHART_VERSION', defaultValue: '7.11.2', description: 'SemVer version of Helm chart to be used.')
     string(name: 'HELM_VERSION', defaultValue: '3.5.2', description: 'SemVer version of Helm to be used.')
     string(name: 'KIND_VERSION', defaultValue: '0.10.0', description: 'SemVer version of Kind to be used.')
diff --git a/.stack-version b/.stack-version
index f1358e3..8cb6912 100644
--- a/.stack-version
+++ b/.stack-version
@@ -1 +1 @@
-8.0.0-SNAPSHOT
+8.0.0-3beeb19e
diff --git a/cli/config/compose/profiles/fleet/docker-compose.yml b/cli/config/compose/profiles/fleet/docker-compose.yml
index b6e24cd..0af295c 100644
--- a/cli/config/compose/profiles/fleet/docker-compose.yml
+++ b/cli/config/compose/profiles/fleet/docker-compose.yml
@@ -16,7 +16,7 @@ services:
       - xpack.security.authc.api_key.enabled=true
       - ELASTIC_USERNAME=elastic
       - ELASTIC_PASSWORD=changeme
-    image: "docker.elastic.co/elasticsearch/elasticsearch:${stackVersion:-8.0.0-a6334483-SNAPSHOT}"
+    image: "docker.elastic.co/elasticsearch/elasticsearch:${stackVersion:-8.0.0-3beeb19e-SNAPSHOT}"
     platform: ${stackPlatform:-linux/amd64}
     ports:
       - "9200:9200"
@@ -28,7 +28,7 @@ services:
       test: "curl -f http://localhost:5601/login | grep kbn-injected-metadata 2>&1 >/dev/null"
       retries: 600
       interval: 1s
-    image: "docker.elastic.co/${kibanaDockerNamespace:-kibana}/kibana:${kibanaVersion:-8.0.0-a6334483-SNAPSHOT}"
+    image: "docker.elastic.co/${kibanaDockerNamespace:-kibana}/kibana:${kibanaVersion:-8.0.0-3beeb19e-SNAPSHOT}"
     platform: ${stackPlatform:-linux/amd64}
     ports:
       - "5601:5601"
@@ -48,7 +48,7 @@ services:
       - "XPACK_FLEET_AGENTS_FLEET_SERVER_HOSTS=[\"http://fleet-server:8220\"]"
       - "XPACK_FLEET_AGENTS_TLSCHECKDISABLED=true"
   fleet-server:
-    image: "docker.elastic.co/beats/elastic-agent:${stackVersion:-8.0.0-a6334483-SNAPSHOT}"
+    image: "docker.elastic.co/beats/elastic-agent:${stackVersion:-8.0.0-3beeb19e-SNAPSHOT}"
     depends_on:
       elasticsearch:
         condition: service_healthy
diff --git a/cli/config/compose/profiles/metricbeat/docker-compose.yml b/cli/config/compose/profiles/metricbeat/docker-compose.yml
index cfb9afe..e87a416 100644
--- a/cli/config/compose/profiles/metricbeat/docker-compose.yml
+++ b/cli/config/compose/profiles/metricbeat/docker-compose.yml
@@ -9,7 +9,7 @@ services:
       - xpack.monitoring.collection.enabled=true
       - ELASTIC_USERNAME=elastic
       - ELASTIC_PASSWORD=changeme
-    image: "docker.elastic.co/elasticsearch/elasticsearch:${stackVersion:-8.0.0-a6334483-SNAPSHOT}"
+    image: "docker.elastic.co/elasticsearch/elasticsearch:${stackVersion:-8.0.0-3beeb19e-SNAPSHOT}"
     platform: ${stackPlatform:-linux/amd64}
     ports:
       - "9200:9200"
diff --git a/cli/config/kubernetes/base/elasticsearch/deployment.yaml b/cli/config/kubernetes/base/elasticsearch/deployment.yaml
index 98b60f5..6b47cf2 100644
--- a/cli/config/kubernetes/base/elasticsearch/deployment.yaml
+++ b/cli/config/kubernetes/base/elasticsearch/deployment.yaml
@@ -16,7 +16,7 @@ spec:
     spec:
       containers:
       - name: elasticsearch
-        image: docker.elastic.co/elasticsearch/elasticsearch:8.0.0-a6334483-SNAPSHOT
+        image: docker.elastic.co/elasticsearch/elasticsearch:8.0.0-3beeb19e-SNAPSHOT
         envFrom:
           - configMapRef:
               name: elasticsearch-config
diff --git a/cli/config/kubernetes/base/fleet-server/deployment.yaml b/cli/config/kubernetes/base/fleet-server/deployment.yaml
index f77d7d6..45ff9d9 100644
--- a/cli/config/kubernetes/base/fleet-server/deployment.yaml
+++ b/cli/config/kubernetes/base/fleet-server/deployment.yaml
@@ -16,7 +16,7 @@ spec:
     spec:
       containers:
       - name: fleet-server
-        image: docker.elastic.co/beats/elastic-agent:8.0.0-a6334483-SNAPSHOT
+        image: docker.elastic.co/beats/elastic-agent:8.0.0-3beeb19e-SNAPSHOT
         env:
         - name: FLEET_SERVER_ENABLE
           value: "1"
diff --git a/cli/config/kubernetes/base/kibana/deployment.yaml b/cli/config/kubernetes/base/kibana/deployment.yaml
index c59fc46..d0daffc 100644
--- a/cli/config/kubernetes/base/kibana/deployment.yaml
+++ b/cli/config/kubernetes/base/kibana/deployment.yaml
@@ -16,7 +16,7 @@ spec:
     spec:
       containers:
       - name: kibana
-        image: docker.elastic.co/kibana/kibana:8.0.0-a6334483-SNAPSHOT
+        image: docker.elastic.co/kibana/kibana:8.0.0-3beeb19e-SNAPSHOT
         env:
         - name: ELASTICSEARCH_URL
           value: http://elasticsearch:9200
diff --git a/internal/common/defaults.go b/internal/common/defaults.go
index ef1d84f..6947dbc 100644
--- a/internal/common/defaults.go
+++ b/internal/common/defaults.go
@@ -40,7 +40,7 @@ const FleetServerAgentServiceName = "fleet-server"
 var AgentStaleVersion = "7.13-SNAPSHOT"
 
 // BeatVersionBase is the base version of the Beat to use
-var BeatVersionBase = "8.0.0-SNAPSHOT"
+var BeatVersionBase = "8.0.0-3beeb19e-SNAPSHOT"
 
 // BeatVersion is the version of the Beat to use
 // It can be overriden by BEAT_VERSION env var

.ci/bump-stack-version.sh Outdated Show resolved Hide resolved
.ci/bump-stack-version.sh Outdated Show resolved Hide resolved
@mdelapenya
Copy link
Contributor Author

diff --git a/.stack-version b/.stack-version
index f1358e3..8cb6912 100644
--- a/.stack-version
+++ b/.stack-version
@@ -1 +1 @@
-8.0.0-SNAPSHOT
+8.0.0-3beeb19e

Ahh good catch! I found that the .stack-version file is wrong!

Copy link
Member

@v1v v1v left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good, there is only a couple of questions regarding the find, since I only see one file

@mdelapenya mdelapenya merged commit 395bdb2 into elastic:master Jul 22, 2021
mergify bot pushed a commit that referenced this pull request Jul 22, 2021
* feat: automated update Beats' base version

* chore: reduce number of version occurrences in tests

* chore: decouple unit tests from the current version

* feat: update Jenkinsfile

* feat: automate .stack-version

* fix: append snapshot

* chore: simplify finding single files

There is only one file to modify

(cherry picked from commit 395bdb2)

# Conflicts:
#	internal/_testresources/gcp/commits.json
#	internal/_testresources/gcp/snapshots.json
#	internal/utils/utils_test.go
mergify bot pushed a commit that referenced this pull request Jul 22, 2021
* feat: automated update Beats' base version

* chore: reduce number of version occurrences in tests

* chore: decouple unit tests from the current version

* feat: update Jenkinsfile

* feat: automate .stack-version

* fix: append snapshot

* chore: simplify finding single files

There is only one file to modify

(cherry picked from commit 395bdb2)

# Conflicts:
#	.ci/bump-stack-version.sh
#	internal/_testresources/gcp/commits.json
#	internal/_testresources/gcp/snapshots.json
#	internal/utils/utils_test.go
mergify bot pushed a commit that referenced this pull request Jul 22, 2021
* feat: automated update Beats' base version

* chore: reduce number of version occurrences in tests

* chore: decouple unit tests from the current version

* feat: update Jenkinsfile

* feat: automate .stack-version

* fix: append snapshot

* chore: simplify finding single files

There is only one file to modify

(cherry picked from commit 395bdb2)

# Conflicts:
#	.ci/bump-stack-version.sh
#	internal/_testresources/gcp/commits.json
#	internal/_testresources/gcp/snapshots.json
#	internal/utils/utils_test.go
@mdelapenya mdelapenya deleted the improve-stack-automation branch July 22, 2021 11:00
mdelapenya added a commit to mdelapenya/e2e-testing that referenced this pull request Jul 22, 2021
* feat: automated update Beats' base version

* chore: reduce number of version occurrences in tests

* chore: decouple unit tests from the current version

* feat: update Jenkinsfile

* feat: automate .stack-version

* fix: append snapshot

* chore: simplify finding single files

There is only one file to modify
# Conflicts:
#	internal/_testresources/gcp/commits.json
#	internal/_testresources/gcp/snapshots.json
#	internal/utils/utils_test.go
mdelapenya added a commit to mdelapenya/e2e-testing that referenced this pull request Jul 22, 2021
* feat: automated update Beats' base version

* chore: reduce number of version occurrences in tests

* chore: decouple unit tests from the current version

* feat: update Jenkinsfile

* feat: automate .stack-version

* fix: append snapshot

* chore: simplify finding single files

There is only one file to modify
# Conflicts:
#	.ci/bump-stack-version.sh
#	internal/_testresources/gcp/commits.json
#	internal/_testresources/gcp/snapshots.json
#	internal/utils/utils_test.go
mdelapenya added a commit to mdelapenya/e2e-testing that referenced this pull request Jul 22, 2021
* feat: automated update Beats' base version

* chore: reduce number of version occurrences in tests

* chore: decouple unit tests from the current version

* feat: update Jenkinsfile

* feat: automate .stack-version

* fix: append snapshot

* chore: simplify finding single files

There is only one file to modify
# Conflicts:
#	.ci/bump-stack-version.sh
#	internal/_testresources/gcp/commits.json
#	internal/_testresources/gcp/snapshots.json
#	internal/utils/utils_test.go
mdelapenya added a commit that referenced this pull request Jul 22, 2021
* feat: automated update Beats' base version

* chore: reduce number of version occurrences in tests

* chore: decouple unit tests from the current version

* feat: update Jenkinsfile

* feat: automate .stack-version

* fix: append snapshot

* chore: simplify finding single files

There is only one file to modify
# Conflicts:
#	.ci/bump-stack-version.sh
#	internal/_testresources/gcp/commits.json
#	internal/_testresources/gcp/snapshots.json
#	internal/utils/utils_test.go
mdelapenya added a commit that referenced this pull request Jul 22, 2021
* feat: automated update Beats' base version

* chore: reduce number of version occurrences in tests

* chore: decouple unit tests from the current version

* feat: update Jenkinsfile

* feat: automate .stack-version

* fix: append snapshot

* chore: simplify finding single files

There is only one file to modify
# Conflicts:
#	internal/_testresources/gcp/commits.json
#	internal/_testresources/gcp/snapshots.json
#	internal/utils/utils_test.go
mdelapenya added a commit that referenced this pull request Jul 22, 2021
* feat: automated update Beats' base version

* chore: reduce number of version occurrences in tests

* chore: decouple unit tests from the current version

* feat: update Jenkinsfile

* feat: automate .stack-version

* fix: append snapshot

* chore: simplify finding single files

There is only one file to modify
# Conflicts:
#	.ci/bump-stack-version.sh
#	internal/_testresources/gcp/commits.json
#	internal/_testresources/gcp/snapshots.json
#	internal/utils/utils_test.go
@mdelapenya mdelapenya added area:ci Anything related to the CI priority:medium Important work, but not urgent or blocking. size:S less than 1 day Team:Automation Label for the Observability productivity team triaged Triaged issues will end up in Backlog column in Robots GH Project labels Jul 22, 2021
mdelapenya added a commit to mdelapenya/e2e-testing that referenced this pull request Jul 27, 2021
* master:
  chore: read elastic-agent logs using native OS' log manager (elastic#1368)
  Add kubernetes autodiscover scenario without autodiscover (elastic#1361)
  fix: expose fleet-server port (elastic#1348)
  chore: improve the automation for the stack version bump (elastic#1351)
  bump stack version 8.0.0-a6334483 (elastic#1350)
  bump stack version 8.0.0-1e9bea0f (elastic#1346)
  chore(ci): be more specific about the underlying ARM OS (elastic#1341)
  fix: apply container name to elastic-agent Docker services (elastic#1336)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area:ci Anything related to the CI priority:medium Important work, but not urgent or blocking. size:S less than 1 day Team:Automation Label for the Observability productivity team triaged Triaged issues will end up in Backlog column in Robots GH Project v7.13.0 v7.14.0 v7.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants