Skip to content

Commit

Permalink
[ci] Favor direct mage invocation on CI (#19960)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
andrewkroh committed Jul 17, 2020
1 parent 785d7db commit 4a1f800
Show file tree
Hide file tree
Showing 13 changed files with 181 additions and 65 deletions.
124 changes: 96 additions & 28 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,41 +38,55 @@ jobs:
# Filebeat
- os: linux
before_install: .ci/scripts/travis_has_changes.sh filebeat libbeat || travis_terminate 0
env: TARGETS="-C filebeat testsuite"
env:
- PROJECT=filebeat
- MAGE='build test'
go: $TRAVIS_GO_VERSION
stage: test
- os: osx
before_install: .ci/scripts/travis_has_changes.sh filebeat libbeat || travis_terminate 0
env: TARGETS="TEST_ENVIRONMENT=0 -C filebeat testsuite"
env:
- PROJECT=filebeat
- MAGE='build unitTest'
go: $TRAVIS_GO_VERSION
stage: test
- os: linux
before_install: .ci/scripts/travis_has_changes.sh x-pack/filebeat filebeat libbeat || travis_terminate 0
env: TARGETS="-C x-pack/filebeat testsuite"
env:
- PROJECT=x-pack/filebeat
- MAGE='build test'
go: $(GO_VERSION)
stage: test

# Heartbeat
- os: linux
before_install: .ci/scripts/travis_has_changes.sh heartbeat libbeat || travis_terminate 0
env: TARGETS="-C heartbeat testsuite"
env:
- PROJECT=heartbeat
- MAGE='build test'
go: $TRAVIS_GO_VERSION
stage: test
- os: osx
before_install: .ci/scripts/travis_has_changes.sh heartbeat libbeat || travis_terminate 0
env: TARGETS="TEST_ENVIRONMENT=0 -C heartbeat testsuite"
env:
- PROJECT=heartbeat
- MAGE='build unitTest'
go: $TRAVIS_GO_VERSION
stage: test

# Auditbeat
- os: linux
before_install: .ci/scripts/travis_has_changes.sh auditbeat libbeat || travis_terminate 0
env: TARGETS="-C auditbeat testsuite"
env:
- PROJECT=auditbeat
- MAGE='build test'
go: $TRAVIS_GO_VERSION
stage: test
- os: osx
before_install: .ci/scripts/travis_has_changes.sh auditbeat libbeat || travis_terminate 0
env: TARGETS="TEST_ENVIRONMENT=0 -C auditbeat testsuite"
env:
- PROJECT=auditbeat
- MAGE='build unitTest'
go: $TRAVIS_GO_VERSION
stage: test
- os: linux
Expand All @@ -82,14 +96,27 @@ jobs:
stage: test
- os: linux
before_install: .ci/scripts/travis_has_changes.sh x-pack/auditbeat auditbeat libbeat || travis_terminate 0
env: TARGETS="-C x-pack/auditbeat testsuite"
env:
- PROJECT=x-pack/auditbeat
- MAGE='build test'
go: $TRAVIS_GO_VERSION
stage: test
- os: osx
before_install: .ci/scripts/travis_has_changes.sh x-pack/auditbeat auditbeat libbeat || travis_terminate 0
env:
- PROJECT=x-pack/auditbeat
- MAGE='build unitTest'
go: $TRAVIS_GO_VERSION
stage: test

# Libbeat
- os: linux
before_install: .ci/scripts/travis_has_changes.sh libbeat || travis_terminate 0
env: TARGETS="-C libbeat testsuite"
env:
- PROJECT=libbeat
- MAGE='build test'
# The libbeat tests are so verbose that they exceed the maximum allowed log length of Travis CI.
- MAGEFILE_VERBOSE=false
go: $TRAVIS_GO_VERSION
stage: test
- os: linux
Expand All @@ -104,35 +131,44 @@ jobs:
stage: test
- os: linux
before_install: .ci/scripts/travis_has_changes.sh x-pack/libbeat libbeat || travis_terminate 0
env: TARGETS="-C x-pack/libbeat testsuite"
env:
- PROJECT=x-pack/libbeat
- MAGE='build test'
go: $TRAVIS_GO_VERSION
stage: test

# Metricbeat
- os: linux
before_install: .ci/scripts/travis_has_changes.sh metricbeat libbeat || travis_terminate 0
env: TARGETS="-C metricbeat unit-tests"
env:
- PROJECT=metricbeat
- MAGE='build unitTest'
go: $TRAVIS_GO_VERSION
stage: test
- os: linux
before_install: .ci/scripts/travis_has_changes.sh metricbeat libbeat || travis_terminate 0
install:
install:
- .ci/scripts/install-kind.sh
- .ci/scripts/install-kubectl.sh
env:
- TARGETS="-C metricbeat integration-tests"
- K8S_VERSION=v1.17.2
- KIND_VERSION=v0.7.0
- PROJECT=metricbeat
- MAGE='goIntegTest'
go: $TRAVIS_GO_VERSION
stage: test
- os: linux
before_install: .ci/scripts/travis_has_changes.sh metricbeat libbeat || travis_terminate 0
env: TARGETS="-C metricbeat system-tests"
env:
- PROJECT=metricbeat
- MAGE='pythonIntegTest'
go: $TRAVIS_GO_VERSION
stage: test
- os: osx
before_install: .ci/scripts/travis_has_changes.sh metricbeat libbeat || travis_terminate 0
env: TARGETS="-C metricbeat testsuite"
env:
- PROJECT=metricbeat
- MAGE='build unitTest'
go: $TRAVIS_GO_VERSION
stage: test
- os: linux
Expand All @@ -142,29 +178,39 @@ jobs:
stage: test
- os: linux
before_install: .ci/scripts/travis_has_changes.sh x-pack/metricbeat metricbeat libbeat || travis_terminate 0
env: TARGETS="-C x-pack/metricbeat unit-tests"
env:
- PROJECT=x-pack/metricbeat
- MAGE='build unitTest'
go: $TRAVIS_GO_VERSION
stage: test
- os: linux
before_install: .ci/scripts/travis_has_changes.sh x-pack/metricbeat metricbeat libbeat || travis_terminate 0
env: TARGETS="-C x-pack/metricbeat integration-tests"
env:
- PROJECT=x-pack/metricbeat
- MAGE='goIntegTest'
go: $TRAVIS_GO_VERSION
stage: test
- os: linux
before_install: .ci/scripts/travis_has_changes.sh x-pack/metricbeat metricbeat libbeat || travis_terminate 0
env: TARGETS="-C x-pack/metricbeat system-tests"
env:
- PROJECT=x-pack/metricbeat
- MAGE='pythonIntegTest'
go: $TRAVIS_GO_VERSION
stage: test
- os: osx
before_install: .ci/scripts/travis_has_changes.sh metricbeat libbeat || travis_terminate 0
env: TARGETS="-C x-pack/metricbeat testsuite"
env:
- PROJECT=x-pack/metricbeat
- MAGE='build unitTest'
go: $TRAVIS_GO_VERSION
stage: test

# Packetbeat
- os: linux
before_install: .ci/scripts/travis_has_changes.sh packetbeat libbeat || travis_terminate 0
env: TARGETS="-C packetbeat testsuite"
env:
- PROJECT=packetbeat
- MAGE='build test'
go: $TRAVIS_GO_VERSION
stage: test

Expand All @@ -178,43 +224,57 @@ jobs:
# Functionbeat
- os: linux
before_install: .ci/scripts/travis_has_changes.sh x-pack/functionbeat libbeat || travis_terminate 0
env: TARGETS="-C x-pack/functionbeat testsuite"
env:
- PROJECT=x-pack/functionbeat
- MAGE='build test'
go: $TRAVIS_GO_VERSION
stage: test
- os: osx
before_install: .ci/scripts/travis_has_changes.sh x-pack/functionbeat libbeat || travis_terminate 0
env: TARGETS="TEST_ENVIRONMENT=0 -C x-pack/functionbeat testsuite"
env:
- PROJECT=x-pack/functionbeat
- MAGE='build unitTest'
go: $TRAVIS_GO_VERSION
stage: test
- os: linux
before_install: .ci/scripts/travis_has_changes.sh x-pack/functionbeat libbeat || travis_terminate 0
env: TARGETS="-C x-pack/functionbeat test-gcp-functions"
env:
- PROJECT=x-pack/functionbeat
- MAGE='testGCPFunctions'
go: 1.13.1
stage: test

# Docker Log Driver
- os: linux
before_install: .ci/scripts/travis_has_changes.sh x-pack/dockerlogbeat libbeat || travis_terminate 0
env: TARGETS="-C x-pack/dockerlogbeat testsuite"
env:
- PROJECT=x-pack/dockerlogbeat
- MAGE='build test'
go: $TRAVIS_GO_VERSION
stage: test

# Journalbeat
- os: linux
before_install: .ci/scripts/travis_has_changes.sh journalbeat libbeat || travis_terminate 0
env: TARGETS="-C journalbeat testsuite"
env:
- PROJECT=journalbeat
- MAGE='build goUnitTest'
go: $TRAVIS_GO_VERSION
stage: test

# Agent
- os: linux
before_install: .ci/scripts/travis_has_changes.sh x-pack/elastic-agent libbeat || travis_terminate 0
env: TARGETS="-C x-pack/elastic-agent testsuite"
env:
- PROJECT=x-pack/elastic-agent
- MAGE='build test'
go: $TRAVIS_GO_VERSION
stage: test
- os: osx
before_install: .ci/scripts/travis_has_changes.sh x-pack/elastic-agent libbeat || travis_terminate 0
env: TARGETS="TEST_ENVIRONMENT=0 -C x-pack/elastic-agent testsuite"
env:
- PROJECT=x-pack/elastic-agent
- MAGE='build unitTest'
go: $TRAVIS_GO_VERSION
stage: test

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

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

notifications:
Expand Down
Loading

0 comments on commit 4a1f800

Please sign in to comment.