Skip to content

Commit 67e19a4

Browse files
Remove hardcoded module definitions in CI (#39506) (#39528)
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 74c52c2 commit 67e19a4

File tree

8 files changed

+22
-37
lines changed

8 files changed

+22
-37
lines changed

.buildkite/metricbeat/pipeline.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ steps:
5353
# defines the MODULE env var based on what's changed in a PR
5454
source .buildkite/scripts/changesets.sh
5555
defineModuleFromTheChangeSet metricbeat
56-
echo "~~~ Will run tests with env var MODULE=$$MODULE"
56+
echo "~~~ Running tests"
5757
5858
# TODO move this section to base image / pre-command hook
5959
echo "~~~ Installing kind"
@@ -86,7 +86,7 @@ steps:
8686
# defines the MODULE env var based on what's changed in a PR
8787
source .buildkite/scripts/changesets.sh
8888
defineModuleFromTheChangeSet metricbeat
89-
echo "~~~ Running tests with env var MODULE=$$MODULE"
89+
echo "~~~ Running tests"
9090
9191
# TODO move this section to base image / pre-command hook
9292
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
@@ -24,11 +24,9 @@ steps:
2424
command: |
2525
Import-Module ./.buildkite/scripts/changesets.psm1
2626
defineModuleFromTheChangeSet 'x-pack/winlogbeat'
27-
Write-Output "~~~ Will run tests with env var MODULE=$$Env:MODULE"
27+
Write-Output "~~~ Running tests"
2828
Set-Location -Path x-pack/winlogbeat
2929
mage build unitTest
30-
env:
31-
MODULE: $MODULE
3230
retry:
3331
automatic:
3432
- limit: 3

0 commit comments

Comments
 (0)