Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 13 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
---
sudo: false
language: ruby
cache: bundler
sudo: required
services: docker
addons:
apt:
packages:
- docker-ce
matrix:
include:
- rvm: jruby-9.1.13.0
env: LOGSTASH_BRANCH=master
- rvm: jruby-9.1.13.0
env: LOGSTASH_BRANCH=7.0
- rvm: jruby-9.1.13.0
env: LOGSTASH_BRANCH=6.7
- rvm: jruby-9.1.13.0
env: LOGSTASH_BRANCH=6.6
- rvm: jruby-1.7.27
env: LOGSTASH_BRANCH=5.6
- env: ELASTIC_STACK_VERSION=8.x SNAPSHOT=true
- env: ELASTIC_STACK_VERSION=7.x SNAPSHOT=true
- env: ELASTIC_STACK_VERSION=7.x
- env: ELASTIC_STACK_VERSION=6.x
- env: ELASTIC_STACK_VERSION=5.x
fast_finish: true
install: true
script: ci/build.sh
jdk: oraclejdk8
before_install: gem install bundler -v '< 2'
install: ci/unit/docker-setup.sh
script: ci/unit/docker-run.sh
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ if Dir.exist?(logstash_path) && use_logstash_source
gem 'logstash-core', :path => "#{logstash_path}/logstash-core"
gem 'logstash-core-plugin-api', :path => "#{logstash_path}/logstash-core-plugin-api"
end

if RUBY_VERSION == "1.9.3"
gem 'rake', '12.2.1'
end
21 changes: 0 additions & 21 deletions ci/build.sh

This file was deleted.

26 changes: 0 additions & 26 deletions ci/setup.sh

This file was deleted.

11 changes: 11 additions & 0 deletions ci/unit/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
ARG ELASTIC_STACK_VERSION
FROM docker.elastic.co/logstash/logstash:$ELASTIC_STACK_VERSION
COPY --chown=logstash:logstash Gemfile /usr/share/plugins/plugin/Gemfile
COPY --chown=logstash:logstash *.gemspec /usr/share/plugins/plugin/
RUN cp /usr/share/logstash/logstash-core/versions-gem-copy.yml /usr/share/logstash/versions.yml
ENV PATH="${PATH}:/usr/share/logstash/vendor/jruby/bin"
ENV LOGSTASH_SOURCE="1"
RUN gem install bundler -v '< 2'
WORKDIR /usr/share/plugins/plugin
RUN bundle install
COPY --chown=logstash:logstash . /usr/share/plugins/plugin
17 changes: 17 additions & 0 deletions ci/unit/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: '3'

# run tests: cd ci/unit; docker-compose up --build --force-recreate
# manual: cd ci/unit; docker-compose run logstash bash
services:

logstash:
build:
context: ../../
dockerfile: ci/unit/Dockerfile
args:
- ELASTIC_STACK_VERSION=$ELASTIC_STACK_VERSION
command: /usr/share/plugins/plugin/ci/unit/run.sh
environment:
LS_JAVA_OPTS: "-Xmx256m -Xms256m"
LOGSTASH_SOURCE: 1
tty: true
5 changes: 5 additions & 0 deletions ci/unit/docker-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

# This is intended to be run inside the docker container as the command of the docker-compose.
set -ex
docker-compose -f ci/unit/docker-compose.yml up --exit-code-from logstash
52 changes: 52 additions & 0 deletions ci/unit/docker-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash

# This is intended to be run the plugin's root directory. `ci/unit/docker-test.sh`
# Ensure you have Docker installed locally and set the ELASTIC_STACK_VERSION environment variable.
set -e

VERSION_URL="https://raw.githubusercontent.com/elastic/logstash/master/ci/logstash_releases.json"

if [ -z "${ELASTIC_STACK_VERSION}" ]; then
echo "Please set the ELASTIC_STACK_VERSION environment variable"
echo "For example: export ELASTIC_STACK_VERSION=6.2.4"
exit 1
fi

echo "Fetching versions from $VERSION_URL"
VERSIONS=$(curl $VERSION_URL)

if [[ "$SNAPSHOT" = "true" ]]; then
ELASTIC_STACK_RETRIEVED_VERSION=$(echo $VERSIONS | jq '.snapshots."'"$ELASTIC_STACK_VERSION"'"')
echo $ELASTIC_STACK_RETRIEVED_VERSION
else
ELASTIC_STACK_RETRIEVED_VERSION=$(echo $VERSIONS | jq '.releases."'"$ELASTIC_STACK_VERSION"'"')
fi

if [[ "$ELASTIC_STACK_RETRIEVED_VERSION" != "null" ]]; then
# remove starting and trailing double quotes
ELASTIC_STACK_RETRIEVED_VERSION="${ELASTIC_STACK_RETRIEVED_VERSION%\"}"
ELASTIC_STACK_RETRIEVED_VERSION="${ELASTIC_STACK_RETRIEVED_VERSION#\"}"
echo "Translated $ELASTIC_STACK_VERSION to ${ELASTIC_STACK_RETRIEVED_VERSION}"
export ELASTIC_STACK_VERSION=$ELASTIC_STACK_RETRIEVED_VERSION
fi

echo "Testing against version: $ELASTIC_STACK_VERSION"

if [[ "$ELASTIC_STACK_VERSION" = *"-SNAPSHOT" ]]; then
cd /tmp
wget https://snapshots.elastic.co/docker/logstash-"$ELASTIC_STACK_VERSION".tar.gz
tar xfvz logstash-"$ELASTIC_STACK_VERSION".tar.gz repositories
echo "Loading docker image: "
cat repositories
docker load < logstash-"$ELASTIC_STACK_VERSION".tar.gz
rm logstash-"$ELASTIC_STACK_VERSION".tar.gz
cd -
fi

if [ -f Gemfile.lock ]; then
rm Gemfile.lock
fi

docker-compose -f ci/unit/docker-compose.yml down
docker-compose -f ci/unit/docker-compose.yml build
#docker-compose -f ci/unit/docker-compose.yml up --exit-code-from logstash --force-recreate
7 changes: 7 additions & 0 deletions ci/unit/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# This is intended to be run inside the docker container as the command of the docker-compose.
set -ex

#bundle exec rspec -fd --pattern spec/**/*_spec.rb,spec/**/*_specs.rb
bundle exec rspec -fd