Skip to content

Commit 99d381c

Browse files
[7.17](backport #39506) Remove hardcoded module definitions in CI (#39527)
For reasons described in [^1], we hard coded `aws` or `kubernetes` for the env var `MODULE`, when no file changes were detected under `modules/` per project. This commit reverts this and allows all module tests to run if no changesets apply. As discussed in [^1], for the tests to run properly (and not go into an infinite loop) if there are no module changes the `MODULE` env var should **not** be set, rather than set to an empty string. This commit is an important fix as it covers a major delta in test coverage between Jenkins and Buildkite. Closes https://github.com/elastic/ingest-dev/issues/2993 [^1]: https://github.com/elastic/ingest-dev/issues/2993#issuecomment-2104741977 (cherry picked from commit c91503b) --------- Co-authored-by: Dimitrios Liappis <dimitrios.liappis@gmail.com>
1 parent 01e4b02 commit 99d381c

File tree

8 files changed

+25
-43
lines changed

8 files changed

+25
-43
lines changed

.buildkite/metricbeat/pipeline.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,10 @@ steps:
5050
key: "mandatory-int-test"
5151
command: |
5252
set -euo pipefail
53-
54-
# TODO: uncomment all lines below (that set MODULE and install kind) when https://github.com/elastic/beats/issues/38874 has been resolved.
55-
# TODO: Note that this problem exists ONLY on 7.17 branch
56-
# # defines the MODULE env var based on what's changed in a PR
57-
# source .buildkite/scripts/changesets.sh
58-
# defineModuleFromTheChangeSet metricbeat
59-
# echo "~~~ Will run tests with env var MODULE=$$MODULE"
53+
# defines the MODULE env var based on what's changed in a PR
54+
source .buildkite/scripts/changesets.sh
55+
defineModuleFromTheChangeSet metricbeat
56+
echo "~~~ Running tests"
6057
6158
# TODO move this section to base image / pre-command hook
6259
# echo "~~~ Installing kind"
@@ -90,7 +87,7 @@ steps:
9087
# defines the MODULE env var based on what's changed in a PR
9188
source .buildkite/scripts/changesets.sh
9289
defineModuleFromTheChangeSet metricbeat
93-
echo "~~~ Running tests with env var MODULE=$$MODULE"
90+
echo "~~~ Running tests"
9491
9592
# TODO move this section to base image / pre-command hook
9693
echo "~~~ Installing kind"

.buildkite/scripts/changesets.psm1

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,9 @@ function DefineModuleFromTheChangeSet($projectPath) {
5656
}
5757
}
5858

59-
# TODO: remove this conditional when issue https://github.com/elastic/ingest-dev/issues/2993 gets resolved
60-
if(!$changedModules) {
61-
if($Env:BUILDKITE_PIPELINE_SLUG -eq 'beats-xpack-metricbeat') {
62-
$Env:MODULE = "aws"
63-
}
64-
else {
65-
$Env:MODULE = "kubernetes"
66-
}
67-
}
68-
else {
69-
# TODO: once https://github.com/elastic/ingest-dev/issues/2993 gets resolved, this should be the only thing we export
70-
$Env:MODULE = $changedModules
59+
if ($changedModules) {
60+
$env:MODULE = $changedModules
61+
Write-Output "~~~ Set env var MODULE to [$env:MODULE]"
62+
Write-Output "~~~ Resuming commands"
7163
}
7264
}

.buildkite/scripts/changesets.sh

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,10 @@ defineModuleFromTheChangeSet() {
6868
fi
6969
done
7070

71-
if [[ -z "$changed_modules" ]]; then # TODO: remove this conditional when issue https://github.com/elastic/ingest-dev/issues/2993 gets resolved
72-
if [[ "$BUILDKITE_PIPELINE_SLUG" == "beats-xpack-metricbeat" ]]; then
73-
export MODULE="aws"
74-
else
75-
export MODULE="kubernetes"
76-
fi
77-
else
78-
export MODULE="${changed_modules}" # TODO: once https://github.com/elastic/ingest-dev/issues/2993 gets resolved, this should be the only thing we export
71+
# export MODULE="" leads to an infinite loop https://github.com/elastic/ingest-dev/issues/2993
72+
if [[ ! -z $changed_modules ]]; then
73+
export MODULE="${changed_modules}"
74+
echo "~~~ Set env var MODULE to [$MODULE]"
75+
echo "~~~ Resuming commands"
7976
fi
8077
}

.buildkite/x-pack/pipeline.xpack.auditbeat.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ steps:
3333
# defines the MODULE env var based on what's changed in a PR
3434
source .buildkite/scripts/changesets.sh
3535
defineModuleFromTheChangeSet x-pack/auditbeat
36-
echo "~~~ Will run tests with env var MODULE=$$MODULE"
36+
echo "~~~ Running tests"
3737
cd x-pack/auditbeat
3838
mage update build test
3939
retry:

.buildkite/x-pack/pipeline.xpack.dockerlogbeat.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,9 @@ steps:
5252
# defines the MODULE env var based on what's changed in a PR
5353
source .buildkite/scripts/changesets.sh
5454
defineModuleFromTheChangeSet x-pack/dockerlogbeat
55-
echo "~~~ Running tests with env var MODULE=$$MODULE"
55+
echo "~~~ Running tests"
5656
cd x-pack/dockerlogbeat
5757
mage goIntegTest
58-
env:
59-
MODULE: $MODULE
6058
retry:
6159
automatic:
6260
- limit: 3

.buildkite/x-pack/pipeline.xpack.filebeat.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ steps:
5151
# defines the MODULE env var based on what's changed in a PR
5252
source .buildkite/scripts/changesets.sh
5353
defineModuleFromTheChangeSet x-pack/filebeat
54-
echo "~~~ Will run tests with env var MODULE=$$MODULE"
54+
echo "~~~ Running tests"
5555
cd x-pack/filebeat && mage goIntegTest
5656
retry:
5757
automatic:
@@ -74,7 +74,7 @@ steps:
7474
# defines the MODULE env var based on what's changed in a PR
7575
source .buildkite/scripts/changesets.sh
7676
defineModuleFromTheChangeSet x-pack/filebeat
77-
echo "~~~ Running tests with env var MODULE=$$MODULE"
77+
echo "~~~ Running tests"
7878
cd x-pack/filebeat && mage pythonIntegTest
7979
retry:
8080
automatic:
@@ -268,7 +268,7 @@ steps:
268268
# defines the MODULE env var based on what's changed in a PR
269269
source .buildkite/scripts/changesets.sh
270270
defineModuleFromTheChangeSet x-pack/filebeat
271-
echo "~~~ Running tests with env var MODULE=$$MODULE"
271+
echo "~~~ Running tests"
272272
273273
.buildkite/scripts/cloud_tests.sh
274274
env:
@@ -297,7 +297,7 @@ steps:
297297
# defines the MODULE env var based on what's changed in a PR
298298
source .buildkite/scripts/changesets.sh
299299
defineModuleFromTheChangeSet x-pack/filebeat
300-
echo "~~~ Running tests with env var MODULE=$$MODULE"
300+
echo "~~~ Running tests"
301301
.buildkite/scripts/cloud_tests.sh
302302
env:
303303
ASDF_TERRAFORM_VERSION: 1.0.2

.buildkite/x-pack/pipeline.xpack.metricbeat.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ steps:
5151
# defines the MODULE env var based on what's changed in a PR
5252
source .buildkite/scripts/changesets.sh
5353
defineModuleFromTheChangeSet x-pack/metricbeat
54-
echo "~~~ Will run tests with env var MODULE=$$MODULE"
54+
echo "~~~ Running tests"
5555
cd x-pack/metricbeat && mage goIntegTest
5656
retry:
5757
automatic:
@@ -74,7 +74,7 @@ steps:
7474
# defines the MODULE env var based on what's changed in a PR
7575
source .buildkite/scripts/changesets.sh
7676
defineModuleFromTheChangeSet x-pack/metricbeat
77-
echo "~~~ Running tests with env var MODULE=$$MODULE"
77+
echo "~~~ Running tests"
7878
cd x-pack/metricbeat && mage pythonIntegTest
7979
retry:
8080
automatic:
@@ -253,7 +253,7 @@ steps:
253253
# defines the MODULE env var based on what's changed in a PR
254254
source .buildkite/scripts/changesets.sh
255255
defineModuleFromTheChangeSet x-pack/metricbeat
256-
echo "~~~ Running tests with env var MODULE=$$MODULE"
256+
echo "~~~ Running tests"
257257
258258
.buildkite/scripts/cloud_tests.sh
259259
env:
@@ -284,7 +284,7 @@ steps:
284284
# defines the MODULE env var based on what's changed in a PR
285285
source .buildkite/scripts/changesets.sh
286286
defineModuleFromTheChangeSet x-pack/metricbeat
287-
echo "~~~ Running tests with env var MODULE=$$MODULE"
287+
echo "~~~ Running tests"
288288
.buildkite/scripts/cloud_tests.sh
289289
env:
290290
ASDF_TERRAFORM_VERSION: 1.0.2

.buildkite/x-pack/pipeline.xpack.winlogbeat.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,9 @@ steps:
2525
command: |
2626
Import-Module ./.buildkite/scripts/changesets.psm1
2727
defineModuleFromTheChangeSet 'x-pack/winlogbeat'
28-
Write-Output "~~~ Will run tests with env var MODULE=$$Env:MODULE"
28+
Write-Output "~~~ Running tests"
2929
Set-Location -Path x-pack/winlogbeat
3030
mage build unitTest
31-
env:
32-
MODULE: $MODULE
3331
retry:
3432
automatic:
3533
- limit: 3

0 commit comments

Comments
 (0)