Skip to content

Commit

Permalink
[ci] Favor direct mage invocation on CI (elastic#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 authored and v1v committed Jul 22, 2020
1 parent a7c87c7 commit 244f01f
Show file tree
Hide file tree
Showing 13 changed files with 202 additions and 64 deletions.
146 changes: 118 additions & 28 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,49 +37,85 @@ jobs:

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

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

# Auditbeat
- os: linux
env: TARGETS="-C auditbeat testsuite"
before_install: .ci/scripts/travis_has_changes.sh auditbeat libbeat || travis_terminate 0
env:
- PROJECT=auditbeat
- MAGE='build test'
go: $TRAVIS_GO_VERSION
stage: test
- os: osx
env: TARGETS="TEST_ENVIRONMENT=0 -C auditbeat testsuite"
before_install: .ci/scripts/travis_has_changes.sh auditbeat libbeat || travis_terminate 0
env:
- PROJECT=auditbeat
- MAGE='build unitTest'
go: $TRAVIS_GO_VERSION
stage: test
- os: linux
env: TARGETS="-C auditbeat crosscompile"
go: $TRAVIS_GO_VERSION
stage: test
- os: linux
env: TARGETS="-C x-pack/auditbeat testsuite"
before_install: .ci/scripts/travis_has_changes.sh x-pack/auditbeat auditbeat libbeat || travis_terminate 0
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
env: TARGETS="-C libbeat testsuite"
before_install: .ci/scripts/travis_has_changes.sh libbeat || travis_terminate 0
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 @@ -91,58 +127,86 @@ jobs:
go: $TRAVIS_GO_VERSION
stage: test
- os: linux
env: TARGETS="-C x-pack/libbeat testsuite"
before_install: .ci/scripts/travis_has_changes.sh x-pack/libbeat libbeat || travis_terminate 0
env:
- PROJECT=x-pack/libbeat
- MAGE='build test'
go: $TRAVIS_GO_VERSION
stage: test

# Metricbeat
- os: linux
env: TARGETS="-C metricbeat unit-tests"
before_install: .ci/scripts/travis_has_changes.sh metricbeat libbeat || travis_terminate 0
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
env: TARGETS="-C metricbeat system-tests"
before_install: .ci/scripts/travis_has_changes.sh metricbeat libbeat || travis_terminate 0
env:
- PROJECT=metricbeat
- MAGE='pythonIntegTest'
go: $TRAVIS_GO_VERSION
stage: test
- os: osx
env: TARGETS="-C metricbeat testsuite"
before_install: .ci/scripts/travis_has_changes.sh metricbeat libbeat || travis_terminate 0
env:
- PROJECT=metricbeat
- MAGE='build unitTest'
go: $TRAVIS_GO_VERSION
stage: test
- os: linux
env: TARGETS="-C metricbeat crosscompile"
go: $TRAVIS_GO_VERSION
stage: test
- os: linux
env: TARGETS="-C x-pack/metricbeat unit-tests"
before_install: .ci/scripts/travis_has_changes.sh x-pack/metricbeat metricbeat libbeat || travis_terminate 0
env:
- PROJECT=x-pack/metricbeat
- MAGE='build unitTest'
go: $TRAVIS_GO_VERSION
stage: test
- os: linux
env: TARGETS="-C x-pack/metricbeat integration-tests"
before_install: .ci/scripts/travis_has_changes.sh x-pack/metricbeat metricbeat libbeat || travis_terminate 0
env:
- PROJECT=x-pack/metricbeat
- MAGE='goIntegTest'
go: $TRAVIS_GO_VERSION
stage: test
- os: linux
env: TARGETS="-C x-pack/metricbeat system-tests"
before_install: .ci/scripts/travis_has_changes.sh x-pack/metricbeat metricbeat libbeat || travis_terminate 0
env:
- PROJECT=x-pack/metricbeat
- MAGE='pythonIntegTest'
go: $TRAVIS_GO_VERSION
stage: test
- os: osx
env: TARGETS="-C x-pack/metricbeat testsuite"
before_install: .ci/scripts/travis_has_changes.sh metricbeat libbeat || travis_terminate 0
env:
- PROJECT=x-pack/metricbeat
- MAGE='build unitTest'
go: $TRAVIS_GO_VERSION
stage: test

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

Expand All @@ -154,40 +218,58 @@ jobs:

# Functionbeat
- os: linux
env: TARGETS="-C x-pack/functionbeat testsuite"
before_install: .ci/scripts/travis_has_changes.sh x-pack/functionbeat libbeat || travis_terminate 0
env:
- PROJECT=x-pack/functionbeat
- MAGE='build test'
go: $TRAVIS_GO_VERSION
stage: test
- os: osx
env: TARGETS="TEST_ENVIRONMENT=0 -C x-pack/functionbeat testsuite"
before_install: .ci/scripts/travis_has_changes.sh x-pack/functionbeat libbeat || travis_terminate 0
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
env: TARGETS="-C x-pack/dockerlogbeat testsuite"
before_install: .ci/scripts/travis_has_changes.sh x-pack/dockerlogbeat libbeat || travis_terminate 0
env:
- PROJECT=x-pack/dockerlogbeat
- MAGE='build test'
go: $TRAVIS_GO_VERSION
stage: test

# Journalbeat
- os: linux
env: TARGETS="-C journalbeat testsuite"
before_install: .ci/scripts/travis_has_changes.sh journalbeat libbeat || travis_terminate 0
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 @@ -279,6 +361,7 @@ before_install:
- 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


# Skips installations step
Expand All @@ -289,7 +372,14 @@ script:
# 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 244f01f

Please sign in to comment.