Skip to content

Commit c16edba

Browse files
andrewkrohmelchiormoulin
authored andcommitted
[ci] Favor direct mage invocation on CI (elastic#19960)
This changes Jenkins and Travis to directly invoke mage where possible instead of going through make. Some of the remaining make don't yet have a mage equivalant (mainly crosscompile). For Packetbeat this add Jenkins stages to test on darwin and Windows. There were a few fixes I had to make related to these changes: - Add some mage target dependencies to ensure fields and dashboards are ready when tests use them. - Swap the order of the Go imports for dev-tools/mage/targets/integtest and unittest so that unit tests run before integ tests when running the 'mage test' target. - chown the shared Python venv that is in the root of the repo after Dockerized integ tests exit to ensure there are no permissions issues caused by root owned files. - I found a few Python string encoding issues that caused tests failures. I thought we fixed these during the Python 3 conversion, but something here exposed a few that we didn't address. One thing of note that I did not correct. Journalbeat has system tests but they are not executed. The existing/old Makefile has SYSTEM_TESTS=false so they are not executed. So when I switched it to mage I left it as 'mage goUnitTest' to avoid the Python when failed when I tried it.
1 parent ad7f7a4 commit c16edba

File tree

13 files changed

+181
-65
lines changed

13 files changed

+181
-65
lines changed

.travis.yml

+96-28
Original file line numberDiff line numberDiff line change
@@ -38,41 +38,55 @@ jobs:
3838
# Filebeat
3939
- os: linux
4040
before_install: .ci/scripts/travis_has_changes.sh filebeat libbeat || travis_terminate 0
41-
env: TARGETS="-C filebeat testsuite"
41+
env:
42+
- PROJECT=filebeat
43+
- MAGE='build test'
4244
go: $TRAVIS_GO_VERSION
4345
stage: test
4446
- os: osx
4547
before_install: .ci/scripts/travis_has_changes.sh filebeat libbeat || travis_terminate 0
46-
env: TARGETS="TEST_ENVIRONMENT=0 -C filebeat testsuite"
48+
env:
49+
- PROJECT=filebeat
50+
- MAGE='build unitTest'
4751
go: $TRAVIS_GO_VERSION
4852
stage: test
4953
- os: linux
5054
before_install: .ci/scripts/travis_has_changes.sh x-pack/filebeat filebeat libbeat || travis_terminate 0
51-
env: TARGETS="-C x-pack/filebeat testsuite"
55+
env:
56+
- PROJECT=x-pack/filebeat
57+
- MAGE='build test'
5258
go: $(GO_VERSION)
5359
stage: test
5460

5561
# Heartbeat
5662
- os: linux
5763
before_install: .ci/scripts/travis_has_changes.sh heartbeat libbeat || travis_terminate 0
58-
env: TARGETS="-C heartbeat testsuite"
64+
env:
65+
- PROJECT=heartbeat
66+
- MAGE='build test'
5967
go: $TRAVIS_GO_VERSION
6068
stage: test
6169
- os: osx
6270
before_install: .ci/scripts/travis_has_changes.sh heartbeat libbeat || travis_terminate 0
63-
env: TARGETS="TEST_ENVIRONMENT=0 -C heartbeat testsuite"
71+
env:
72+
- PROJECT=heartbeat
73+
- MAGE='build unitTest'
6474
go: $TRAVIS_GO_VERSION
6575
stage: test
6676

6777
# Auditbeat
6878
- os: linux
6979
before_install: .ci/scripts/travis_has_changes.sh auditbeat libbeat || travis_terminate 0
70-
env: TARGETS="-C auditbeat testsuite"
80+
env:
81+
- PROJECT=auditbeat
82+
- MAGE='build test'
7183
go: $TRAVIS_GO_VERSION
7284
stage: test
7385
- os: osx
7486
before_install: .ci/scripts/travis_has_changes.sh auditbeat libbeat || travis_terminate 0
75-
env: TARGETS="TEST_ENVIRONMENT=0 -C auditbeat testsuite"
87+
env:
88+
- PROJECT=auditbeat
89+
- MAGE='build unitTest'
7690
go: $TRAVIS_GO_VERSION
7791
stage: test
7892
- os: linux
@@ -82,14 +96,27 @@ jobs:
8296
stage: test
8397
- os: linux
8498
before_install: .ci/scripts/travis_has_changes.sh x-pack/auditbeat auditbeat libbeat || travis_terminate 0
85-
env: TARGETS="-C x-pack/auditbeat testsuite"
99+
env:
100+
- PROJECT=x-pack/auditbeat
101+
- MAGE='build test'
102+
go: $TRAVIS_GO_VERSION
103+
stage: test
104+
- os: osx
105+
before_install: .ci/scripts/travis_has_changes.sh x-pack/auditbeat auditbeat libbeat || travis_terminate 0
106+
env:
107+
- PROJECT=x-pack/auditbeat
108+
- MAGE='build unitTest'
86109
go: $TRAVIS_GO_VERSION
87110
stage: test
88111

89112
# Libbeat
90113
- os: linux
91114
before_install: .ci/scripts/travis_has_changes.sh libbeat || travis_terminate 0
92-
env: TARGETS="-C libbeat testsuite"
115+
env:
116+
- PROJECT=libbeat
117+
- MAGE='build test'
118+
# The libbeat tests are so verbose that they exceed the maximum allowed log length of Travis CI.
119+
- MAGEFILE_VERBOSE=false
93120
go: $TRAVIS_GO_VERSION
94121
stage: test
95122
- os: linux
@@ -104,35 +131,44 @@ jobs:
104131
stage: test
105132
- os: linux
106133
before_install: .ci/scripts/travis_has_changes.sh x-pack/libbeat libbeat || travis_terminate 0
107-
env: TARGETS="-C x-pack/libbeat testsuite"
134+
env:
135+
- PROJECT=x-pack/libbeat
136+
- MAGE='build test'
108137
go: $TRAVIS_GO_VERSION
109138
stage: test
110139

111140
# Metricbeat
112141
- os: linux
113142
before_install: .ci/scripts/travis_has_changes.sh metricbeat libbeat || travis_terminate 0
114-
env: TARGETS="-C metricbeat unit-tests"
143+
env:
144+
- PROJECT=metricbeat
145+
- MAGE='build unitTest'
115146
go: $TRAVIS_GO_VERSION
116147
stage: test
117148
- os: linux
118149
before_install: .ci/scripts/travis_has_changes.sh metricbeat libbeat || travis_terminate 0
119-
install:
150+
install:
120151
- .ci/scripts/install-kind.sh
121152
- .ci/scripts/install-kubectl.sh
122153
env:
123-
- TARGETS="-C metricbeat integration-tests"
124154
- K8S_VERSION=v1.17.2
125155
- KIND_VERSION=v0.7.0
156+
- PROJECT=metricbeat
157+
- MAGE='goIntegTest'
126158
go: $TRAVIS_GO_VERSION
127159
stage: test
128160
- os: linux
129161
before_install: .ci/scripts/travis_has_changes.sh metricbeat libbeat || travis_terminate 0
130-
env: TARGETS="-C metricbeat system-tests"
162+
env:
163+
- PROJECT=metricbeat
164+
- MAGE='pythonIntegTest'
131165
go: $TRAVIS_GO_VERSION
132166
stage: test
133167
- os: osx
134168
before_install: .ci/scripts/travis_has_changes.sh metricbeat libbeat || travis_terminate 0
135-
env: TARGETS="-C metricbeat testsuite"
169+
env:
170+
- PROJECT=metricbeat
171+
- MAGE='build unitTest'
136172
go: $TRAVIS_GO_VERSION
137173
stage: test
138174
- os: linux
@@ -142,29 +178,39 @@ jobs:
142178
stage: test
143179
- os: linux
144180
before_install: .ci/scripts/travis_has_changes.sh x-pack/metricbeat metricbeat libbeat || travis_terminate 0
145-
env: TARGETS="-C x-pack/metricbeat unit-tests"
181+
env:
182+
- PROJECT=x-pack/metricbeat
183+
- MAGE='build unitTest'
146184
go: $TRAVIS_GO_VERSION
147185
stage: test
148186
- os: linux
149187
before_install: .ci/scripts/travis_has_changes.sh x-pack/metricbeat metricbeat libbeat || travis_terminate 0
150-
env: TARGETS="-C x-pack/metricbeat integration-tests"
188+
env:
189+
- PROJECT=x-pack/metricbeat
190+
- MAGE='goIntegTest'
151191
go: $TRAVIS_GO_VERSION
152192
stage: test
153193
- os: linux
154194
before_install: .ci/scripts/travis_has_changes.sh x-pack/metricbeat metricbeat libbeat || travis_terminate 0
155-
env: TARGETS="-C x-pack/metricbeat system-tests"
195+
env:
196+
- PROJECT=x-pack/metricbeat
197+
- MAGE='pythonIntegTest'
156198
go: $TRAVIS_GO_VERSION
157199
stage: test
158200
- os: osx
159201
before_install: .ci/scripts/travis_has_changes.sh metricbeat libbeat || travis_terminate 0
160-
env: TARGETS="-C x-pack/metricbeat testsuite"
202+
env:
203+
- PROJECT=x-pack/metricbeat
204+
- MAGE='build unitTest'
161205
go: $TRAVIS_GO_VERSION
162206
stage: test
163207

164208
# Packetbeat
165209
- os: linux
166210
before_install: .ci/scripts/travis_has_changes.sh packetbeat libbeat || travis_terminate 0
167-
env: TARGETS="-C packetbeat testsuite"
211+
env:
212+
- PROJECT=packetbeat
213+
- MAGE='build test'
168214
go: $TRAVIS_GO_VERSION
169215
stage: test
170216

@@ -178,43 +224,57 @@ jobs:
178224
# Functionbeat
179225
- os: linux
180226
before_install: .ci/scripts/travis_has_changes.sh x-pack/functionbeat libbeat || travis_terminate 0
181-
env: TARGETS="-C x-pack/functionbeat testsuite"
227+
env:
228+
- PROJECT=x-pack/functionbeat
229+
- MAGE='build test'
182230
go: $TRAVIS_GO_VERSION
183231
stage: test
184232
- os: osx
185233
before_install: .ci/scripts/travis_has_changes.sh x-pack/functionbeat libbeat || travis_terminate 0
186-
env: TARGETS="TEST_ENVIRONMENT=0 -C x-pack/functionbeat testsuite"
234+
env:
235+
- PROJECT=x-pack/functionbeat
236+
- MAGE='build unitTest'
187237
go: $TRAVIS_GO_VERSION
188238
stage: test
189239
- os: linux
190240
before_install: .ci/scripts/travis_has_changes.sh x-pack/functionbeat libbeat || travis_terminate 0
191-
env: TARGETS="-C x-pack/functionbeat test-gcp-functions"
241+
env:
242+
- PROJECT=x-pack/functionbeat
243+
- MAGE='testGCPFunctions'
192244
go: 1.13.1
193245
stage: test
194246

195247
# Docker Log Driver
196248
- os: linux
197249
before_install: .ci/scripts/travis_has_changes.sh x-pack/dockerlogbeat libbeat || travis_terminate 0
198-
env: TARGETS="-C x-pack/dockerlogbeat testsuite"
250+
env:
251+
- PROJECT=x-pack/dockerlogbeat
252+
- MAGE='build test'
199253
go: $TRAVIS_GO_VERSION
200254
stage: test
201255

202256
# Journalbeat
203257
- os: linux
204258
before_install: .ci/scripts/travis_has_changes.sh journalbeat libbeat || travis_terminate 0
205-
env: TARGETS="-C journalbeat testsuite"
259+
env:
260+
- PROJECT=journalbeat
261+
- MAGE='build goUnitTest'
206262
go: $TRAVIS_GO_VERSION
207263
stage: test
208264

209265
# Agent
210266
- os: linux
211267
before_install: .ci/scripts/travis_has_changes.sh x-pack/elastic-agent libbeat || travis_terminate 0
212-
env: TARGETS="-C x-pack/elastic-agent testsuite"
268+
env:
269+
- PROJECT=x-pack/elastic-agent
270+
- MAGE='build test'
213271
go: $TRAVIS_GO_VERSION
214272
stage: test
215273
- os: osx
216274
before_install: .ci/scripts/travis_has_changes.sh x-pack/elastic-agent libbeat || travis_terminate 0
217-
env: TARGETS="TEST_ENVIRONMENT=0 -C x-pack/elastic-agent testsuite"
275+
env:
276+
- PROJECT=x-pack/elastic-agent
277+
- MAGE='build unitTest'
218278
go: $TRAVIS_GO_VERSION
219279
stage: test
220280

@@ -318,13 +378,21 @@ before_script:
318378
- chmod +x docker-compose
319379
- sudo mv docker-compose /usr/local/bin
320380
- if [ $TRAVIS_OS_NAME = osx ]; then pip install virtualenv==16.7.9; fi
381+
- make mage
321382

322383
script:
323384
# Replacement for travis_wait which doesn't print output in real time.
324385
# Default Travis timeout is 10min, so this workaround prints timestamps every 9min to reset the counter.
325386
# Using seconds (540s = 9min) instead of minutes for shell compatibility reasons.
326387
- while sleep 540; do echo "=====[ ${SECONDS} seconds still running ]====="; done &
327-
- make $TARGETS
388+
- if [[ -n "$MAGE" ]]; then
389+
echo ">> mage $MAGE from $PROJECT";
390+
cd "$PROJECT";
391+
mage $MAGE;
392+
else
393+
echo ">> make $TARGETS";
394+
make $TARGETS;
395+
fi
328396
- kill %1
329397

330398
notifications:

0 commit comments

Comments
 (0)